@pi-r/chrome 0.5.5 → 0.5.7
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 +6 -6
- package/README.md +4 -6
- package/index.d.ts +6 -6
- package/index.js +16 -20
- package/package.json +28 -28
- package/types/index.d.ts +125 -125
- package/types/squared.d.ts +114 -114
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright
|
|
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
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
|
@@ -28,7 +28,7 @@ const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function (
|
|
|
28
28
|
return [
|
|
29
29
|
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'),
|
|
30
30
|
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
|
|
31
|
-
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(
|
|
31
|
+
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(\\([^)]*\\))?)?(?:\\s*supports\\((${parenthesis})\\))?(.*)$`, 'si')
|
|
32
32
|
];
|
|
33
33
|
})();
|
|
34
34
|
const REGEXP_SRCSETSIZE = /~\s*([\d.]+)\s*([wx])/i;
|
|
@@ -54,9 +54,9 @@ const REGEXP_OBJECT_NAME = /([^[.\s]+)((?:\s*\[[^\]]+\]\s*)+)?\s*\.?\s*/g;
|
|
|
54
54
|
const REGEXP_OBJECT_SUBSCRIPT = /\[\s*(["'])?(.+?)\1\s*\]/g;
|
|
55
55
|
const REGEXP_TEMPLATE_LEADING = /\s*\{\{- \s*((?:[^}]|}(?!}))+?)\}\}/g;
|
|
56
56
|
const REGEXP_TEMPLATE_TRAILING = /\{\{((?:[^}]|}(?!}))+?)\s*? -\}\}\s*/g;
|
|
57
|
-
const REGEXP_URL = /(?:\
|
|
57
|
+
const REGEXP_URL = /(?:\burl\(|@import\s+(["'])|\b(href)\s*=)/gi;
|
|
58
58
|
const REGEXP_URL_JS = /\bimport\(/g;
|
|
59
|
-
const REGEXP_URL_SVG = /(?:\
|
|
59
|
+
const REGEXP_URL_SVG = /(?:\burl\(|@import\s+(["'])|\b(href)\s*=)/gi;
|
|
60
60
|
const REGEXP_IMAGESET = /\b(?:-webkit-)?image-set\(/gi;
|
|
61
61
|
const REGEXP_IMAGESET_URL = /(?:^|[^(])\s*("(\s*[^)][^"]*)"|'(\s*[^)][^"]*)')\s*(?:,|$|[^)][^,]*,?)/g;
|
|
62
62
|
function removeNamespace(name, source, newline, comments) {
|
|
@@ -202,7 +202,7 @@ function hasCondition(data, condition) {
|
|
|
202
202
|
if (items.length && !isSpace(match[0][0])) {
|
|
203
203
|
return false;
|
|
204
204
|
}
|
|
205
|
-
items.push([match[1], match[2], match[3]]);
|
|
205
|
+
items.push([match[1], trimQuote(match[2]), match[3] ? trimQuote(match[3]) : '']);
|
|
206
206
|
}
|
|
207
207
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
208
208
|
const length = items.length;
|
|
@@ -213,18 +213,13 @@ function hasCondition(data, condition) {
|
|
|
213
213
|
if (!isNaN(+value)) {
|
|
214
214
|
return +value;
|
|
215
215
|
}
|
|
216
|
-
if (match = /^(["'])([\S\s]*)\1$/.exec(value)) {
|
|
217
|
-
return match[2];
|
|
218
|
-
}
|
|
219
216
|
return getObjectValue(data, value);
|
|
220
217
|
};
|
|
221
218
|
for (let i = 0; i < length; ++i) {
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const arg2 = item[2];
|
|
225
|
-
let valid;
|
|
219
|
+
const [cmp, arg1, arg2] = items[i];
|
|
220
|
+
let valid = false;
|
|
226
221
|
if (arg2) {
|
|
227
|
-
switch (
|
|
222
|
+
switch (cmp) {
|
|
228
223
|
case 'eq':
|
|
229
224
|
valid = parseArg(arg1) == parseArg(arg2);
|
|
230
225
|
break;
|
|
@@ -247,7 +242,7 @@ function hasCondition(data, condition) {
|
|
|
247
242
|
return false;
|
|
248
243
|
}
|
|
249
244
|
}
|
|
250
|
-
else if (
|
|
245
|
+
else if (cmp) {
|
|
251
246
|
return false;
|
|
252
247
|
}
|
|
253
248
|
else {
|
|
@@ -586,7 +581,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
586
581
|
if (!isText) {
|
|
587
582
|
let j = startIndex;
|
|
588
583
|
while (isSpace(source[--j])) { }
|
|
589
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
584
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
590
585
|
}
|
|
591
586
|
else {
|
|
592
587
|
k = startIndex;
|
|
@@ -1689,14 +1684,14 @@ class ChromeDocument extends Document {
|
|
|
1689
1684
|
}
|
|
1690
1685
|
}
|
|
1691
1686
|
replaceContent(source, statement, mimeType) {
|
|
1692
|
-
var _a;
|
|
1687
|
+
var _a, _b;
|
|
1693
1688
|
switch (mimeType) {
|
|
1694
1689
|
case 'text/css': {
|
|
1695
1690
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1696
1691
|
if (match) {
|
|
1697
1692
|
const layer = match[1];
|
|
1698
1693
|
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1699
|
-
const query = match[4].trim();
|
|
1694
|
+
const query = match[4].trim().replace(/;+$/, '');
|
|
1700
1695
|
if (layer || supports || query) {
|
|
1701
1696
|
const newline = (0, util_1.getNewline)(source);
|
|
1702
1697
|
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
@@ -1704,8 +1699,8 @@ class ChromeDocument extends Document {
|
|
|
1704
1699
|
result += `@media ${query} {` + newline;
|
|
1705
1700
|
}
|
|
1706
1701
|
if (layer) {
|
|
1707
|
-
|
|
1708
|
-
result += '@layer ' + (name
|
|
1702
|
+
const name = (_b = match[2]) === null || _b === void 0 ? void 0 : _b.replace(/\s+/g, '');
|
|
1703
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1709
1704
|
}
|
|
1710
1705
|
else if (query) {
|
|
1711
1706
|
result += source + newline + '}';
|
|
@@ -3141,7 +3136,8 @@ class ChromeDocument extends Document {
|
|
|
3141
3136
|
const row = items[0];
|
|
3142
3137
|
let condition = NaN;
|
|
3143
3138
|
for (let seg of template) {
|
|
3144
|
-
|
|
3139
|
+
seg = seg.trim();
|
|
3140
|
+
switch (seg.toLowerCase()) {
|
|
3145
3141
|
case ':is(and)':
|
|
3146
3142
|
if (condition === 0) {
|
|
3147
3143
|
remove = false;
|
|
@@ -3338,7 +3334,7 @@ class ChromeDocument extends Document {
|
|
|
3338
3334
|
const parseSelector = (value) => {
|
|
3339
3335
|
const items = [];
|
|
3340
3336
|
const revised = value.replace(useUnsafeCssReplace ? REGEXP_NTHCHILD_UNSAFE : REGEXP_NTHCHILD, (...capture) => {
|
|
3341
|
-
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) + '`';
|
|
3337
|
+
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) + '`';
|
|
3342
3338
|
});
|
|
3343
3339
|
let selector = '';
|
|
3344
3340
|
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.5.
|
|
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.7.
|
|
24
|
-
"@e-mc/core": "^0.7.
|
|
25
|
-
"@e-mc/document": "^0.7.
|
|
26
|
-
"@e-mc/types": "^0.7.
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-r/chrome",
|
|
3
|
+
"version": "0.5.7",
|
|
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.7.23",
|
|
24
|
+
"@e-mc/core": "^0.7.23",
|
|
25
|
+
"@e-mc/document": "^0.7.23",
|
|
26
|
+
"@e-mc/types": "^0.7.23"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
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
|
-
export const enum PROPERTIES {
|
|
14
|
-
INDEX = '__index__',
|
|
15
|
-
FROM_HTML = '__fromhtml__',
|
|
16
|
-
ASSIGN = '__assign__',
|
|
17
|
-
SERVERROOT = '__serverroot__'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface DocumentDirectory extends IDocumentDirectory {
|
|
21
|
-
template?: string;
|
|
22
|
-
data?: string;
|
|
23
|
-
export?: string;
|
|
24
|
-
schema?: string;
|
|
25
|
-
sql?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface DocumentComponentExtended<T> extends DbSourceDataType<T> {
|
|
29
|
-
uri?: T;
|
|
30
|
-
local?: T;
|
|
31
|
-
export?: T;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
|
|
35
|
-
|
|
36
|
-
interface DocumentEval extends IDocumentEval {
|
|
37
|
-
template?: boolean;
|
|
38
|
-
userconfig?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ChromeDocumentSettings extends IDocumentSettings {
|
|
42
|
-
directory?: DocumentDirectory;
|
|
43
|
-
options?: DocumentComponentOptions<boolean | number>;
|
|
44
|
-
export?: ObjectMap<string | FunctionType>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap" | "userAgentData";
|
|
48
|
-
|
|
49
|
-
export interface FormatUri extends Partial<LocationUri> {
|
|
50
|
-
dictionary?: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
|
|
54
|
-
readonly host: T;
|
|
55
|
-
readonly startTime: LogTime;
|
|
56
|
-
readonly hashed: Set<DocumentAsset>;
|
|
57
|
-
readonly contentMap: StringMap;
|
|
58
|
-
readonly bufferMap: ObjectMap<BufferContent>;
|
|
59
|
-
readonly cacheMiss: string[];
|
|
60
|
-
readonly productionRelease: Undef<true>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
|
|
64
|
-
|
|
65
|
-
export interface DocumentModule extends IDocumentModule {
|
|
66
|
-
eval?: DocumentEval;
|
|
67
|
-
format?: PlainObject & { uuid?: FormatUri };
|
|
68
|
-
settings?: ChromeDocumentSettings;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
|
|
72
|
-
relativeUrl?: string;
|
|
73
|
-
inlineFilename?: string;
|
|
74
|
-
srcSet?: string[];
|
|
75
|
-
inlineUrl?: string;
|
|
76
|
-
inlineUrlMap?: StringMap;
|
|
77
|
-
inlineUrlCloud?: string;
|
|
78
|
-
inlineUrlCloudMap?: StringMap;
|
|
79
|
-
inlineBase64?: string;
|
|
80
|
-
modified?: boolean;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
|
|
84
|
-
useUnsafeHtmlReplace?: boolean;
|
|
85
|
-
useUnsafeCssReplace?: boolean;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
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> {
|
|
89
|
-
htmlFile: Null<U>;
|
|
90
|
-
cssFiles: U[];
|
|
91
|
-
jsFiles: U[];
|
|
92
|
-
svgFiles: U[];
|
|
93
|
-
baseDirectory: string;
|
|
94
|
-
baseUrl: string;
|
|
95
|
-
config: UserConfig;
|
|
96
|
-
related: Map<U, Set<U>>;
|
|
97
|
-
replaced: U[];
|
|
98
|
-
formatMap?: ObjectMap<FormatUri>;
|
|
99
|
-
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
100
|
-
findDataValue(name: string): Undef<string>;
|
|
101
|
-
setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
102
|
-
applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
103
|
-
rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
104
|
-
setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
105
|
-
applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
106
|
-
setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
107
|
-
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
108
|
-
removeServerRoot(value: string): string;
|
|
109
|
-
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
110
|
-
cloudInit(state: CloudScopeOrigin<T, U, V>): void;
|
|
111
|
-
cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
|
|
112
|
-
cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
|
|
113
|
-
cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
|
|
114
|
-
get editing(): U[];
|
|
115
|
-
set dataSource(value);
|
|
116
|
-
get dataSource(): DataSource[];
|
|
117
|
-
get elements(): XmlTagNode[];
|
|
118
|
-
get settings(): ChromeDocumentSettings;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
|
|
122
|
-
INTERNAL_ASSIGNUUID: string;
|
|
123
|
-
INTERNAL_SERVERROOT: string;
|
|
124
|
-
readonly prototype: IChromeDocument<T, U>;
|
|
125
|
-
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
|
+
export const enum PROPERTIES {
|
|
14
|
+
INDEX = '__index__',
|
|
15
|
+
FROM_HTML = '__fromhtml__',
|
|
16
|
+
ASSIGN = '__assign__',
|
|
17
|
+
SERVERROOT = '__serverroot__'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface DocumentDirectory extends IDocumentDirectory {
|
|
21
|
+
template?: string;
|
|
22
|
+
data?: string;
|
|
23
|
+
export?: string;
|
|
24
|
+
schema?: string;
|
|
25
|
+
sql?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface DocumentComponentExtended<T> extends DbSourceDataType<T> {
|
|
29
|
+
uri?: T;
|
|
30
|
+
local?: T;
|
|
31
|
+
export?: T;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
|
|
35
|
+
|
|
36
|
+
interface DocumentEval extends IDocumentEval {
|
|
37
|
+
template?: boolean;
|
|
38
|
+
userconfig?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ChromeDocumentSettings extends IDocumentSettings {
|
|
42
|
+
directory?: DocumentDirectory;
|
|
43
|
+
options?: DocumentComponentOptions<boolean | number>;
|
|
44
|
+
export?: ObjectMap<string | FunctionType>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap" | "userAgentData";
|
|
48
|
+
|
|
49
|
+
export interface FormatUri extends Partial<LocationUri> {
|
|
50
|
+
dictionary?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
|
|
54
|
+
readonly host: T;
|
|
55
|
+
readonly startTime: LogTime;
|
|
56
|
+
readonly hashed: Set<DocumentAsset>;
|
|
57
|
+
readonly contentMap: StringMap;
|
|
58
|
+
readonly bufferMap: ObjectMap<BufferContent>;
|
|
59
|
+
readonly cacheMiss: string[];
|
|
60
|
+
readonly productionRelease: Undef<true>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
|
|
64
|
+
|
|
65
|
+
export interface DocumentModule extends IDocumentModule {
|
|
66
|
+
eval?: DocumentEval;
|
|
67
|
+
format?: PlainObject & { uuid?: FormatUri };
|
|
68
|
+
settings?: ChromeDocumentSettings;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
|
|
72
|
+
relativeUrl?: string;
|
|
73
|
+
inlineFilename?: string;
|
|
74
|
+
srcSet?: string[];
|
|
75
|
+
inlineUrl?: string;
|
|
76
|
+
inlineUrlMap?: StringMap;
|
|
77
|
+
inlineUrlCloud?: string;
|
|
78
|
+
inlineUrlCloudMap?: StringMap;
|
|
79
|
+
inlineBase64?: string;
|
|
80
|
+
modified?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
|
|
84
|
+
useUnsafeHtmlReplace?: boolean;
|
|
85
|
+
useUnsafeCssReplace?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
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> {
|
|
89
|
+
htmlFile: Null<U>;
|
|
90
|
+
cssFiles: U[];
|
|
91
|
+
jsFiles: U[];
|
|
92
|
+
svgFiles: U[];
|
|
93
|
+
baseDirectory: string;
|
|
94
|
+
baseUrl: string;
|
|
95
|
+
config: UserConfig;
|
|
96
|
+
related: Map<U, Set<U>>;
|
|
97
|
+
replaced: U[];
|
|
98
|
+
formatMap?: ObjectMap<FormatUri>;
|
|
99
|
+
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
100
|
+
findDataValue(name: string): Undef<string>;
|
|
101
|
+
setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
102
|
+
applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
103
|
+
rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
104
|
+
setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
105
|
+
applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
106
|
+
setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
107
|
+
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
108
|
+
removeServerRoot(value: string): string;
|
|
109
|
+
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
110
|
+
cloudInit(state: CloudScopeOrigin<T, U, V>): void;
|
|
111
|
+
cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
|
|
112
|
+
cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
|
|
113
|
+
cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
|
|
114
|
+
get editing(): U[];
|
|
115
|
+
set dataSource(value);
|
|
116
|
+
get dataSource(): DataSource[];
|
|
117
|
+
get elements(): XmlTagNode[];
|
|
118
|
+
get settings(): ChromeDocumentSettings;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
|
|
122
|
+
INTERNAL_ASSIGNUUID: string;
|
|
123
|
+
INTERNAL_SERVERROOT: string;
|
|
124
|
+
readonly prototype: IChromeDocument<T, U>;
|
|
125
|
+
new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
|
|
126
126
|
}
|
package/types/squared.d.ts
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
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
|
-
useSessionCache?: boolean;
|
|
33
|
-
stripCommentsAndCDATA?: boolean | string;
|
|
34
|
-
normalizeHtmlOutput?: boolean | string;
|
|
35
|
-
escapeReservedCharacters?: boolean;
|
|
36
|
-
ignoreServerCodeBlocks?: string[];
|
|
37
|
-
webBundle?: {
|
|
38
|
-
rootDirAlias?: string;
|
|
39
|
-
baseUrl?: string;
|
|
40
|
-
primaryUrl?: string;
|
|
41
|
-
copyTo?: string;
|
|
42
|
-
rewriteHtmlPage?: boolean | string;
|
|
43
|
-
excludeHtmlPage?: boolean;
|
|
44
|
-
excludeTransforms?: boolean;
|
|
45
|
-
includeScopes?: string[];
|
|
46
|
-
excludeScopes?: string[];
|
|
47
|
-
};
|
|
48
|
-
templateMap?: TemplateMap;
|
|
49
|
-
userAgentData?: Partial<UserAgentData>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
|
|
53
|
-
|
|
54
|
-
export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
|
|
55
|
-
preserve?: boolean;
|
|
56
|
-
static?: boolean;
|
|
57
|
-
editing?: boolean;
|
|
58
|
-
inlineContent?: string;
|
|
59
|
-
originAddress?: boolean;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface TemplateMap extends PlainObject {
|
|
63
|
-
html?: ObjectMap<StringMap>;
|
|
64
|
-
js?: ObjectMap<StringMap>;
|
|
65
|
-
css?: ObjectMap<StringMap>;
|
|
66
|
-
data?: StringMap;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface CssRuleData {
|
|
70
|
-
usedVariables?: string[];
|
|
71
|
-
usedFontFace?: string[];
|
|
72
|
-
usedKeyframes?: string[];
|
|
73
|
-
unusedStyles?: string[];
|
|
74
|
-
unusedMedia?: string[];
|
|
75
|
-
unusedContainer?: string[];
|
|
76
|
-
unusedSupports?: string[];
|
|
77
|
-
unusedAtRules?: UnusedAtRule[];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface UnusedAtRule {
|
|
81
|
-
selector?: string;
|
|
82
|
-
media?: ConditionProperty;
|
|
83
|
-
supports?: ConditionProperty;
|
|
84
|
-
container?: CssConditionData & Partial<ConditionProperty>;
|
|
85
|
-
layer?: string[];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
|
|
89
|
-
source: "cloud" | "uri" | "local" | "export" | DbSource;
|
|
90
|
-
element?: XmlTagNode;
|
|
91
|
-
type?: "text" | "attribute" | "display";
|
|
92
|
-
dynamic?: boolean;
|
|
93
|
-
value?: StringOfArray | ObjectMap<unknown>;
|
|
94
|
-
template?: string;
|
|
95
|
-
viewEngine?: ViewEngine | string;
|
|
96
|
-
ignoreEmpty?: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface UriDataSource extends DataSource, DataObject {
|
|
100
|
-
source: "uri";
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface LocalDataSource extends DataSource, DataObject {
|
|
104
|
-
source: "local";
|
|
105
|
-
pathname?: string;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface ExportDataSource extends DataSource, CascadeAction {
|
|
109
|
-
source: "export";
|
|
110
|
-
execute?: FunctionType;
|
|
111
|
-
pathname?: string;
|
|
112
|
-
settings?: string;
|
|
113
|
-
params?: unknown;
|
|
114
|
-
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
|
+
useSessionCache?: boolean;
|
|
33
|
+
stripCommentsAndCDATA?: boolean | string;
|
|
34
|
+
normalizeHtmlOutput?: boolean | string;
|
|
35
|
+
escapeReservedCharacters?: boolean;
|
|
36
|
+
ignoreServerCodeBlocks?: string[];
|
|
37
|
+
webBundle?: {
|
|
38
|
+
rootDirAlias?: string;
|
|
39
|
+
baseUrl?: string;
|
|
40
|
+
primaryUrl?: string;
|
|
41
|
+
copyTo?: string;
|
|
42
|
+
rewriteHtmlPage?: boolean | string;
|
|
43
|
+
excludeHtmlPage?: boolean;
|
|
44
|
+
excludeTransforms?: boolean;
|
|
45
|
+
includeScopes?: string[];
|
|
46
|
+
excludeScopes?: string[];
|
|
47
|
+
};
|
|
48
|
+
templateMap?: TemplateMap;
|
|
49
|
+
userAgentData?: Partial<UserAgentData>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
|
|
53
|
+
|
|
54
|
+
export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
|
|
55
|
+
preserve?: boolean;
|
|
56
|
+
static?: boolean;
|
|
57
|
+
editing?: boolean;
|
|
58
|
+
inlineContent?: string;
|
|
59
|
+
originAddress?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface TemplateMap extends PlainObject {
|
|
63
|
+
html?: ObjectMap<StringMap>;
|
|
64
|
+
js?: ObjectMap<StringMap>;
|
|
65
|
+
css?: ObjectMap<StringMap>;
|
|
66
|
+
data?: StringMap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface CssRuleData {
|
|
70
|
+
usedVariables?: string[];
|
|
71
|
+
usedFontFace?: string[];
|
|
72
|
+
usedKeyframes?: string[];
|
|
73
|
+
unusedStyles?: string[];
|
|
74
|
+
unusedMedia?: string[];
|
|
75
|
+
unusedContainer?: string[];
|
|
76
|
+
unusedSupports?: string[];
|
|
77
|
+
unusedAtRules?: UnusedAtRule[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface UnusedAtRule {
|
|
81
|
+
selector?: string;
|
|
82
|
+
media?: ConditionProperty;
|
|
83
|
+
supports?: ConditionProperty;
|
|
84
|
+
container?: CssConditionData & Partial<ConditionProperty>;
|
|
85
|
+
layer?: string[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
|
|
89
|
+
source: "cloud" | "uri" | "local" | "export" | DbSource;
|
|
90
|
+
element?: XmlTagNode;
|
|
91
|
+
type?: "text" | "attribute" | "display";
|
|
92
|
+
dynamic?: boolean;
|
|
93
|
+
value?: StringOfArray | ObjectMap<unknown>;
|
|
94
|
+
template?: string;
|
|
95
|
+
viewEngine?: ViewEngine | string;
|
|
96
|
+
ignoreEmpty?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface UriDataSource extends DataSource, DataObject {
|
|
100
|
+
source: "uri";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface LocalDataSource extends DataSource, DataObject {
|
|
104
|
+
source: "local";
|
|
105
|
+
pathname?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ExportDataSource extends DataSource, CascadeAction {
|
|
109
|
+
source: "export";
|
|
110
|
+
execute?: FunctionType;
|
|
111
|
+
pathname?: string;
|
|
112
|
+
settings?: string;
|
|
113
|
+
params?: unknown;
|
|
114
|
+
persist?: boolean;
|
|
115
115
|
}
|