@pi-r/chrome 0.2.1 → 0.2.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2023 Mile Square Park
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,5 +1,7 @@
1
- ### @pi-r/chrome
1
+ # @pi-r/chrome
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
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
@@ -123,23 +123,9 @@ function findClosingIndex(source, lastIndex) {
123
123
  }
124
124
  return [endIndex, trailing];
125
125
  }
126
- function getPackageName(err, value) {
126
+ function getPackageName(err) {
127
127
  if (err instanceof Error && err.code === types_1.ERR_CODE.MODULE_NOT_FOUND) {
128
- switch (value) {
129
- case 'mongodb':
130
- case 'redis':
131
- return value;
132
- case 'mysql':
133
- return 'mysql2';
134
- case 'postgres':
135
- return 'pg';
136
- case 'oracle':
137
- return 'oracledb';
138
- case 'mssql':
139
- return 'tedious';
140
- default:
141
- return (0, util_1.getModuleName)(err);
142
- }
128
+ return (0, util_1.getModuleName)(err);
143
129
  }
144
130
  }
145
131
  function getCacheItem(map, key) {
@@ -156,7 +142,7 @@ function addCacheItem(map, key, data, timeout) {
156
142
  map.set(key, [
157
143
  Date.now(),
158
144
  data,
159
- setTimeout(() => deleteCacheItem(map, key), timeout * 1000 /* TIME.S */)
145
+ setTimeout(() => deleteCacheItem(map, key), timeout * 1000)
160
146
  ]);
161
147
  }
162
148
  function deleteCacheItem(map, key) {
@@ -214,10 +200,10 @@ function hasCondition(data, condition) {
214
200
  if (arg2) {
215
201
  switch (item[0]) {
216
202
  case 'eq':
217
- valid = parseArg(arg1) == parseArg(arg2); // eslint-disable-line eqeqeq
203
+ valid = parseArg(arg1) == parseArg(arg2);
218
204
  break;
219
205
  case 'ne':
220
- valid = parseArg(arg1) != parseArg(arg2); // eslint-disable-line eqeqeq
206
+ valid = parseArg(arg1) != parseArg(arg2);
221
207
  break;
222
208
  case 'lt':
223
209
  valid = parseArg(arg1) < parseArg(arg2);
@@ -347,7 +333,7 @@ function createHash(host, file, bufferMap) {
347
333
  throw (0, types_1.errorMessage)('hash', 'Source not found', file.filename);
348
334
  }
349
335
  catch (err) {
350
- host.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, file.filename], err, 32 /* LOG_TYPE.FILE */);
336
+ host.writeFail(["Unable to read file", file.filename], err, 32);
351
337
  }
352
338
  }
353
339
  }
@@ -489,7 +475,7 @@ function transformURL(host, parent, type, source, importFile) {
489
475
  }
490
476
  }
491
477
  if (asset.initialValue && !asset.initialValue.cacheable) {
492
- parent.flags |= 16 /* ASSET_FLAG.MODIFIED */;
478
+ parent.flags |= 16;
493
479
  }
494
480
  related.push(asset);
495
481
  }
@@ -585,7 +571,7 @@ function transformURL(host, parent, type, source, importFile) {
585
571
  else {
586
572
  related.push(asset);
587
573
  if (!(0, types_1.existsFlag)(asset.flags)) {
588
- asset.flags |= 8 /* ASSET_FLAG.WATCH */;
574
+ asset.flags |= 8;
589
575
  }
590
576
  }
591
577
  modified = true;
@@ -745,12 +731,12 @@ function transformJs(host, file, output) {
745
731
  });
746
732
  }
747
733
  else {
748
- this.writeFail(['Unable to create element entry point', path.basename(chunkUri)], (0, types_1.errorMessage)('js', 'Element not found', chunkUri), 4 /* LOG_TYPE.PROCESS */);
734
+ this.writeFail(['Unable to create element entry point', path.basename(chunkUri)], (0, types_1.errorMessage)('js', 'Element not found', chunkUri), 4);
749
735
  }
750
736
  }
751
737
  }
752
738
  catch (err) {
753
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(chunkUri)], err, 32 /* LOG_TYPE.FILE */);
739
+ this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
754
740
  }
