@pi-r/chrome 0.3.0 → 0.3.2
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 +4 -2
- package/index.d.ts +6 -6
- package/index.js +59 -58
- package/package.json +6 -6
- package/types/index.d.ts +7 -7
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Studio Trigger
|
|
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
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IFileManager } from '@e-mc/types/lib';
|
|
2
|
-
|
|
3
|
-
import type { ChromeDocumentConstructor, DocumentAsset } from './types';
|
|
4
|
-
|
|
5
|
-
declare const Chrome: ChromeDocumentConstructor<IFileManager<DocumentAsset>>;
|
|
6
|
-
|
|
1
|
+
import type { IFileManager } from '@e-mc/types/lib';
|
|
2
|
+
|
|
3
|
+
import type { ChromeDocumentConstructor, DocumentAsset } from './types';
|
|
4
|
+
|
|
5
|
+
declare const Chrome: ChromeDocumentConstructor<IFileManager<DocumentAsset>>;
|
|
6
|
+
|
|
7
7
|
export = Chrome;
|
package/index.js
CHANGED
|
@@ -148,7 +148,7 @@ function addCacheItem(map, key, data, timeout) {
|
|
|
148
148
|
map.set(key, [
|
|
149
149
|
Date.now(),
|
|
150
150
|
data,
|
|
151
|
-
setTimeout(() => deleteCacheItem(map, key), timeout * 1000
|
|
151
|
+
setTimeout(() => deleteCacheItem(map, key), timeout * 1000)
|
|
152
152
|
]);
|
|
153
153
|
}
|
|
154
154
|
function deleteCacheItem(map, key) {
|
|
@@ -206,10 +206,10 @@ function hasCondition(data, condition) {
|
|
|
206
206
|
if (arg2) {
|
|
207
207
|
switch (item[0]) {
|
|
208
208
|
case 'eq':
|
|
209
|
-
valid = parseArg(arg1) == parseArg(arg2);
|
|
209
|
+
valid = parseArg(arg1) == parseArg(arg2);
|
|
210
210
|
break;
|
|
211
211
|
case 'ne':
|
|
212
|
-
valid = parseArg(arg1) != parseArg(arg2);
|
|
212
|
+
valid = parseArg(arg1) != parseArg(arg2);
|
|
213
213
|
break;
|
|
214
214
|
case 'lt':
|
|
215
215
|
valid = parseArg(arg1) < parseArg(arg2);
|
|
@@ -338,7 +338,7 @@ function createHash(host, file, bufferMap) {
|
|
|
338
338
|
throw (0, types_1.errorMessage)('hash', 'Source not found', filename);
|
|
339
339
|
}
|
|
340
340
|
catch (err) {
|
|
341
|
-
host.writeFail(["Unable to read file"
|
|
341
|
+
host.writeFail(["Unable to read file", filename], err, 32);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
function getSrcURL(parent, file) {
|
|
@@ -479,7 +479,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
if (asset.initialValue && !asset.initialValue.cacheable) {
|
|
482
|
-
parent.flags |= 16
|
|
482
|
+
parent.flags |= 16;
|
|
483
483
|
}
|
|
484
484
|
related.push(asset);
|
|
485
485
|
}
|
|
@@ -575,7 +575,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
575
575
|
else {
|
|
576
576
|
related.push(asset);
|
|
577
577
|
if (!(0, types_1.existsFlag)(asset.flags)) {
|
|
578
|
-
asset.flags |= 8
|
|
578
|
+
asset.flags |= 8;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
modified = true;
|
|
@@ -735,12 +735,12 @@ function transformJs(host, file, output) {
|
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
737
|
else {
|
|
738
|
-
this.writeFail(['Unable to create element entry point', path.basename(chunkUri)], (0, types_1.errorMessage)('js', 'Element not found', chunkUri), 4
|
|
738
|
+
this.writeFail(['Unable to create element entry point', path.basename(chunkUri)], (0, types_1.errorMessage)('js', 'Element not found', chunkUri), 4);
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
742
|
catch (err) {
|
|
743
|
-
this.writeFail(["Unable to write file"
|
|
743
|
+
this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
appending?.forEach(item => item.order += order);
|
|
@@ -823,19 +823,18 @@ async function checkData(item, name, result, validate) {
|
|
|
823
823
|
if (typeof callback === 'function') {
|
|
824
824
|
try {
|
|
825
825
|
let output;
|
|
826
|
-
|
|
827
|
-
if (callback["__cjs__" /* INTERNAL.CJS */]) {
|
|
826
|
+
if (callback["__cjs__"]) {
|
|
828
827
|
output = await callback(result, item);
|
|
829
828
|
}
|
|
830
829
|
else {
|
|
831
|
-
output = await callback.apply(Document.enabled("node.process.inline"
|
|
830
|
+
output = await callback.apply(Document.enabled("node.process.inline") ? process : null, Document.enabled("node.require.inline") ? [result, item, require] : [result, item]);
|
|
832
831
|
}
|
|
833
832
|
if (validate(output)) {
|
|
834
833
|
return output;
|
|
835
834
|
}
|
|
836
835
|
}
|
|
837
836
|
catch (err) {
|
|
838
|
-
this.writeFail(["Unable to parse inline method"
|
|
837
|
+
this.writeFail(["Unable to parse inline method", name], err);
|
|
839
838
|
}
|
|
840
839
|
}
|
|
841
840
|
}
|
|
@@ -866,7 +865,6 @@ const getEndIndex = (match) => match.index + match[0].length;
|
|
|
866
865
|
const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url?.search) : '');
|
|
867
866
|
const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
|
|
868
867
|
const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
|
|
869
|
-
// @ts-ignore
|
|
870
868
|
class ChromeDocument extends Document {
|
|
871
869
|
constructor() {
|
|
872
870
|
super(...arguments);
|
|
@@ -946,7 +944,7 @@ class ChromeDocument extends Document {
|
|
|
946
944
|
const { Db: db, htmlFile, assets } = instance;
|
|
947
945
|
const outHtml = htmlFile && !isIgnored(htmlFile, true);
|
|
948
946
|
if (db && await db.commit()) {
|
|
949
|
-
db.writeTimeElapsed('DB', ["Transactions were committed"
|
|
947
|
+
db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
|
|
950
948
|
}
|
|
951
949
|
if (instance.dataSource.length === 0 && outHtml) {
|
|
952
950
|
const incremental = htmlFile.incremental ?? this.incremental;
|
|
@@ -989,7 +987,7 @@ class ChromeDocument extends Document {
|
|
|
989
987
|
}
|
|
990
988
|
case 'exists':
|
|
991
989
|
if (hint || isHtmlOnly()) {
|
|
992
|
-
this.formatMessage(4
|
|
990
|
+
this.formatMessage(4, 'HTML', ['No changes detected', 'incremental: ' + incremental], hint, { ...Document.LOG_STYLE_NOTICE, messageBgColor: 'bgWhite', messageColor: 'black' });
|
|
993
991
|
return super.finalize.call(this, instance);
|
|
994
992
|
}
|
|
995
993
|
break;
|
|
@@ -1031,7 +1029,7 @@ class ChromeDocument extends Document {
|
|
|
1031
1029
|
continue;
|
|
1032
1030
|
}
|
|
1033
1031
|
if (isWatched.call(instance, item)) {
|
|
1034
|
-
item.flags |= 8
|
|
1032
|
+
item.flags |= 8;
|
|
1035
1033
|
}
|
|
1036
1034
|
items.add(item);
|
|
1037
1035
|
const next = related.get(item);
|
|
@@ -1065,16 +1063,16 @@ class ChromeDocument extends Document {
|
|
|
1065
1063
|
this.delete(value);
|
|
1066
1064
|
}
|
|
1067
1065
|
else {
|
|
1068
|
-
instance.writeFail(["Unable to move file"
|
|
1066
|
+
instance.writeFail(["Unable to move file", instance.moduleName], (0, types_1.errorMessage)('production', path.join(this.baseDirectory, value)), { fatal: true });
|
|
1069
1067
|
}
|
|
1070
1068
|
}
|
|
1071
1069
|
}
|
|
1072
1070
|
else {
|
|
1073
|
-
instance.writeFail(["Unable to write directory"
|
|
1071
|
+
instance.writeFail(["Unable to write directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Access denied', productionRelease));
|
|
1074
1072
|
}
|
|
1075
1073
|
}
|
|
1076
1074
|
else {
|
|
1077
|
-
instance.writeFail(["Unable to read directory"
|
|
1075
|
+
instance.writeFail(["Unable to read directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Invalid directory', productionRelease), 32);
|
|
1078
1076
|
}
|
|
1079
1077
|
}
|
|
1080
1078
|
static sanitizeAssets(assets, exclusions = []) {
|
|
@@ -1394,7 +1392,7 @@ class ChromeDocument extends Document {
|
|
|
1394
1392
|
await instance.tryFile(buffer, { format: to, filename: file.filename, etag: file.etag }, (err, result, ext) => {
|
|
1395
1393
|
if (err) {
|
|
1396
1394
|
setFormat();
|
|
1397
|
-
this.writeFail("Unable to compress file"
|
|
1395
|
+
this.writeFail("Unable to compress file", err, 8);
|
|
1398
1396
|
}
|
|
1399
1397
|
else if (result) {
|
|
1400
1398
|
if (ext) {
|
|
@@ -1408,7 +1406,7 @@ class ChromeDocument extends Document {
|
|
|
1408
1406
|
host.replace(file, output);
|
|
1409
1407
|
}
|
|
1410
1408
|
else {
|
|
1411
|
-
this.writeFail("Unable to write file"
|
|
1409
|
+
this.writeFail("Unable to write file", error, 32);
|
|
1412
1410
|
}
|
|
1413
1411
|
});
|
|
1414
1412
|
}
|
|
@@ -1718,7 +1716,7 @@ class ChromeDocument extends Document {
|
|
|
1718
1716
|
item.sourceUTF8 = output;
|
|
1719
1717
|
}
|
|
1720
1718
|
catch (err) {
|
|
1721
|
-
host.writeFail(["Unable to write file"
|
|
1719
|
+
host.writeFail(["Unable to write file", path.basename(item.localUri)], err, 32);
|
|
1722
1720
|
}
|
|
1723
1721
|
}
|
|
1724
1722
|
}
|
|
@@ -1920,7 +1918,7 @@ class ChromeDocument extends Document {
|
|
|
1920
1918
|
host.removeAsset(item);
|
|
1921
1919
|
}
|
|
1922
1920
|
catch (err) {
|
|
1923
|
-
this.writeFail(["Unable to read file"
|
|
1921
|
+
this.writeFail(["Unable to read file", item.filename], err, { type: 32, startTime });
|
|
1924
1922
|
return false;
|
|
1925
1923
|
}
|
|
1926
1924
|
}
|
|
@@ -2103,7 +2101,7 @@ class ChromeDocument extends Document {
|
|
|
2103
2101
|
const { moduleName, config } = this;
|
|
2104
2102
|
const htmlFile = this.htmlFile;
|
|
2105
2103
|
const localUri = htmlFile.localUri;
|
|
2106
|
-
this.formatMessage(4
|
|
2104
|
+
this.formatMessage(4, 'HTML', ['Rewriting content...', path.dirname(localUri)]);
|
|
2107
2105
|
let source = host.getUTF8String(htmlFile, localUri), output;
|
|
2108
2106
|
const domBase = new dom_1.DomWriter(moduleName, source, this.elements, { normalize: config.normalizeHtmlOutput, stripComments: config.stripCommentsAndCDATA, ignoreTagGroup: config.ignoreServerCodeBlocks, escapeEntities: config.escapeReservedCharacters });
|
|
2109
2107
|
if (config.useUnsafeHtmlReplace) {
|
|
@@ -2129,7 +2127,7 @@ class ChromeDocument extends Document {
|
|
|
2129
2127
|
const domElement = new dom_1.HtmlElement(moduleName, element, item.attributes);
|
|
2130
2128
|
domElement.remove = true;
|
|
2131
2129
|
if (!domBase.write(domElement)) {
|
|
2132
|
-
this.writeFail('Unable to exclude HTML element', errorHtml(element), 4
|
|
2130
|
+
this.writeFail('Unable to exclude HTML element', errorHtml(element), 4);
|
|
2133
2131
|
}
|
|
2134
2132
|
}
|
|
2135
2133
|
}
|
|
@@ -2169,7 +2167,7 @@ class ChromeDocument extends Document {
|
|
|
2169
2167
|
domBase.errors.forEach(err => this.addLog(types_1.STATUS_TYPE.WARN, 'dom-writer -> ' + err.message, timeStamp));
|
|
2170
2168
|
}
|
|
2171
2169
|
if (domBase.failCount > 0) {
|
|
2172
|
-
this.writeFail(['Unable to update document', moduleName], (0, types_1.errorMessage)('html', 'DOM rewrite failed', domBase.failCount + ' errors'), { type: 4
|
|
2170
|
+
this.writeFail(['Unable to update document', moduleName], (0, types_1.errorMessage)('html', 'DOM rewrite failed', domBase.failCount + ' errors'), { type: 4, startTime });
|
|
2173
2171
|
}
|
|
2174
2172
|
else {
|
|
2175
2173
|
this.writeTimeProcess('html', `dom-writer (${domBase.modifyCount} modified) -> ` + path.basename(localUri), startTime);
|
|
@@ -2180,7 +2178,7 @@ class ChromeDocument extends Document {
|
|
|
2180
2178
|
for (const name in data) {
|
|
2181
2179
|
message.push(name + `(${data[name]})`);
|
|
2182
2180
|
}
|
|
2183
|
-
this.formatMessage(65536
|
|
2181
|
+
this.formatMessage(65536, 'DB', ['Cache statistics', cacheMiss.length + ' missed'], message.join(' - '), { ...Document.LOG_STYLE_NOTICE, hintBold: true });
|
|
2184
2182
|
}
|
|
2185
2183
|
}
|
|
2186
2184
|
htmlFile.modified = true;
|
|
@@ -2296,7 +2294,7 @@ class ChromeDocument extends Document {
|
|
|
2296
2294
|
}
|
|
2297
2295
|
}
|
|
2298
2296
|
if (!domBase.write(domElement)) {
|
|
2299
|
-
this.writeFail(inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4
|
|
2297
|
+
this.writeFail(inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4, startTime });
|
|
2300
2298
|
delete item.inlineUrlCloud;
|
|
2301
2299
|
}
|
|
2302
2300
|
else if (inlineContent) {
|
|
@@ -2320,7 +2318,7 @@ class ChromeDocument extends Document {
|
|
|
2320
2318
|
if (item.removeEmpty || item.type === 'display') {
|
|
2321
2319
|
(element || (element = new dom_1.HtmlElement(moduleName, item.element))).remove = true;
|
|
2322
2320
|
if (!domBase.write(element)) {
|
|
2323
|
-
this.writeFail('Unable to remove element', errorHtml(item.element), { type: 4
|
|
2321
|
+
this.writeFail('Unable to remove element', errorHtml(item.element), { type: 4, startTime });
|
|
2324
2322
|
}
|
|
2325
2323
|
}
|
|
2326
2324
|
};
|
|
@@ -2328,7 +2326,7 @@ class ChromeDocument extends Document {
|
|
|
2328
2326
|
removeElement(item);
|
|
2329
2327
|
const pkg = getPackageName(err);
|
|
2330
2328
|
if (!(pkg && this.checkPackage(err, pkg))) {
|
|
2331
|
-
this.writeFail(["Invalid credentials"
|
|
2329
|
+
this.writeFail(["Invalid credentials", item.source], err);
|
|
2332
2330
|
}
|
|
2333
2331
|
};
|
|
2334
2332
|
const checkObject = (item, data) => {
|
|
@@ -2358,7 +2356,7 @@ class ChromeDocument extends Document {
|
|
|
2358
2356
|
}
|
|
2359
2357
|
catch (err) {
|
|
2360
2358
|
this.abort(item.source);
|
|
2361
|
-
this.checkPackage(err, pkg, ["Unable to filter results"
|
|
2359
|
+
this.checkPackage(err, pkg, ["Unable to filter results", item.source]);
|
|
2362
2360
|
}
|
|
2363
2361
|
}
|
|
2364
2362
|
}
|
|
@@ -2381,7 +2379,7 @@ class ChromeDocument extends Document {
|
|
|
2381
2379
|
(batchMap[key] || (batchMap[key] = [])).push(item);
|
|
2382
2380
|
}
|
|
2383
2381
|
else {
|
|
2384
|
-
errorCredential(item, (0, types_1.errorValue)("Cloud module not installed"
|
|
2382
|
+
errorCredential(item, (0, types_1.errorValue)("Cloud module not installed", service));
|
|
2385
2383
|
}
|
|
2386
2384
|
break;
|
|
2387
2385
|
}
|
|
@@ -2414,7 +2412,7 @@ class ChromeDocument extends Document {
|
|
|
2414
2412
|
}
|
|
2415
2413
|
}
|
|
2416
2414
|
else {
|
|
2417
|
-
errorCredential(item, (0, types_1.errorValue)(db ? "Database provider not found"
|
|
2415
|
+
errorCredential(item, (0, types_1.errorValue)(db ? "Database provider not found" : "Db module not installed", type));
|
|
2418
2416
|
}
|
|
2419
2417
|
break;
|
|
2420
2418
|
}
|
|
@@ -2431,7 +2429,7 @@ class ChromeDocument extends Document {
|
|
|
2431
2429
|
const errorClient = (item, reason) => {
|
|
2432
2430
|
removeElement(item);
|
|
2433
2431
|
if (reason) {
|
|
2434
|
-
this.writeFail(["Unable to configure client"
|
|
2432
|
+
this.writeFail(["Unable to configure client", item.source], reason);
|
|
2435
2433
|
}
|
|
2436
2434
|
reject();
|
|
2437
2435
|
};
|
|
@@ -2473,7 +2471,7 @@ class ChromeDocument extends Document {
|
|
|
2473
2471
|
}
|
|
2474
2472
|
catch (err) {
|
|
2475
2473
|
this.abort(type);
|
|
2476
|
-
this.writeFail(["Unable to read file"
|
|
2474
|
+
this.writeFail(["Unable to read file", path.basename(location)], err, { type: 32, startTime });
|
|
2477
2475
|
errorRemove(current);
|
|
2478
2476
|
return;
|
|
2479
2477
|
}
|
|
@@ -2509,7 +2507,7 @@ class ChromeDocument extends Document {
|
|
|
2509
2507
|
}
|
|
2510
2508
|
catch (err) {
|
|
2511
2509
|
this.abort(type);
|
|
2512
|
-
this.writeFail(["Unable to download file"
|
|
2510
|
+
this.writeFail(["Unable to download file", target], err, { type: 1024, startTime });
|
|
2513
2511
|
errorRemove(current);
|
|
2514
2512
|
return;
|
|
2515
2513
|
}
|
|
@@ -2538,7 +2536,7 @@ class ChromeDocument extends Document {
|
|
|
2538
2536
|
}
|
|
2539
2537
|
catch (err) {
|
|
2540
2538
|
this.abort(type);
|
|
2541
|
-
this.writeFail(["Unable to read file"
|
|
2539
|
+
this.writeFail(["Unable to read file", path.basename(pathname)], err, { type: 32, startTime });
|
|
2542
2540
|
errorRemove(current);
|
|
2543
2541
|
return;
|
|
2544
2542
|
}
|
|
@@ -2552,7 +2550,7 @@ class ChromeDocument extends Document {
|
|
|
2552
2550
|
}
|
|
2553
2551
|
catch (err) {
|
|
2554
2552
|
this.abort(type);
|
|
2555
|
-
this.writeFail(['Unable to parse data source', format], err, { type: 4
|
|
2553
|
+
this.writeFail(['Unable to parse data source', format], err, { type: 4, startTime });
|
|
2556
2554
|
errorRemove(current);
|
|
2557
2555
|
return;
|
|
2558
2556
|
}
|
|
@@ -2630,13 +2628,12 @@ class ChromeDocument extends Document {
|
|
|
2630
2628
|
if (params && this.settingsOf(type, 'coerce') === true) {
|
|
2631
2629
|
(0, types_1.coerceObject)(params);
|
|
2632
2630
|
}
|
|
2633
|
-
|
|
2634
|
-
if (getData["__cjs__" /* INTERNAL.CJS */]) {
|
|
2631
|
+
if (getData["__cjs__"]) {
|
|
2635
2632
|
data = await getData(params);
|
|
2636
2633
|
}
|
|
2637
2634
|
else {
|
|
2638
|
-
const thisArg = Document.enabled("node.process.inline"
|
|
2639
|
-
const inline = Document.enabled("node.require.inline"
|
|
2635
|
+
const thisArg = Document.enabled("node.process.inline") ? process : null;
|
|
2636
|
+
const inline = Document.enabled("node.require.inline");
|
|
2640
2637
|
const args = [params];
|
|
2641
2638
|
if (getData.toString().startsWith('async')) {
|
|
2642
2639
|
if (inline) {
|
|
@@ -2658,7 +2655,7 @@ class ChromeDocument extends Document {
|
|
|
2658
2655
|
}
|
|
2659
2656
|
catch (err) {
|
|
2660
2657
|
this.abort(type);
|
|
2661
|
-
this.writeFail(['Unable to retrieve data source', hint], err, { type: 4
|
|
2658
|
+
this.writeFail(['Unable to retrieve data source', hint], err, { type: 4, startTime });
|
|
2662
2659
|
errorRemove(current);
|
|
2663
2660
|
return;
|
|
2664
2661
|
}
|
|
@@ -2744,12 +2741,12 @@ class ChromeDocument extends Document {
|
|
|
2744
2741
|
}
|
|
2745
2742
|
}
|
|
2746
2743
|
else {
|
|
2747
|
-
throw (0, types_1.errorMessage)(type, "File not found"
|
|
2744
|
+
throw (0, types_1.errorMessage)(type, "File not found", query);
|
|
2748
2745
|
}
|
|
2749
2746
|
}
|
|
2750
2747
|
catch (err) {
|
|
2751
2748
|
this.abort(type);
|
|
2752
|
-
this.writeFail(["Unable to read file"
|
|
2749
|
+
this.writeFail(["Unable to read file", pathname ? path.basename(pathname) : query], err, { startTime });
|
|
2753
2750
|
errorRemove(current);
|
|
2754
2751
|
return;
|
|
2755
2752
|
}
|
|
@@ -2786,7 +2783,7 @@ class ChromeDocument extends Document {
|
|
|
2786
2783
|
this.abort(type);
|
|
2787
2784
|
}
|
|
2788
2785
|
if (err) {
|
|
2789
|
-
this.writeFail(["Unable to execute query"
|
|
2786
|
+
this.writeFail(["Unable to execute query", message || "Unknown"], err, { type: 65536, startTime });
|
|
2790
2787
|
}
|
|
2791
2788
|
return this.aborted;
|
|
2792
2789
|
};
|
|
@@ -2800,7 +2797,7 @@ class ChromeDocument extends Document {
|
|
|
2800
2797
|
}
|
|
2801
2798
|
break;
|
|
2802
2799
|
}
|
|
2803
|
-
errorRemove(current, errorDataSource('Not found', type || "Unknown"
|
|
2800
|
+
errorRemove(current, errorDataSource('Not found', type || "Unknown"));
|
|
2804
2801
|
return;
|
|
2805
2802
|
}
|
|
2806
2803
|
if (this.aborted) {
|
|
@@ -2864,7 +2861,7 @@ class ChromeDocument extends Document {
|
|
|
2864
2861
|
setCacheData.call(this, item, item.value, pathname, cacheData, true);
|
|
2865
2862
|
}
|
|
2866
2863
|
catch (err) {
|
|
2867
|
-
this.writeFail(["Unable to read file"
|
|
2864
|
+
this.writeFail(["Unable to read file", path.basename(pathname)], err, { type: 32, startTime });
|
|
2868
2865
|
errors = true;
|
|
2869
2866
|
}
|
|
2870
2867
|
}
|
|
@@ -2907,7 +2904,7 @@ class ChromeDocument extends Document {
|
|
|
2907
2904
|
const literal = segment.trim();
|
|
2908
2905
|
if (literal[0] === '`' && literal[literal.length - 1] === '`') {
|
|
2909
2906
|
if (!this.hasEval('function')) {
|
|
2910
|
-
errors = (0, types_1.errorMessage)('eval', "Unsupported access"
|
|
2907
|
+
errors = (0, types_1.errorMessage)('eval', "Unsupported access", 'function');
|
|
2911
2908
|
continue;
|
|
2912
2909
|
}
|
|
2913
2910
|
try {
|
|
@@ -3123,34 +3120,34 @@ class ChromeDocument extends Document {
|
|
|
3123
3120
|
default:
|
|
3124
3121
|
removeElement(item, domElement);
|
|
3125
3122
|
if (length === 1) {
|
|
3126
|
-
reject(errorDataSource('Invalid action', item.type || "Unknown"
|
|
3123
|
+
reject(errorDataSource('Invalid action', item.type || "Unknown"));
|
|
3127
3124
|
return;
|
|
3128
3125
|
}
|
|
3129
3126
|
break invalid;
|
|
3130
3127
|
}
|
|
3131
3128
|
if (!domBase.write(domElement) || errors) {
|
|
3132
|
-
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
|
|
3129
|
+
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 });
|
|
3133
3130
|
}
|
|
3134
3131
|
}
|
|
3135
3132
|
}
|
|
3136
3133
|
else {
|
|
3137
3134
|
if (!empty && item.type !== 'display' || item.transactionFail) {
|
|
3138
|
-
const emptyResponse = (value, service = item.source) => errorDataSource(service + ' -> Empty', value || "Unknown"
|
|
3135
|
+
const emptyResponse = (value, service = item.source) => errorDataSource(service + ' -> Empty', value || "Unknown");
|
|
3139
3136
|
switch (item.source) {
|
|
3140
3137
|
case 'cloud': {
|
|
3141
3138
|
const { service, table, id, query } = item;
|
|
3142
3139
|
const queryString = (table ? 'table=' + table : '') + (id || query ? (table ? ';' : '') + (id ? 'id=' + id : 'query=' + asString(query)) : '');
|
|
3143
|
-
(cloud || this).formatFail(64
|
|
3140
|
+
(cloud || this).formatFail(64, service, ["Unable to execute query", queryString], emptyResponse(queryString, service), { ...Cloud.LOG_CLOUD_FAIL, startTime });
|
|
3144
3141
|
break;
|
|
3145
3142
|
}
|
|
3146
3143
|
case 'uri': {
|
|
3147
3144
|
const { uri, format = uri && path.extname(uri).substring(1) } = item;
|
|
3148
|
-
this.formatFail(4
|
|
3145
|
+
this.formatFail(4, format || 'URI', ['No records were found', uri], emptyResponse(uri), { startTime });
|
|
3149
3146
|
break;
|
|
3150
3147
|
}
|
|
3151
3148
|
case 'local': {
|
|
3152
3149
|
const { pathname, format = pathname && path.extname(pathname).substring(1) } = item;
|
|
3153
|
-
this.formatFail(4
|
|
3150
|
+
this.formatFail(4, format || 'LOCAL', ['No records were found', pathname], emptyResponse(pathname), { startTime });
|
|
3154
3151
|
break;
|
|
3155
3152
|
}
|
|
3156
3153
|
case 'export': {
|
|
@@ -3159,7 +3156,7 @@ class ChromeDocument extends Document {
|
|
|
3159
3156
|
if (typeof target === 'function') {
|
|
3160
3157
|
target = target.name;
|
|
3161
3158
|
}
|
|
3162
|
-
this.formatFail(4
|
|
3159
|
+
this.formatFail(4, 'EXPORT', ['No records were retrieved', target], emptyResponse(target), { startTime });
|
|
3163
3160
|
break;
|
|
3164
3161
|
}
|
|
3165
3162
|
}
|
|
@@ -3211,7 +3208,7 @@ class ChromeDocument extends Document {
|
|
|
3211
3208
|
throw (0, types_1.errorMessage)('hash', 'Source not found', item.filename);
|
|
3212
3209
|
}
|
|
3213
3210
|
catch (err) {
|
|
3214
|
-
this.writeFail(["Unable to read file"
|
|
3211
|
+
this.writeFail(["Unable to read file", item.filename], err, { type: 32, startTime });
|
|
3215
3212
|
}
|
|
3216
3213
|
default:
|
|
3217
3214
|
if (algorithm) {
|
|
@@ -3571,5 +3568,9 @@ class ChromeDocument extends Document {
|
|
|
3571
3568
|
}
|
|
3572
3569
|
ChromeDocument.INTERNAL_ASSIGNUUID = '__assign__';
|
|
3573
3570
|
ChromeDocument.INTERNAL_SERVERROOT = '__serverroot__';
|
|
3571
|
+
exports.default = ChromeDocument;
|
|
3574
3572
|
|
|
3575
|
-
|
|
3573
|
+
if (exports.default) {
|
|
3574
|
+
module.exports = exports.default;
|
|
3575
|
+
module.exports.default = exports.default;
|
|
3576
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Chrome document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/anpham6/pi-r.git",
|
|
11
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
12
|
"directory": "src/module/chrome"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -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.6.
|
|
24
|
-
"@e-mc/core": "^0.6.
|
|
25
|
-
"@e-mc/document": "^0.6.
|
|
26
|
-
"@e-mc/types": "^0.6.
|
|
23
|
+
"@e-mc/cloud": "^0.6.1",
|
|
24
|
+
"@e-mc/core": "^0.6.1",
|
|
25
|
+
"@e-mc/document": "^0.6.1",
|
|
26
|
+
"@e-mc/types": "^0.6.1"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -91,12 +91,12 @@ export interface IChromeDocument<T extends IFileManager<U>, U extends DocumentAs
|
|
|
91
91
|
formatMap?: ObjectMap<FormatUri>;
|
|
92
92
|
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
93
93
|
findDataValue(name: string): Undef<string>;
|
|
94
|
-
setInlinedAttributes(processing: FinalizeProcessing<T>): void;
|
|
95
|
-
applyTransforms(processing: FinalizeProcessing<T>): Promise<void>;
|
|
96
|
-
rewriteHtml(processing: FinalizeProcessing<T>): Promise<void>;
|
|
97
|
-
setElementAttributes(processing: FinalizeProcessing<T>, domBase: IDomWriter): Promise<void>;
|
|
98
|
-
applyDataSource(processing: FinalizeProcessing<T>, domBase: IDomWriter): Promise<void>;
|
|
99
|
-
setProductionAttributes(processing: FinalizeProcessing<T>): void;
|
|
94
|
+
setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
95
|
+
applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
96
|
+
rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
97
|
+
setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
98
|
+
applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
99
|
+
setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
100
100
|
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
101
101
|
removeServerRoot(value: string): string;
|
|
102
102
|
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
@@ -116,4 +116,4 @@ export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends
|
|
|
116
116
|
INTERNAL_SERVERROOT: string;
|
|
117
117
|
readonly prototype: IChromeDocument<T, U>;
|
|
118
118
|
new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
|
|
119
|
-
}
|
|
119
|
+
}
|