@pi-r/chrome 0.8.2 → 0.8.3
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/README.md +6 -6
- package/index.js +18 -19
- package/package.json +5 -5
- package/types/index.d.ts +131 -131
- package/types/squared.d.ts +147 -147
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
### @pi-r/chrome
|
|
2
|
-
|
|
3
|
-
https://e-mc.readthedocs.io/en/latest/document
|
|
4
|
-
|
|
5
|
-
### LICENSE
|
|
6
|
-
|
|
1
|
+
### @pi-r/chrome
|
|
2
|
+
|
|
3
|
+
https://e-mc.readthedocs.io/en/latest/document
|
|
4
|
+
|
|
5
|
+
### LICENSE
|
|
6
|
+
|
|
7
7
|
MIT
|
package/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function removeNamespace(name, source, newline, comments) {
|
|
|
78
78
|
}
|
|
79
79
|
function getObjectValue(value, key) {
|
|
80
80
|
REGEXP_OBJECT_NAME.lastIndex = 0;
|
|
81
|
-
let found, match;
|
|
81
|
+
let found = false, match;
|
|
82
82
|
while (match = REGEXP_OBJECT_NAME.exec(key)) {
|
|
83
83
|
if ((0, types_1.isObject)(value)) {
|
|
84
84
|
value = value[match[1]];
|
|
@@ -185,8 +185,9 @@ function spliceSource(source, startIndex, endIndex, pattern, leading = '', trail
|
|
|
185
185
|
return (0, util_1.spliceString)(source, startIndex, endIndex, content, pattern);
|
|
186
186
|
}
|
|
187
187
|
function parseArg(data, value) {
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
const n = +value;
|
|
189
|
+
if (!isNaN(n)) {
|
|
190
|
+
return n;
|
|
190
191
|
}
|
|
191
192
|
const match = /^(["'])(.*)\1$/s.exec(value);
|
|
192
193
|
if (match) {
|
|
@@ -211,12 +212,10 @@ function hasCondition(data, condition) {
|
|
|
211
212
|
items.push([match[1], match[2], match[3]]);
|
|
212
213
|
}
|
|
213
214
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
214
|
-
|
|
215
|
-
if (length > 1 && !join) {
|
|
215
|
+
if (items.length > 1 && !join) {
|
|
216
216
|
return false;
|
|
217
217
|
}
|
|
218
|
-
for (
|
|
219
|
-
const item = items[i];
|
|
218
|
+
for (const item of items) {
|
|
220
219
|
const arg1 = item[1];
|
|
221
220
|
const arg2 = item[2];
|
|
222
221
|
let valid;
|
|
@@ -368,10 +367,10 @@ function createHash(host, file, hash, bufferMap) {
|
|
|
368
367
|
function getSrcURL(instance, parent, file) {
|
|
369
368
|
const relativeUrl = file.relativeUrl || instance.host.removeCwd(file.localUri) && getRelativeURL(file);
|
|
370
369
|
if (!relativeUrl) {
|
|
371
|
-
return [''];
|
|
370
|
+
return ['', false];
|
|
372
371
|
}
|
|
373
372
|
if (parent.inlineContent) {
|
|
374
|
-
return [relativeUrl];
|
|
373
|
+
return [relativeUrl, false];
|
|
375
374
|
}
|
|
376
375
|
let parentDir = parent.pathname, assetDir = file.pathname;
|
|
377
376
|
if (!instance.productionRelease) {
|
|
@@ -387,13 +386,13 @@ function getSrcURL(instance, parent, file) {
|
|
|
387
386
|
}
|
|
388
387
|
const prefix = splitPath(parentDir);
|
|
389
388
|
const suffix = splitPath(assetDir);
|
|
390
|
-
let found;
|
|
389
|
+
let found = false;
|
|
391
390
|
while (prefix.length > 0 && suffix.length > 0 && prefix[0] === suffix[0]) {
|
|
392
391
|
prefix.shift();
|
|
393
392
|
suffix.shift();
|
|
394
393
|
found = true;
|
|
395
394
|
}
|
|
396
|
-
return [found ? Document.joinPath('../'.repeat(prefix.length), suffix.join('/'), file.filename) : '../'.repeat(prefix.length) + relativeUrl];
|
|
395
|
+
return [found ? Document.joinPath('../'.repeat(prefix.length), suffix.join('/'), file.filename) : '../'.repeat(prefix.length) + relativeUrl, false];
|
|
397
396
|
}
|
|
398
397
|
function transformURL(instance, host, parent, type, source, importFile) {
|
|
399
398
|
const related = [];
|
|
@@ -403,7 +402,7 @@ function transformURL(instance, host, parent, type, source, importFile) {
|
|
|
403
402
|
const pattern = isJs ? REGEXP_URL_JS : type === 'svg' ? REGEXP_URL_SVG : REGEXP_URL;
|
|
404
403
|
pattern.lastIndex = 0;
|
|
405
404
|
REGEXP_IMAGESET.lastIndex = 0;
|
|
406
|
-
let length = source.length, modified, match;
|
|
405
|
+
let length = source.length, modified = false, match;
|
|
407
406
|
while (match = REGEXP_IMAGESET.exec(source)) {
|
|
408
407
|
const startIndex = match.index + match[0].length;
|
|
409
408
|
const endIndex = findClosingIndex(source, startIndex, '(');
|
|
@@ -626,7 +625,7 @@ function transformURL(instance, host, parent, type, source, importFile) {
|
|
|
626
625
|
}
|
|
627
626
|
}
|
|
628
627
|
if (hasSameOrigin(asset.url || fullUrl, ...baseHref)) {
|
|
629
|
-
let sameDir;
|
|
628
|
+
let sameDir = false;
|
|
630
629
|
[fullUrl, sameDir] = getSrcURL(instance, parent, asset);
|
|
631
630
|
if (sameDir && isJs) {
|
|
632
631
|
fullUrl = './' + fullUrl;
|
|
@@ -673,7 +672,7 @@ function getFormatUUID(instance, attr, ext) {
|
|
|
673
672
|
function setLocationUUID(instance, data, file, ext) {
|
|
674
673
|
const { pathname, filename } = data;
|
|
675
674
|
const assignUUID = ChromeDocument.INTERNAL_ASSIGNUUID;
|
|
676
|
-
let index = 0, modified;
|
|
675
|
+
let index = 0, modified = false;
|
|
677
676
|
if (filename) {
|
|
678
677
|
ext ||= path.extname(filename).substring(1);
|
|
679
678
|
if ((index = filename.indexOf(assignUUID)) !== -1) {
|
|
@@ -1764,7 +1763,7 @@ class ChromeDocument extends Document {
|
|
|
1764
1763
|
if (!Array.isArray(file.imports)) {
|
|
1765
1764
|
return;
|
|
1766
1765
|
}
|
|
1767
|
-
let bundleMain, modified;
|
|
1766
|
+
let bundleMain, modified = false;
|
|
1768
1767
|
if ((0, types_1.isPlainObject)(baseFile)) {
|
|
1769
1768
|
bundleMain = baseFile;
|
|
1770
1769
|
}
|
|
@@ -1999,7 +1998,7 @@ class ChromeDocument extends Document {
|
|
|
1999
1998
|
if (main?.editing && main.mimeType === "text/html") {
|
|
2000
1999
|
const inlineUrlCloudMap = main.inlineUrlCloudMap || {};
|
|
2001
2000
|
const using = [];
|
|
2002
|
-
let found;
|
|
2001
|
+
let found = false;
|
|
2003
2002
|
for (let i = 0, length = assets.length, current, upload; i < length; ++i) {
|
|
2004
2003
|
const asset = assets[i];
|
|
2005
2004
|
if (asset.element && isUnedited(asset)) {
|
|
@@ -3183,7 +3182,7 @@ class ChromeDocument extends Document {
|
|
|
3183
3182
|
if ((0, types_1.isPlainObject)(map)) {
|
|
3184
3183
|
for (const attr in map) {
|
|
3185
3184
|
value = '';
|
|
3186
|
-
let segment = map[attr], valid;
|
|
3185
|
+
let segment = map[attr], valid = false;
|
|
3187
3186
|
if (item.viewEngine) {
|
|
3188
3187
|
if (!(0, types_1.isString)(segment)) {
|
|
3189
3188
|
errors = true;
|
|
@@ -3470,7 +3469,7 @@ class ChromeDocument extends Document {
|
|
|
3470
3469
|
const selectorMap = useSessionCache ? CACHE_SELECTOR : this._selectorMap;
|
|
3471
3470
|
const [stringSome, stringMany] = useUnsafeCssReplace ? ['\\s*', '\\s+'] : [PATTERN_STRING_SOME, PATTERN_STRING_MANY];
|
|
3472
3471
|
const replaceMap = [];
|
|
3473
|
-
let current = source, modified, checkEmpty, match;
|
|
3472
|
+
let current = source, modified = false, checkEmpty, match;
|
|
3474
3473
|
const parseSelector = (value) => {
|
|
3475
3474
|
const items = [];
|
|
3476
3475
|
const revised = value.replace(useUnsafeCssReplace ? REGEXP_NTHCHILD_UNSAFE : REGEXP_NTHCHILD, (...capture) => {
|
|
@@ -3575,7 +3574,7 @@ class ChromeDocument extends Document {
|
|
|
3575
3574
|
const key = name + '_' + value + (increment === 2 && (valueTo = items[i + 1].trim()) ? '_' + valueTo : '') + (useUnsafeCssReplace ? '_1' : '');
|
|
3576
3575
|
let pattern = queryMap.get(key), rule;
|
|
3577
3576
|
if (!pattern) {
|
|
3578
|
-
let flags = 'gi', selector = '', revised;
|
|
3577
|
+
let flags = 'gi', selector = '', revised = false;
|
|
3579
3578
|
if (name === 'container') {
|
|
3580
3579
|
for (let j = 0, length = value.length, casing = true; j < length; j++) {
|
|
3581
3580
|
let ch = value[j];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Chrome document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/cloud": "^0.10.
|
|
25
|
-
"@e-mc/core": "^0.10.
|
|
26
|
-
"@e-mc/document": "^0.10.
|
|
27
|
-
"@e-mc/types": "^0.10.
|
|
24
|
+
"@e-mc/cloud": "^0.10.3",
|
|
25
|
+
"@e-mc/core": "^0.10.3",
|
|
26
|
+
"@e-mc/document": "^0.10.3",
|
|
27
|
+
"@e-mc/types": "^0.10.3"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
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, DocumentUserSettings as IDocumentUserSettings } 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
|
-
json?: T;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
|
|
36
|
-
|
|
37
|
-
interface DocumentEval extends IDocumentEval {
|
|
38
|
-
template?: boolean;
|
|
39
|
-
userconfig?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface ChromeDocumentUserSettings extends IDocumentUserSettings {
|
|
43
|
-
server_root?: ObjectMap<StringMap>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface ChromeDocumentSettings extends IDocumentSettings<ChromeDocumentUserSettings> {
|
|
47
|
-
directory?: DocumentDirectory;
|
|
48
|
-
options?: DocumentComponentOptions<boolean | number>;
|
|
49
|
-
server_root?: ObjectMap<StringMap>;
|
|
50
|
-
export?: ObjectMap<string | FunctionType>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "serverRootMapping" | "sanitizeFramework" | "templateMap" | "userAgentData";
|
|
54
|
-
|
|
55
|
-
export interface FormatUri extends Partial<LocationUri> {
|
|
56
|
-
dictionary?: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
|
|
60
|
-
readonly host: T;
|
|
61
|
-
readonly startTime: LogTime;
|
|
62
|
-
readonly hashed: Set<DocumentAsset>;
|
|
63
|
-
readonly contentMap: StringMap;
|
|
64
|
-
readonly bufferMap: ObjectMap<Bufferable>;
|
|
65
|
-
readonly cacheMiss: string[];
|
|
66
|
-
readonly productionRelease: Undef<true>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
|
|
70
|
-
|
|
71
|
-
export interface DocumentModule extends IDocumentModule {
|
|
72
|
-
eval?: DocumentEval;
|
|
73
|
-
format?: PlainObject & { uuid?: FormatUri };
|
|
74
|
-
settings?: ChromeDocumentSettings;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
|
|
78
|
-
relativeUrl?: string;
|
|
79
|
-
inlineFilename?: string;
|
|
80
|
-
srcSet?: string[];
|
|
81
|
-
inlineUrl?: string;
|
|
82
|
-
inlineUrlMap?: StringMap;
|
|
83
|
-
inlineUrlCloud?: string;
|
|
84
|
-
inlineUrlCloudMap?: StringMap;
|
|
85
|
-
inlineBase64?: string;
|
|
86
|
-
modified?: boolean;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
|
|
90
|
-
useUnsafeHtmlReplace?: boolean;
|
|
91
|
-
useUnsafeCssReplace?: boolean;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
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> {
|
|
95
|
-
htmlFile: Null<U>;
|
|
96
|
-
cssFiles: U[];
|
|
97
|
-
jsFiles: U[];
|
|
98
|
-
svgFiles: U[];
|
|
99
|
-
baseDirectory: string;
|
|
100
|
-
baseUrl: string;
|
|
101
|
-
config: UserConfig;
|
|
102
|
-
related: Map<U, Set<U>>;
|
|
103
|
-
replaced: U[];
|
|
104
|
-
formatMap?: ObjectMap<FormatUri>;
|
|
105
|
-
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
106
|
-
findDataValue(name: string): Undef<string>;
|
|
107
|
-
setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
108
|
-
applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
109
|
-
rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
110
|
-
setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
111
|
-
applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
112
|
-
setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
113
|
-
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
114
|
-
removeServerRoot(value: string): string;
|
|
115
|
-
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
116
|
-
cloudInit(state: CloudScopeOrigin<T, U, V>): void;
|
|
117
|
-
cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
|
|
118
|
-
cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
|
|
119
|
-
cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
|
|
120
|
-
get editing(): U[];
|
|
121
|
-
set dataSource(value);
|
|
122
|
-
get dataSource(): DataSource[];
|
|
123
|
-
get elements(): XmlTagNode[];
|
|
124
|
-
get settings(): ChromeDocumentSettings;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends ConstructorDerived<DocumentConstructor<T, U>> {
|
|
128
|
-
INTERNAL_ASSIGNUUID: string;
|
|
129
|
-
INTERNAL_SERVERROOT: string;
|
|
130
|
-
readonly prototype: IChromeDocument<T, U>;
|
|
131
|
-
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, DocumentUserSettings as IDocumentUserSettings } 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
|
+
json?: T;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
|
|
36
|
+
|
|
37
|
+
interface DocumentEval extends IDocumentEval {
|
|
38
|
+
template?: boolean;
|
|
39
|
+
userconfig?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface ChromeDocumentUserSettings extends IDocumentUserSettings {
|
|
43
|
+
server_root?: ObjectMap<StringMap>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface ChromeDocumentSettings extends IDocumentSettings<ChromeDocumentUserSettings> {
|
|
47
|
+
directory?: DocumentDirectory;
|
|
48
|
+
options?: DocumentComponentOptions<boolean | number>;
|
|
49
|
+
server_root?: ObjectMap<StringMap>;
|
|
50
|
+
export?: ObjectMap<string | FunctionType>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "serverRootMapping" | "sanitizeFramework" | "templateMap" | "userAgentData";
|
|
54
|
+
|
|
55
|
+
export interface FormatUri extends Partial<LocationUri> {
|
|
56
|
+
dictionary?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
|
|
60
|
+
readonly host: T;
|
|
61
|
+
readonly startTime: LogTime;
|
|
62
|
+
readonly hashed: Set<DocumentAsset>;
|
|
63
|
+
readonly contentMap: StringMap;
|
|
64
|
+
readonly bufferMap: ObjectMap<Bufferable>;
|
|
65
|
+
readonly cacheMiss: string[];
|
|
66
|
+
readonly productionRelease: Undef<true>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
|
|
70
|
+
|
|
71
|
+
export interface DocumentModule extends IDocumentModule {
|
|
72
|
+
eval?: DocumentEval;
|
|
73
|
+
format?: PlainObject & { uuid?: FormatUri };
|
|
74
|
+
settings?: ChromeDocumentSettings;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
|
|
78
|
+
relativeUrl?: string;
|
|
79
|
+
inlineFilename?: string;
|
|
80
|
+
srcSet?: string[];
|
|
81
|
+
inlineUrl?: string;
|
|
82
|
+
inlineUrlMap?: StringMap;
|
|
83
|
+
inlineUrlCloud?: string;
|
|
84
|
+
inlineUrlCloudMap?: StringMap;
|
|
85
|
+
inlineBase64?: string;
|
|
86
|
+
modified?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
|
|
90
|
+
useUnsafeHtmlReplace?: boolean;
|
|
91
|
+
useUnsafeCssReplace?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
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> {
|
|
95
|
+
htmlFile: Null<U>;
|
|
96
|
+
cssFiles: U[];
|
|
97
|
+
jsFiles: U[];
|
|
98
|
+
svgFiles: U[];
|
|
99
|
+
baseDirectory: string;
|
|
100
|
+
baseUrl: string;
|
|
101
|
+
config: UserConfig;
|
|
102
|
+
related: Map<U, Set<U>>;
|
|
103
|
+
replaced: U[];
|
|
104
|
+
formatMap?: ObjectMap<FormatUri>;
|
|
105
|
+
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
106
|
+
findDataValue(name: string): Undef<string>;
|
|
107
|
+
setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
108
|
+
applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
109
|
+
rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
|
|
110
|
+
setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
111
|
+
applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
|
|
112
|
+
setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
|
|
113
|
+
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
114
|
+
removeServerRoot(value: string): string;
|
|
115
|
+
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
116
|
+
cloudInit(state: CloudScopeOrigin<T, U, V>): void;
|
|
117
|
+
cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
|
|
118
|
+
cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
|
|
119
|
+
cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
|
|
120
|
+
get editing(): U[];
|
|
121
|
+
set dataSource(value);
|
|
122
|
+
get dataSource(): DataSource[];
|
|
123
|
+
get elements(): XmlTagNode[];
|
|
124
|
+
get settings(): ChromeDocumentSettings;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends ConstructorDerived<DocumentConstructor<T, U>> {
|
|
128
|
+
INTERNAL_ASSIGNUUID: string;
|
|
129
|
+
INTERNAL_SERVERROOT: string;
|
|
130
|
+
readonly prototype: IChromeDocument<T, U>;
|
|
131
|
+
new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
|
|
132
132
|
}
|
package/types/squared.d.ts
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
import type { AttributeAction, ElementAction, ExcludeAction, FileAsset, FromAction, HashAction, DataSource as IDataSource, ImportAction, MetadataAction, ViewEngine } 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
|
-
import type { BufferFormat } from '@e-mc/types/lib/request';
|
|
7
|
-
|
|
8
|
-
interface ImportFrom {
|
|
9
|
-
placeholder: string;
|
|
10
|
-
original: string;
|
|
11
|
-
uri: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
dynamic?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface DataObject extends CascadeAction {
|
|
17
|
-
format?: BufferFormat;
|
|
18
|
-
options?: PlainObject;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface ScopeData {
|
|
22
|
-
start: Null<string>;
|
|
23
|
-
end: Null<string>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface ConditionProperty {
|
|
27
|
-
conditionText: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
interface CssConditionData extends ConditionProperty {
|
|
31
|
-
name?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface UserAgentData {
|
|
35
|
-
platform: string;
|
|
36
|
-
name: string;
|
|
37
|
-
brand: string;
|
|
38
|
-
browser: number;
|
|
39
|
-
version: Null<number[]>;
|
|
40
|
-
majorVersion: number;
|
|
41
|
-
mobile: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface DocumentOutput {
|
|
45
|
-
productionRelease?: boolean | string;
|
|
46
|
-
productionIncremental?: boolean;
|
|
47
|
-
serverRootMapping?: StringMap;
|
|
48
|
-
useOriginalHtmlPage?: boolean | string;
|
|
49
|
-
useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
|
|
50
|
-
useSessionCache?: boolean;
|
|
51
|
-
stripCommentsAndCDATA?: boolean | string;
|
|
52
|
-
normalizeHtmlOutput?: boolean | string;
|
|
53
|
-
escapeReservedCharacters?: boolean;
|
|
54
|
-
ignoreServerCodeBlocks?: string[];
|
|
55
|
-
sanitizeFramework?: string[];
|
|
56
|
-
webBundle?: {
|
|
57
|
-
rootDirAlias?: string;
|
|
58
|
-
baseUrl?: string;
|
|
59
|
-
primaryUrl?: string;
|
|
60
|
-
copyTo?: string;
|
|
61
|
-
rewriteHtmlPage?: boolean | string;
|
|
62
|
-
excludeHtmlPage?: boolean;
|
|
63
|
-
excludeTransforms?: boolean;
|
|
64
|
-
includeScopes?: string[];
|
|
65
|
-
excludeScopes?: string[];
|
|
66
|
-
};
|
|
67
|
-
templateMap?: TemplateMap;
|
|
68
|
-
userAgentData?: Partial<UserAgentData>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
|
|
72
|
-
|
|
73
|
-
export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
|
|
74
|
-
preserve?: boolean;
|
|
75
|
-
static?: boolean;
|
|
76
|
-
editing?: boolean;
|
|
77
|
-
inlineContent?: string;
|
|
78
|
-
originAddress?: boolean;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface TemplateMap extends PlainObject {
|
|
82
|
-
html?: ObjectMap<StringMap>;
|
|
83
|
-
js?: ObjectMap<StringMap>;
|
|
84
|
-
css?: ObjectMap<StringMap>;
|
|
85
|
-
data?: StringMap;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface CssRuleData {
|
|
89
|
-
usedVariables?: string[];
|
|
90
|
-
usedFontFace?: string[];
|
|
91
|
-
usedKeyframes?: string[];
|
|
92
|
-
unusedStyles?: string[];
|
|
93
|
-
unusedMedia?: string[];
|
|
94
|
-
unusedSupports?: string[];
|
|
95
|
-
unusedContainer?: string[];
|
|
96
|
-
unusedScope?: ScopeData[];
|
|
97
|
-
unusedAtRules?: UnusedAtRule[];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface UnusedAtRule {
|
|
101
|
-
selector?: string;
|
|
102
|
-
media?: ConditionProperty;
|
|
103
|
-
supports?: ConditionProperty;
|
|
104
|
-
container?: CssConditionData & Partial<ConditionProperty>;
|
|
105
|
-
layer?: string[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
|
|
109
|
-
source: "cloud" | "json" | "uri" | "local" | "export" | DbSource;
|
|
110
|
-
type?: "text" | "attribute" | "display";
|
|
111
|
-
dynamic?: boolean;
|
|
112
|
-
value?: ArrayOf<string> | AnyObject;
|
|
113
|
-
template?: string;
|
|
114
|
-
viewEngine?: ViewEngine | string;
|
|
115
|
-
ignoreEmpty?: boolean;
|
|
116
|
-
ignoreCoerce?: boolean;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface TextDataSource extends DataSource {
|
|
120
|
-
type: "text";
|
|
121
|
-
leadingText?: string;
|
|
122
|
-
trailingText?: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface UriDataSource extends DataSource, DataObject {
|
|
126
|
-
source: "uri";
|
|
127
|
-
body?: unknown;
|
|
128
|
-
contentType?: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface LocalDataSource extends DataSource, DataObject {
|
|
132
|
-
source: "local";
|
|
133
|
-
pathname?: string;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface JSONDataSource extends DataSource, CascadeAction {
|
|
137
|
-
source: "json";
|
|
138
|
-
items?: unknown;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface ExportDataSource extends DataSource, CascadeAction {
|
|
142
|
-
source: "export";
|
|
143
|
-
execute?: FunctionType;
|
|
144
|
-
pathname?: string;
|
|
145
|
-
settings?: string;
|
|
146
|
-
params?: unknown;
|
|
147
|
-
persist?: boolean;
|
|
1
|
+
import type { AttributeAction, ElementAction, ExcludeAction, FileAsset, FromAction, HashAction, DataSource as IDataSource, ImportAction, MetadataAction, ViewEngine } 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
|
+
import type { BufferFormat } from '@e-mc/types/lib/request';
|
|
7
|
+
|
|
8
|
+
interface ImportFrom {
|
|
9
|
+
placeholder: string;
|
|
10
|
+
original: string;
|
|
11
|
+
uri: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
dynamic?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DataObject extends CascadeAction {
|
|
17
|
+
format?: BufferFormat;
|
|
18
|
+
options?: PlainObject;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ScopeData {
|
|
22
|
+
start: Null<string>;
|
|
23
|
+
end: Null<string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ConditionProperty {
|
|
27
|
+
conditionText: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface CssConditionData extends ConditionProperty {
|
|
31
|
+
name?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface UserAgentData {
|
|
35
|
+
platform: string;
|
|
36
|
+
name: string;
|
|
37
|
+
brand: string;
|
|
38
|
+
browser: number;
|
|
39
|
+
version: Null<number[]>;
|
|
40
|
+
majorVersion: number;
|
|
41
|
+
mobile: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface DocumentOutput {
|
|
45
|
+
productionRelease?: boolean | string;
|
|
46
|
+
productionIncremental?: boolean;
|
|
47
|
+
serverRootMapping?: StringMap;
|
|
48
|
+
useOriginalHtmlPage?: boolean | string;
|
|
49
|
+
useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
|
|
50
|
+
useSessionCache?: boolean;
|
|
51
|
+
stripCommentsAndCDATA?: boolean | string;
|
|
52
|
+
normalizeHtmlOutput?: boolean | string;
|
|
53
|
+
escapeReservedCharacters?: boolean;
|
|
54
|
+
ignoreServerCodeBlocks?: string[];
|
|
55
|
+
sanitizeFramework?: string[];
|
|
56
|
+
webBundle?: {
|
|
57
|
+
rootDirAlias?: string;
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
primaryUrl?: string;
|
|
60
|
+
copyTo?: string;
|
|
61
|
+
rewriteHtmlPage?: boolean | string;
|
|
62
|
+
excludeHtmlPage?: boolean;
|
|
63
|
+
excludeTransforms?: boolean;
|
|
64
|
+
includeScopes?: string[];
|
|
65
|
+
excludeScopes?: string[];
|
|
66
|
+
};
|
|
67
|
+
templateMap?: TemplateMap;
|
|
68
|
+
userAgentData?: Partial<UserAgentData>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
|
|
72
|
+
|
|
73
|
+
export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
|
|
74
|
+
preserve?: boolean;
|
|
75
|
+
static?: boolean;
|
|
76
|
+
editing?: boolean;
|
|
77
|
+
inlineContent?: string;
|
|
78
|
+
originAddress?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface TemplateMap extends PlainObject {
|
|
82
|
+
html?: ObjectMap<StringMap>;
|
|
83
|
+
js?: ObjectMap<StringMap>;
|
|
84
|
+
css?: ObjectMap<StringMap>;
|
|
85
|
+
data?: StringMap;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface CssRuleData {
|
|
89
|
+
usedVariables?: string[];
|
|
90
|
+
usedFontFace?: string[];
|
|
91
|
+
usedKeyframes?: string[];
|
|
92
|
+
unusedStyles?: string[];
|
|
93
|
+
unusedMedia?: string[];
|
|
94
|
+
unusedSupports?: string[];
|
|
95
|
+
unusedContainer?: string[];
|
|
96
|
+
unusedScope?: ScopeData[];
|
|
97
|
+
unusedAtRules?: UnusedAtRule[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface UnusedAtRule {
|
|
101
|
+
selector?: string;
|
|
102
|
+
media?: ConditionProperty;
|
|
103
|
+
supports?: ConditionProperty;
|
|
104
|
+
container?: CssConditionData & Partial<ConditionProperty>;
|
|
105
|
+
layer?: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
|
|
109
|
+
source: "cloud" | "json" | "uri" | "local" | "export" | DbSource;
|
|
110
|
+
type?: "text" | "attribute" | "display";
|
|
111
|
+
dynamic?: boolean;
|
|
112
|
+
value?: ArrayOf<string> | AnyObject;
|
|
113
|
+
template?: string;
|
|
114
|
+
viewEngine?: ViewEngine | string;
|
|
115
|
+
ignoreEmpty?: boolean;
|
|
116
|
+
ignoreCoerce?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface TextDataSource extends DataSource {
|
|
120
|
+
type: "text";
|
|
121
|
+
leadingText?: string;
|
|
122
|
+
trailingText?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface UriDataSource extends DataSource, DataObject {
|
|
126
|
+
source: "uri";
|
|
127
|
+
body?: unknown;
|
|
128
|
+
contentType?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface LocalDataSource extends DataSource, DataObject {
|
|
132
|
+
source: "local";
|
|
133
|
+
pathname?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface JSONDataSource extends DataSource, CascadeAction {
|
|
137
|
+
source: "json";
|
|
138
|
+
items?: unknown;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface ExportDataSource extends DataSource, CascadeAction {
|
|
142
|
+
source: "export";
|
|
143
|
+
execute?: FunctionType;
|
|
144
|
+
pathname?: string;
|
|
145
|
+
settings?: string;
|
|
146
|
+
params?: unknown;
|
|
147
|
+
persist?: boolean;
|
|
148
148
|
}
|