755
741
  }
756
742
  appending?.forEach(item => item.order += order);
@@ -832,19 +818,18 @@ async function checkData(item, name, result, validate) {
832
818
  if (typeof callback === 'function') {
833
819
  try {
834
820
  let output;
835
- // @ts-ignore
836
- if (callback["__cjs__" /* INTERNAL.CJS */]) {
821
+ if (callback["__cjs__"]) {
837
822
  output = await callback(result, item);
838
823
  }
839
824
  else {
840
- output = await callback.apply(Document.enabled("node.process.inline" /* KEY_NAME.NODE_PROCESS_INLINE */) ? process : null, Document.enabled("node.require.inline" /* KEY_NAME.NODE_REQUIRE_INLINE */) ? [result, item, require] : [result, item]);
825
+ output = await callback.apply(Document.enabled("node.process.inline") ? process : null, Document.enabled("node.require.inline") ? [result, item, require] : [result, item]);
841
826
  }
842
827
  if (validate(output)) {
843
828
  return output;
844
829
  }
845
830
  }
846
831
  catch (err) {
847
- this.writeFail(["Unable to parse inline method" /* ERR_MESSAGE.INLINE_METHOD */, name], err);
832
+ this.writeFail(["Unable to parse inline method", name], err);
848
833
  }
849
834
  }
850
835
  }
@@ -872,7 +857,6 @@ const getEndIndex = (match) => match.index + match[0].length;
872
857
  const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url?.search) : '');
873
858
  const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
874
859
  const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
