@pi-r/chrome 0.7.2 → 0.7.4

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 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
@@ -14,6 +14,8 @@ const CACHE_LOCALFILE = new Map();
14
14
  const CACHE_QUERY = new Map();
15
15
  const CACHE_SELECTOR = new Map();
16
16
  const CACHE_ETAG = new Map();
17
+ const CACHE_CONTENT = new Map();
18
+ const CACHE_FORMAT = new Map();
17
19
  const CACHE_DATASET = {};
18
20
  const CACHE_ATRULES = {};
19
21
  let CACHE_TOTAL = 0;
@@ -901,8 +903,47 @@ const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('htm
901
903
  const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
902
904
  const isHtmlOnly = (assets, items, htmlFile) => !items.find(item => item !== htmlFile && assets.includes(item));
903
905
  class ChromeDocument extends Document {
904
- static INTERNAL_ASSIGNUUID = "__assign__";
905
- static INTERNAL_SERVERROOT = "__serverroot__";
906
+ constructor() {
907
+ super(...arguments);
908
+ this.config = {
909
+ usedVariables: undefined,
910
+ usedFontFace: undefined,
911
+ usedKeyframes: undefined,
912
+ unusedStyles: undefined,
913
+ unusedMedia: undefined,
914
+ unusedSupports: undefined,
915
+ unusedContainer: undefined,
916
+ unusedScope: undefined,
917
+ unusedAtRules: undefined,
918
+ useOriginalHtmlPage: undefined,
919
+ useUnsafeHtmlReplace: undefined,
920
+ useUnsafeCssReplace: undefined,
921
+ useSessionCache: undefined,
922
+ stripCommentsAndCDATA: undefined,
923
+ normalizeHtmlOutput: undefined,
924
+ escapeReservedCharacters: undefined,
925
+ ignoreServerCodeBlocks: undefined
926
+ };
927
+ this.htmlFile = null;
928
+ this.cssFiles = [];
929
+ this.jsFiles = [];
930
+ this.svgFiles = [];
931
+ this.baseDirectory = '';
932
+ this.baseUrl = '';
933
+ this.productionRelease = false;
934
+ this.productionIncremental = false;
935
+ this.templateMap = {};
936
+ this.userAgentData = {};
937
+ this.related = new Map();
938
+ this.replaced = [];
939
+ this._moduleName = 'chrome';
940
+ this._threadable = true;
941
+ this._elements = null;
942
+ this._idMap = Object.create(null);
943
+ this._editing = [];
944
+ this._queryMap = new Map();
945
+ this._selectorMap = new Map();
946
+ }
906
947
  static async purgeMemory(percent = 1, limit = 0, parent) {
907
948
  if (typeof limit === 'boolean') {
908
949
  parent = limit;
@@ -934,6 +975,8 @@ class ChromeDocument extends Document {
934
975
  CACHE_QUERY.clear();
935
976
  CACHE_SELECTOR.clear();
936
977
  CACHE_ETAG.clear();
978
+ CACHE_CONTENT.clear();
979
+ CACHE_FORMAT.clear();
937
980
  }
938
981
  return result + (parent && result > 0 ? await super.purgeMemory(typeof parent === 'number' && parent > 0 ? parent : percent, limit, true) : 0);
939
982
  }
@@ -961,16 +1004,26 @@ class ChromeDocument extends Document {
961
1004
  const { etag, initialValue } = htmlFile;
962
1005
  let buffer;
963
1006
  if (!initialValue || !(etag && initialValue.etag === etag && (buffer = initialValue.buffer)) || fetched.find(item => item !== htmlFile && item.etag && CACHE_ETAG.get(item.localUri) !== item.etag && (item.inlineContent || item.bundleReplace && (!(0, types_1.isArray)(item.from) || item.from.includes('style'))))) {
964
- fetched.forEach(item => {
965
- if (item.etag && item !== htmlFile && !item.invalid) {
1007
+ const isValid = (item) => !!item.localUri && item !== htmlFile && !item.invalid;
1008
+ for (const item of fetched) {
1009
+ if (item.etag && !item.content && isValid(item)) {
966
1010
  CACHE_ETAG.set(item.localUri, item.etag);
967
1011
  }
968
- });
1012
+ }
1013
+ for (const item of instance.assets) {
1014
+ if (isValid(item)) {
1015
+ if (item.content) {
1016
+ CACHE_CONTENT.set(item.localUri, item.content);
1017
+ }
1018
+ if (item.format) {
1019
+ CACHE_FORMAT.set(item.localUri, item.format.toString());
1020
+ }
1021
+ }
1022
+ }
969
1023
  break;
970
1024
  }
971
1025
  try {
972
- const { localUri, encoding } = htmlFile;
973
- fs.writeFileSync(localUri, buffer, (0, types_1.getEncoding)(encoding));
1026
+ fs.writeFileSync(htmlFile.localUri, buffer, (0, types_1.getEncoding)(htmlFile.encoding));
974
1027
  htmlFile.buffer = buffer;
975
1028
  htmlFile.sourceUTF8 = undefined;
976
1029
  }
@@ -978,12 +1031,39 @@ class ChromeDocument extends Document {
978
1031
  break;
979
1032
  }
980
1033
  }
981
- const { jsFiles, cssFiles, svgFiles } = instance;
982
- const copiedAssets = this.copiedAssets;
983
- const wasModified = (item) => fetched.includes(item) || copiedAssets.includes(item) && (!(0, types_1.isEmpty)(item.bundleId) || !(0, types_1.isEmpty)(item.trailingContent));
984
- const js = jsFiles.filter(item => item.imports || wasModified(item));
985
- const css = cssFiles.filter(wasModified);
986
- const svg = svgFiles.filter(wasModified);
1034
+ const wasModified = (item) => {
1035
+ const localUri = item.localUri;
1036
+ let result = fetched.includes(item) || Array.isArray(item.from) && item.from.includes('style');
1037
+ if (localUri) {
1038
+ if (item.etag && !item.content && !item.invalid) {
1039
+ CACHE_ETAG.set(localUri, item.etag);
1040
+ }
1041
+ else {
1042
+ CACHE_ETAG.delete(localUri);
1043
+ }
1044
+ if (!item.content || item.invalid) {
1045
+ CACHE_CONTENT.delete(localUri);
1046
+ }
1047
+ else if (CACHE_CONTENT.get(localUri) !== item.content || !item.inlineContent && !Document.isPath(localUri)) {
1048
+ CACHE_CONTENT.set(localUri, item.content);
1049
+ result = true;
1050
+ }
1051
+ if (!item.format || item.invalid) {
1052
+ CACHE_FORMAT.delete(localUri);
1053
+ }
1054
+ else {
1055
+ const format = item.format.toString();
1056
+ if (CACHE_FORMAT.get(localUri) !== format || !item.inlineContent && !Document.isPath(localUri)) {
1057
+ CACHE_FORMAT.set(localUri, format);
1058
+ result = true;
1059
+ }
1060
+ }
1061
+ }
1062
+ return result || this.copiedAssets.includes(item) && (!(0, types_1.isEmpty)(item.bundleId) || !(0, types_1.isEmpty)(item.trailingContent));
1063
+ };
1064
+ const js = instance.jsFiles.filter(item => wasModified(item) || !!item.imports);
1065
+ const css = instance.cssFiles.filter(wasModified);
1066
+ const svg = instance.svgFiles.filter(wasModified);
987
1067
  if (js.length || css.length || svg.length) {
988
1068
  instance.jsFiles = js;
989
1069
  instance.cssFiles = css;
@@ -1101,50 +1181,6 @@ class ChromeDocument extends Document {
1101
1181
  }
1102
1182
  });
1103
1183
  }
1104
- config = {
1105
- usedVariables: undefined,
1106
- usedFontFace: undefined,
1107
- usedKeyframes: undefined,
1108
- unusedStyles: undefined,
1109
- unusedMedia: undefined,
1110
- unusedSupports: undefined,
1111
- unusedContainer: undefined,
1112
- unusedScope: undefined,
1113
- unusedAtRules: undefined,
1114
- useOriginalHtmlPage: undefined,
1115
- useUnsafeHtmlReplace: undefined,
1116
- useUnsafeCssReplace: undefined,
1117
- useSessionCache: undefined,
1118
- stripCommentsAndCDATA: undefined,
1119
- normalizeHtmlOutput: undefined,
1120
- escapeReservedCharacters: undefined,
1121
- ignoreServerCodeBlocks: undefined
1122
- };
1123
- htmlFile = null;
1124
- cssFiles = [];
1125
- jsFiles = [];
1126
- svgFiles = [];
1127
- baseDirectory = '';
1128
- baseUrl = '';
1129
- productionRelease = false;
1130
- productionIncremental = false;
1131
- templateMap = {};
1132
- userAgentData = {};
1133
- related = new Map();
1134
- replaced = [];
1135
- formatMap;
1136
- _moduleName = 'chrome';
1137
- _threadable = true;
1138
- _dataSource;
1139
- _mimeMap;
1140
- _elements = null;
1141
- _cloudUrlMap;
1142
- _cloudUploaded;
1143
- _cloudEndpoint;
1144
- _idMap = Object.create(null);
1145
- _editing = [];
1146
- _queryMap = new Map();
1147
- _selectorMap = new Map();
1148
1184
  init(assets, config) {
1149
1185
  assets.sort((a, b) => {
1150
1186
  if (!(0, types_1.isEmpty)(a.bundleId) && a.bundleId === b.bundleId) {
@@ -3737,4 +3773,6 @@ class ChromeDocument extends Document {
3737
3773
  return this.module.settings ||= {};
3738
3774
  }
3739
3775
  }
3776
+ ChromeDocument.INTERNAL_ASSIGNUUID = "__assign__";
3777
+ ChromeDocument.INTERNAL_SERVERROOT = "__serverroot__";
3740
3778
  module.exports = ChromeDocument;
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "@pi-r/chrome",
3
- "version": "0.7.2",
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.9.4",
24
- "@e-mc/core": "^0.9.4",
25
- "@e-mc/document": "^0.9.4",
26
- "@e-mc/types": "^0.9.4"
27
- }
28
- }
1
+ {
2
+ "name": "@pi-r/chrome",
3
+ "version": "0.7.4",
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.9.12",
24
+ "@e-mc/core": "^0.9.12",
25
+ "@e-mc/document": "^0.9.12",
26
+ "@e-mc/types": "^0.9.12"
27
+ }
28
+ }
package/types/index.d.ts CHANGED
@@ -1,127 +1,127 @@
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
- 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 ChromeDocumentSettings extends IDocumentSettings {
43
- directory?: DocumentDirectory;
44
- options?: DocumentComponentOptions<boolean | number>;
45
- export?: ObjectMap<string | FunctionType>;
46
- }
47
-
48
- type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap" | "userAgentData";
49
-
50
- export interface FormatUri extends Partial<LocationUri> {
51
- dictionary?: string;
52
- }
53
-
54
- export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
55
- readonly host: T;
56
- readonly startTime: LogTime;
57
- readonly hashed: Set<DocumentAsset>;
58
- readonly contentMap: StringMap;
59
- readonly bufferMap: ObjectMap<Bufferable>;
60
- readonly cacheMiss: string[];
61
- readonly productionRelease: Undef<true>;
62
- }
63
-
64
- export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
65
-
66
- export interface DocumentModule extends IDocumentModule {
67
- eval?: DocumentEval;
68
- format?: PlainObject & { uuid?: FormatUri };
69
- settings?: ChromeDocumentSettings;
70
- }
71
-
72
- export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
73
- relativeUrl?: string;
74
- inlineFilename?: string;
75
- srcSet?: string[];
76
- inlineUrl?: string;
77
- inlineUrlMap?: StringMap;
78
- inlineUrlCloud?: string;
79
- inlineUrlCloudMap?: StringMap;
80
- inlineBase64?: string;
81
- modified?: boolean;
82
- }
83
-
84
- export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
85
- useUnsafeHtmlReplace?: boolean;
86
- useUnsafeCssReplace?: boolean;
87
- }
88
-
89
- 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> {
90
- htmlFile: Null<U>;
91
- cssFiles: U[];
92
- jsFiles: U[];
93
- svgFiles: U[];
94
- baseDirectory: string;
95
- baseUrl: string;
96
- config: UserConfig;
97
- related: Map<U, Set<U>>;
98
- replaced: U[];
99
- formatMap?: ObjectMap<FormatUri>;
100
- setElementSrc(asset: U, element: IXmlElement, value: string): void;
101
- findDataValue(name: string): Undef<string>;
102
- setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
103
- applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
104
- rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
105
- setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
106
- applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
107
- setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
108
- removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
109
- removeServerRoot(value: string): string;
110
- replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
111
- cloudInit(state: CloudScopeOrigin<T, U, V>): void;
112
- cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
113
- cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
114
- cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
115
- get editing(): U[];
116
- set dataSource(value);
117
- get dataSource(): DataSource[];
118
- get elements(): XmlTagNode[];
119
- get settings(): ChromeDocumentSettings;
120
- }
121
-
122
- export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
123
- INTERNAL_ASSIGNUUID: string;
124
- INTERNAL_SERVERROOT: string;
125
- readonly prototype: IChromeDocument<T, U>;
126
- new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
127
- }
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
+ 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 ChromeDocumentSettings extends IDocumentSettings {
43
+ directory?: DocumentDirectory;
44
+ options?: DocumentComponentOptions<boolean | number>;
45
+ export?: ObjectMap<string | FunctionType>;
46
+ }
47
+
48
+ type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap" | "userAgentData";
49
+
50
+ export interface FormatUri extends Partial<LocationUri> {
51
+ dictionary?: string;
52
+ }
53
+
54
+ export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
55
+ readonly host: T;
56
+ readonly startTime: LogTime;
57
+ readonly hashed: Set<DocumentAsset>;
58
+ readonly contentMap: StringMap;
59
+ readonly bufferMap: ObjectMap<Bufferable>;
60
+ readonly cacheMiss: string[];
61
+ readonly productionRelease: Undef<true>;
62
+ }
63
+
64
+ export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
65
+
66
+ export interface DocumentModule extends IDocumentModule {
67
+ eval?: DocumentEval;
68
+ format?: PlainObject & { uuid?: FormatUri };
69
+ settings?: ChromeDocumentSettings;
70
+ }
71
+
72
+ export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
73
+ relativeUrl?: string;
74
+ inlineFilename?: string;
75
+ srcSet?: string[];
76
+ inlineUrl?: string;
77
+ inlineUrlMap?: StringMap;
78
+ inlineUrlCloud?: string;
79
+ inlineUrlCloudMap?: StringMap;
80
+ inlineBase64?: string;
81
+ modified?: boolean;
82
+ }
83
+
84
+ export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
85
+ useUnsafeHtmlReplace?: boolean;
86
+ useUnsafeCssReplace?: boolean;
87
+ }
88
+
89
+ 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> {
90
+ htmlFile: Null<U>;
91
+ cssFiles: U[];
92
+ jsFiles: U[];
93
+ svgFiles: U[];
94
+ baseDirectory: string;
95
+ baseUrl: string;
96
+ config: UserConfig;
97
+ related: Map<U, Set<U>>;
98
+ replaced: U[];
99
+ formatMap?: ObjectMap<FormatUri>;
100
+ setElementSrc(asset: U, element: IXmlElement, value: string): void;
101
+ findDataValue(name: string): Undef<string>;
102
+ setInlinedAttributes(processing: FinalizeProcessing<T, U>): void;
103
+ applyTransforms(processing: FinalizeProcessing<T, U>): Promise<void>;
104
+ rewriteHtml(processing: FinalizeProcessing<T, U>): Promise<void>;
105
+ setElementAttributes(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
106
+ applyDataSource(processing: FinalizeProcessing<T, U>, domBase: IDomWriter): Promise<void>;
107
+ setProductionAttributes(processing: FinalizeProcessing<T, U>): void;
108
+ removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
109
+ removeServerRoot(value: string): string;
110
+ replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
111
+ cloudInit(state: CloudScopeOrigin<T, U, V>): void;
112
+ cloudObject(state: CloudScopeOrigin<T, U, V>, file: U): boolean;
113
+ cloudUpload(state: CloudScopeOrigin<T, U, V>, file: U, url: string, active: boolean): Promise<boolean>;
114
+ cloudFinalize(state: CloudScopeOrigin<T, U, V>): Promise<unknown[]>;
115
+ get editing(): U[];
116
+ set dataSource(value);
117
+ get dataSource(): DataSource[];
118
+ get elements(): XmlTagNode[];
119
+ get settings(): ChromeDocumentSettings;
120
+ }
121
+
122
+ export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
123
+ INTERNAL_ASSIGNUUID: string;
124
+ INTERNAL_SERVERROOT: string;
125
+ readonly prototype: IChromeDocument<T, U>;
126
+ new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
127
+ }
@@ -1,138 +1,138 @@
1
- import type { AttributeAction, ConditionProperty, CssConditionData, 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
- export interface UserAgentData {
27
- platform: string;
28
- name: string;
29
- brand: string;
30
- browser: number;
31
- version: Null<number[]>;
32
- majorVersion: number;
33
- mobile: boolean;
34
- }
35
-
36
- export interface DocumentOutput {
37
- productionRelease?: boolean | string;
38
- productionIncremental?: boolean;
39
- useOriginalHtmlPage?: boolean | string;
40
- useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
41
- useSessionCache?: boolean;
42
- stripCommentsAndCDATA?: boolean | string;
43
- normalizeHtmlOutput?: boolean | string;
44
- escapeReservedCharacters?: boolean;
45
- ignoreServerCodeBlocks?: string[];
46
- webBundle?: {
47
- rootDirAlias?: string;
48
- baseUrl?: string;
49
- primaryUrl?: string;
50
- copyTo?: string;
51
- rewriteHtmlPage?: boolean | string;
52
- excludeHtmlPage?: boolean;
53
- excludeTransforms?: boolean;
54
- includeScopes?: string[];
55
- excludeScopes?: string[];
56
- };
57
- templateMap?: TemplateMap;
58
- userAgentData?: Partial<UserAgentData>;
59
- }
60
-
61
- export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
62
-
63
- export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
64
- preserve?: boolean;
65
- static?: boolean;
66
- editing?: boolean;
67
- inlineContent?: string;
68
- originAddress?: boolean;
69
- }
70
-
71
- export interface TemplateMap extends PlainObject {
72
- html?: ObjectMap<StringMap>;
73
- js?: ObjectMap<StringMap>;
74
- css?: ObjectMap<StringMap>;
75
- data?: StringMap;
76
- }
77
-
78
- export interface CssRuleData {
79
- usedVariables?: string[];
80
- usedFontFace?: string[];
81
- usedKeyframes?: string[];
82
- unusedStyles?: string[];
83
- unusedMedia?: string[];
84
- unusedSupports?: string[];
85
- unusedContainer?: string[];
86
- unusedScope?: ScopeData[];
87
- unusedAtRules?: UnusedAtRule[];
88
- }
89
-
90
- export interface UnusedAtRule {
91
- selector?: string;
92
- media?: ConditionProperty;
93
- supports?: ConditionProperty;
94
- container?: CssConditionData & Partial<ConditionProperty>;
95
- layer?: string[];
96
- }
97
-
98
- export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
99
- source: "cloud" | "json" | "uri" | "local" | "export" | DbSource;
100
- type?: "text" | "attribute" | "display";
101
- dynamic?: boolean;
102
- value?: ArrayOf<string> | AnyObject;
103
- template?: string;
104
- viewEngine?: ViewEngine | string;
105
- ignoreEmpty?: boolean;
106
- ignoreCoerce?: boolean;
107
- }
108
-
109
- export interface TextDataSource extends DataSource {
110
- type: "text";
111
- leadingText?: string;
112
- trailingText?: string;
113
- }
114
-
115
- export interface UriDataSource extends DataSource, DataObject {
116
- source: "uri";
117
- body?: unknown;
118
- contentType?: string;
119
- }
120
-
121
- export interface LocalDataSource extends DataSource, DataObject {
122
- source: "local";
123
- pathname?: string;
124
- }
125
-
126
- export interface JSONDataSource extends DataSource, CascadeAction {
127
- source: "json";
128
- items?: unknown;
129
- }
130
-
131
- export interface ExportDataSource extends DataSource, CascadeAction {
132
- source: "export";
133
- execute?: FunctionType;
134
- pathname?: string;
135
- settings?: string;
136
- params?: unknown;
137
- persist?: boolean;
1
+ import type { AttributeAction, ConditionProperty, CssConditionData, 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
+ export interface UserAgentData {
27
+ platform: string;
28
+ name: string;
29
+ brand: string;
30
+ browser: number;
31
+ version: Null<number[]>;
32
+ majorVersion: number;
33
+ mobile: boolean;
34
+ }
35
+
36
+ export interface DocumentOutput {
37
+ productionRelease?: boolean | string;
38
+ productionIncremental?: boolean;
39
+ useOriginalHtmlPage?: boolean | string;
40
+ useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
41
+ useSessionCache?: boolean;
42
+ stripCommentsAndCDATA?: boolean | string;
43
+ normalizeHtmlOutput?: boolean | string;
44
+ escapeReservedCharacters?: boolean;
45
+ ignoreServerCodeBlocks?: string[];
46
+ webBundle?: {
47
+ rootDirAlias?: string;
48
+ baseUrl?: string;
49
+ primaryUrl?: string;
50
+ copyTo?: string;
51
+ rewriteHtmlPage?: boolean | string;
52
+ excludeHtmlPage?: boolean;
53
+ excludeTransforms?: boolean;
54
+ includeScopes?: string[];
55
+ excludeScopes?: string[];
56
+ };
57
+ templateMap?: TemplateMap;
58
+ userAgentData?: Partial<UserAgentData>;
59
+ }
60
+
61
+ export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
62
+
63
+ export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
64
+ preserve?: boolean;
65
+ static?: boolean;
66
+ editing?: boolean;
67
+ inlineContent?: string;
68
+ originAddress?: boolean;
69
+ }
70
+
71
+ export interface TemplateMap extends PlainObject {
72
+ html?: ObjectMap<StringMap>;
73
+ js?: ObjectMap<StringMap>;
74
+ css?: ObjectMap<StringMap>;
75
+ data?: StringMap;
76
+ }
77
+
78
+ export interface CssRuleData {
79
+ usedVariables?: string[];
80
+ usedFontFace?: string[];
81
+ usedKeyframes?: string[];
82
+ unusedStyles?: string[];
83
+ unusedMedia?: string[];
84
+ unusedSupports?: string[];
85
+ unusedContainer?: string[];
86
+ unusedScope?: ScopeData[];
87
+ unusedAtRules?: UnusedAtRule[];
88
+ }
89
+
90
+ export interface UnusedAtRule {
91
+ selector?: string;
92
+ media?: ConditionProperty;
93
+ supports?: ConditionProperty;
94
+ container?: CssConditionData & Partial<ConditionProperty>;
95
+ layer?: string[];
96
+ }
97
+
98
+ export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
99
+ source: "cloud" | "json" | "uri" | "local" | "export" | DbSource;
100
+ type?: "text" | "attribute" | "display";
101
+ dynamic?: boolean;
102
+ value?: ArrayOf<string> | AnyObject;
103
+ template?: string;
104
+ viewEngine?: ViewEngine | string;
105
+ ignoreEmpty?: boolean;
106
+ ignoreCoerce?: boolean;
107
+ }
108
+
109
+ export interface TextDataSource extends DataSource {
110
+ type: "text";
111
+ leadingText?: string;
112
+ trailingText?: string;
113
+ }
114
+
115
+ export interface UriDataSource extends DataSource, DataObject {
116
+ source: "uri";
117
+ body?: unknown;
118
+ contentType?: string;
119
+ }
120
+
121
+ export interface LocalDataSource extends DataSource, DataObject {
122
+ source: "local";
123
+ pathname?: string;
124
+ }
125
+
126
+ export interface JSONDataSource extends DataSource, CascadeAction {
127
+ source: "json";
128
+ items?: unknown;
129
+ }
130
+
131
+ export interface ExportDataSource extends DataSource, CascadeAction {
132
+ source: "export";
133
+ execute?: FunctionType;
134
+ pathname?: string;
135
+ settings?: string;
136
+ params?: unknown;
137
+ persist?: boolean;
138
138
  }