@pi-r/chrome 0.2.12 → 0.2.14

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,7 +1,7 @@
1
- Copyright 2024 An Pham
2
-
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
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
1
+ Copyright 2023 An Pham
2
+
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
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
7
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
- # @pi-r/chrome
2
-
3
- PEP 402 - Forever
4
-
5
- ## LICENSE
6
-
1
+ # @pi-r/chrome
2
+
3
+ ## LICENSE
4
+
7
5
  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
@@ -32,7 +32,7 @@ const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function (
32
32
  return [
33
33
  new RegExp(`\\(${PATTERN_STRING_SOME}([+-])?(?:(\\d*)[nN]|(0))?${PATTERN_STRING_SOME}([+-])?${PATTERN_STRING_SOME}(\\d*)(?:${PATTERN_STRING_MANY}[oO][fF]${PATTERN_STRING_MANY}(${parenthesis})${PATTERN_STRING_SOME}\\)|${PATTERN_STRING_SOME}\\))`, 'g'),
34
34
  new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
35
- new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(?:\\(([^)]*)\\)|\\b))?(?:\\s*supports\\((${parenthesis})\\))?(.*?);?$`)
35
+ new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(\\([^)]*\\))?)?(?:\\s*supports\\((${parenthesis})\\))?(.*)$`, 'si')
36
36
  ];
37
37
  })();
38
38
  const REGEXP_COMMENT = new RegExp(dom_1.DomWriter.PATTERN_COMMENT, 'g');
@@ -184,7 +184,7 @@ function hasCondition(data, condition) {
184
184
  if (items.length && !isSpace(match[0][0])) {
185
185
  return false;
186
186
  }
187
- items.push([match[1], match[2], match[3]]);
187
+ items.push([match[1], trimQuote(match[2]), match[3] ? trimQuote(match[3]) : '']);
188
188
  }
189
189
  REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
190
190
  const length = items.length;