875
- // @ts-ignore
876
860
  class ChromeDocument extends Document {
877
861
  constructor() {
878
862
  super(...arguments);
@@ -952,7 +936,7 @@ class ChromeDocument extends Document {
952
936
  const { Db: db, htmlFile, assets } = instance;
953
937
  const outHtml = htmlFile && !isIgnored(htmlFile, true);
954
938
  if (db && await db.commit()) {
955
- db.writeTimeElapsed('DB', ["Transactions were committed" /* VAL_MESSAGE.COMMIT_TRANSACTION */, db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 /* LOG_TYPE.DB */ });
939
+ db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
956
940
  }
957
941
  if (instance.dataSource.length === 0 && outHtml) {
958
942
  const incremental = htmlFile.incremental ?? this.incremental;
@@ -995,7 +979,7 @@ class ChromeDocument extends Document {
995
979
  }
996
980
  case 'exists':
997
981
  if (hint || isHtmlOnly()) {
998
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, 'HTML', ['No changes detected', 'incremental: ' + incremental], hint, { ...Document.LOG_STYLE_NOTICE, messageBgColor: 'bgWhite', messageColor: 'black' });
982
+ this.formatMessage(4, 'HTML', ['No changes detected', 'incremental: ' + incremental], hint, { ...Document.LOG_STYLE_NOTICE, messageBgColor: 'bgWhite', messageColor: 'black' });
999
983
  return super.finalize.call(this, instance);
1000
984
  }
1001
985
  break;
@@ -1035,7 +1019,7 @@ class ChromeDocument extends Document {
1035
1019
  for (const item of children) {
1036
1020
  if (!items.has(item)) {
1037
1021
  if (isWatched.call(instance, item)) {
1038
- item.flags |= 8 /* ASSET_FLAG.WATCH */;
1022
+ item.flags |= 8;
1039
1023
  }
1040
1024
  items.add(item);
1041
1025
  const next = related.get(item);
@@ -1064,18 +1048,18 @@ class ChromeDocument extends Document {
1064
1048
  this.delete(value);
1065
1049
  }
1066
1050
  else {
1067
- instance.writeFail(["Unable to move file" /* ERR_MESSAGE.MOVE_FILE */, instance.moduleName], (0, types_1.errorMessage)('production', path.join(this.baseDirectory, value)), { fatal: true });
1051
+ instance.writeFail(["Unable to move file", instance.moduleName], (0, types_1.errorMessage)('production', path.join(this.baseDirectory, value)), { fatal: true });
1068
1052
  }
1069
1053
  }
1070
1054
  }
1071
1055
  }
1072
1056
  }
1073
1057
  else {
1074
- instance.writeFail(["Unable to write directory" /* ERR_MESSAGE.WRITE_DIRECTORY */, instance.moduleName], (0, types_1.errorMessage)('production', 'Access denied', productionRelease));
1058
+ instance.writeFail(["Unable to write directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Access denied', productionRelease));
1075
1059
  }
1076
1060
  }
1077
1061
  else {
1078
- instance.writeFail(["Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, instance.moduleName], (0, types_1.errorMessage)('production', 'Invalid directory', productionRelease), 32 /* LOG_TYPE.FILE */);
1062
+ instance.writeFail(["Unable to read directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Invalid directory', productionRelease), 32);
1079
1063
  }
1080
1064
  }
1081
1065
  }
@@ -1380,7 +1364,7 @@ class ChromeDocument extends Document {
1380
1364
  await instance.tryFile(buffer, { format: to, filename: file.filename, etag: file.etag }, (err, result, ext) => {
1381
1365
  if (err) {
1382
1366
  setFormat();
1383
- this.writeFail("Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, err, 8 /* LOG_TYPE.COMPRESS */);
1367
+ this.writeFail("Unable to compress file", err, 8);
1384
1368
  }
1385
1369
  else if (result) {
1386
1370
  if (ext) {
@@ -1394,7 +1378,7 @@ class ChromeDocument extends Document {
1394
1378
  host.replace(file, output);
1395
1379
  }
1396
1380
  else {
1397
- this.writeFail("Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, error, 32 /* LOG_TYPE.FILE */);
1381
+ this.writeFail("Unable to write file", error, 32);
1398
1382
  }
1399
1383
  });
1400
1384
  }
@@ -1703,7 +1687,7 @@ class ChromeDocument extends Document {
1703
1687
  item.sourceUTF8 = output;
1704
1688
  }
1705
1689
  catch (err) {
1706
- host.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(item.localUri)], err, 32 /* LOG_TYPE.FILE */);
1690
+ host.writeFail(["Unable to write file", path.basename(item.localUri)], err, 32);
1707
1691
  }
1708
1692
  }
1709
1693
  }
@@ -1907,7 +1891,7 @@ class ChromeDocument extends Document {
1907
1891
  host.removeAsset(item);
1908
1892
  }
1909
1893
  catch (err) {
1910
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, item.filename], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
1894
+ this.writeFail(["Unable to read file", item.filename], err, { type: 32, startTime });
1911
1895
  return false;
1912
1896
  }
1913
1897
  }
@@ -2089,7 +2073,7 @@ class ChromeDocument extends Document {
2089
2073
  const { moduleName, config } = this;
2090
2074
  const htmlFile = this.htmlFile;
2091
2075
  const localUri = htmlFile.localUri;
2092
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, 'HTML', ['Rewriting content...', path.dirname(localUri)]);
2076
+ this.formatMessage(4, 'HTML', ['Rewriting content...', path.dirname(localUri)]);
2093
2077
  let source = host.getUTF8String(htmlFile, localUri), output;
2094
2078
  const domBase = new dom_1.DomWriter(moduleName, source, this.elements, { normalize: config.normalizeHtmlOutput, stripComments: config.stripCommentsAndCDATA, ignoreTagGroup: config.ignoreServerCodeBlocks, escapeEntities: config.escapeReservedCharacters });
2095
2079
  if (config.useUnsafeHtmlReplace) {
@@ -2114,7 +2098,7 @@ class ChromeDocument extends Document {
2114
2098
  const domElement = new dom_1.HtmlElement(moduleName, item.element, item.attributes);
2115
2099
  domElement.remove = true;
2116
2100
  if (!domBase.write(domElement)) {
2117
- this.writeFail('Unable to exclude HTML element', errorHtml(item.element), 4 /* LOG_TYPE.PROCESS */);
2101
+ this.writeFail('Unable to exclude HTML element', errorHtml(item.element), 4);
2118
2102
  }
2119
2103
  }
2120
2104
  }
@@ -2152,7 +2136,7 @@ class ChromeDocument extends Document {
2152
2136
  domBase.errors.forEach(err => this.addLog(types_1.STATUS_TYPE.WARN, 'dom-writer -> ' + err.message, timeStamp));
2153
2137
  }
2154
2138
  if (domBase.failCount > 0) {
2155
- this.writeFail(['Unable to update document', moduleName], (0, types_1.errorMessage)('html', 'DOM rewrite failed', domBase.failCount + ' errors'), { type: 4 /* LOG_TYPE.PROCESS */, startTime });
2139
+ this.writeFail(['Unable to update document', moduleName], (0, types_1.errorMessage)('html', 'DOM rewrite failed', domBase.failCount + ' errors'), { type: 4, startTime });
2156
2140
  }
2157
2141
  else {
2158
2142
  this.writeTimeProcess('html', `dom-writer (${domBase.modifyCount} modified) -> ` + path.basename(localUri), startTime);
@@ -2163,7 +2147,7 @@ class ChromeDocument extends Document {
2163
2147
  for (const name in data) {
2164
2148
  message.push(name + `(${data[name]})`);
2165
2149
  }
2166
- this.formatMessage(65536 /* LOG_TYPE.DB */, 'DB', ['Cache statistics', cacheMiss.length + ' missed'], message.join(' - '), { ...Document.LOG_STYLE_NOTICE, hintBold: true });
2150
+ this.formatMessage(65536, 'DB', ['Cache statistics', cacheMiss.length + ' missed'], message.join(' - '), { ...Document.LOG_STYLE_NOTICE, hintBold: true });
2167
2151
  }
2168
2152
  }
2169
2153
  htmlFile.modified = true;
@@ -2279,7 +2263,7 @@ class ChromeDocument extends Document {
2279
2263
  }
2280
2264
  }
2281
2265
  if (!domBase.write(domElement)) {
2282
- this.writeFail(item.inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4 /* LOG_TYPE.PROCESS */, startTime });
2266
+ this.writeFail(item.inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4, startTime });
2283
2267
  delete item.inlineUrlCloud;
2284
2268
  }
