@pi-r/chrome 0.10.0 → 0.10.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.
Files changed (2) hide show
  1. package/index.js +13 -13
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -22,7 +22,7 @@ const CACHE_FORMAT = new Map();
22
22
  const CACHE_DATASET = {};
23
23
  const CACHE_ATRULES = {};
24
24
  const [PATTERN_STRING_SOME, PATTERN_STRING_MANY] = (function () {
25
- const grouping = '(?:\\s|' + dom_1.DomWriter.PATTERN_COMMENT + '|`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`)';
25
+ const grouping = '(?:\\s|' + dom_1.DomWriter.PATTERN_COMMENT + '|`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}`)';
26
26
  return [grouping + '*', grouping + '+'];
27
27
  })();
28
28
  const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function () {
@@ -38,7 +38,7 @@ const REGEXP_TEMPLATECONDITIONAL = /(\n\s+)?\{\{\s*if\s+((?:[^}]|}(?!}))+?)\}\}(
38
38
  const REGEXP_TEMPLATEELSEIF = /\{\{\s*else if\s+((?:[^}]|}(?!}))+?)\}\}(\s*)((?:.(?!\{\{\s*else if))*)/gs;
39
39
  const REGEXP_TEMPLATECOMPARISON = /\s*\(\s*(?:(eq|ne|lt|le|gt|ge)\s+)?("[^"]+"|'[^']+'|[^\s)]+)(?:\s+("[^"]+"|'[^']+'|[^\s)]+))?\s*\)/g;
40
40
  const REGEXP_TEMPLATEMATCH = new RegExp(`^(?:(and|or|not)\\s+)?((?:${REGEXP_TEMPLATECOMPARISON.source})+)|(!|not\\s+)?([^\\s][\\S\\s]*)$`);
41
- const REGEXP_IMPORTMODULE = /(?:(?:^|[\n;]+)\s*import\s+(?:("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')|.+?from\s+("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')(?:[ \t]+(?:assert|with)[ \t]+\{((?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|`(?:[^`]|(?<=\\)`)+`|{[^{]*{|{[^}]*}|}[^}]*}|[^"'`]+)+)\})?)|\bimport\(\s*("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*(?:,\s*\{((?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|`(?:[^`]|(?<=\\)`)+`|{[^{]*{|{[^}]*}|}[^}]*}|[^"'`]+)+)\}\s*)?\))/gd;
41
+ const REGEXP_IMPORTMODULE = /(?:(?:^|[\n;]+)\s*import\s+(?:("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')|.+?from\s+("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')(?:[ \t]+with[ \t]+\{((?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|`(?:[^`]|(?<=\\)`)+`|{[^{]*{|{[^}]*}|}[^}]*}|[^"'`]+)+)\})?)|\bimport\(\s*("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*(?:,\s*\{((?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|`(?:[^`]|(?<=\\)`)+`|{[^{]*{|{[^}]*}|}[^}]*}|[^"'`]+)+)\}\s*)?\))/gd;
42
42
  const REGEXP_BLOCKEXCLUDE = new RegExp(`(\\s*)<!--\\s*exclude\\s*:\\s*(?:start|end)\\s*-->` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'gi');
43
43
  const REGEXP_COMMENT = new RegExp(dom_1.DomWriter.PATTERN_COMMENT, 'g');
44
44
  const REGEXP_QUOTEDVALUE = new RegExp(`\\b(?:@import${PATTERN_STRING_MANY}|content${PATTERN_STRING_SOME}:${PATTERN_STRING_SOME})(?:"[^"]*"|'[^']*')`, 'gi');
@@ -749,7 +749,7 @@ class ChromeDocument extends Document {
749
749
  }
750
750
  const dest = path.join(destDir, subDir[subDir.length - 1]);
751
751
  Document.renameFile(src, dest);
752
- instance.addLog(types_1.STATUS_TYPE.INFO, `production: ${dest} (mapped)`, { source: subDir.join(path.sep) });
752
+ instance.addLog(4, `production: ${dest} (mapped)`, { source: subDir.join(path.sep) });
753
753
  emptyDir.add(path.dirname(src));
