@pi-r/chrome 0.2.8 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Mile Square Park
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
@@ -1,6 +1,6 @@
1
1
  # @pi-r/chrome
2
2
 
3
- PEP 402 - Forever
3
+ PEP 402 - Forever Aina
4
4
 
5
5
  ## LICENSE
6
6
 
package/index.js CHANGED
@@ -38,9 +38,13 @@ const REGEXP_FONTFACE_UNSAFE = new RegExp(`(\\s*)@font-face\\s*{([^}]+)}` + dom_
38
38
  const REGEXP_FONTFAMILY_UNSAFE = /font-family\s*:([^;}]+)/i;
39
39
  const REGEXP_KEYFRAMES_UNSAFE = /(\s*)@keyframes\s+([^{]+){/gi;
40
40
  const REGEXP_NTHCHILD_UNSAFE = /\(\s*([+-])?(?:(\d*)[nN]|(0))\s*([+-])?\s*(\d*)\s*\)/g;
41
+ const REGEXP_OBJECT_NAME = /([^[.\s]+)((?:\s*\[[^\]]+\]\s*)+)?\s*\.?\s*/g;
42
+ const REGEXP_OBJECT_SUBSCRIPT = /\[\s*(["'])?(.+?)\1\s*\]/g;
43
+ const REGEXP_TEMPLATE_LEADING = /\s*\{\{- \s*((?:[^}]|}(?!}))+?)\}\}/g;
44
+ const REGEXP_TEMPLATE_TRAILING = /\{\{((?:[^}]|}(?!}))+?)\s*? -\}\}\s*/g;
41
45
  function removeNamespace(name, source, newline, comments) {
42
46
  if (source.indexOf('-' + name) !== -1) {
43
- const dataset = CACHE_DATASET[name] || (CACHE_DATASET[name] = [
47
+ const [a, b, c, d, e] = CACHE_DATASET[name] || (CACHE_DATASET[name] = [
44
48
  new RegExp(`(\\s*)<(script|style)(${dom_1.DomWriter.PATTERN_TAGOPEN}+)>[\\S\\s]*?<\\/\\2\\s*>` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'gi'),
45
49
  new RegExp(`(\\s*)<link(${dom_1.DomWriter.PATTERN_TAGOPEN}+)>` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'gi'),
46
50
  new RegExp(`\\s+data-${name}-[a-z-]+\\s*` + dom_1.DomWriter.PATTERN_ATTRVALUE, 'g'),
@@ -48,24 +52,26 @@ function removeNamespace(name, source, newline, comments) {
48
52
  new RegExp(`data-${name}-template\\s*` + dom_1.DomWriter.PATTERN_ATTRVALUE)
49
53
  ]);
50
54
  source = source
51
- .replace(dataset[0], (...capture) => dataset[3].test(capture[3]) || dataset[4].test(capture[3]) ? getNewlineString(capture[1], capture[7], newline) : capture[0])
52
- .replace(dataset[1], (...capture) => dataset[3].test(capture[2]) ? getNewlineString(capture[1], capture[6], newline) : capture[0])
53
- .replace(dataset[2], '');
55
+ .replace(a, (...capture) => d.test(capture[3]) || e.test(capture[3]) ? getNewlineString(capture[1], capture[7], newline) : capture[0])
56
+ .replace(b, (...capture) => d.test(capture[2]) ? getNewlineString(capture[1], capture[6], newline) : capture[0])
57
+ .replace(c, '');
54
58
  }
55
59
  return (0, types_1.isArray)(comments) ? source.replace(REGEXP_BLOCKEXCLUDE, (...capture) => getNewlineString(capture[1], capture[2], newline)) : source;
56
60
  }
57
61
  function getObjectValue(value, key) {
58
- const pattern = /([^[.\s]+)((?:\s*\[[^\]]+\]\s*)+)?\s*\.?\s*/g;
62
+ REGEXP_OBJECT_NAME.lastIndex = 0;
59
63
  let found, match;
60
- while (match = pattern.exec(key)) {
64
+ while (match = REGEXP_OBJECT_NAME.exec(key)) {
61
65
  if ((0, types_1.isObject)(value)) {
62
66
  value = value[match[1]];
63
- if (match[2]) {
64
- const subscript = /\[\s*(["'])?(.+?)\1\s*\]/g;
67
+ const name = match[2];
68
+ if (name) {
69
+ REGEXP_OBJECT_SUBSCRIPT.lastIndex = 0;
65
70
  let index;
66
- while (index = subscript.exec(match[2])) {
67
- const attr = index[1] ? index[2] : index[2].trim();
68
- if (index[1] && (0, types_1.isObject)(value) || /^\d+$/.test(attr) && (typeof value === 'string' || (0, types_1.isObject)(value))) {
71
+ while (index = REGEXP_OBJECT_SUBSCRIPT.exec(name)) {
72
+ const quote = index[1];
73
+ const attr = quote ? index[2] : index[2].trim();
74
+ if (quote && (0, types_1.isObject)(value) || /^\d+$/.test(attr) && (typeof value === 'string' || (0, types_1.isObject)(value))) {
69
75
  value = value[attr];
70
76
  }
71
77
  else {
@@ -83,14 +89,14 @@ function getObjectValue(value, key) {
83
89
  return found ? value : null;
84
90
  }
85
91
  function trimTemplate(value) {
86
- const leading = /\s*\{\{- \s*((?:[^}]|}(?!}))+?)\}\}/g;
92
+ REGEXP_TEMPLATE_LEADING.lastIndex = 0;
87
93
  let match;
88
- while (match = leading.exec(value)) {
89
- value = replaceMatch(match, value, 1, leading);
94
+ while (match = REGEXP_TEMPLATE_LEADING.exec(value)) {
95
+ value = replaceMatch(match, value, 1, REGEXP_TEMPLATE_LEADING);
90
96
  }
91
- const trailing = /\{\{((?:[^}]|}(?!}))+?)\s*? -\}\}\s*/g;
92
- while (match = trailing.exec(value)) {
93
- value = replaceMatch(match, value, 1, trailing);
97
+ REGEXP_TEMPLATE_TRAILING.lastIndex = 0;
98
+ while (match = REGEXP_TEMPLATE_TRAILING.exec(value)) {
99
+ value = replaceMatch(match, value, 1, REGEXP_TEMPLATE_TRAILING);
94
100
  }
95
101
  return value;
96
102
  }
@@ -168,9 +174,9 @@ function hasCondition(data, condition) {
168
174
  }
169
175
  let match = REGEXP_TEMPLATEMATCH.exec(condition.trim());
170
176
  if (match) {
171
- if (match[2]) {
177
+ const comparison = match[2];
178
+ if (comparison) {
172
179
  const join = match[1];
173
- const comparison = match[2];
174
180
  const items = [];
175
181
  while (match = REGEXP_TEMPLATECOMPARISON.exec(comparison)) {
176
182
  if (items.length && !isSpace(match[0][0])) {
@@ -275,17 +281,14 @@ function hasSameOrigin(value, ...other) {
275
281
  return false;
276
282
  }
277
283
  function restoreSearchParams(value, prefix = '__sqd') {
278
- if (value) {
279
- if (value.indexOf(prefix) !== -1) {
280
- const params = new URLSearchParams(value);
281
- params.forEach((_, key) => key.startsWith(prefix) && params.delete(key));
282
- if (value = params.toString()) {
283
- return '?' + value;
284
- }
284
+ if (value?.indexOf(prefix) !== -1) {
285
+ const params = new URLSearchParams(value);
286
+ params.forEach((_, key) => key.startsWith(prefix) && params.delete(key));
287
+ if (value = params.toString()) {
288
+ return '?' + value;
285
289
  }
286
- return value;
287
290
  }
288
- return '';
291
+ return value || '';
289
292
  }
290
293
  function getBaseURLs(asset, baseUrl) {
291
294
  const result = [];
@@ -315,26 +318,27 @@ function getBaseURLs(asset, baseUrl) {
315
318
  }
316
319
  function createHash(host, file, bufferMap) {
317
320
  const hash = file.hash;
318
- if (hash) {
319
- try {
320
- const localUri = file.localUri;
321
- const buffer = localUri && bufferMap[localUri] || getBuffer(file);
322
- if (buffer) {
323
- const [algorithm, length] = (0, util_1.getHashData)(hash);
324
- let value;
325
- if (algorithm && (value = Document.asHash(buffer, { algorithm, encoding: file.encoding }))) {
326
- if (localUri) {
327
- bufferMap[localUri] = buffer;
328
- }
329
- host.rename(file, (0, util_1.appendSuffix)(file.filename, length ? value.substring(0, length) : value));
330
- return file.filename;
321
+ if (!hash) {
322
+ return;
323
+ }
324
+ const { filename, localUri } = file;
325
+ try {
326
+ const buffer = localUri && bufferMap[localUri] || getBuffer(file);
327
+ if (buffer) {
328
+ const [algorithm, length] = (0, util_1.getHashData)(hash);
329
+ let value;
330
+ if (algorithm && (value = Document.asHash(buffer, { algorithm, encoding: file.encoding }))) {
331
+ if (localUri) {
332
+ bufferMap[localUri] = buffer;
331
333
  }
334
+ host.rename(file, (0, util_1.appendSuffix)(filename, length ? value.substring(0, length) : value));
335
+ return file.filename;
332
336
  }
333
- throw (0, types_1.errorMessage)('hash', 'Source not found', file.filename);
334
- }
335
- catch (err) {
336
- host.writeFail(["Unable to read file", file.filename], err, 32);
337
337
  }
338
+ throw (0, types_1.errorMessage)('hash', 'Source not found', filename);
339
+ }
340
+ catch (err) {
341
+ host.writeFail(["Unable to read file", filename], err, 32);
338
342
  }
339
343
  }
340
344
  function getSrcURL(parent, file) {
@@ -654,7 +658,7 @@ function transformOptions(file, mimeType, code, bundleContent) {
654
658
  const metadata = { userAgentData: this.userAgentData };
655
659
  switch (mimeType) {
656
660
  case 'text/html':
657
- metadata['__fromhtml__'] = true;
661
+ metadata.__fromhtml__ = true;
658
662
  case 'text/css':
659
663
  Object.assign(metadata, this.config);
660
664
  default:
@@ -753,11 +757,12 @@ function replaceCss(file) {
753
757
  map[id] = this.removeServerRoot(map[id]);
754
758
  }
755
759
  };
756
- if (file.inlineUrlMap) {
757
- sanitize(file.inlineUrlMap);
760
+ const { inlineUrlMap, inlineUrlCloudMap } = file;
761
+ if (inlineUrlMap) {
762
+ sanitize(inlineUrlMap);
758
763
  }
759
- if (file.inlineUrlCloudMap) {
760
- sanitize(file.inlineUrlCloudMap);
764
+ if (inlineUrlCloudMap) {
765
+ sanitize(inlineUrlCloudMap);
761
766
  }
762
767
  }
763
768
  function replaceHtml(source, { productionRelease, contentMap }, cssMap) {
@@ -833,6 +838,10 @@ async function checkData(item, name, result, validate) {
833
838
  }
834
839
  }
835
840
  }
841
+ function getBuffer(item) {
842
+ let localUri;
843
+ return item.sourceUTF8 || item.buffer || ((localUri = item.localUri) && isPath(localUri) ? fs.readFileSync(localUri, item.encoding) : null);
844
+ }
836
845
  const getNewlineString = dom_1.DomWriter.getNewlineString.bind(dom_1.DomWriter);
837
846
  const isSpace = dom_1.DomWriter.isSpace.bind(dom_1.DomWriter);
838
847
  const replaceMatch = dom_1.DomWriter.replaceMatch.bind(dom_1.DomWriter);
@@ -843,11 +852,10 @@ const asString = Document.asString.bind(Document);
843
852
  const resolvePath = Document.resolvePath.bind(Document);
844
853
  const toPosix = Document.toPosix.bind(Document);
845
854
  const isDir = Document.isDir.bind(Document);
846
- const hasSourceMap = (metadata, value) => (0, types_1.isObject)(metadata) && metadata['__sourcemap__'] === value;
855
+ const hasSourceMap = (metadata, value) => (0, types_1.isObject)(metadata) && metadata.__sourcemap__ === value;
847
856
  const isBundled = (value, main) => typeof value === 'number' && (value > 0 || main && value === 0);
848
857
  const isFont = (value) => value === 'truetype' || value === 'opentype' || value === 'woff' || value === 'woff2';
849
858
  const isImage = (value) => typeof value === 'string' && value.startsWith('image/') && value !== 'image/svg+xml';
850
- const getBuffer = (item) => item.sourceUTF8 || item.buffer || (item.localUri && isPath(item.localUri) ? fs.readFileSync(item.localUri, item.encoding) : null);
851
859
  const isRemoved = (item) => item.exclude === true || isBundled(item.bundleIndex);
852
860
  const isUnedited = (item) => !item.attributes && !item.inlineContent && !item.srcSet && !item.element.dynamic && item.element.textContent === undefined && (!item.uri && !isBundled(item.bundleIndex, true) || (0, util_1.hasValue)(item.format, 'crossorigin'));
853
861
  const isIgnored = (item, exists) => item.invalid || (0, types_1.ignoreFlag)(item.flags) || !exists && (0, types_1.existsFlag)(item.flags);
@@ -1017,15 +1025,16 @@ class ChromeDocument extends Document {
1017
1025
  const items = new Set((asset.watch.assets || []));
1018
1026
  (function recurse(children) {
1019
1027
  for (const item of children) {
1020
- if (!items.has(item)) {
1021
- if (isWatched.call(instance, item)) {
1022
- item.flags |= 8;
1023
- }
1024
- items.add(item);
1025
- const next = related.get(item);
1026
- if (next) {
1027
- recurse(next);
1028
- }
1028
+ if (items.has(item)) {
1029
+ continue;
1030
+ }
1031
+ if (isWatched.call(instance, item)) {
1032
+ item.flags |= 8;
1033
+ }
1034
+ items.add(item);
1035
+ const next = related.get(item);
1036
+ if (next) {
1037
+ recurse(next);
1029
1038
  }
1030
1039
  }
1031
1040
  })(includes);
@@ -1034,34 +1043,37 @@ class ChromeDocument extends Document {
1034
1043
  }
1035
1044
  }
1036
1045
  let productionRelease = instance.productionRelease;
1037
- if ((0, types_1.isString)(productionRelease)) {
1038
- if (path.isAbsolute(productionRelease = path.normalize(productionRelease)) && isDir(productionRelease)) {
1039
- if (this.canWrite(productionRelease)) {
1040
- const serverRoot = ChromeDocument.INTERNAL_SERVERROOT;
1041
- const srcDir = path.join(this.baseDirectory, serverRoot);
1042
- if (isDir(srcDir)) {
1043
- const result = await Document.copyDir(srcDir, productionRelease, this.incremental !== 'staging');
1044
- const failed = result.failed.map(value => this.removeCwd(value));
1045
- for (const value of this.files) {
1046
- if (value.startsWith(serverRoot)) {
1047
- if (!failed.includes(value)) {
1048
- this.delete(value);
1049
- }
1050
- else {
1051
- instance.writeFail(["Unable to move file", instance.moduleName], (0, types_1.errorMessage)('production', path.join(this.baseDirectory, value)), { fatal: true });
1052
- }
1053
- }
1054
- }
1055
- }
1046
+ if (!(0, types_1.isString)(productionRelease)) {
1047
+ return;
1048
+ }
1049
+ if (path.isAbsolute(productionRelease = path.normalize(productionRelease)) && isDir(productionRelease)) {
1050
+ if (this.canWrite(productionRelease)) {
1051
+ const serverRoot = ChromeDocument.INTERNAL_SERVERROOT;
1052
+ const srcDir = path.join(this.baseDirectory, serverRoot);
1053
+ if (!isDir(srcDir)) {
1054
+ return;
1056
1055
  }
1057
- else {
1058
- instance.writeFail(["Unable to write directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Access denied', productionRelease));
1056
+ const result = await Document.copyDir(srcDir, productionRelease, this.incremental !== 'staging');
1057
+ const failed = result.failed.map(value => this.removeCwd(value));
1058
+ for (const value of this.files) {
1059
+ if (!value.startsWith(serverRoot)) {
1060
+ continue;
1061
+ }
1062
+ if (!failed.includes(value)) {
1063
+ this.delete(value);
1064
+ }
1065
+ else {
1066
+ instance.writeFail(["Unable to move file", instance.moduleName], (0, types_1.errorMessage)('production', path.join(this.baseDirectory, value)), { fatal: true });
1067
+ }
1059
1068
  }
1060
1069
  }
1061
1070
  else {
1062
- instance.writeFail(["Unable to read directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Invalid directory', productionRelease), 32);
1071
+ instance.writeFail(["Unable to write directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Access denied', productionRelease));
1063
1072
  }
1064
1073
  }
1074
+ else {
1075
+ instance.writeFail(["Unable to read directory", instance.moduleName], (0, types_1.errorMessage)('production', 'Invalid directory', productionRelease), 32);
1076
+ }
1065
1077
  }
1066
1078
  static sanitizeAssets(assets, exclusions = []) {
1067
1079
  assets.forEach(item => {
@@ -1142,8 +1154,9 @@ class ChromeDocument extends Document {
1142
1154
  }
1143
1155
  return 0;
1144
1156
  });
1157
+ let imports;
1145
1158
  if (config) {
1146
- const { useUnsafeReplace, baseUrl, productionRelease, productionIncremental, templateMap, userAgentData, imports, cache } = config;
1159
+ const { useUnsafeReplace, baseUrl, productionRelease, productionIncremental, templateMap, userAgentData, cache } = config;
1147
1160
  const target = this.config;
1148
1161
  for (const attr in config) {
1149
1162
  if (attr in target) {
@@ -1188,22 +1201,37 @@ class ChromeDocument extends Document {
1188
1201
  if ((0, types_1.isObject)(userAgentData)) {
1189
1202
  this.userAgentData = userAgentData;
1190
1203
  }
1191
- this.imports = (0, types_1.isPlainObject)(imports) ? { ...this.module.imports, ...imports } : this.module.imports;
1192
1204
  if ((0, types_1.isObject)(cache) && 'transform' in cache) {
1193
1205
  this.customize({ transform: cache.transform });
1194
1206
  }
1207
+ if (!(0, types_1.isPlainObject)(imports = config.imports)) {
1208
+ imports = undefined;
1209
+ }
1195
1210
  }
1196
1211
  super.init(assets, config);
1197
1212
  const mimeMap = this._mimeMap;
1198
- if (mimeMap && 'format' in mimeMap) {
1199
- const format = mimeMap.format;
1200
- if ((0, types_1.isObject)(format)) {
1201
- this.formatMap = 'pathname' in format || 'filename' in format || 'dictionary' in format ? { uuid: format } : format;
1213
+ if (mimeMap) {
1214
+ if ('imports' in mimeMap) {
1215
+ const imported = mimeMap.imports;
1216
+ if ((0, types_1.isPlainObject)(imported)) {
1217
+ imports = imports ? Object.assign(imported, imports) : imported;
1218
+ }
1219
+ delete mimeMap.imports;
1202
1220
  }
1203
- else {
1204
- this.formatMap = undefined;
1221
+ if ('format' in mimeMap) {
1222
+ const format = mimeMap.format;
1223
+ if ((0, types_1.isObject)(format)) {
1224
+ this.formatMap = 'pathname' in format || 'filename' in format || 'dictionary' in format ? { uuid: format } : format;
1225
+ }
1226
+ else {
1227
+ this.formatMap = undefined;
1228
+ }
1229
+ delete mimeMap.format;
1205
1230
  }
1206
1231
  }
1232
+ if (imports) {
1233
+ this.imports = imports;
1234
+ }
1207
1235
  for (const storage of cloud) {
1208
1236
  for (const { service, upload, download } of storage) {
1209
1237
  if (upload) {
@@ -1627,8 +1655,9 @@ class ChromeDocument extends Document {
1627
1655
  this._cloudUrlMap = Object.create(null);
1628
1656
  this._cloudUploaded = new Set();
1629
1657
  this._cloudEndpoint = null;
1630
- if (this.htmlFile) {
1631
- const endpoint = instance.getStorage('upload', this.htmlFile.cloudStorage)?.upload?.endpoint;
1658
+ const htmlFile = this.htmlFile;
1659
+ if (htmlFile) {
1660
+ const endpoint = instance.getStorage('upload', htmlFile.cloudStorage)?.upload?.endpoint;
1632
1661
  if (endpoint) {
1633
1662
  this._cloudEndpoint = new RegExp((0, types_1.escapePattern)(toPosix(endpoint)) + '/', 'g');
1634
1663
  }
@@ -1806,9 +1835,7 @@ class ChromeDocument extends Document {
1806
1835
  }
1807
1836
  }
1808
1837
  search ?? (search = restoreSearchParams(asset.url?.search));
1809
- if (status) {
1810
- status = status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN);
1811
- }
1838
+ status && (status = status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN));
1812
1839
  watch.send(types_1.WATCH_EVENT.MODIFIED, {
1813
1840
  action: pathname && watch.hot && !watch.main ? 'hot' : '',
1814
1841
  type: asset.mimeType,
@@ -1983,8 +2010,9 @@ class ChromeDocument extends Document {
1983
2010
  item.modified = true;
1984
2011
  }
1985
2012
  source = sanitizeSource(item, source);
1986
- if (item.format) {
1987
- const result = await this.transform('html', source, item.format, transformOptions.call(this, item, 'image/svg+xml'));
2013
+ const format = item.format;
2014
+ if (format) {
2015
+ const result = await this.transform('html', source, format, transformOptions.call(this, item, 'image/svg+xml'));
1988
2016
  if (result) {
1989
2017
  item.modified = true;
1990
2018
  source = result.code;
@@ -2094,11 +2122,12 @@ class ChromeDocument extends Document {
2094
2122
  await this.setElementAttributes(processing, domBase);
2095
2123
  await this.applyDataSource(processing, domBase);
2096
2124
  for (const item of this.assets) {
2097
- if (item.element && isRemoved(item) && !(0, types_1.ignoreFlag)(item.flags)) {
2098
- const domElement = new dom_1.HtmlElement(moduleName, item.element, item.attributes);
2125
+ const element = item.element;
2126
+ if (element && isRemoved(item) && !(0, types_1.ignoreFlag)(item.flags)) {
2127
+ const domElement = new dom_1.HtmlElement(moduleName, element, item.attributes);
2099
2128
  domElement.remove = true;
2100
2129
  if (!domBase.write(domElement)) {
2101
- this.writeFail('Unable to exclude HTML element', errorHtml(item.element), 4);
2130
+ this.writeFail('Unable to exclude HTML element', errorHtml(element), 4);
2102
2131
  }
2103
2132
  }
2104
2133
  }
@@ -2119,13 +2148,15 @@ class ChromeDocument extends Document {
2119
2148
  if ((0, types_1.isString)(config.stripCommentsAndCDATA)) {
2120
2149
  source = dom_1.DomWriter.getCommentsAndCDATA(source, config.stripCommentsAndCDATA, true, true);
2121
2150
  }
2122
- if (htmlFile.format) {
2123
- const result = await this.transform('html', source, htmlFile.format, {
2151
+ const format = htmlFile.format;
2152
+ if (format) {
2153
+ const { filename, uri, encoding, metadata } = htmlFile;
2154
+ const result = await this.transform('html', source, format, {
2124
2155
  pathname: path.dirname(localUri),
2125
- filename: htmlFile.filename,
2156
+ filename,
2126
2157
  mimeType: 'text/html',
2127
- metadata: Object.assign({ '__fromhtml__': true, ...this.config }, htmlFile.metadata),
2128
- cacheData: !productionRelease || this.productionIncremental ? { uri: htmlFile.uri, encoding: htmlFile.encoding } : undefined
2158
+ metadata: Object.assign({ '__fromhtml__': true, ...this.config }, metadata),
2159
+ cacheData: !productionRelease || this.productionIncremental ? { uri, encoding } : undefined
2129
2160
  });
2130
2161
  if (result) {
2131
2162
  source = result.code;
@@ -2159,12 +2190,12 @@ class ChromeDocument extends Document {
2159
2190
  const cloud = host.Cloud;
2160
2191
  const removeWatchReload = (item) => (0, types_1.isObject)(item.watch) && delete item.watch.reload;
2161
2192
  for (const item of this.assets) {
2162
- const element = item.element;
2193
+ const { element, inlineContent } = item;
2163
2194
  if (!element || element.removed || isRemoved(item) || isUnedited(item) || (0, types_1.ignoreFlag)(item.flags) && !(0, types_1.processFlag)(item.flags)) {
2164
2195
  continue;
2165
2196
  }
2166
2197
  const domElement = new dom_1.HtmlElement(moduleName, element, item.attributes);
2167
- if (item.inlineContent) {
2198
+ if (inlineContent) {
2168
2199
  let [innerXml, sourceMappingURL, inlineMap] = transform_1.SourceMap.removeSourceMappingURL(host.getUTF8String(item).trim());
2169
2200
  if (sourceMappingURL && !inlineMap && item.localUri) {
2170
2201
  let mapUri = path.resolve(sourceMappingURL = decodeURIComponent(sourceMappingURL));
@@ -2173,7 +2204,7 @@ class ChromeDocument extends Document {
2173
2204
  }
2174
2205
  host.deleteFile(mapUri);
2175
2206
  }
2176
- domElement.tagName = item.inlineContent;
2207
+ domElement.tagName = inlineContent;
2177
2208
  domElement.innerXml = innerXml;
2178
2209
  domElement.removeAttribute('src', 'href');
2179
2210
  }
@@ -2263,10 +2294,10 @@ class ChromeDocument extends Document {
2263
2294
  }
2264
2295
  }
2265
2296
  if (!domBase.write(domElement)) {
2266
- this.writeFail(item.inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4, startTime });
2297
+ this.writeFail(inlineContent ? 'Inline tag replacement' : 'Element attribute replacement', errorHtml(element), { type: 4, startTime });
2267
2298
  delete item.inlineUrlCloud;
2268
2299
  }
2269
- else if (item.inlineContent) {
2300
+ else if (inlineContent) {
2270
2301
  host.removeAsset(item);
2271
2302
  removeWatchReload(item);
2272
2303
  }
@@ -2862,7 +2893,7 @@ class ChromeDocument extends Document {
2862
2893
  for (let j = 0, match; j < items.length; ++j) {
2863
2894
  const row = items[j];
2864
2895
  if ((0, types_1.isPlainObject)(row)) {
2865
- row['__index__'] ?? (row['__index__'] = j + 1);
2896
+ row.__index__ ?? (row.__index__ = j + 1);
2866
2897
  }
2867
2898
  let segment = template;
2868
2899
  while (match = REGEXP_TEMPLATECONDITIONAL.exec(segment)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/chrome",
3
- "version": "0.2.8",
3
+ "version": "0.3.2",
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.5.4",
24
- "@e-mc/core": "^0.5.4",
25
- "@e-mc/document": "^0.5.4",
26
- "@e-mc/types": "^0.5.4"
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>;
@@ -104,10 +104,11 @@ export interface IChromeDocument<T extends IFileManager<U>, U extends DocumentAs
104
104
  cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
105
105
  cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
106
106
  cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
107
- get settings(): ChromeDocumentSettings;
108
107
  get editing(): U[];
108
+ set dataSource(value);
109
109
  get dataSource(): DataSource[];
110
110
  get elements(): XmlTagNode[];
111
+ get settings(): ChromeDocumentSettings;
111
112
  }
112
113
 
113
114
  export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
@@ -115,4 +116,4 @@ export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends
115
116
  INTERNAL_SERVERROOT: string;
116
117
  readonly prototype: IChromeDocument<T, U>;
117
118
  new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
118
- }
119
+ }