2285
2269
  else if (item.inlineContent) {
@@ -2303,15 +2287,15 @@ class ChromeDocument extends Document {
2303
2287
  if (item.removeEmpty || item.type === 'display') {
2304
2288
  (element || (element = new dom_1.HtmlElement(moduleName, item.element))).remove = true;
2305
2289
  if (!domBase.write(element)) {
2306
- this.writeFail('Unable to remove element', errorHtml(item.element), { type: 4 /* LOG_TYPE.PROCESS */, startTime });
2290
+ this.writeFail('Unable to remove element', errorHtml(item.element), { type: 4, startTime });
2307
2291
  }
2308
2292
  }
2309
2293
  };
2310
2294
  const errorCredential = (item, err) => {
2311
2295
  removeElement(item);
2312
- const pkg = getPackageName(err, item.source);
2296
+ const pkg = getPackageName(err);
2313
2297
  if (!(pkg && this.checkPackage(err, pkg))) {
2314
- this.writeFail(["Invalid credentials" /* ERR_DB.CREDENTIALS */, item.source], err);
2298
+ this.writeFail(["Invalid credentials", item.source], err);
2315
2299
  }
2316
2300
  };
2317
2301
  const checkObject = (item, data) => {
@@ -2341,7 +2325,7 @@ class ChromeDocument extends Document {
2341
2325
  }
2342
2326
  catch (err) {
2343
2327
  this.abort(item.source);
2344
- this.checkPackage(err, pkg, ["Unable to filter results" /* ERR_DB.FILTER_QUERY */, item.source]);
2328
+ this.checkPackage(err, pkg, ["Unable to filter results", item.source]);
2345
2329
  }
2346
2330
  }
2347
2331
  }
@@ -2364,7 +2348,7 @@ class ChromeDocument extends Document {
2364
2348
  (batchMap[key] || (batchMap[key] = [])).push(item);
2365
2349
  }
2366
2350
  else {
2367
- errorCredential(item, (0, types_1.errorValue)("Cloud module not installed" /* ERR_CLOUD.MODULE_NOTFOUND */, service));
2351
+ errorCredential(item, (0, types_1.errorValue)("Cloud module not installed", service));
2368
2352
  }
