@pi-r/chrome 0.6.4 → 0.6.5
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/LICENSE +1 -1
- package/README.md +6 -3
- package/index.js +60 -64
- package/package.json +5 -5
- package/types/index.d.ts +7 -7
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
# @pi-r/chrome
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Documentation
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- [E-mc](https://e-mc.readthedocs.io/en/latest/document/index.html)
|
|
6
|
+
- [squared](https://squared.readthedocs.io)
|
|
7
|
+
|
|
8
|
+
## LICENSE
|
|
6
9
|
|
|
7
10
|
MIT
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const fs = require("fs");
|
|
5
4
|
const asset_1 = require("@e-mc/document/asset");
|
|
@@ -166,7 +165,7 @@ function addCacheItem(map, key, data, timeout) {
|
|
|
166
165
|
map.set(key, [
|
|
167
166
|
Date.now(),
|
|
168
167
|
data,
|
|
169
|
-
setTimeout(() => deleteCacheItem(map, key), timeout * 1000
|
|
168
|
+
setTimeout(() => deleteCacheItem(map, key), timeout * 1000)
|
|
170
169
|
]);
|
|
171
170
|
}
|
|
172
171
|
function deleteCacheItem(map, key) {
|
|
@@ -224,10 +223,10 @@ function hasCondition(data, condition) {
|
|
|
224
223
|
if (arg2) {
|
|
225
224
|
switch (item[0]) {
|
|
226
225
|
case 'eq':
|
|
227
|
-
valid = parseArg(arg1) == parseArg(arg2);
|
|
226
|
+
valid = parseArg(arg1) == parseArg(arg2);
|
|
228
227
|
break;
|
|
229
228
|
case 'ne':
|
|
230
|
-
valid = parseArg(arg1) != parseArg(arg2);
|
|
229
|
+
valid = parseArg(arg1) != parseArg(arg2);
|
|
231
230
|
break;
|
|
232
231
|
case 'lt':
|
|
233
232
|
valid = parseArg(arg1) < parseArg(arg2);
|
|
@@ -351,7 +350,7 @@ function createHash(host, file, hash, bufferMap) {
|
|
|
351
350
|
throw (0, types_1.errorMessage)('hash', 'Source not found', filename);
|
|
352
351
|
}
|
|
353
352
|
catch (err) {
|
|
354
|
-
host.writeFail(["Unable to read file"
|
|
353
|
+
host.writeFail(["Unable to read file", filename], err, 32);
|
|
355
354
|
}
|
|
356
355
|
}
|
|
357
356
|
function getSrcURL(parent, file) {
|
|
@@ -513,7 +512,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
513
512
|
}
|
|
514
513
|
}
|
|
515
514
|
if (asset.initialValue && !asset.initialValue.cacheable) {
|
|
516
|
-
parent.flags |= 16
|
|
515
|
+
parent.flags |= 16;
|
|
517
516
|
}
|
|
518
517
|
related.push(asset);
|
|
519
518
|
}
|
|
@@ -609,7 +608,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
609
608
|
else {
|
|
610
609
|
related.push(asset);
|
|
611
610
|
if (!(0, types_1.existsFlag)(asset.flags)) {
|
|
612
|
-
asset.flags |= 8
|
|
611
|
+
asset.flags |= 8;
|
|
613
612
|
}
|
|
614
613
|
}
|
|
615
614
|
modified = true;
|
|
@@ -769,12 +768,12 @@ function transformJs(host, file, output) {
|
|
|
769
768
|
});
|
|
770
769
|
}
|
|
771
770
|
else {
|
|
772
|
-
this.writeFail(['Unable to create script entry point', path.basename(chunkUri)], (0, types_1.errorMessage)('js', 'Element not found', chunkUri), 4
|
|
771
|
+
this.writeFail(['Unable to create script entry point', path.basename(chunkUri)], (0, types_1.errorMessage)('js', 'Element not found', chunkUri), 4);
|
|
773
772
|
}
|
|
774
773
|
}
|
|
775
774
|
}
|
|
776
775
|
catch (err) {
|
|
777
|
-
this.writeFail(["Unable to write file"
|
|
776
|
+
this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
|
|
778
777
|
}
|
|
779
778
|
}
|
|
780
779
|
appending?.forEach(item => item.order += order);
|
|
@@ -862,19 +861,18 @@ async function checkData(item, name, result, validate) {
|
|
|
862
861
|
if (typeof callback === 'function') {
|
|
863
862
|
try {
|
|
864
863
|
let output;
|
|
865
|
-
|
|
866
|
-
if (callback["__cjs__" /* INTERNAL.CJS */]) {
|
|
864
|
+
if (callback["__cjs__"]) {
|
|
867
865
|
output = await callback(result, item);
|
|
868
866
|
}
|
|
869
867
|
else {
|
|
870
|
-
output = await callback.apply(Document.enabled("node.process.inline"
|
|
868
|
+
output = await callback.apply(Document.enabled("node.process.inline") ? process : null, Document.enabled("node.require.inline") ? [result, item, require] : [result, item]);
|
|
871
869
|
}
|
|
872
870
|
if (validate(output)) {
|
|
873
871
|
return output;
|
|
874
872
|
}
|
|
875
873
|
}
|
|
876
874
|
catch (err) {
|
|
877
|
-
this.writeFail(["Unable to parse inline method"
|
|
875
|
+
this.writeFail(["Unable to parse inline method", name], err);
|
|
878
876
|
}
|
|
879
877
|
}
|
|
880
878
|
}
|
|
@@ -902,7 +900,6 @@ const getEndIndex = (match) => match.index + match[0].length;
|
|
|
902
900
|
const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url?.search) : '');
|
|
903
901
|
const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
|
|
904
902
|
const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
|
|
905
|
-
// @ts-ignore
|
|
906
903
|
class ChromeDocument extends Document {
|
|
907
904
|
constructor() {
|
|
908
905
|
super(...arguments);
|
|
@@ -986,7 +983,7 @@ class ChromeDocument extends Document {
|
|
|
986
983
|
const { Db: db, htmlFile, assets } = instance;
|
|
987
984
|
const outHtml = htmlFile && !isIgnored(htmlFile, true);
|
|
988
985
|
if (db && await db.commit()) {
|
|
989
|
-
db.writeTimeElapsed('DB', ["Transactions were committed"
|
|
986
|
+
db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
|
|
990
987
|
}
|
|
991
988
|
if (instance.dataSource.length === 0 && outHtml) {
|
|
992
989
|
const incremental = htmlFile.incremental ?? this.incremental;
|
|
@@ -1029,7 +1026,7 @@ class ChromeDocument extends Document {
|
|
|
1029
1026
|
}
|
|
1030
1027
|
case 'exists':
|
|
1031
1028
|
if (hint || isHtmlOnly()) {
|
|
1032
|
-
this.formatMessage(4
|
|
1029
|
+
this.formatMessage(4, 'HTML', ['No changes detected', 'incremental: ' + incremental], hint, { ...Document.LOG_STYLE_NOTICE, messageBgColor: 'bgWhite', messageColor: 'black' });
|
|
1033
1030
|
return super.finalize.call(this, instance);
|
|
1034
1031
|
}
|
|
1035
1032
|
break;
|
|
@@ -1069,7 +1066,7 @@ class ChromeDocument extends Document {
|
|
|
1069
1066
|
for (const item of children) {
|
|
1070
1067
|
if (!items.has(item)) {
|
|
1071
1068
|
if (isWatched.call(instance, item)) {
|
|
1072
|
-
item.flags |= 8
|
|
1069
|
+
item.flags |= 8;
|
|
1073
1070
|
}
|
|
1074
1071
|
items.add(item);
|
|
1075
1072
|
const next = related.get(item);
|
|
@@ -1100,18 +1097,18 @@ class ChromeDocument extends Document {
|
|
|
1100
1097
|
this.delete(value);
|
|
1101
1098
|
}
|
|
1102
1099
|
else {
|
|
1103
|
-
instance.writeFail(["Unable to move file"
|
|
1100
|
+
instance.writeFail(["Unable to move file", instance.moduleName], (0, types_1.errorMessage)('production', path.join(this.baseDirectory, value)), { fatal: true });
|
|
1104
1101
|
}
|
|
1105
1102
|
}
|
|
1106
1103
|
}
|
|
1107
1104
|
}
|
|
1108
1105
|
}
|
|
1109
1106
|
else {
|
|
1110
|
-
instance.writeFail(["Unable to write directory"
|
|
1107
|
+
instance.writeFail(["Unable to write directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Access denied', productionRelease));
|
|
1111
1108
|
}
|
|
1112
1109
|
}
|
|
1113
1110
|
else {
|
|
1114
|
-
instance.writeFail(["Unable to read directory"
|
|
1111
|
+
instance.writeFail(["Unable to read directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Invalid directory', productionRelease), 32);
|
|
1115
1112
|
}
|
|
1116
1113
|
}
|
|
1117
1114
|
static sanitizeAssets(assets, exclusions = []) {
|
|
@@ -1432,7 +1429,7 @@ class ChromeDocument extends Document {
|
|
|
1432
1429
|
await instance.tryFile(buffer, { format: to, filename: file.filename, etag: file.etag }, (err, result, ext) => {
|
|
1433
1430
|
if (err) {
|
|
1434
1431
|
setFormat();
|
|
1435
|
-
this.writeFail("Unable to compress file"
|
|
1432
|
+
this.writeFail("Unable to compress file", err, 8);
|
|
1436
1433
|
}
|
|
1437
1434
|
else if (result) {
|
|
1438
1435
|
if (ext) {
|
|
@@ -1446,7 +1443,7 @@ class ChromeDocument extends Document {
|
|
|
1446
1443
|
host.replace(file, output);
|
|
1447
1444
|
}
|
|
1448
1445
|
else {
|
|
1449
|
-
this.writeFail("Unable to write file"
|
|
1446
|
+
this.writeFail("Unable to write file", error, 32);
|
|
1450
1447
|
}
|
|
1451
1448
|
});
|
|
1452
1449
|
}
|
|
@@ -1758,7 +1755,7 @@ class ChromeDocument extends Document {
|
|
|
1758
1755
|
item.sourceUTF8 = output;
|
|
1759
1756
|
}
|
|
1760
1757
|
catch (err) {
|
|
1761
|
-
host.writeFail(["Unable to write file"
|
|
1758
|
+
host.writeFail(["Unable to write file", path.basename(item.localUri)], err, 32);
|
|
1762
1759
|
}
|
|
1763
1760
|
}
|
|
1764
1761
|
}
|
|
@@ -1960,7 +1957,7 @@ class ChromeDocument extends Document {
|
|
|
1960
1957
|
host.removeAsset(item);
|
|
1961
1958
|
}
|
|
1962
1959
|
catch (err) {
|
|
1963
|
-
this.writeFail(["Unable to read file"
|
|
1960
|
+
this.writeFail(["Unable to read file", item.filename], err, { type: 32, startTime });
|
|
1964
1961
|
return false;
|
|
1965
1962
|
}
|
|
1966
1963
|
}
|
|
@@ -2143,7 +2140,7 @@ class ChromeDocument extends Document {
|
|
|
2143
2140
|
const { moduleName, config } = this;
|
|
2144
2141
|
const htmlFile = this.htmlFile;
|
|
2145
2142
|
const localUri = htmlFile.localUri;
|
|
2146
|
-
this.formatMessage(4
|
|
2143
|
+
this.formatMessage(4, 'HTML', ['Rewriting content...', path.dirname(localUri)]);
|
|
2147
2144
|
let source = host.getUTF8String(htmlFile, localUri), output;
|
|
2148
2145
|
const domBase = new dom_1.DomWriter(moduleName, source, this.elements, { normalize: config.normalizeHtmlOutput, stripComments: config.stripCommentsAndCDATA, ignoreTagGroup: config.ignoreServerCodeBlocks, escapeEntities: config.escapeReservedCharacters });
|
|
2149
2146
|
if (config.useUnsafeHtmlReplace) {
|
|
@@ -2169,7 +2166,7 @@ class ChromeDocument extends Document {
|
|
|
2169
2166
|
const domElement = new dom_1.HtmlElement(moduleName, element, item.attributes);
|
|
2170
2167
|
domElement.remove = true;
|
|
2171
2168
|
if (!domBase.write(domElement)) {
|
|
2172
|
-
this.writeFail('Unable to exclude HTML element', errorHtml(element), 4
|
|
2169
|
+
this.writeFail('Unable to exclude HTML element', errorHtml(element), 4);
|
|
2173
2170
|
}
|
|
2174
2171
|
}
|
|
2175
2172
|
}
|
|
@@ -2209,7 +2206,7 @@ class ChromeDocument extends Document {
|
|
|
2209
2206
|
domBase.errors.forEach(err => this.addLog(types_1.STATUS_TYPE.WARN, 'dom-writer -> ' + err.message, timeStamp));
|
|
2210
2207
|
}
|
|
2211
2208
|
if (domBase.failCount > 0) {
|
|
2212
|
-
this.writeFail(['Unable to update document', moduleName], (0, types_1.errorMessage)('html', 'DOM rewrite failed', domBase.failCount + ' errors'), { type: 4
|
|
2209
|
+
this.writeFail(['Unable to update document', moduleName], (0, types_1.errorMessage)('html', 'DOM rewrite failed', domBase.failCount + ' errors'), { type: 4, startTime });
|
|
2213
2210
|
}
|
|
2214
2211
|
else {
|
|
2215
2212
|
this.writeTimeProcess('html', `dom-writer (${domBase.modifyCount} modified) -> ` + path.basename(localUri), startTime);
|
|
@@ -2220,7 +2217,7 @@ class ChromeDocument extends Document {
|
|
|
2220
2217
|
for (const name in data) {
|
|
2221
2218
|
message.push(name + `(${data[name]})`);
|
|
2222
2219
|
}
|
|
2223
|
-
this.formatMessage(65536
|
|
2220
|
+
this.formatMessage(65536, 'DB', ['Cache statistics', cacheMiss.length + ' missed'], message.join(' - '), { ...Document.LOG_STYLE_NOTICE, hintBold: true });
|
|
2224
2221
|
}
|
|
2225
2222
|
}
|
|
2226
2223
|
htmlFile.modified = true;
|
|
@@ -2304,7 +2301,7 @@ class ChromeDocument extends Document {
|
|
|
2304
2301
|
try {
|
|
2305
2302
|
const dimension = require(packageName = 'probe-image-size').sync(buffer);
|
|
2306
2303
|
if (!dimension) {
|
|
2307
|
-
throw new Error("MIME not found"
|
|
2304
|
+
throw new Error("MIME not found");
|
|
2308
2305
|
}
|
|
2309
2306
|
({ width, height } = dimension);
|
|
2310
2307
|
}
|
|
@@ -2339,7 +2336,7 @@ class ChromeDocument extends Document {
|
|
|
2339
2336
|
}
|
|
2340
2337
|
}
|
|
2341
2338
|
if (!domBase.write(domElement)) {
|
|
2342
|
-
this.writeFail(inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4
|
|
2339
|
+
this.writeFail(inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4, startTime });
|
|
2343
2340
|
delete item.inlineUrlCloud;
|
|
2344
2341
|
}
|
|
2345
2342
|
else if (inlineContent) {
|
|
@@ -2363,7 +2360,7 @@ class ChromeDocument extends Document {
|
|
|
2363
2360
|
if (item.removeEmpty || item.type === 'display') {
|
|
2364
2361
|
(element || (element = new dom_1.HtmlElement(moduleName, item.element))).remove = true;
|
|
2365
2362
|
if (!domBase.write(element)) {
|
|
2366
|
-
this.writeFail('Unable to remove element', errorHtml(item.element), { type: 4
|
|
2363
|
+
this.writeFail('Unable to remove element', errorHtml(item.element), { type: 4, startTime });
|
|
2367
2364
|
}
|
|
2368
2365
|
}
|
|
2369
2366
|
};
|
|
@@ -2371,7 +2368,7 @@ class ChromeDocument extends Document {
|
|
|
2371
2368
|
removeElement(item);
|
|
2372
2369
|
const pkg = getPackageName(err);
|
|
2373
2370
|
if (!(pkg && this.checkPackage(err, pkg))) {
|
|
2374
|
-
this.writeFail(["Invalid credentials"
|
|
2371
|
+
this.writeFail(["Invalid credentials", item.source], err);
|
|
2375
2372
|
}
|
|
2376
2373
|
};
|
|
2377
2374
|
const checkObject = (item, data) => {
|
|
@@ -2401,7 +2398,7 @@ class ChromeDocument extends Document {
|
|
|
2401
2398
|
}
|
|
2402
2399
|
catch (err) {
|
|
2403
2400
|
this.abort(item.source);
|
|
2404
|
-
this.checkPackage(err, pkg, ["Unable to filter results"
|
|
2401
|
+
this.checkPackage(err, pkg, ["Unable to filter results", item.source]);
|
|
2405
2402
|
}
|
|
2406
2403
|
}
|
|
2407
2404
|
}
|
|
@@ -2424,7 +2421,7 @@ class ChromeDocument extends Document {
|
|
|
2424
2421
|
(batchMap[key] || (batchMap[key] = [])).push(item);
|
|
2425
2422
|
}
|
|
2426
2423
|
else {
|
|
2427
|
-
errorCredential(item, (0, types_1.errorValue)("Cloud module not installed"
|
|
2424
|
+
errorCredential(item, (0, types_1.errorValue)("Cloud module not installed", service));
|
|
2428
2425
|
}
|
|
2429
2426
|
break;
|
|
2430
2427
|
}
|
|
@@ -2458,7 +2455,7 @@ class ChromeDocument extends Document {
|
|
|
2458
2455
|
}
|
|
2459
2456
|
}
|
|
2460
2457
|
else {
|
|
2461
|
-
errorCredential(item, (0, types_1.errorValue)(db ? "Database provider not found"
|
|
2458
|
+
errorCredential(item, (0, types_1.errorValue)(db ? "Database provider not found" : "Db module not installed", type));
|
|
2462
2459
|
}
|
|
2463
2460
|
break;
|
|
2464
2461
|
}
|
|
@@ -2475,7 +2472,7 @@ class ChromeDocument extends Document {
|
|
|
2475
2472
|
const errorClient = (item, reason) => {
|
|
2476
2473
|
removeElement(item);
|
|
2477
2474
|
if (reason) {
|
|
2478
|
-
this.writeFail(["Unable to configure client"
|
|
2475
|
+
this.writeFail(["Unable to configure client", item.source], reason);
|
|
2479
2476
|
}
|
|
2480
2477
|
reject();
|
|
2481
2478
|
};
|
|
@@ -2496,7 +2493,7 @@ class ChromeDocument extends Document {
|
|
|
2496
2493
|
case 'json':
|
|
2497
2494
|
if ((result[0] = checkObject(current, current.items)) === null) {
|
|
2498
2495
|
this.abort(type);
|
|
2499
|
-
errorRemove(current, errorDataSource("Invalid parameters"
|
|
2496
|
+
errorRemove(current, errorDataSource("Invalid parameters" + ' (items)', type));
|
|
2500
2497
|
return;
|
|
2501
2498
|
}
|
|
2502
2499
|
if (this.settingsOf(type, 'coerce') === true) {
|
|
@@ -2525,7 +2522,7 @@ class ChromeDocument extends Document {
|
|
|
2525
2522
|
}
|
|
2526
2523
|
catch (err) {
|
|
2527
2524
|
this.abort(type);
|
|
2528
|
-
this.writeFail(["Unable to read file"
|
|
2525
|
+
this.writeFail(["Unable to read file", path.basename(location)], err, { type: 32, startTime });
|
|
2529
2526
|
errorRemove(current);
|
|
2530
2527
|
return;
|
|
2531
2528
|
}
|
|
@@ -2554,7 +2551,7 @@ class ChromeDocument extends Document {
|
|
|
2554
2551
|
}
|
|
2555
2552
|
catch (err) {
|
|
2556
2553
|
this.abort(type);
|
|
2557
|
-
this.writeFail(["Unable to download file"
|
|
2554
|
+
this.writeFail(["Unable to download file", target], err, { type: 1024, startTime });
|
|
2558
2555
|
errorRemove(current);
|
|
2559
2556
|
return;
|
|
2560
2557
|
}
|
|
@@ -2573,7 +2570,7 @@ class ChromeDocument extends Document {
|
|
|
2573
2570
|
}
|
|
2574
2571
|
catch (err) {
|
|
2575
2572
|
this.abort(type);
|
|
2576
|
-
this.writeFail(["Unable to download file"
|
|
2573
|
+
this.writeFail(["Unable to download file", target], err, { type: 1024, startTime });
|
|
2577
2574
|
errorRemove(current);
|
|
2578
2575
|
return;
|
|
2579
2576
|
}
|
|
@@ -2601,7 +2598,7 @@ class ChromeDocument extends Document {
|
|
|
2601
2598
|
}
|
|
2602
2599
|
catch (err) {
|
|
2603
2600
|
this.abort(type);
|
|
2604
|
-
this.writeFail(["Unable to read file"
|
|
2601
|
+
this.writeFail(["Unable to read file", path.basename(pathname)], err, { type: 32, startTime });
|
|
2605
2602
|
errorRemove(current);
|
|
2606
2603
|
return;
|
|
2607
2604
|
}
|
|
@@ -2618,7 +2615,7 @@ class ChromeDocument extends Document {
|
|
|
2618
2615
|
}
|
|
2619
2616
|
catch (err) {
|
|
2620
2617
|
this.abort(type);
|
|
2621
|
-
this.writeFail(['Unable to parse data source', format], err, { type: 4
|
|
2618
|
+
this.writeFail(['Unable to parse data source', format], err, { type: 4, startTime });
|
|
2622
2619
|
errorRemove(current);
|
|
2623
2620
|
return;
|
|
2624
2621
|
}
|
|
@@ -2698,13 +2695,12 @@ class ChromeDocument extends Document {
|
|
|
2698
2695
|
if (params && this.settingsOf(type, 'coerce') === true) {
|
|
2699
2696
|
(0, types_1.coerceObject)(params);
|
|
2700
2697
|
}
|
|
2701
|
-
|
|
2702
|
-
if (getData["__cjs__" /* INTERNAL.CJS */]) {
|
|
2698
|
+
if (getData["__cjs__"]) {
|
|
2703
2699
|
data = await getData(params);
|
|
2704
2700
|
}
|
|
2705
2701
|
else {
|
|
2706
|
-
const thisArg = Document.enabled("node.process.inline"
|
|
2707
|
-
const inline = Document.enabled("node.require.inline"
|
|
2702
|
+
const thisArg = Document.enabled("node.process.inline") ? process : null;
|
|
2703
|
+
const inline = Document.enabled("node.require.inline");
|
|
2708
2704
|
const args = [params];
|
|
2709
2705
|
if (getData.toString().startsWith('async')) {
|
|
2710
2706
|
if (inline) {
|
|
@@ -2726,7 +2722,7 @@ class ChromeDocument extends Document {
|
|
|
2726
2722
|
}
|
|
2727
2723
|
catch (err) {
|
|
2728
2724
|
this.abort(type);
|
|
2729
|
-
this.writeFail(['Unable to retrieve data source', hint], err, { type: 4
|
|
2725
|
+
this.writeFail(['Unable to retrieve data source', hint], err, { type: 4, startTime });
|
|
2730
2726
|
errorRemove(current);
|
|
2731
2727
|
return;
|
|
2732
2728
|
}
|
|
@@ -2812,12 +2808,12 @@ class ChromeDocument extends Document {
|
|
|
2812
2808
|
}
|
|
2813
2809
|
}
|
|
2814
2810
|
else {
|
|
2815
|
-
throw (0, types_1.errorMessage)(type, "File not found"
|
|
2811
|
+
throw (0, types_1.errorMessage)(type, "File not found", query);
|
|
2816
2812
|
}
|
|
2817
2813
|
}
|
|
2818
2814
|
catch (err) {
|
|
2819
2815
|
this.abort(type);
|
|
2820
|
-
this.writeFail(["Unable to read file"
|
|
2816
|
+
this.writeFail(["Unable to read file", pathname ? path.basename(pathname) : query], err, { startTime });
|
|
2821
2817
|
errorRemove(current);
|
|
2822
2818
|
return;
|
|
2823
2819
|
}
|
|
@@ -2854,7 +2850,7 @@ class ChromeDocument extends Document {
|
|
|
2854
2850
|
this.abort(type, err);
|
|
2855
2851
|
}
|
|
2856
2852
|
if (err) {
|
|
2857
|
-
this.writeFail(["Unable to execute query"
|
|
2853
|
+
this.writeFail(["Unable to execute query", message || "Unknown"], err instanceof Error ? errors = err : err, { type: 65536, startTime });
|
|
2858
2854
|
}
|
|
2859
2855
|
return this.aborted;
|
|
2860
2856
|
};
|
|
@@ -2868,7 +2864,7 @@ class ChromeDocument extends Document {
|
|
|
2868
2864
|
}
|
|
2869
2865
|
break;
|
|
2870
2866
|
}
|
|
2871
|
-
errorRemove(current, errorDataSource('Not found', type || "Unknown"
|
|
2867
|
+
errorRemove(current, errorDataSource('Not found', type || "Unknown"));
|
|
2872
2868
|
return;
|
|
2873
2869
|
}
|
|
2874
2870
|
if (this.aborted) {
|
|
@@ -2932,7 +2928,7 @@ class ChromeDocument extends Document {
|
|
|
2932
2928
|
setCacheData.call(this, item, item.value, pathname, cacheData, true);
|
|
2933
2929
|
}
|
|
2934
2930
|
catch (err) {
|
|
2935
|
-
this.writeFail(["Unable to read file"
|
|
2931
|
+
this.writeFail(["Unable to read file", path.basename(pathname)], err, { type: 32, startTime });
|
|
2936
2932
|
errors = true;
|
|
2937
2933
|
}
|
|
2938
2934
|
}
|
|
@@ -2975,7 +2971,7 @@ class ChromeDocument extends Document {
|
|
|
2975
2971
|
const literal = segment.trim();
|
|
2976
2972
|
if (literal.startsWith('`') && literal.endsWith('`')) {
|
|
2977
2973
|
if (!this.hasEval('function')) {
|
|
2978
|
-
errors = (0, types_1.errorMessage)('eval', "Unsupported access"
|
|
2974
|
+
errors = (0, types_1.errorMessage)('eval', "Unsupported access", 'function');
|
|
2979
2975
|
continue;
|
|
2980
2976
|
}
|
|
2981
2977
|
try {
|
|
@@ -2996,7 +2992,7 @@ class ChromeDocument extends Document {
|
|
|
2996
2992
|
else {
|
|
2997
2993
|
const pattern = /\$\{\s*([^\s}]+)\s*\}/g;
|
|
2998
2994
|
while (match = pattern.exec(segment)) {
|
|
2999
|
-
segment = replaceMatch(match, segment, match[1] === "__index__"
|
|
2995
|
+
segment = replaceMatch(match, segment, match[1] === "__index__" && !(0, types_1.isObject)(row) ? (j + 1).toString() : valueAsString(getObjectValue(row, match[1]), ', '), pattern);
|
|
3000
2996
|
}
|
|
3001
2997
|
}
|
|
3002
2998
|
value += trimTemplate(segment);
|
|
@@ -3198,37 +3194,37 @@ class ChromeDocument extends Document {
|
|
|
3198
3194
|
default:
|
|
3199
3195
|
removeElement(item, domElement);
|
|
3200
3196
|
if (length === 1) {
|
|
3201
|
-
reject(errorDataSource('Invalid action', item.type || "Unknown"
|
|
3197
|
+
reject(errorDataSource('Invalid action', item.type || "Unknown"));
|
|
3202
3198
|
return;
|
|
3203
3199
|
}
|
|
3204
3200
|
break invalid;
|
|
3205
3201
|
}
|
|
3206
3202
|
if (!domBase.write(domElement) || errors) {
|
|
3207
|
-
this.writeFail(item.type === 'display' ? domElement.remove ? errors ? 'Element was removed with errors' : 'Unable to remove element' : 'Unable to determine display conditional' : 'Unable to replace ' + item.type, errors instanceof Error ? errors : errorHtml(element), { type: 4
|
|
3203
|
+
this.writeFail(item.type === 'display' ? domElement.remove ? errors ? 'Element was removed with errors' : 'Unable to remove element' : 'Unable to determine display conditional' : 'Unable to replace ' + item.type, errors instanceof Error ? errors : errorHtml(element), { type: 4, startTime });
|
|
3208
3204
|
}
|
|
3209
3205
|
}
|
|
3210
3206
|
}
|
|
3211
3207
|
else {
|
|
3212
3208
|
if (!empty && item.type !== 'display' || item.transactionFail) {
|
|
3213
3209
|
const emptyResponse = (value, service = item.source) => {
|
|
3214
|
-
value || (value = "Unknown"
|
|
3210
|
+
value || (value = "Unknown");
|
|
3215
3211
|
return errors instanceof Error ? (0, types_1.errorMessage)(service, value, errors.message) : errorDataSource(service + ' -> Empty', value);
|
|
3216
3212
|
};
|
|
3217
3213
|
switch (item.source) {
|
|
3218
3214
|
case 'cloud': {
|
|
3219
3215
|
const { service, table, id, query } = item;
|
|
3220
3216
|
const queryString = (table ? 'table=' + table : '') + (id || query ? (table ? ';' : '') + (id ? 'id=' + id : 'query=' + asString(query)) : '');
|
|
3221
|
-
(cloud || this).formatFail(64
|
|
3217
|
+
(cloud || this).formatFail(64, service, ["Unable to execute query", queryString], emptyResponse(queryString, service), { ...Cloud.LOG_CLOUD_FAIL, startTime });
|
|
3222
3218
|
break;
|
|
3223
3219
|
}
|
|
3224
3220
|
case 'uri': {
|
|
3225
3221
|
const { uri, format = uri && path.extname(uri).substring(1) } = item;
|
|
3226
|
-
this.formatFail(4
|
|
3222
|
+
this.formatFail(4, format || 'URI', ['No records were found', uri], emptyResponse(uri), { startTime });
|
|
3227
3223
|
break;
|
|
3228
3224
|
}
|
|
3229
3225
|
case 'local': {
|
|
3230
3226
|
const { pathname, format = pathname && path.extname(pathname).substring(1) } = item;
|
|
3231
|
-
this.formatFail(4
|
|
3227
|
+
this.formatFail(4, format || 'LOCAL', ['No records were found', pathname], emptyResponse(pathname), { startTime });
|
|
3232
3228
|
break;
|
|
3233
3229
|
}
|
|
3234
3230
|
case 'export': {
|
|
@@ -3237,7 +3233,7 @@ class ChromeDocument extends Document {
|
|
|
3237
3233
|
if (typeof target === 'function') {
|
|
3238
3234
|
target = target.name;
|
|
3239
3235
|
}
|
|
3240
|
-
this.formatFail(4
|
|
3236
|
+
this.formatFail(4, 'EXPORT', ['No records were retrieved', target], emptyResponse(target), { startTime });
|
|
3241
3237
|
break;
|
|
3242
3238
|
}
|
|
3243
3239
|
}
|
|
@@ -3289,7 +3285,7 @@ class ChromeDocument extends Document {
|
|
|
3289
3285
|
throw (0, types_1.errorMessage)('hash', 'Source not found', item.filename);
|
|
3290
3286
|
}
|
|
3291
3287
|
catch (err) {
|
|
3292
|
-
this.writeFail(["Unable to read file"
|
|
3288
|
+
this.writeFail(["Unable to read file", item.filename], err, { type: 32, startTime });
|
|
3293
3289
|
}
|
|
3294
3290
|
default:
|
|
3295
3291
|
if (algorithm) {
|
|
@@ -3728,7 +3724,7 @@ class ChromeDocument extends Document {
|
|
|
3728
3724
|
return (_a = this.module).settings || (_a.settings = {});
|
|
3729
3725
|
}
|
|
3730
3726
|
}
|
|
3731
|
-
ChromeDocument.INTERNAL_ASSIGNUUID = "__assign__"
|
|
3732
|
-
ChromeDocument.INTERNAL_SERVERROOT = "__serverroot__"
|
|
3727
|
+
ChromeDocument.INTERNAL_ASSIGNUUID = "__assign__";
|
|
3728
|
+
ChromeDocument.INTERNAL_SERVERROOT = "__serverroot__";
|
|
3733
3729
|
|
|
3734
3730
|
module.exports = ChromeDocument;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "Chrome document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.8.
|
|
24
|
-
"@e-mc/core": "^0.8.
|
|
25
|
-
"@e-mc/document": "^0.8.
|
|
26
|
-
"@e-mc/types": "^0.8.
|
|
23
|
+
"@e-mc/cloud": "^0.8.6",
|
|
24
|
+
"@e-mc/core": "^0.8.6",
|
|
25
|
+
"@e-mc/document": "^0.8.6",
|
|
26
|
+
"@e-mc/types": "^0.8.6"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -99,12 +99,12 @@ export interface IChromeDocument<T extends IFileManager<U>, U extends DocumentAs
|
|
|
99
99
|
formatMap?: ObjectMap<FormatUri>;
|
|
100
100
|
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
101
101
|
findDataValue(name: string): Undef<string>;
|
|
102
|
-
setInlinedAttributes(processing: FinalizeProcessing<T>): void;
|
|
103
|
-
applyTransforms(processing: FinalizeProcessing<T>): Promise<void>;
|
|
104
|
-
rewriteHtml(processing: FinalizeProcessing<T>): Promise<void>;
|
|
105
|
-
setElementAttributes(processing: FinalizeProcessing<T>, domBase: IDomWriter): Promise<void>;
|
|
106
|
-
applyDataSource(processing: FinalizeProcessing<T>, domBase: IDomWriter): Promise<void>;
|
|
107
|
-
setProductionAttributes(processing: FinalizeProcessing<T>): void;
|
|
102
|
+
setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
103
|
+
applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
104
|
+
rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
105
|
+
setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
106
|
+
applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
107
|
+
setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
108
108
|
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
109
109
|
removeServerRoot(value: string): string;
|
|
110
110
|
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
@@ -124,4 +124,4 @@ export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends
|
|
|
124
124
|
INTERNAL_SERVERROOT: string;
|
|
125
125
|
readonly prototype: IChromeDocument<T, U>;
|
|
126
126
|
new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
|
|
127
|
-
}
|
|
127
|
+
}
|