@@ -195,18 +195,13 @@ function hasCondition(data, condition) {
195
195
  if (!isNaN(+value)) {
196
196
  return +value;
197
197
  }
198
- if (match = /^(["'])([\S\s]*)\1$/.exec(value)) {
199
- return match[2];
200
- }
201
198
  return getObjectValue(data, value);
202
199
  };
203
200
  for (let i = 0; i < length; ++i) {
204
- const item = items[i];
205
- const arg1 = item[1];
206
- const arg2 = item[2];
207
- let valid;
201
+ const [cmp, arg1, arg2] = items[i];
202
+ let valid = false;
208
203
  if (arg2) {
209
- switch (item[0]) {
204
+ switch (cmp) {
210
205
  case 'eq':
211
206
  valid = parseArg(arg1) == parseArg(arg2);
212
207
  break;
@@ -229,7 +224,7 @@ function hasCondition(data, condition) {
229
224
  return false;
230
225
  }
231
226
  }
232
- else if (item[0]) {
227
+ else if (cmp) {
233
228
  return false;
234
229
  }
235
230
  else {
@@ -382,7 +377,7 @@ function transformURL(host, parent, type, source, importFile) {
382
377
  const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
383
378
  const isHtml = type === 'html';
384
379
  const isJs = type === 'js';
385
- const pattern = isJs ? /\bimport\(/g : type === 'svg' ? /(?:\b[Uu][Rr][Ll]\(|@import\s+(["'])|\b([Hh][Rr][Ee][Ff])\s*=)/g : /\b[Uu][Rr][Ll]\(|@import\s+(["'])/g;
380
+ const pattern = isJs ? /\bimport\(/g : type === 'svg' ? /(?:\burl\(|@import\s+(["'])|\b(href)\s*=)/gi : /\burl\(|@import\s+(["'])/gi;
386
381
  let length = source.length, modified, match;
387
382
  while (match = pattern.exec(source)) {
388
383
  const isText = !!match[1];
@@ -554,7 +549,7 @@ function transformURL(host, parent, type, source, importFile) {
554
549
  if (!isText) {
555
550
  let j = startIndex;
556
551
  while (isSpace(source[--j])) { }
557
- valid = source.substring(k = j - 6, j + 1) === '@import';
552
+ valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
558
553
  }
559
554
  else {
560
555
  k = startIndex;
@@ -1630,14 +1625,14 @@ class ChromeDocument extends Document {
1630
1625
  }
1631
1626
  }
1632
1627
  replaceContent(source, statement, mimeType) {
1633
- var _a;
1628
+ var _a, _b;
1634
1629
  switch (mimeType) {
1635
1630
  case 'text/css': {
1636
1631
  const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
1637
1632
  if (match) {
1638
1633
  const layer = match[1];
1639
1634
  const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
1640
- const query = match[4].trim();
1635
+ const query = match[4].trim().replace(/;+$/, '');
1641
1636
  if (layer || supports || query) {
1642
1637
  const newline = (0, util_1.getNewline)(source);
1643
1638
  let result = supports ? `@supports (${supports}) {` + newline : '';
@@ -1645,8 +1640,8 @@ class ChromeDocument extends Document {
1645
1640
  result += `@media ${query} {` + newline;
1646
1641
  }
1647
1642
  if (layer) {
1648
- let name = match[2];
1649
- result += '@layer ' + (name && (name = name.trim()) ? name + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
1643
+ const name = (_b = match[2]) === null || _b === void 0 ? void 0 : _b.replace(/\s+/g, '');
1644
+ result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
1650
1645
  }
1651
1646
  else if (query) {
1652
1647
  result += source + newline + '}';
@@ -3081,7 +3076,8 @@ class ChromeDocument extends Document {
3081
3076
  const row = items[0];
3082
3077
  let condition = NaN;
3083
3078
  for (let seg of template) {
3084
- switch ((seg = seg.trim()).toLowerCase()) {
3079
+ seg = seg.trim();
3080
+ switch (seg.toLowerCase()) {
3085
3081
  case ':is(and)':
3086
3082
  if (condition === 0) {
3087
3083
  remove = false;
@@ -3274,7 +3270,7 @@ class ChromeDocument extends Document {
3274
3270
  const parseSelector = (value) => {
3275
3271
  const items = [];
3276
3272
  const revised = value.replace(useUnsafeCssReplace ? REGEXP_NTHCHILD_UNSAFE : REGEXP_NTHCHILD, (...capture) => {
3277
- return '`%' + (items.push('\\(' + getStringSome() + (capture[1] === '-' ? '\\x2d' : '\\x2b?') + (capture[2] || '[01]?') + (capture[3] === '0' ? !capture[1] && !capture[2] && !capture[4] && !capture[5] ? '[+-]?0[nN]?' : '0' : '[nN]') + getStringSome() + (capture[5] ? (capture[4] === '-' ? '\\x2d' : '\\x2b') + getStringSome() + capture[5] : `(?:[+-]${getStringSome()}0)?`) + (capture[6] ? getStringMany() + '[oO][fF]' + getStringMany() + capture[6].trim() : '') + getStringSome() + '\\)') - 1) + '`';
3273
+ return '`%' + (items.push('\\(' + getStringSome() + (capture[1] === '-' ? '\\x2d' : '\\x2b?') + (capture[2] || '[01]?') + (capture[3] === '0' ? !capture[1] && !capture[2] && !capture[4] && !capture[5] ? '[+-]?0[nN]?' : '0' : '[nN]?') + getStringSome() + (capture[5] ? (capture[4] === '-' ? '\\x2d' : '\\x2b?') + getStringSome() + capture[5] : `(?:[+-]${getStringSome()}0)?`) + (capture[6] ? getStringMany() + '[oO][fF]' + getStringMany() + capture[6].trim() : '') + getStringSome() + '\\)') - 1) + '`';
3278
3274
  });
3279
3275
  let selector = '';
3280
3276
  for (let i = 0, length = revised.length, casing = false, attr = false, quote = false; i < length; i++) {
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "@pi-r/chrome",
3
- "version": "0.2.12",
4
- "description": "Chrome document constructor for E-mc.",
5
- "main": "index.js",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/anpham6/pi-r.git",
12
- "directory": "src/module/chrome"
13
- },
14
- "keywords": [
15
- "squared",
16
- "e-mc",
17
- "squared-functions"
18
- ],
19
- "author": "An Pham <anpham6@gmail.com>",
20
- "license": "MIT",
21
- "homepage": "https://github.com/anpham6/pi-r#readme",
22
- "dependencies": {
23
- "@e-mc/cloud": "^0.5.10",
24
- "@e-mc/core": "^0.5.10",
25
- "@e-mc/document": "^0.5.10",
26
- "@e-mc/types": "^0.5.10"
27
- }
28
- }
1
+ {
2
+ "name": "@pi-r/chrome",
3
+ "version": "0.2.14",
4
+ "description": "Chrome document constructor for E-mc.",
5
+ "main": "index.js",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
+ "directory": "src/module/chrome"
13
+ },
14
+ "keywords": [
15
+ "squared",
16
+ "e-mc",
17
+ "squared-functions"
18
+ ],
19
+ "author": "An Pham <anpham6@gmail.com>",
20
+ "license": "MIT",
21
+ "homepage": "https://github.com/anpham6/pi-r#readme",
22
+ "dependencies": {
23
+ "@e-mc/cloud": "^0.5.21",
24
+ "@e-mc/core": "^0.5.21",
25
+ "@e-mc/document": "^0.5.21",
26
+ "@e-mc/types": "^0.5.21"
27
+ }
28
+ }
package/types/index.d.ts CHANGED
@@ -1,118 +1,118 @@
1
- import type { LocationUri, XmlTagNode } from '@e-mc/types/lib/squared';
2
-
3
- import type { DocumentConstructor, ICloud, IDocument, IFileManager } from '@e-mc/types/lib';
4
- import type { DocumentAsset as IDocumentAsset } from '@e-mc/types/lib/document';
5
- import type { LogTime } from '@e-mc/types/lib/logger';
6
- import type { DbSourceDataType, DocumentComponentOption, DocumentComponent as IDocumentComponent, DocumentComponentOptions as IDocumentComponentOptions, DocumentDirectory as IDocumentDirectory, DocumentEval as IDocumentEval, DocumentModule as IDocumentModule, DocumentSettings as IDocumentSettings } from '@e-mc/types/lib/settings';
7
-
8
- import type { CloudScopeOrigin } from '@e-mc/cloud/types';
9
- import type { IDomWriter, IXmlElement } from '@e-mc/document/parse/types';
10
-
11
- import type { ChromeAsset, CssRuleData, DataSource, DocumentOutput } from './squared';
12
-
13
- interface DocumentDirectory extends IDocumentDirectory {
14
- template?: string;
15
- data?: string;
16
- export?: string;
17
- schema?: string;
18
- sql?: string;
19
- }
20
-
21
- interface DocumentComponentExtended<T> extends DbSourceDataType<T> {
22
- uri?: T;
23
- local?: T;
24
- export?: T;
25
- }
26
-
27
- interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
28
-
29
- interface DocumentEval extends IDocumentEval {
30
- template?: boolean;
31
- userconfig?: boolean;
32
- }
33
-
34
- interface ChromeDocumentSettings extends IDocumentSettings {
35
- directory?: DocumentDirectory;
36
- options?: DocumentComponentOptions<boolean | number>;
37
- export?: ObjectMap<string | FunctionType>;
38
- }
39
-
40
- type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap" | "userAgentData";
41
-
42
- export interface FormatUri extends Partial<LocationUri> {
43
- dictionary?: string;
44
- }
45
-
46
- export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
47
- readonly host: T;
48
- readonly startTime: LogTime;
49
- readonly hashed: Set<DocumentAsset>;
50
- readonly contentMap: StringMap;
51
- readonly bufferMap: ObjectMap<BufferContent>;
52
- readonly cacheMiss: string[];
53
- readonly productionRelease: Undef<true>;
54
- }
55
-
56
- export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
57
-
58
- export interface DocumentModule extends IDocumentModule {
59
- eval?: DocumentEval;
60
- format?: PlainObject & { uuid?: FormatUri };
61
- settings?: ChromeDocumentSettings;
62
- }
63
-
64
- export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
65
- relativeUrl?: string;
66
- inlineFilename?: string;
67
- srcSet?: string[];
68
- inlineUrl?: string;
69
- inlineUrlMap?: StringMap;
70
- inlineUrlCloud?: string;
71
- inlineUrlCloudMap?: StringMap;
72
- inlineBase64?: string;
73
- modified?: boolean;
74
- }
75
-
76
- export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
77
- useUnsafeHtmlReplace?: boolean;
78
- useUnsafeCssReplace?: boolean;
79
- }
80
-
81
- export interface IChromeDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset, V extends ICloud = ICloud<T>> extends IDocument<T, U, DocumentModule, DocumentComponent, DocumentComponentOption, V>, Pick<DocumentOutput, OutputType> {
82
- htmlFile: Null<U>;
83
- cssFiles: U[];
84
- jsFiles: U[];
85
- svgFiles: U[];
86
- baseDirectory: string;
87
- baseUrl: string;
88
- config: UserConfig;
89
- related: Map<U, Set<U>>;
90
- replaced: U[];
91
- formatMap?: ObjectMap<FormatUri>;
92
- setElementSrc(asset: U, element: IXmlElement, value: string): void;
93
- findDataValue(name: string): Undef<string>;
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
- removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
101
- removeServerRoot(value: string): string;
102
- replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
103
- cloudInit(state: CloudScopeOrigin<T, U, V>): void;
104
- cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
105
- cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
106
- cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
107
- get settings(): ChromeDocumentSettings;
108
- get editing(): U[];
109
- get dataSource(): DataSource[];
110
- get elements(): XmlTagNode[];
111
- }
112
-
113
- export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
114
- INTERNAL_ASSIGNUUID: string;
115
- INTERNAL_SERVERROOT: string;
116
- readonly prototype: IChromeDocument<T, U>;
117
- new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
1
+ import type { LocationUri, XmlTagNode } from '@e-mc/types/lib/squared';
2
+
3
+ import type { DocumentConstructor, ICloud, IDocument, IFileManager } from '@e-mc/types/lib';
4
+ import type { DocumentAsset as IDocumentAsset } from '@e-mc/types/lib/document';
5
+ import type { LogTime } from '@e-mc/types/lib/logger';
6
+ import type { DbSourceDataType, DocumentComponentOption, DocumentComponent as IDocumentComponent, DocumentComponentOptions as IDocumentComponentOptions, DocumentDirectory as IDocumentDirectory, DocumentEval as IDocumentEval, DocumentModule as IDocumentModule, DocumentSettings as IDocumentSettings } from '@e-mc/types/lib/settings';
7
+
8
+ import type { CloudScopeOrigin } from '@e-mc/cloud/types';
9
+ import type { IDomWriter, IXmlElement } from '@e-mc/document/parse/types';
10
+
11
+ import type { ChromeAsset, CssRuleData, DataSource, DocumentOutput } from './squared';
12
+
13
+ interface DocumentDirectory extends IDocumentDirectory {
14
+ template?: string;
15
+ data?: string;
16
+ export?: string;
17
+ schema?: string;
18
+ sql?: string;
19
+ }
20
+
21
+ interface DocumentComponentExtended<T> extends DbSourceDataType<T> {
22
+ uri?: T;
23
+ local?: T;
24
+ export?: T;
25
+ }
26
+
27
+ interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
28
+
29
+ interface DocumentEval extends IDocumentEval {
30
+ template?: boolean;
31
+ userconfig?: boolean;
32
+ }
33
+
34
+ interface ChromeDocumentSettings extends IDocumentSettings {
35
+ directory?: DocumentDirectory;
36
+ options?: DocumentComponentOptions<boolean | number>;
37
+ export?: ObjectMap<string | FunctionType>;
38
+ }
39
+
40
+ type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap" | "userAgentData";
41
+
42
+ export interface FormatUri extends Partial<LocationUri> {
43
+ dictionary?: string;
44
+ }
45
+
46
+ export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
47
+ readonly host: T;
48
+ readonly startTime: LogTime;
49
+ readonly hashed: Set<DocumentAsset>;
50
+ readonly contentMap: StringMap;
51
+ readonly bufferMap: ObjectMap<BufferContent>;
52
+ readonly cacheMiss: string[];
53
+ readonly productionRelease: Undef<true>;
54
+ }
55
+
56
+ export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
57
+
58
+ export interface DocumentModule extends IDocumentModule {
59
+ eval?: DocumentEval;
60
+ format?: PlainObject & { uuid?: FormatUri };
61
+ settings?: ChromeDocumentSettings;
62
+ }
63
+
64
+ export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
65
+ relativeUrl?: string;
66
+ inlineFilename?: string;
67
+ srcSet?: string[];
68
+ inlineUrl?: string;
69
+ inlineUrlMap?: StringMap;
70
+ inlineUrlCloud?: string;
71
+ inlineUrlCloudMap?: StringMap;
72
+ inlineBase64?: string;
73
+ modified?: boolean;
74
+ }
75
+
76
+ export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
77
+ useUnsafeHtmlReplace?: boolean;
78
+ useUnsafeCssReplace?: boolean;
79
+ }
80
+
81
+ export interface IChromeDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset, V extends ICloud = ICloud<T>> extends IDocument<T, U, DocumentModule, DocumentComponent, DocumentComponentOption, V>, Pick<DocumentOutput, OutputType> {
82
+ htmlFile: Null<U>;
83
+ cssFiles: U[];
84
+ jsFiles: U[];
85
+ svgFiles: U[];
86
+ baseDirectory: string;
87
+ baseUrl: string;
88
+ config: UserConfig;
89
+ related: Map<U, Set<U>>;
90
+ replaced: U[];
91
+ formatMap?: ObjectMap<FormatUri>;
92
+ setElementSrc(asset: U, element: IXmlElement, value: string): void;
93
+ findDataValue(name: string): Undef<string>;
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
+ removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
101
+ removeServerRoot(value: string): string;
102
+ replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
103
+ cloudInit(state: CloudScopeOrigin<T, U, V>): void;
104
+ cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
105
+ cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
106
+ cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
107
+ get settings(): ChromeDocumentSettings;
108
+ get editing(): U[];
109
+ get dataSource(): DataSource[];
110
+ get elements(): XmlTagNode[];
111
+ }
112
+
113
+ export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
114
+ INTERNAL_ASSIGNUUID: string;
115
+ INTERNAL_SERVERROOT: string;
116
+ readonly prototype: IChromeDocument<T, U>;
117
+ new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
118
118
  }
@@ -1,114 +1,114 @@
1
- import type { AttributeAction, ConditionProperty, CssConditionData, ElementAction, ExcludeAction, FileAsset, FromAction, HashAction, DataSource as IDataSource, ImportAction, MetadataAction, ViewEngine, XmlTagNode } from '@e-mc/types/lib/squared';
2
-
3
- import type { UploadAction } from '@e-mc/types/lib/cloud';
4
- import type { CascadeAction, DbSource } from '@e-mc/types/lib/db';
5
- import type { RequestData as IRequestData } from '@e-mc/types/lib/node';
6
-
7
- interface ImportFrom {
8
- placeholder: string;
9
- original: string;
10
- uri: string;
11
- type?: string;
12
- dynamic?: boolean;
13
- }
14
-
15
- interface DataObject extends CascadeAction {
16
- format?: string;
17
- options?: PlainObject;
18
- }
19
-
20
- export interface UserAgentData {
21
- platform: string;
22
- brand: string;
23
- browser: number;
24
- version: Null<number[]>;
25
- }
26
-
27
- export interface DocumentOutput {
28
- productionRelease?: boolean | string;
29
- productionIncremental?: boolean;
30
- useOriginalHtmlPage?: boolean | string;
31
- useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
32
- stripCommentsAndCDATA?: boolean | string;
33
- normalizeHtmlOutput?: boolean | string;
34
- escapeReservedCharacters?: boolean;
35
- ignoreServerCodeBlocks?: string[];
36
- webBundle?: {
37
- rootDirAlias?: string;
38
- baseUrl?: string;
39
- primaryUrl?: string;
40
- copyTo?: string;
41
- rewriteHtmlPage?: boolean | string;
42
- excludeHtmlPage?: boolean;
43
- excludeTransforms?: boolean;
44
- includeScopes?: string[];
45
- excludeScopes?: string[];
46
- };
47
- templateMap?: TemplateMap;
48
- userAgentData?: Partial<UserAgentData>;
49
- }
50
-
51
- export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
52
-
53
- export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
54
- preserve?: boolean;
55
- static?: boolean;
56
- editing?: boolean;
57
- inlineContent?: string;
58
- originAddress?: boolean;
59
- }
60
-
61
- export interface TemplateMap extends PlainObject {
62
- html?: ObjectMap<StringMap>;
63
- js?: ObjectMap<StringMap>;
64
- css?: ObjectMap<StringMap>;
65
- data?: StringMap;
66
- }
67
-
68
- export interface CssRuleData {
69
- usedVariables?: string[];
70
- usedFontFace?: string[];
71
- usedKeyframes?: string[];
72
- unusedStyles?: string[];
73
- unusedMedia?: string[];
74
- unusedContainer?: string[];
75
- unusedSupports?: string[];
76
- unusedAtRules?: UnusedAtRule[];
77
- }
78
-
79
- export interface UnusedAtRule {
80
- selector?: string;
81
- media?: ConditionProperty;
82
- supports?: ConditionProperty;
83
- container?: CssConditionData & Partial<ConditionProperty>;
84
- layer?: string[];
85
- }
86
-
87
- export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
88
- source: "cloud" | "uri" | "local" | "export" | DbSource;
89
- element?: XmlTagNode;
90
- type?: "text" | "attribute" | "display";
91
- dynamic?: boolean;
92
- value?: StringOfArray | ObjectMap<unknown>;
93
- template?: string;
94
- viewEngine?: ViewEngine | string;
95
- ignoreEmpty?: boolean;
96
- }
97
-
98
- export interface UriDataSource extends DataSource, DataObject {
99
- source: "uri";
100
- }
101
-
102
- export interface LocalDataSource extends DataSource, DataObject {
103
- source: "local";
104
- pathname?: string;
105
- }
106
-
107
- export interface ExportDataSource extends DataSource, CascadeAction {
108
- source: "export";
109
- execute?: FunctionType;
110
- pathname?: string;
111
- settings?: string;
112
- params?: unknown;
113
- persist?: boolean;
1
+ import type { AttributeAction, ConditionProperty, CssConditionData, ElementAction, ExcludeAction, FileAsset, FromAction, HashAction, DataSource as IDataSource, ImportAction, MetadataAction, ViewEngine, XmlTagNode } from '@e-mc/types/lib/squared';
2
+
3
+ import type { UploadAction } from '@e-mc/types/lib/cloud';
4
+ import type { CascadeAction, DbSource } from '@e-mc/types/lib/db';
5
+ import type { RequestData as IRequestData } from '@e-mc/types/lib/node';
6
+
7
+ interface ImportFrom {
8
+ placeholder: string;
9
+ original: string;
10
+ uri: string;
11
+ type?: string;
12
+ dynamic?: boolean;
13
+ }
14
+
15
+ interface DataObject extends CascadeAction {
16
+ format?: string;
17
+ options?: PlainObject;
18
+ }
19
+
20
+ export interface UserAgentData {
21
+ platform: string;
22
+ brand: string;
23
+ browser: number;
24
+ version: Null<number[]>;
25
+ }
26
+
27
+ export interface DocumentOutput {
28
+ productionRelease?: boolean | string;
29
+ productionIncremental?: boolean;
30
+ useOriginalHtmlPage?: boolean | string;
31
+ useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
32
+ stripCommentsAndCDATA?: boolean | string;
33
+ normalizeHtmlOutput?: boolean | string;
34
+ escapeReservedCharacters?: boolean;
35
+ ignoreServerCodeBlocks?: string[];
36
+ webBundle?: {
37
+ rootDirAlias?: string;
38
+ baseUrl?: string;
39
+ primaryUrl?: string;
40
+ copyTo?: string;
41
+ rewriteHtmlPage?: boolean | string;
42
+ excludeHtmlPage?: boolean;
43
+ excludeTransforms?: boolean;
44
+ includeScopes?: string[];
45
+ excludeScopes?: string[];
46
+ };
47
+ templateMap?: TemplateMap;
48
+ userAgentData?: Partial<UserAgentData>;
49
+ }
50
+
51
+ export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
52
+
53
+ export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
54
+ preserve?: boolean;
55
+ static?: boolean;
56
+ editing?: boolean;
57
+ inlineContent?: string;
58
+ originAddress?: boolean;
59
+ }
60
+
61
+ export interface TemplateMap extends PlainObject {
62
+ html?: ObjectMap<StringMap>;
63
+ js?: ObjectMap<StringMap>;
64
+ css?: ObjectMap<StringMap>;
65
+ data?: StringMap;
66
+ }
67
+
68
+ export interface CssRuleData {
69
+ usedVariables?: string[];
70
+ usedFontFace?: string[];
71
+ usedKeyframes?: string[];
72
+ unusedStyles?: string[];
73
+ unusedMedia?: string[];
74
+ unusedContainer?: string[];
75
+ unusedSupports?: string[];
76
+ unusedAtRules?: UnusedAtRule[];
77
+ }
78
+
79
+ export interface UnusedAtRule {
80
+ selector?: string;
81
+ media?: ConditionProperty;
82
+ supports?: ConditionProperty;
83
+ container?: CssConditionData & Partial<ConditionProperty>;
84
+ layer?: string[];
85
+ }
86
+
87
+ export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
88
+ source: "cloud" | "uri" | "local" | "export" | DbSource;
89
+ element?: XmlTagNode;
90
+ type?: "text" | "attribute" | "display";
91
+ dynamic?: boolean;
92
+ value?: StringOfArray | ObjectMap<unknown>;
93
+ template?: string;
94
+ viewEngine?: ViewEngine | string;
95
+ ignoreEmpty?: boolean;
96
+ }
97
+
98
+ export interface UriDataSource extends DataSource, DataObject {
99
+ source: "uri";
100
+ }
101
+
102
+ export interface LocalDataSource extends DataSource, DataObject {
103
+ source: "local";
104
+ pathname?: string;
105
+ }
106
+
107
+ export interface ExportDataSource extends DataSource, CascadeAction {
108
+ source: "export";
109
+ execute?: FunctionType;
110
+ pathname?: string;
111
+ settings?: string;
112
+ params?: unknown;
113
+ persist?: boolean;
114
114
  }