2369
2353
  break;
2370
2354
  }
@@ -2397,7 +2381,7 @@ class ChromeDocument extends Document {
2397
2381
  }
2398
2382
  }
2399
2383
  else {
2400
- errorCredential(item, (0, types_1.errorValue)(db ? "Database provider not found" /* ERR_DB.PROVIDER_NOTFOUND */ : "Db module not installed" /* ERR_DB.MODULE_NOTFOUND */, type));
2384
+ errorCredential(item, (0, types_1.errorValue)(db ? "Database provider not found" : "Db module not installed", type));
2401
2385
  }
2402
2386
  break;
2403
2387
  }
@@ -2414,7 +2398,7 @@ class ChromeDocument extends Document {
2414
2398
  const errorClient = (item, reason) => {
2415
2399
  removeElement(item);
2416
2400
  if (reason) {
2417
- this.writeFail(["Unable to configure client" /* ERR_DB.CLIENT */, item.source], reason);
2401
+ this.writeFail(["Unable to configure client", item.source], reason);
2418
2402
  }
2419
2403
  reject();
2420
2404
  };
@@ -2456,7 +2440,7 @@ class ChromeDocument extends Document {
2456
2440
  }
2457
2441
  catch (err) {
2458
2442
  this.abort(type);
2459
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(location)], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
2443
+ this.writeFail(["Unable to read file", path.basename(location)], err, { type: 32, startTime });
2460
2444
  errorRemove(current);
2461
2445
  return;
2462
2446
  }
@@ -2492,7 +2476,7 @@ class ChromeDocument extends Document {
2492
2476
  }
2493
2477
  catch (err) {
2494
2478
  this.abort(type);
2495
- this.writeFail(["Unable to download file" /* ERR_MESSAGE.DOWNLOAD_FILE */, target], err, { type: 1024 /* LOG_TYPE.HTTP */, startTime });
2479
+ this.writeFail(["Unable to download file", target], err, { type: 1024, startTime });
2496
2480
  errorRemove(current);
2497
2481
  return;
2498
2482
  }
@@ -2521,7 +2505,7 @@ class ChromeDocument extends Document {
2521
2505
  }
2522
2506
  catch (err) {
2523
2507
  this.abort(type);
2524
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(pathname)], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
2508
+ this.writeFail(["Unable to read file", path.basename(pathname)], err, { type: 32, startTime });
2525
2509
  errorRemove(current);
2526
2510
  return;
2527
2511
  }
@@ -2535,7 +2519,7 @@ class ChromeDocument extends Document {
2535
2519
  }
2536
2520
  catch (err) {
2537
2521
  this.abort(type);
2538
- this.writeFail(['Unable to parse data source', format], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime });
2522
+ this.writeFail(['Unable to parse data source', format], err, { type: 4, startTime });
2539
2523
  errorRemove(current);
2540
2524
  return;
2541
2525
  }
