@pi-r/chrome 0.0.1
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 +7 -0
- package/README.md +5 -0
- package/index.d.ts +7 -0
- package/index.js +3548 -0
- package/package.json +28 -0
- package/types/index.d.ts +118 -0
- package/types/squared.d.ts +106 -0
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-r/chrome",
|
|
3
|
+
"version": "0.0.1",
|
|
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": "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.4.0",
|
|
24
|
+
"@e-mc/core": "^0.4.0",
|
|
25
|
+
"@e-mc/document": "^0.4.0",
|
|
26
|
+
"@e-mc/types": "^0.4.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { LocationUri, XmlTagNode } from '@e-mc/types/lib/squared';
|
|
2
|
+
|
|
3
|
+
import type { DocumentConstructor, IDocument, IFileManager } from '@e-mc/types/lib';
|
|
4
|
+
import type { DocumentAsset as IDocumentAsset } from '@e-mc/types/lib/document';
|
|
5
|
+
import type { LogTime } from '@e-mc/types/lib/logger';
|
|
6
|
+
import type { DbSourceDataType, DocumentComponentOption, DocumentComponent as IDocumentComponent, DocumentComponentOptions as IDocumentComponentOptions, DocumentDirectory as IDocumentDirectory, DocumentEval as IDocumentEval, DocumentModule as IDocumentModule, DocumentSettings as IDocumentSettings } from '@e-mc/types/lib/settings';
|
|
7
|
+
|
|
8
|
+
import type { CloudScopeOrigin } from '@e-mc/cloud/types';
|
|
9
|
+
import type { IDomWriter, IXmlElement } from '@e-mc/document/parse/types';
|
|
10
|
+
|
|
11
|
+
import type { ChromeAsset, CssRuleData, DataSource, DocumentOutput } from './squared';
|
|
12
|
+
|
|
13
|
+
interface DocumentDirectory extends IDocumentDirectory {
|
|
14
|
+
template?: string;
|
|
15
|
+
data?: string;
|
|
16
|
+
export?: string;
|
|
17
|
+
schema?: string;
|
|
18
|
+
sql?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface DocumentComponentExtended<T> extends DbSourceDataType<T> {
|
|
22
|
+
uri?: T;
|
|
23
|
+
local?: T;
|
|
24
|
+
export?: T;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface DocumentComponentOptions<T> extends IDocumentComponentOptions, DocumentComponentExtended<DocumentComponentOption<T>> {}
|
|
28
|
+
|
|
29
|
+
interface DocumentEval extends IDocumentEval {
|
|
30
|
+
template?: boolean;
|
|
31
|
+
userconfig?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ChromeDocumentSettings extends IDocumentSettings {
|
|
35
|
+
directory?: DocumentDirectory;
|
|
36
|
+
options?: DocumentComponentOptions<boolean | number>;
|
|
37
|
+
export?: ObjectMap<string | FunctionType>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type OutputType = "useUnsafeReplace" | "productionRelease" | "productionIncremental" | "templateMap";
|
|
41
|
+
|
|
42
|
+
export interface FormatUri extends Partial<LocationUri> {
|
|
43
|
+
dictionary?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface FinalizeProcessing<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> {
|
|
47
|
+
readonly host: T;
|
|
48
|
+
readonly startTime: LogTime;
|
|
49
|
+
readonly hashed: Set<DocumentAsset>;
|
|
50
|
+
readonly contentMap: StringMap;
|
|
51
|
+
readonly bufferMap: ObjectMap<BufferContent>;
|
|
52
|
+
readonly cacheMiss: string[];
|
|
53
|
+
readonly productionRelease: Undef<true>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface DocumentComponent<T = boolean> extends IDocumentComponent<T, T>, DocumentComponentExtended<T> {}
|
|
57
|
+
|
|
58
|
+
export interface DocumentModule extends IDocumentModule {
|
|
59
|
+
eval?: DocumentEval;
|
|
60
|
+
format?: PlainObject & { uuid?: FormatUri };
|
|
61
|
+
settings?: ChromeDocumentSettings;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface DocumentAsset extends IDocumentAsset, ChromeAsset {
|
|
65
|
+
relativeUrl?: string;
|
|
66
|
+
inlineFilename?: string;
|
|
67
|
+
srcSet?: string[];
|
|
68
|
+
inlineUrl?: string;
|
|
69
|
+
inlineUrlMap?: StringMap;
|
|
70
|
+
inlineUrlCloud?: string;
|
|
71
|
+
inlineUrlCloudMap?: StringMap;
|
|
72
|
+
inlineBase64?: string;
|
|
73
|
+
modified?: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface UserConfig extends CssRuleData, Omit<DocumentOutput, OutputType> {
|
|
77
|
+
useUnsafeHtmlReplace?: boolean;
|
|
78
|
+
useUnsafeCssReplace?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface IChromeDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends IDocument<T, U, DocumentModule, DocumentComponent>, Pick<DocumentOutput, OutputType> {
|
|
82
|
+
htmlFile: Null<U>;
|
|
83
|
+
cssFiles: U[];
|
|
84
|
+
jsFiles: U[];
|
|
85
|
+
svgFiles: U[];
|
|
86
|
+
baseDirectory: string;
|
|
87
|
+
baseUrl: string;
|
|
88
|
+
config: UserConfig;
|
|
89
|
+
related: Map<U, Set<U>>;
|
|
90
|
+
replaced: U[];
|
|
91
|
+
formatMap?: ObjectMap<FormatUri>;
|
|
92
|
+
setElementSrc(asset: U, element: IXmlElement, value: string): void;
|
|
93
|
+
findDataValue(name: string): Undef<string>;
|
|
94
|
+
setInlinedAttributes(processing: FinalizeProcessing<T>): void;
|
|
95
|
+
applyTransforms(processing: FinalizeProcessing<T>): Promise<void>;
|
|
96
|
+
rewriteHtml(processing: FinalizeProcessing<T>): Promise<void>;
|
|
97
|
+
setElementAttributes(processing: FinalizeProcessing<T>, domBase: IDomWriter): Promise<void>;
|
|
98
|
+
applyDataSource(processing: FinalizeProcessing<T>, domBase: IDomWriter): Promise<void>;
|
|
99
|
+
setProductionAttributes(processing: FinalizeProcessing<T>): void;
|
|
100
|
+
removeUnusedStyles(source: string, options?: UserConfig): Undef<string>;
|
|
101
|
+
removeServerRoot(value: string): string;
|
|
102
|
+
replaceContent(source: string, match: RegExpExecArray | string, mimeType?: string): Undef<string>;
|
|
103
|
+
cloudInit(state: CloudScopeOrigin<T, U>): void;
|
|
104
|
+
cloudObject(state: CloudScopeOrigin<T, U>, file: U): boolean;
|
|
105
|
+
cloudUpload(state: CloudScopeOrigin<T, U>, file: U, url: string, active: boolean): Promise<boolean>;
|
|
106
|
+
cloudFinalize(state: CloudScopeOrigin<T, U>): Promise<unknown[]>;
|
|
107
|
+
get settings(): ChromeDocumentSettings;
|
|
108
|
+
get editing(): U[];
|
|
109
|
+
get dataSource(): DataSource[];
|
|
110
|
+
get elements(): XmlTagNode[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface ChromeDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends DocumentConstructor<T, U> {
|
|
114
|
+
INTERNAL_ASSIGNUUID: string;
|
|
115
|
+
INTERNAL_SERVERROOT: string;
|
|
116
|
+
readonly prototype: IChromeDocument<T, U>;
|
|
117
|
+
new(module?: DocumentModule, ...args: unknown[]): IChromeDocument<T, U>;
|
|
118
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 DocumentOutput {
|
|
21
|
+
productionRelease?: boolean | string;
|
|
22
|
+
productionIncremental?: boolean;
|
|
23
|
+
useOriginalHtmlPage?: boolean | string;
|
|
24
|
+
useUnsafeReplace?: ArrayOf<"html" | "css"> | boolean;
|
|
25
|
+
stripCommentsAndCDATA?: boolean | string;
|
|
26
|
+
normalizeHtmlOutput?: boolean | string;
|
|
27
|
+
escapeReservedCharacters?: boolean;
|
|
28
|
+
ignoreServerCodeBlocks?: string[];
|
|
29
|
+
webBundle?: {
|
|
30
|
+
rootDirAlias?: string;
|
|
31
|
+
baseUrl?: string;
|
|
32
|
+
primaryUrl?: string;
|
|
33
|
+
copyTo?: string;
|
|
34
|
+
rewriteHtmlPage?: boolean | string;
|
|
35
|
+
excludeHtmlPage?: boolean;
|
|
36
|
+
excludeTransforms?: boolean;
|
|
37
|
+
includeScopes?: string[];
|
|
38
|
+
excludeScopes?: string[];
|
|
39
|
+
};
|
|
40
|
+
templateMap?: TemplateMap;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface RequestData extends IRequestData<ChromeAsset>, Readonly<DocumentOutput>, Readonly<CssRuleData> {}
|
|
44
|
+
|
|
45
|
+
export interface ChromeAsset extends FileAsset, AttributeAction, ElementAction, MetadataAction<PlainObject>, UploadAction, HashAction, ExcludeAction, ImportAction<ImportFrom[] | boolean>, FromAction {
|
|
46
|
+
preserve?: boolean;
|
|
47
|
+
static?: boolean;
|
|
48
|
+
editing?: boolean;
|
|
49
|
+
inlineContent?: string;
|
|
50
|
+
originAddress?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TemplateMap extends PlainObject {
|
|
54
|
+
html?: ObjectMap<StringMap>;
|
|
55
|
+
js?: ObjectMap<StringMap>;
|
|
56
|
+
css?: ObjectMap<StringMap>;
|
|
57
|
+
data?: StringMap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CssRuleData {
|
|
61
|
+
usedVariables?: string[];
|
|
62
|
+
usedFontFace?: string[];
|
|
63
|
+
usedKeyframes?: string[];
|
|
64
|
+
unusedStyles?: string[];
|
|
65
|
+
unusedMedia?: string[];
|
|
66
|
+
unusedContainer?: string[];
|
|
67
|
+
unusedSupports?: string[];
|
|
68
|
+
unusedAtRules?: UnusedAtRule[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface UnusedAtRule {
|
|
72
|
+
selector?: string;
|
|
73
|
+
media?: ConditionProperty;
|
|
74
|
+
supports?: ConditionProperty;
|
|
75
|
+
container?: CssConditionData & Partial<ConditionProperty>;
|
|
76
|
+
layer?: string[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface DataSource<T = string> extends IDataSource<T>, ElementAction {
|
|
80
|
+
source: "cloud" | "uri" | "local" | "export" | DbSource;
|
|
81
|
+
element?: XmlTagNode;
|
|
82
|
+
type?: "text" | "attribute" | "display";
|
|
83
|
+
dynamic?: boolean;
|
|
84
|
+
value?: StringOfArray | ObjectMap<unknown>;
|
|
85
|
+
template?: string;
|
|
86
|
+
viewEngine?: ViewEngine | string;
|
|
87
|
+
ignoreEmpty?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface UriDataSource extends DataSource, DataObject {
|
|
91
|
+
source: "uri";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface LocalDataSource extends DataSource, DataObject {
|
|
95
|
+
source: "local";
|
|
96
|
+
pathname?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ExportDataSource extends DataSource, CascadeAction {
|
|
100
|
+
source: "export";
|
|
101
|
+
execute?: FunctionType;
|
|
102
|
+
pathname?: string;
|
|
103
|
+
settings?: string;
|
|
104
|
+
params?: unknown;
|
|
105
|
+
persist?: boolean;
|
|
106
|
+
}
|