754
754
  if (i !== start) {
755
755
  for (let j = 0; j < i; ++j) {
@@ -774,7 +774,7 @@ class ChromeDocument extends Document {
774
774
  }
775
775
  for (const item of mapped) {
776
776
  if (item[2] === 0) {
777
- instance.addLog(types_1.STATUS_TYPE.INFO, `production: ${item[1]} (mapped: 0)`, { source: item[0] });
777
+ instance.addLog(4, `production: ${item[1]} (mapped: 0)`, { source: item[0] });
778
778
  }
779
779
  }
780
780
  for (const pathname of Array.from(emptyDir).sort((a, b) => b.length - a.length)) {
@@ -1273,13 +1273,13 @@ class ChromeDocument extends Document {
1273
1273
  let mainFile, pathname, match;
1274
1274
  const ignorePath = bundleMain && (mainFile = this.findSourceRoot(bundleMain.uri)) && (Document.isDir(mainFile) || (mainFile = path.dirname(mainFile))) && mainFile === localFile;
1275
1275
  while (match = REGEXP_IMPORTMODULE.exec(output)) {
1276
- const assert = match[3] || match[5];
1276
+ const type = match[3] || match[5];
1277
1277
  const idx = match[1] ? 1 : match[2] ? 2 : 4;
1278
1278
  const [a, b] = match.indices[idx];
1279
1279
  const from = (0, util_1.trimQuote)(match[idx]);
1280
1280
  const quote = output[a];
1281
1281
  const relative = /^\.{0,2}\//.test(from);
1282
- if (assert && /\btype\s*:\s*(["'`])(?:css|json)\1/.test(assert)) {
1282
+ if (type && /\btype\s*:\s*(["'`])(?:css|json)\1/.test(type)) {
1283
1283
  try {
1284
1284
  const asset = host.findAsset(relative ? new URL(from, uri) : from);
1285
1285
  if (asset) {
@@ -1645,7 +1645,7 @@ class ChromeDocument extends Document {
1645
1645
  }
1646
1646
  }
1647
1647
  search ??= restoreSearchParams(asset.url?.search);
1648
- status &&= status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN);
1648
+ status &&= status.filter(item => item.type >= 1 && item.type <= 3);
1649
1649
  watch.send(types_1.WATCH_EVENT.MODIFIED, {
1650
1650
  action: pathname && watch.hot && !watch.main ? 'hot' : '',
1651
1651
  type: asset.mimeType,
@@ -1979,7 +1979,7 @@ class ChromeDocument extends Document {
1979
1979
  if (domBase.hasErrors()) {
1980
1980
  const timeStamp = Date.now();
1981
1981
  for (const err of domBase.errors) {
1982
- this.addLog(types_1.STATUS_TYPE.WARN, err, { timeStamp, source: 'dom-writer' });
1982
+ this.addLog(3, err, { timeStamp, source: 'dom-writer' });
1983
1983
  }
1984
1984
  }
1985
1985
  if (domBase.failCount > 0) {
@@ -2068,7 +2068,7 @@ class ChromeDocument extends Document {
2068
2068
  if (detectWidth || detectHeight) {
2069
2069
  let width = 0, height = 0, buffer = null;
2070
2070
  const addLog = (suffix, err) => {
2071
- this.addLog(types_1.STATUS_TYPE.WARN, err instanceof Error ? err : 'Could not detect image ' + suffix, { source: item.localUri ? path.basename(item.localUri) : item.filename });
2071
+ this.addLog(3, err instanceof Error ? err : 'Could not detect image ' + suffix, { source: item.localUri ? path.basename(item.localUri) : item.filename });
2072
2072
  };
2073
2073
  if (isImage(item.mimeType) && (buffer = host.getBuffer(item))) {
2074
2074
  try {
@@ -2170,7 +2170,7 @@ class ChromeDocument extends Document {
2170
2170
  const batchGroup = [];
2171
2171
  for (const item of sourceSet) {
2172
2172
  if (!item.element) {
2173
- this.addLog(types_1.STATUS_TYPE.WARN, `No target element {${JSON.stringify(item)}}`, { source: 'dom-writer' });
2173
+ this.addLog(3, `No target element {${JSON.stringify(item)}}`, { source: 'dom-writer' });
2174
2174
  continue;
2175
2175
  }
2176
2176
  const type = item.source;
@@ -2246,7 +2246,7 @@ class ChromeDocument extends Document {
2246
2246
  result = await cloud.getDatabaseBatchRows(batch, true, this.sessionKey).catch((err) => {
2247
2247
  this.abort(type);
2248
2248
  if (err instanceof Error) {
2249
- cloud.addLog(this.aborted ? types_1.STATUS_TYPE.ERROR : types_1.STATUS_TYPE.WARN, errors = err, { source: batch[0].service });
2249
+ cloud.addLog(this.aborted ? 2 : 3, errors = err, { source: batch[0].service });
2250
2250
  }
2251
2251
  return [];
2252
2252
  });
@@ -3249,7 +3249,7 @@ class ChromeDocument extends Document {
3249
3249
  while (bracket = pattern.exec(current)) {
3250
3250
  const segment = bracket[0];
3251
3251
  if (/[{}]/.test(segment)) {
3252
- const placeholder = '`' + (0, node_crypto_1.randomUUID)() + '`';
3252
+ const placeholder = '`' + (0, node_crypto_1.randomUUID)().substring(0, 18) + '`';
3253
3253
  replaceMap.push([placeholder, segment]);
3254
3254
  current = replaceMatch(bracket, current, placeholder, pattern);
3255
3255
  }
@@ -3262,7 +3262,7 @@ class ChromeDocument extends Document {
3262
3262
  for (let i = 0, length = values.length; i < length; ++i) {
3263
3263
  const seg = values[i];
3264
3264
  if (/^url\([^{}]*[{}].*\)$/is.test(seg)) {
3265
- replaceMap.push([values[i] = (0, node_crypto_1.randomUUID)(), seg]);
3265
+ replaceMap.push([values[i] = (0, node_crypto_1.randomUUID)().substring(0, 18), seg]);
3266
3266
  }
3267
3267
  }
3268
3268
  if (replaceMap.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/chrome",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Chrome document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,10 +20,10 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "^0.12.0",
24
- "@e-mc/core": "^0.12.0",
25
- "@e-mc/document": "^0.12.0",
26
- "@e-mc/types": "^0.12.0",
23
+ "@e-mc/cloud": "^0.12.5",
24
+ "@e-mc/core": "^0.12.5",
25
+ "@e-mc/document": "^0.12.5",
26
+ "@e-mc/types": "^0.12.5",
27
27
  "image-size": "^2.0.2"
28
28
  }
29
29
  }