@@ -2613,13 +2597,12 @@ class ChromeDocument extends Document {
2613
2597
  if (params && this.settingsOf(type, 'coerce') === true) {
2614
2598
  (0, types_1.coerceObject)(params);
2615
2599
  }
2616
- // @ts-ignore
2617
- if (getData["__cjs__" /* INTERNAL.CJS */]) {
2600
+ if (getData["__cjs__"]) {
2618
2601
  data = await getData(params);
2619
2602
  }
2620
2603
  else {
2621
- const thisArg = Document.enabled("node.process.inline" /* KEY_NAME.NODE_PROCESS_INLINE */) ? process : null;
2622
- const inline = Document.enabled("node.require.inline" /* KEY_NAME.NODE_REQUIRE_INLINE */);
2604
+ const thisArg = Document.enabled("node.process.inline") ? process : null;
2605
+ const inline = Document.enabled("node.require.inline");
2623
2606
  const args = [params];
2624
2607
  if (getData.toString().startsWith('async')) {
2625
2608
  if (inline) {
@@ -2641,7 +2624,7 @@ class ChromeDocument extends Document {
2641
2624
  }
2642
2625
  catch (err) {
2643
2626
  this.abort(type);
2644
- this.writeFail(['Unable to retrieve data source', hint], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime });
2627
+ this.writeFail(['Unable to retrieve data source', hint], err, { type: 4, startTime });
2645
2628
  errorRemove(current);
2646
2629
  return;
2647
2630
  }
@@ -2727,12 +2710,12 @@ class ChromeDocument extends Document {
2727
2710
  }
2728
2711
  }
2729
2712
  else {
2730
- throw (0, types_1.errorMessage)(type, "File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, query);
2713
+ throw (0, types_1.errorMessage)(type, "File not found", query);
2731
2714
  }
2732
2715
  }
2733
2716
  catch (err) {
2734
2717
  this.abort(type);
2735
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, pathname ? path.basename(pathname) : query], err, { startTime });
2718
+ this.writeFail(["Unable to read file", pathname ? path.basename(pathname) : query], err, { startTime });
2736
2719
  errorRemove(current);
2737
2720
  return;
2738
2721
  }
@@ -2769,7 +2752,7 @@ class ChromeDocument extends Document {
2769
2752
  this.abort(type);
2770
2753
  }
2771
2754
  if (err) {
2772
- this.writeFail(["Unable to execute query" /* ERR_DB.EXEC_QUERY */, message || "Unknown" /* ERR_MESSAGE.UNKNOWN */], err, { type: 65536 /* LOG_TYPE.DB */, startTime });
2755
+ this.writeFail(["Unable to execute query", message || "Unknown"], err, { type: 65536, startTime });
2773
2756
  }
2774
2757
  return this.aborted;
2775
2758
  };
@@ -2778,12 +2761,12 @@ class ChromeDocument extends Document {
2778
2761
  }
2779
2762
  catch (err) {
2780
2763
  this.abort(type);
2781
- const pkg = getPackageName(err, type);
2764
+ const pkg = getPackageName(err);
2782
2765
  errorClient(current, pkg && this.checkPackage(err, pkg) ? null : err);
2783
2766
  }
2784
2767
  break;
2785
2768
  }
2786
- errorRemove(current, errorDataSource('Not found', type || "Unknown" /* ERR_MESSAGE.UNKNOWN */));
2769
+ errorRemove(current, errorDataSource('Not found', type || "Unknown"));
2787
2770
  return;
2788
2771
  }
2789
2772
  if (this.aborted) {
@@ -2847,7 +2830,7 @@ class ChromeDocument extends Document {
2847
2830
  setCacheData.call(this, item, item.value, pathname, cacheData, true);
2848
2831
  }
2849
2832
  catch (err) {
2850
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(pathname)], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
2833
+ this.writeFail(["Unable to read file", path.basename(pathname)], err, { type: 32, startTime });
2851
2834
  errors = true;
2852
2835
  }
2853
2836
  }
@@ -2890,7 +2873,7 @@ class ChromeDocument extends Document {
2890
2873
  const literal = segment.trim();
2891
2874
  if (literal[0] === '`' && literal[literal.length - 1] === '`') {
2892
2875
  if (!this.hasEval('function')) {
2893
- errors = (0, types_1.errorMessage)('eval', "Unsupported access" /* ERR_MESSAGE.UNSUPPORTED_ACCESS */, 'function');
2876
+ errors = (0, types_1.errorMessage)('eval', "Unsupported access", 'function');
2894
2877
  continue;
2895
2878
  }
2896
2879
  try {
@@ -3106,34 +3089,34 @@ class ChromeDocument extends Document {
3106
3089
  default:
3107
3090
  removeElement(item, domElement);
3108
3091
  if (length === 1) {
3109
- reject(errorDataSource('Invalid action', item.type || "Unknown" /* ERR_MESSAGE.UNKNOWN */));
3092
+ reject(errorDataSource('Invalid action', item.type || "Unknown"));
3110
3093
  return;
3111
3094
  }
3112
3095
  break invalid;
3113
3096
  }
3114
3097
  if (!domBase.write(domElement) || errors) {
3115
- 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 /* LOG_TYPE.PROCESS */, startTime });
3098
+ 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 });
3116
3099
  }
3117
3100
  }
3118
3101
  }
3119
3102
  else {
3120
3103
  if (!empty && item.type !== 'display' || item.transactionFail) {
3121
- const emptyResponse = (value, service = item.source) => errorDataSource(service + ' -> Empty', value || "Unknown" /* ERR_MESSAGE.UNKNOWN */);
3104
+ const emptyResponse = (value, service = item.source) => errorDataSource(service + ' -> Empty', value || "Unknown");
3122
3105
  switch (item.source) {
3123
3106
  case 'cloud': {
3124
3107
  const { service, table, id, query } = item;
3125
3108
  const queryString = (table ? 'table=' + table : '') + (id || query ? (table ? ';' : '') + (id ? 'id=' + id : 'query=' + asString(query)) : '');
3126
- (cloud || this).formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to execute query" /* ERR_DB.EXEC_QUERY */, queryString], emptyResponse(queryString, service), { ...Cloud.LOG_CLOUD_FAIL, startTime });
3109
+ (cloud || this).formatFail(64, service, ["Unable to execute query", queryString], emptyResponse(queryString, service), { ...Cloud.LOG_CLOUD_FAIL, startTime });
3127
3110
  break;
3128
3111
  }
3129
3112
  case 'uri': {
3130
3113
  const { uri, format = uri && path.extname(uri).substring(1) } = item;
3131
- this.formatFail(4 /* LOG_TYPE.PROCESS */, format || 'URI', ['No records were found', uri], emptyResponse(uri), { startTime });
3114
+ this.formatFail(4, format || 'URI', ['No records were found', uri], emptyResponse(uri), { startTime });
3132
3115
  break;
3133
3116
  }
3134
3117
  case 'local': {
3135
3118
  const { pathname, format = pathname && path.extname(pathname).substring(1) } = item;
3136
- this.formatFail(4 /* LOG_TYPE.PROCESS */, format || 'LOCAL', ['No records were found', pathname], emptyResponse(pathname), { startTime });
3119
+ this.formatFail(4, format || 'LOCAL', ['No records were found', pathname], emptyResponse(pathname), { startTime });
3137
3120
  break;
3138
3121
  }
3139
3122
  case 'export': {
@@ -3142,7 +3125,7 @@ class ChromeDocument extends Document {
3142
3125
  if (typeof target === 'function') {
3143
3126
  target = target.name;
3144
3127
  }
3145
- this.formatFail(4 /* LOG_TYPE.PROCESS */, 'EXPORT', ['No records were retrieved', target], emptyResponse(target), { startTime });
3128
+ this.formatFail(4, 'EXPORT', ['No records were retrieved', target], emptyResponse(target), { startTime });
3146
3129
  break;
3147
3130
  }
3148
3131
  }
@@ -3194,7 +3177,7 @@ class ChromeDocument extends Document {
3194
3177
  throw (0, types_1.errorMessage)('hash', 'Source not found', item.filename);
3195
3178
  }
3196
3179
  catch (err) {
3197
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, item.filename], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
3180
+ this.writeFail(["Unable to read file", item.filename], err, { type: 32, startTime });
3198
3181
  }
3199
3182
  default:
3200
3183
  if (algorithm) {
@@ -3554,5 +3537,9 @@ class ChromeDocument extends Document {
3554
3537
  }
3555
3538
  ChromeDocument.INTERNAL_ASSIGNUUID = '__assign__';
3556
3539
  ChromeDocument.INTERNAL_SERVERROOT = '__serverroot__';
3540
+ exports.default = ChromeDocument;
3557
3541
 
3558
- module.exports = ChromeDocument;
3542
+ if (exports.default) {
3543
+ module.exports = exports.default;
3544
+ module.exports.default = exports.default;
3545
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/chrome",
3
- "version": "0.2.1",
3
+ "version": "0.2.8",
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.5.2",
24
- "@e-mc/core": "^0.5.2",
25
- "@e-mc/document": "^0.5.2",
26
- "@e-mc/types": "^0.5.2"
23
+ "@e-mc/cloud": "^0.5.4",
24
+ "@e-mc/core": "^0.5.4",
25
+ "@e-mc/document": "^0.5.4",
26
+ "@e-mc/types": "^0.5.4"
27
27
  }
28
28
  }