@e-mc/document 0.8.17 → 0.8.18
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 +98 -98
- package/asset.d.ts +7 -7
- package/package.json +31 -31
- package/parse/dom.d.ts +8 -8
- package/parse/dom.js +1 -1
- package/parse/index.d.ts +8 -8
- package/parse/index.js +2 -2
- package/parse/types/index.d.ts +240 -240
- package/util.d.ts +16 -16
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2024 An Pham
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
# @e-mc/document
|
|
2
|
-
|
|
3
|
-
* NodeJS 14
|
|
4
|
-
* ES2019
|
|
5
|
-
|
|
6
|
-
## General Usage
|
|
7
|
-
|
|
8
|
-
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
-
|
|
10
|
-
## Interface
|
|
11
|
-
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import type { DataSource, ViewEngine } from "./squared";
|
|
16
|
-
|
|
17
|
-
import type { IFileManager, IScopeOrigin } from "./index";
|
|
18
|
-
import type { ExternalAsset, FileCommand, IFileThread, OutputFinalize } from "./asset";
|
|
19
|
-
import type { HostInitConfig, IClient } from "./core";
|
|
20
|
-
import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from "./document";
|
|
21
|
-
import type { PostFinalizeCallback } from "./filemanager";
|
|
22
|
-
import type { LogComponent } from "./logger";
|
|
23
|
-
import type { DocumentComponent, DocumentComponentOption, DocumentModule } from "./settings";
|
|
24
|
-
import type { IFileGroup, WatchInitResult } from "./watch";
|
|
25
|
-
|
|
26
|
-
interface IDocument extends IClient<IFileManager, DocumentModule, TransformCallback<IFileManager, ExternalAsset>> {
|
|
27
|
-
Db: IDb | null;
|
|
28
|
-
assets: ExternalAsset[];
|
|
29
|
-
config: Record<string, any>;
|
|
30
|
-
init(assets: ExternalAsset[], config?: HostInitConfig): this;
|
|
31
|
-
customize(options?: CustomizeOptions): void;
|
|
32
|
-
findConfig(data: object, name: string, type?: string): PluginConfig;
|
|
33
|
-
loadConfig(data: object, name: string): ConfigOrTransformer | null | undefined;
|
|
34
|
-
asSourceFile(value: string, options?: AsSourceFileOptions | boolean): unknown;
|
|
35
|
-
findVersion(name: string | string[], fallback?: string): string;
|
|
36
|
-
findSourceScope(uri: string, imports: Record<string, unknown>): Record<string, string | undefined>[];
|
|
37
|
-
findSourceRoot(uri: string, imports?: Record<string, string | undefined>): string | undefined;
|
|
38
|
-
resolveDir(name: string, ...paths: string[]): string | undefined;
|
|
39
|
-
locateSourceFiles(file: ExternalAsset, code?: string, bundleContent?: string[]): (imports?: Record<string, string | undefined>) => SourceInput | undefined;
|
|
40
|
-
resolveSourceFile(file: ExternalAsset): (code?: string, imports?: Record<string, string | undefined>) => SourceInput<string> | undefined;
|
|
41
|
-
tryParse(source: string, format: string, options?: Record<string | number | symbol, unknown>): unknown;
|
|
42
|
-
forDb(item: DataSource): boolean;
|
|
43
|
-
hasEval(name: string): boolean;
|
|
44
|
-
settingsOf(name: keyof DocumentComponent, option: keyof DocumentComponentOption): unknown;
|
|
45
|
-
parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise<string | null>;
|
|
46
|
-
transform(type: string, code: string, format: string | string[], options?: TransformOutput & TransformAction): Promise<TransformResult | void>;
|
|
47
|
-
abort(name?: keyof DocumentComponent | Error, reason?: unknown): void;
|
|
48
|
-
restart(): void;
|
|
49
|
-
using?(data: IFileThread): Promise<unknown>;
|
|
50
|
-
setLocalUri?(file: ExternalAsset, replace?: boolean): void;
|
|
51
|
-
resolveUri?(file: ExternalAsset, source: string): string;
|
|
52
|
-
resolveUri?(file: ExternalAsset, source: string, trailing: string): [string, string];
|
|
53
|
-
resolveImports?(file: ExternalAsset, code: string, baseFile?: string | ExternalAsset): string | undefined;
|
|
54
|
-
replaceContent?(source: string, statement: RegExpExecArray | string, mimeType?: string): string | undefined;
|
|
55
|
-
addCopy?(data: FileCommand<ExternalAsset>, saveAs: string, replace?: boolean): string | undefined;
|
|
56
|
-
writeImage?(output: OutputFinalize<ExternalAsset>): boolean;
|
|
57
|
-
cloudInit?(state: IScopeOrigin<IFileManager, ICloud>): void;
|
|
58
|
-
cloudObject?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset): boolean;
|
|
59
|
-
cloudUpload?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, url: string, active: boolean): Promise<boolean>;
|
|
60
|
-
cloudFinalize?(state: IScopeOrigin<IFileManager, ICloud>): Promise<unknown[]>;
|
|
61
|
-
watchInit?(watch: IFileGroup<ExternalAsset>, assets: ExternalAsset[], sanitize?: boolean): WatchInitResult | undefined;
|
|
62
|
-
watchModified?(watch: IFileGroup<ExternalAsset>, assets?: ExternalAsset[]): PostFinalizeCallback;
|
|
63
|
-
set dataSource(value: DataSource[]);
|
|
64
|
-
get dataSource(): DataSource[];
|
|
65
|
-
set imports(value);
|
|
66
|
-
get imports(): Record<string, string | undefined>;
|
|
67
|
-
get watching(): boolean;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
interface DocumentConstructor extends ModuleConstructor {
|
|
71
|
-
finalize(this: IFileManager, instance: IDocument): Promise<unknown>;
|
|
72
|
-
createSourceMap(code: string, remove: boolean): SourceMap;
|
|
73
|
-
createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
|
|
74
|
-
writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined;
|
|
75
|
-
updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions | boolean): string;
|
|
76
|
-
generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
|
|
77
|
-
/* @deprecated - IDocument.using */
|
|
78
|
-
using?(this: IFileManager, instance: IDocument, file: ExternalAsset): Promise<unknown>;
|
|
79
|
-
cleanup?(this: IFileManager, instance: IDocument): Promise<unknown>;
|
|
80
|
-
sanitizeAssets?(assets: ExternalAsset[], exclusions?: ExternalAsset[]): ExternalAsset[];
|
|
81
|
-
readonly prototype: IDocument;
|
|
82
|
-
new(module?: DocumentModule, ...args: unknown[]): IDocument;
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## References
|
|
87
|
-
|
|
88
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
89
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
90
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
91
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
92
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
93
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
94
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
95
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
96
|
-
|
|
97
|
-
## LICENSE
|
|
98
|
-
|
|
1
|
+
# @e-mc/document
|
|
2
|
+
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2019
|
|
5
|
+
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/index.d.ts
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { DataSource, ViewEngine } from "./squared";
|
|
16
|
+
|
|
17
|
+
import type { IFileManager, IScopeOrigin } from "./index";
|
|
18
|
+
import type { ExternalAsset, FileCommand, IFileThread, OutputFinalize } from "./asset";
|
|
19
|
+
import type { HostInitConfig, IClient } from "./core";
|
|
20
|
+
import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from "./document";
|
|
21
|
+
import type { PostFinalizeCallback } from "./filemanager";
|
|
22
|
+
import type { LogComponent } from "./logger";
|
|
23
|
+
import type { DocumentComponent, DocumentComponentOption, DocumentModule } from "./settings";
|
|
24
|
+
import type { IFileGroup, WatchInitResult } from "./watch";
|
|
25
|
+
|
|
26
|
+
interface IDocument extends IClient<IFileManager, DocumentModule, TransformCallback<IFileManager, ExternalAsset>> {
|
|
27
|
+
Db: IDb | null;
|
|
28
|
+
assets: ExternalAsset[];
|
|
29
|
+
config: Record<string, any>;
|
|
30
|
+
init(assets: ExternalAsset[], config?: HostInitConfig): this;
|
|
31
|
+
customize(options?: CustomizeOptions): void;
|
|
32
|
+
findConfig(data: object, name: string, type?: string): PluginConfig;
|
|
33
|
+
loadConfig(data: object, name: string): ConfigOrTransformer | null | undefined;
|
|
34
|
+
asSourceFile(value: string, options?: AsSourceFileOptions | boolean): unknown;
|
|
35
|
+
findVersion(name: string | string[], fallback?: string): string;
|
|
36
|
+
findSourceScope(uri: string, imports: Record<string, unknown>): Record<string, string | undefined>[];
|
|
37
|
+
findSourceRoot(uri: string, imports?: Record<string, string | undefined>): string | undefined;
|
|
38
|
+
resolveDir(name: string, ...paths: string[]): string | undefined;
|
|
39
|
+
locateSourceFiles(file: ExternalAsset, code?: string, bundleContent?: string[]): (imports?: Record<string, string | undefined>) => SourceInput | undefined;
|
|
40
|
+
resolveSourceFile(file: ExternalAsset): (code?: string, imports?: Record<string, string | undefined>) => SourceInput<string> | undefined;
|
|
41
|
+
tryParse(source: string, format: string, options?: Record<string | number | symbol, unknown>): unknown;
|
|
42
|
+
forDb(item: DataSource): boolean;
|
|
43
|
+
hasEval(name: string): boolean;
|
|
44
|
+
settingsOf(name: keyof DocumentComponent, option: keyof DocumentComponentOption): unknown;
|
|
45
|
+
parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise<string | null>;
|
|
46
|
+
transform(type: string, code: string, format: string | string[], options?: TransformOutput & TransformAction): Promise<TransformResult | void>;
|
|
47
|
+
abort(name?: keyof DocumentComponent | Error, reason?: unknown): void;
|
|
48
|
+
restart(): void;
|
|
49
|
+
using?(data: IFileThread): Promise<unknown>;
|
|
50
|
+
setLocalUri?(file: ExternalAsset, replace?: boolean): void;
|
|
51
|
+
resolveUri?(file: ExternalAsset, source: string): string;
|
|
52
|
+
resolveUri?(file: ExternalAsset, source: string, trailing: string): [string, string];
|
|
53
|
+
resolveImports?(file: ExternalAsset, code: string, baseFile?: string | ExternalAsset): string | undefined;
|
|
54
|
+
replaceContent?(source: string, statement: RegExpExecArray | string, mimeType?: string): string | undefined;
|
|
55
|
+
addCopy?(data: FileCommand<ExternalAsset>, saveAs: string, replace?: boolean): string | undefined;
|
|
56
|
+
writeImage?(output: OutputFinalize<ExternalAsset>): boolean;
|
|
57
|
+
cloudInit?(state: IScopeOrigin<IFileManager, ICloud>): void;
|
|
58
|
+
cloudObject?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset): boolean;
|
|
59
|
+
cloudUpload?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, url: string, active: boolean): Promise<boolean>;
|
|
60
|
+
cloudFinalize?(state: IScopeOrigin<IFileManager, ICloud>): Promise<unknown[]>;
|
|
61
|
+
watchInit?(watch: IFileGroup<ExternalAsset>, assets: ExternalAsset[], sanitize?: boolean): WatchInitResult | undefined;
|
|
62
|
+
watchModified?(watch: IFileGroup<ExternalAsset>, assets?: ExternalAsset[]): PostFinalizeCallback;
|
|
63
|
+
set dataSource(value: DataSource[]);
|
|
64
|
+
get dataSource(): DataSource[];
|
|
65
|
+
set imports(value);
|
|
66
|
+
get imports(): Record<string, string | undefined>;
|
|
67
|
+
get watching(): boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface DocumentConstructor extends ModuleConstructor {
|
|
71
|
+
finalize(this: IFileManager, instance: IDocument): Promise<unknown>;
|
|
72
|
+
createSourceMap(code: string, remove: boolean): SourceMap;
|
|
73
|
+
createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
|
|
74
|
+
writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined;
|
|
75
|
+
updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions | boolean): string;
|
|
76
|
+
generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
|
|
77
|
+
/* @deprecated - IDocument.using */
|
|
78
|
+
using?(this: IFileManager, instance: IDocument, file: ExternalAsset): Promise<unknown>;
|
|
79
|
+
cleanup?(this: IFileManager, instance: IDocument): Promise<unknown>;
|
|
80
|
+
sanitizeAssets?(assets: ExternalAsset[], exclusions?: ExternalAsset[]): ExternalAsset[];
|
|
81
|
+
readonly prototype: IDocument;
|
|
82
|
+
new(module?: DocumentModule, ...args: unknown[]): IDocument;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## References
|
|
87
|
+
|
|
88
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/squared.d.ts
|
|
89
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/asset.d.ts
|
|
90
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/core.d.ts
|
|
91
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/document.d.ts
|
|
92
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/filemanager.d.ts
|
|
93
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/logger.d.ts
|
|
94
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/settings.d.ts
|
|
95
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/watch.d.ts
|
|
96
|
+
|
|
97
|
+
## LICENSE
|
|
98
|
+
|
|
99
99
|
MIT
|
package/asset.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ExternalAsset, InitialValue } from '../types/lib/asset';
|
|
2
|
-
|
|
3
|
-
declare namespace asset {
|
|
4
|
-
function isEqual(item: ExternalAsset, other: ExternalAsset): boolean;
|
|
5
|
-
function setInitialValue(file: ExternalAsset, cacheable?: boolean): InitialValue;
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
import type { ExternalAsset, InitialValue } from '../types/lib/asset';
|
|
2
|
+
|
|
3
|
+
declare namespace asset {
|
|
4
|
+
function isEqual(item: ExternalAsset, other: ExternalAsset): boolean;
|
|
5
|
+
function setInitialValue(file: ExternalAsset, cacheable?: boolean): InitialValue;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
8
|
export = asset;
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Document constructor for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
-
"directory": "src/document"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.8.
|
|
24
|
-
"@e-mc/db": "0.8.
|
|
25
|
-
"@e-mc/types": "0.8.
|
|
26
|
-
"chalk": "4.1.2",
|
|
27
|
-
"htmlparser2": "^9.1.0",
|
|
28
|
-
"js-yaml": "^4.1.0",
|
|
29
|
-
"picomatch": "^3.0.1"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/document",
|
|
3
|
+
"version": "0.8.18",
|
|
4
|
+
"description": "Document constructor for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
+
"directory": "src/document"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/core": "0.8.18",
|
|
24
|
+
"@e-mc/db": "0.8.18",
|
|
25
|
+
"@e-mc/types": "0.8.18",
|
|
26
|
+
"chalk": "4.1.2",
|
|
27
|
+
"htmlparser2": "^9.1.0",
|
|
28
|
+
"js-yaml": "^4.1.0",
|
|
29
|
+
"picomatch": "^3.0.1"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/parse/dom.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { DomWriterConstructor, HtmlElementConstructor, IGNORE_FLAG } from './types';
|
|
2
|
-
|
|
3
|
-
declare namespace dom {
|
|
4
|
-
const IGNORE_FLAG: IGNORE_FLAG;
|
|
5
|
-
const DomWriter: DomWriterConstructor;
|
|
6
|
-
const HtmlElement: HtmlElementConstructor;
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
import type { DomWriterConstructor, HtmlElementConstructor, IGNORE_FLAG } from './types';
|
|
2
|
+
|
|
3
|
+
declare namespace dom {
|
|
4
|
+
const IGNORE_FLAG: IGNORE_FLAG;
|
|
5
|
+
const DomWriter: DomWriterConstructor;
|
|
6
|
+
const HtmlElement: HtmlElementConstructor;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
9
|
export = dom;
|
package/parse/dom.js
CHANGED
|
@@ -10,7 +10,7 @@ const index_1 = require("@e-mc/document/parse");
|
|
|
10
10
|
Object.defineProperty(exports, "IGNORE_FLAG", { enumerable: true, get: function () { return index_1.IGNORE_FLAG; } });
|
|
11
11
|
const Parser = htmlparser2.Parser;
|
|
12
12
|
const DomHandler = domhandler.DomHandler;
|
|
13
|
-
const TAG_VOID = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
13
|
+
const TAG_VOID = ['area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'isindex', 'keygen', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
14
14
|
const REGEXP_VOID = TAG_VOID.map(tagName => new RegExp(`(\\s*)</${tagName}\\s*>` + index_1.XmlWriter.PATTERN_TRAILINGSPACE, 'gi'));
|
|
15
15
|
const REGEXP_TAGNAME = new RegExp(`^${index_1.XmlWriter.PATTERN_TAGNAME}$`);
|
|
16
16
|
const PARSER_OPTIONS = Object.freeze({ xmlMode: false, decodeEntities: false });
|
package/parse/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IGNORE_FLAG, XmlElementConstructor, XmlWriterConstructor } from './types';
|
|
2
|
-
|
|
3
|
-
declare namespace parse {
|
|
4
|
-
const IGNORE_FLAG: IGNORE_FLAG;
|
|
5
|
-
const XmlWriter: XmlWriterConstructor;
|
|
6
|
-
const XmlElement: XmlElementConstructor;
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
import type { IGNORE_FLAG, XmlElementConstructor, XmlWriterConstructor } from './types';
|
|
2
|
+
|
|
3
|
+
declare namespace parse {
|
|
4
|
+
const IGNORE_FLAG: IGNORE_FLAG;
|
|
5
|
+
const XmlWriter: XmlWriterConstructor;
|
|
6
|
+
const XmlElement: XmlElementConstructor;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
9
|
export = parse;
|
package/parse/index.js
CHANGED
|
@@ -135,7 +135,7 @@ class XmlWriter {
|
|
|
135
135
|
return leading + content + trailing;
|
|
136
136
|
}
|
|
137
137
|
static escapeXmlString(value, ampersand) {
|
|
138
|
-
return value.replace(ampersand ? /[<>"'&]/g : /[<>"']|&([
|
|
138
|
+
return value.replace(ampersand ? /[<>"'&]/g : /[<>"']|&(?![a-z][a-z\d]+|#(?:\d+|x[a-f\d]+))/gi, capture => {
|
|
139
139
|
switch (capture) {
|
|
140
140
|
case '<':
|
|
141
141
|
return '<';
|
|
@@ -146,7 +146,7 @@ class XmlWriter {
|
|
|
146
146
|
case "'":
|
|
147
147
|
return ''';
|
|
148
148
|
default:
|
|
149
|
-
return '&'
|
|
149
|
+
return '&';
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
}
|
package/parse/types/index.d.ts
CHANGED
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
import type { XmlTagNode as IXmlTagNode, TagAppend, TagData } from '../../../types/lib/squared';
|
|
2
|
-
|
|
3
|
-
import type { ParserOptions } from 'htmlparser2';
|
|
4
|
-
import type { AnyNode, Element } from 'domhandler';
|
|
5
|
-
|
|
6
|
-
export interface IGNORE_FLAG {
|
|
7
|
-
NONE: 0;
|
|
8
|
-
INTERIOR: 1;
|
|
9
|
-
LOCATOR: 2;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ParserAction {
|
|
13
|
-
parser?: ParserOptions;
|
|
14
|
-
outDom?: AnyNode[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SourceIndex {
|
|
18
|
-
startIndex: number;
|
|
19
|
-
endIndex: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface SourceContent extends SourceIndex {
|
|
23
|
-
outerXml: string;
|
|
24
|
-
type?: "node" | "comment" | "cdata" | "block";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface SourceTagNode extends SourceContent, TagData {
|
|
28
|
-
id?: string;
|
|
29
|
-
ignoreCase?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface XmlTagNode extends IXmlTagNode, Partial<SourceIndex> {}
|
|
33
|
-
|
|
34
|
-
export type AttributeMap = Map<string, unknown>;
|
|
35
|
-
export type AttributeList = [string, unknown][];
|
|
36
|
-
export type TagOffsetMap = ObjectMap<Undef<number>>;
|
|
37
|
-
export type WriteResult = [string, string, Null<Error>?];
|
|
38
|
-
export type SaveResult = [string, Null<Error>?];
|
|
39
|
-
export type XmlWriterOptions = ParserAction;
|
|
40
|
-
|
|
41
|
-
export interface ParserResult extends Partial<TagData>, ParserAction {
|
|
42
|
-
element: Null<Element>;
|
|
43
|
-
error: Null<Error>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ReplaceOptions extends SourceIndex {
|
|
47
|
-
append?: TagAppend;
|
|
48
|
-
remove?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface FindElementOptions extends ParserAction {
|
|
52
|
-
document?: string;
|
|
53
|
-
id?: string;
|
|
54
|
-
locatorAttr?: string;
|
|
55
|
-
tagCount?: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface TagOffsetOptions extends ParserAction {
|
|
59
|
-
ignoreCase?: boolean;
|
|
60
|
-
ignoreTagName?: string;
|
|
61
|
-
ignoreTagGroup?: string[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface TagNodeOptions {
|
|
65
|
-
tagVoid?: boolean;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface TagNodeByIdOptions extends TagNodeOptions {
|
|
69
|
-
tagName?: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface XmlElementOptions extends TagNodeOptions, ParserAction {}
|
|
73
|
-
|
|
74
|
-
export interface DomWriterOptions extends ParserAction {
|
|
75
|
-
normalize?: boolean | string;
|
|
76
|
-
ignoreTagGroup?: string[];
|
|
77
|
-
escapeEntities?: boolean;
|
|
78
|
-
stripComments?: boolean | string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface ReplaceMatchOptions {
|
|
82
|
-
pattern?: RegExp;
|
|
83
|
-
trimLeading?: boolean;
|
|
84
|
-
trimTrailing?: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface NormalizeOptions {
|
|
88
|
-
newline?: string;
|
|
89
|
-
ignoreChar?: string;
|
|
90
|
-
ignoreTagGroup?: string[];
|
|
91
|
-
escapeEntities?: boolean;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export class IXmlBase {
|
|
95
|
-
newline: string;
|
|
96
|
-
readonly documentName: string;
|
|
97
|
-
write(...args: unknown[]): unknown;
|
|
98
|
-
save(...args: unknown[]): unknown;
|
|
99
|
-
reset(): void;
|
|
100
|
-
get nameOfId(): string;
|
|
101
|
-
get modified(): boolean;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export class IXmlWriter extends IXmlBase {
|
|
105
|
-
modifyCount: number;
|
|
106
|
-
failCount: number;
|
|
107
|
-
elements: XmlTagNode[];
|
|
108
|
-
errors: Error[];
|
|
109
|
-
parser?: ParserOptions;
|
|
110
|
-
ignoreTagName?: string;
|
|
111
|
-
ignoreTagGroup?: string[];
|
|
112
|
-
readonly rootName?: string;
|
|
113
|
-
readonly ignoreCaseTagName?: boolean;
|
|
114
|
-
init(offsetMap?: TagOffsetMap): void;
|
|
115
|
-
getInvalidArea(): Undef<SourceContent[]>;
|
|
116
|
-
ignoreFlag(...values: number[]): void;
|
|
117
|
-
insertNodes(nodes?: XmlTagNode[]): void;
|
|
118
|
-
fromNode(node: XmlTagNode, append?: TagAppend): IXmlElement;
|
|
119
|
-
newElement(node: XmlTagNode): IXmlElement;
|
|
120
|
-
append(node: XmlTagNode): Null<IXmlElement>;
|
|
121
|
-
write(element: IXmlElement): boolean;
|
|
122
|
-
save(): string;
|
|
123
|
-
close(): string;
|
|
124
|
-
update(node: XmlTagNode, outerXml: string, append?: TagAppend, offsetMap?: Null<TagOffsetMap>): void;
|
|
125
|
-
increment(nodes: XmlTagNode[], offset?: number): void;
|
|
126
|
-
decrement(node: XmlTagNode, offset?: number, remove?: boolean): XmlTagNode[];
|
|
127
|
-
renameTag(node: XmlTagNode, tagName: string): void;
|
|
128
|
-
indexTag(tagName: string, append?: TagAppend, offset?: number): void;
|
|
129
|
-
resetTag(tagName: string): void;
|
|
130
|
-
ignoreTag(value: StringOfArray): void;
|
|
131
|
-
resetPosition(startIndex?: number): void;
|
|
132
|
-
getElementById(id: string, ignoreCase?: boolean, options?: TagNodeByIdOptions): Undef<SourceTagNode>;
|
|
133
|
-
getElementsByTagName(tagName: string, ignoreCase?: boolean, options?: TagNodeOptions): SourceTagNode[];
|
|
134
|
-
setRawString(targetXml: string, outerXml: string): string;
|
|
135
|
-
getRawString(index: SourceIndex): string;
|
|
136
|
-
spliceRawString(content: SourceContent, reset?: boolean): string;
|
|
137
|
-
getComments(): Null<SourceContent[]>;
|
|
138
|
-
hasErrors(): boolean;
|
|
139
|
-
get newId(): string;
|
|
140
|
-
get patternIgnore(): Null<RegExp>;
|
|
141
|
-
set source(value);
|
|
142
|
-
get source(): string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface XmlWriterConstructor {
|
|
146
|
-
readonly PATTERN_ATTRNAME: string;
|
|
147
|
-
readonly PATTERN_ATTRVALUE: string;
|
|
148
|
-
readonly PATTERN_TAGNAME: string;
|
|
149
|
-
readonly PATTERN_TAGOPEN: string;
|
|
150
|
-
readonly PATTERN_QUOTEVALUE: string;
|
|
151
|
-
readonly PATTERN_COMMENT: string;
|
|
152
|
-
readonly PATTERN_TRAILINGSPACE: string;
|
|
153
|
-
replaceMatch(match: RegExpMatchArray, source: string, content: NumString, options: ReplaceMatchOptions): string;
|
|
154
|
-
replaceMatch(match: RegExpMatchArray, source: string, content?: NumString, pattern?: RegExp): string;
|
|
155
|
-
escapeXmlString(value: string, ampersand?: boolean): string;
|
|
156
|
-
escapeAttributes(source: string): string;
|
|
157
|
-
getNewlineString(leading: string, trailing: string, newline?: string): string;
|
|
158
|
-
findCloseTag(source: string, startIndex?: number): number;
|
|
159
|
-
findElement(source: string, node: XmlTagNode, options?: FindElementOptions): ParserResult;
|
|
160
|
-
getTagOffset(source: string, options?: TagOffsetOptions): TagOffsetMap;
|
|
161
|
-
getTagOffset(source: string, replacement?: string, options?: TagOffsetOptions): TagOffsetMap;
|
|
162
|
-
namesOfTagVoid(type: string, values: string[]): void;
|
|
163
|
-
isTagVoid(type: string, tagName: string): boolean;
|
|
164
|
-
getNodeId(node: XmlTagNode, document: string): string;
|
|
165
|
-
getNameOfId(document: string): string;
|
|
166
|
-
getPatternId(name: string): RegExp;
|
|
167
|
-
getCommentsAndCDATA(source: string, tagPattern: unknown, ignoreCase: boolean, stripXml: true): string;
|
|
168
|
-
getCommentsAndCDATA(source: string, tagPattern?: StringOfArray | [Undef<string>, Undef<string[]>], ignoreCase?: boolean, stripXml?: boolean): SourceContent[];
|
|
169
|
-
isEqual(node: XmlTagNode, other: XmlTagNode, ignoreCase: boolean): boolean;
|
|
170
|
-
isEqual(node: XmlTagNode, other: XmlTagNode, documentName?: string, ignoreCase?: boolean): boolean;
|
|
171
|
-
isIndex(value: Undef<number>): value is number;
|
|
172
|
-
isCount(value: Undef<number>): value is number;
|
|
173
|
-
isSpace(ch: string): boolean;
|
|
174
|
-
readonly prototype: IXmlWriter;
|
|
175
|
-
new(documentName: string, source: string, elements: XmlTagNode[], options?: XmlWriterOptions): IXmlWriter;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export class IXmlElement extends IXmlBase {
|
|
179
|
-
parser?: ParserOptions;
|
|
180
|
-
readonly node: XmlTagNode;
|
|
181
|
-
setAppend(value?: TagAppend): void;
|
|
182
|
-
parseOuterXml(value?: string, tagVoid?: boolean): [string, string, boolean];
|
|
183
|
-
getTagOffset(replacement?: string, options?: TagOffsetOptions): Undef<TagOffsetMap>;
|
|
184
|
-
setAttribute(name: string, value: string): void;
|
|
185
|
-
getAttribute(name: string): string;
|
|
186
|
-
removeAttribute(...names: string[]): void;
|
|
187
|
-
hasAttribute(name: string): boolean;
|
|
188
|
-
hasModifiedContent(): boolean;
|
|
189
|
-
write(source: string, invalid?: SourceIndex[]): WriteResult;
|
|
190
|
-
save(source: string, invalid?: SourceIndex[]): SaveResult;
|
|
191
|
-
replace(source: string, options: ReplaceOptions): WriteResult;
|
|
192
|
-
findIndexOf(source: string): Undef<SourceIndex>;
|
|
193
|
-
getOuterContent(): [string, AttributeList, string];
|
|
194
|
-
getInnerOffset(tagName: string): number;
|
|
195
|
-
hasPosition(): boolean;
|
|
196
|
-
set id(value: string);
|
|
197
|
-
get id(): string;
|
|
198
|
-
set tagName(value: string);
|
|
199
|
-
get tagName(): string;
|
|
200
|
-
get documentType(): string;
|
|
201
|
-
get tagVoid(): boolean;
|
|
202
|
-
set innerXml(value: string);
|
|
203
|
-
get innerXml(): string;
|
|
204
|
-
get outerXml(): string;
|
|
205
|
-
set remove(value);
|
|
206
|
-
get remove(): boolean;
|
|
207
|
-
get append(): Undef<TagAppend>;
|
|
208
|
-
set tagOffset(value: Undef<TagOffsetMap>);
|
|
209
|
-
get tagOffset(): Undef<TagOffsetMap>;
|
|
210
|
-
get ignoreCase(): boolean;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface XmlElementConstructor {
|
|
214
|
-
writeAttributes(attrs: AttributeMap | AttributeList, escapeEntities?: boolean): string;
|
|
215
|
-
readonly prototype: IXmlElement;
|
|
216
|
-
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: XmlElementOptions): IXmlElement;
|
|
217
|
-
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, tagVoid?: boolean, parser?: ParserOptions): IXmlElement;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export class IDomWriter extends IXmlWriter {
|
|
221
|
-
documentElement: Null<XmlTagNode>;
|
|
222
|
-
readonly initOpts: DomWriterOptions;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export interface DomWriterConstructor extends XmlWriterConstructor {
|
|
226
|
-
hasInnerXml(tagName: string): boolean;
|
|
227
|
-
normalize(source: string, options: NormalizeOptions): string;
|
|
228
|
-
normalize(source: string, newline?: string, ignoreChar?: string, escapeEntities?: boolean): string;
|
|
229
|
-
getDocumentElement(source: string, parser?: ParserOptions): ParserResult;
|
|
230
|
-
getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: ArrayOf<AnyNode>, recurse?: boolean, limit?: number): Element[];
|
|
231
|
-
readonly prototype: IDomWriter;
|
|
232
|
-
new(documentName: string, source: string, elements: XmlTagNode[], options?: DomWriterOptions): IDomWriter;
|
|
233
|
-
new(documentName: string, source: string, elements: XmlTagNode[], normalize?: boolean | string, escapeEntities?: boolean, parser?: ParserOptions): IDomWriter;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export class IHtmlElement extends IXmlElement {}
|
|
237
|
-
|
|
238
|
-
export interface HtmlElementConstructor extends XmlElementConstructor {
|
|
239
|
-
readonly prototype: IHtmlElement;
|
|
240
|
-
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: ParserAction): IHtmlElement;
|
|
1
|
+
import type { XmlTagNode as IXmlTagNode, TagAppend, TagData } from '../../../types/lib/squared';
|
|
2
|
+
|
|
3
|
+
import type { ParserOptions } from 'htmlparser2';
|
|
4
|
+
import type { AnyNode, Element } from 'domhandler';
|
|
5
|
+
|
|
6
|
+
export interface IGNORE_FLAG {
|
|
7
|
+
NONE: 0;
|
|
8
|
+
INTERIOR: 1;
|
|
9
|
+
LOCATOR: 2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ParserAction {
|
|
13
|
+
parser?: ParserOptions;
|
|
14
|
+
outDom?: AnyNode[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SourceIndex {
|
|
18
|
+
startIndex: number;
|
|
19
|
+
endIndex: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SourceContent extends SourceIndex {
|
|
23
|
+
outerXml: string;
|
|
24
|
+
type?: "node" | "comment" | "cdata" | "block";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SourceTagNode extends SourceContent, TagData {
|
|
28
|
+
id?: string;
|
|
29
|
+
ignoreCase?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface XmlTagNode extends IXmlTagNode, Partial<SourceIndex> {}
|
|
33
|
+
|
|
34
|
+
export type AttributeMap = Map<string, unknown>;
|
|
35
|
+
export type AttributeList = [string, unknown][];
|
|
36
|
+
export type TagOffsetMap = ObjectMap<Undef<number>>;
|
|
37
|
+
export type WriteResult = [string, string, Null<Error>?];
|
|
38
|
+
export type SaveResult = [string, Null<Error>?];
|
|
39
|
+
export type XmlWriterOptions = ParserAction;
|
|
40
|
+
|
|
41
|
+
export interface ParserResult extends Partial<TagData>, ParserAction {
|
|
42
|
+
element: Null<Element>;
|
|
43
|
+
error: Null<Error>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ReplaceOptions extends SourceIndex {
|
|
47
|
+
append?: TagAppend;
|
|
48
|
+
remove?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FindElementOptions extends ParserAction {
|
|
52
|
+
document?: string;
|
|
53
|
+
id?: string;
|
|
54
|
+
locatorAttr?: string;
|
|
55
|
+
tagCount?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface TagOffsetOptions extends ParserAction {
|
|
59
|
+
ignoreCase?: boolean;
|
|
60
|
+
ignoreTagName?: string;
|
|
61
|
+
ignoreTagGroup?: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface TagNodeOptions {
|
|
65
|
+
tagVoid?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface TagNodeByIdOptions extends TagNodeOptions {
|
|
69
|
+
tagName?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface XmlElementOptions extends TagNodeOptions, ParserAction {}
|
|
73
|
+
|
|
74
|
+
export interface DomWriterOptions extends ParserAction {
|
|
75
|
+
normalize?: boolean | string;
|
|
76
|
+
ignoreTagGroup?: string[];
|
|
77
|
+
escapeEntities?: boolean;
|
|
78
|
+
stripComments?: boolean | string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ReplaceMatchOptions {
|
|
82
|
+
pattern?: RegExp;
|
|
83
|
+
trimLeading?: boolean;
|
|
84
|
+
trimTrailing?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface NormalizeOptions {
|
|
88
|
+
newline?: string;
|
|
89
|
+
ignoreChar?: string;
|
|
90
|
+
ignoreTagGroup?: string[];
|
|
91
|
+
escapeEntities?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class IXmlBase {
|
|
95
|
+
newline: string;
|
|
96
|
+
readonly documentName: string;
|
|
97
|
+
write(...args: unknown[]): unknown;
|
|
98
|
+
save(...args: unknown[]): unknown;
|
|
99
|
+
reset(): void;
|
|
100
|
+
get nameOfId(): string;
|
|
101
|
+
get modified(): boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class IXmlWriter extends IXmlBase {
|
|
105
|
+
modifyCount: number;
|
|
106
|
+
failCount: number;
|
|
107
|
+
elements: XmlTagNode[];
|
|
108
|
+
errors: Error[];
|
|
109
|
+
parser?: ParserOptions;
|
|
110
|
+
ignoreTagName?: string;
|
|
111
|
+
ignoreTagGroup?: string[];
|
|
112
|
+
readonly rootName?: string;
|
|
113
|
+
readonly ignoreCaseTagName?: boolean;
|
|
114
|
+
init(offsetMap?: TagOffsetMap): void;
|
|
115
|
+
getInvalidArea(): Undef<SourceContent[]>;
|
|
116
|
+
ignoreFlag(...values: number[]): void;
|
|
117
|
+
insertNodes(nodes?: XmlTagNode[]): void;
|
|
118
|
+
fromNode(node: XmlTagNode, append?: TagAppend): IXmlElement;
|
|
119
|
+
newElement(node: XmlTagNode): IXmlElement;
|
|
120
|
+
append(node: XmlTagNode): Null<IXmlElement>;
|
|
121
|
+
write(element: IXmlElement): boolean;
|
|
122
|
+
save(): string;
|
|
123
|
+
close(): string;
|
|
124
|
+
update(node: XmlTagNode, outerXml: string, append?: TagAppend, offsetMap?: Null<TagOffsetMap>): void;
|
|
125
|
+
increment(nodes: XmlTagNode[], offset?: number): void;
|
|
126
|
+
decrement(node: XmlTagNode, offset?: number, remove?: boolean): XmlTagNode[];
|
|
127
|
+
renameTag(node: XmlTagNode, tagName: string): void;
|
|
128
|
+
indexTag(tagName: string, append?: TagAppend, offset?: number): void;
|
|
129
|
+
resetTag(tagName: string): void;
|
|
130
|
+
ignoreTag(value: StringOfArray): void;
|
|
131
|
+
resetPosition(startIndex?: number): void;
|
|
132
|
+
getElementById(id: string, ignoreCase?: boolean, options?: TagNodeByIdOptions): Undef<SourceTagNode>;
|
|
133
|
+
getElementsByTagName(tagName: string, ignoreCase?: boolean, options?: TagNodeOptions): SourceTagNode[];
|
|
134
|
+
setRawString(targetXml: string, outerXml: string): string;
|
|
135
|
+
getRawString(index: SourceIndex): string;
|
|
136
|
+
spliceRawString(content: SourceContent, reset?: boolean): string;
|
|
137
|
+
getComments(): Null<SourceContent[]>;
|
|
138
|
+
hasErrors(): boolean;
|
|
139
|
+
get newId(): string;
|
|
140
|
+
get patternIgnore(): Null<RegExp>;
|
|
141
|
+
set source(value);
|
|
142
|
+
get source(): string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface XmlWriterConstructor {
|
|
146
|
+
readonly PATTERN_ATTRNAME: string;
|
|
147
|
+
readonly PATTERN_ATTRVALUE: string;
|
|
148
|
+
readonly PATTERN_TAGNAME: string;
|
|
149
|
+
readonly PATTERN_TAGOPEN: string;
|
|
150
|
+
readonly PATTERN_QUOTEVALUE: string;
|
|
151
|
+
readonly PATTERN_COMMENT: string;
|
|
152
|
+
readonly PATTERN_TRAILINGSPACE: string;
|
|
153
|
+
replaceMatch(match: RegExpMatchArray, source: string, content: NumString, options: ReplaceMatchOptions): string;
|
|
154
|
+
replaceMatch(match: RegExpMatchArray, source: string, content?: NumString, pattern?: RegExp): string;
|
|
155
|
+
escapeXmlString(value: string, ampersand?: boolean): string;
|
|
156
|
+
escapeAttributes(source: string): string;
|
|
157
|
+
getNewlineString(leading: string, trailing: string, newline?: string): string;
|
|
158
|
+
findCloseTag(source: string, startIndex?: number): number;
|
|
159
|
+
findElement(source: string, node: XmlTagNode, options?: FindElementOptions): ParserResult;
|
|
160
|
+
getTagOffset(source: string, options?: TagOffsetOptions): TagOffsetMap;
|
|
161
|
+
getTagOffset(source: string, replacement?: string, options?: TagOffsetOptions): TagOffsetMap;
|
|
162
|
+
namesOfTagVoid(type: string, values: string[]): void;
|
|
163
|
+
isTagVoid(type: string, tagName: string): boolean;
|
|
164
|
+
getNodeId(node: XmlTagNode, document: string): string;
|
|
165
|
+
getNameOfId(document: string): string;
|
|
166
|
+
getPatternId(name: string): RegExp;
|
|
167
|
+
getCommentsAndCDATA(source: string, tagPattern: unknown, ignoreCase: boolean, stripXml: true): string;
|
|
168
|
+
getCommentsAndCDATA(source: string, tagPattern?: StringOfArray | [Undef<string>, Undef<string[]>], ignoreCase?: boolean, stripXml?: boolean): SourceContent[];
|
|
169
|
+
isEqual(node: XmlTagNode, other: XmlTagNode, ignoreCase: boolean): boolean;
|
|
170
|
+
isEqual(node: XmlTagNode, other: XmlTagNode, documentName?: string, ignoreCase?: boolean): boolean;
|
|
171
|
+
isIndex(value: Undef<number>): value is number;
|
|
172
|
+
isCount(value: Undef<number>): value is number;
|
|
173
|
+
isSpace(ch: string): boolean;
|
|
174
|
+
readonly prototype: IXmlWriter;
|
|
175
|
+
new(documentName: string, source: string, elements: XmlTagNode[], options?: XmlWriterOptions): IXmlWriter;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export class IXmlElement extends IXmlBase {
|
|
179
|
+
parser?: ParserOptions;
|
|
180
|
+
readonly node: XmlTagNode;
|
|
181
|
+
setAppend(value?: TagAppend): void;
|
|
182
|
+
parseOuterXml(value?: string, tagVoid?: boolean): [string, string, boolean];
|
|
183
|
+
getTagOffset(replacement?: string, options?: TagOffsetOptions): Undef<TagOffsetMap>;
|
|
184
|
+
setAttribute(name: string, value: string): void;
|
|
185
|
+
getAttribute(name: string): string;
|
|
186
|
+
removeAttribute(...names: string[]): void;
|
|
187
|
+
hasAttribute(name: string): boolean;
|
|
188
|
+
hasModifiedContent(): boolean;
|
|
189
|
+
write(source: string, invalid?: SourceIndex[]): WriteResult;
|
|
190
|
+
save(source: string, invalid?: SourceIndex[]): SaveResult;
|
|
191
|
+
replace(source: string, options: ReplaceOptions): WriteResult;
|
|
192
|
+
findIndexOf(source: string): Undef<SourceIndex>;
|
|
193
|
+
getOuterContent(): [string, AttributeList, string];
|
|
194
|
+
getInnerOffset(tagName: string): number;
|
|
195
|
+
hasPosition(): boolean;
|
|
196
|
+
set id(value: string);
|
|
197
|
+
get id(): string;
|
|
198
|
+
set tagName(value: string);
|
|
199
|
+
get tagName(): string;
|
|
200
|
+
get documentType(): string;
|
|
201
|
+
get tagVoid(): boolean;
|
|
202
|
+
set innerXml(value: string);
|
|
203
|
+
get innerXml(): string;
|
|
204
|
+
get outerXml(): string;
|
|
205
|
+
set remove(value);
|
|
206
|
+
get remove(): boolean;
|
|
207
|
+
get append(): Undef<TagAppend>;
|
|
208
|
+
set tagOffset(value: Undef<TagOffsetMap>);
|
|
209
|
+
get tagOffset(): Undef<TagOffsetMap>;
|
|
210
|
+
get ignoreCase(): boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface XmlElementConstructor {
|
|
214
|
+
writeAttributes(attrs: AttributeMap | AttributeList, escapeEntities?: boolean): string;
|
|
215
|
+
readonly prototype: IXmlElement;
|
|
216
|
+
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: XmlElementOptions): IXmlElement;
|
|
217
|
+
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, tagVoid?: boolean, parser?: ParserOptions): IXmlElement;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export class IDomWriter extends IXmlWriter {
|
|
221
|
+
documentElement: Null<XmlTagNode>;
|
|
222
|
+
readonly initOpts: DomWriterOptions;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface DomWriterConstructor extends XmlWriterConstructor {
|
|
226
|
+
hasInnerXml(tagName: string): boolean;
|
|
227
|
+
normalize(source: string, options: NormalizeOptions): string;
|
|
228
|
+
normalize(source: string, newline?: string, ignoreChar?: string, escapeEntities?: boolean): string;
|
|
229
|
+
getDocumentElement(source: string, parser?: ParserOptions): ParserResult;
|
|
230
|
+
getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: ArrayOf<AnyNode>, recurse?: boolean, limit?: number): Element[];
|
|
231
|
+
readonly prototype: IDomWriter;
|
|
232
|
+
new(documentName: string, source: string, elements: XmlTagNode[], options?: DomWriterOptions): IDomWriter;
|
|
233
|
+
new(documentName: string, source: string, elements: XmlTagNode[], normalize?: boolean | string, escapeEntities?: boolean, parser?: ParserOptions): IDomWriter;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export class IHtmlElement extends IXmlElement {}
|
|
237
|
+
|
|
238
|
+
export interface HtmlElementConstructor extends XmlElementConstructor {
|
|
239
|
+
readonly prototype: IHtmlElement;
|
|
240
|
+
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: ParserAction): IHtmlElement;
|
|
241
241
|
}
|
package/util.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
declare namespace util {
|
|
2
|
-
const IMPORTS: Record<string, string | undefined>;
|
|
3
|
-
function loadPlugins<T = unknown>(name: string | unknown[], plugins?: unknown[]): T[];
|
|
4
|
-
function replaceAll(source: string, valueOf: (name: string) => string, opening?: string, closing?: string): string;
|
|
5
|
-
function concatString(values: string[] | string | undefined, newline?: string): string;
|
|
6
|
-
function splitEnclosing(value: string, pattern?: string | RegExp, options?: { trim?: boolean; start?: number; startWith?: number; count?: number } | boolean | number, opening?: string, closing?: string): string[];
|
|
7
|
-
function appendSuffix(filename: string, value: string, separator?: string): string;
|
|
8
|
-
function getIndent(value: string, spaces?: number): string;
|
|
9
|
-
function getNewline(value: string): string;
|
|
10
|
-
function getHashData(value: string): [string, number];
|
|
11
|
-
function hasValue(target: string | string[] | undefined, ...values: string[]): boolean;
|
|
12
|
-
function getModuleName(err: unknown): string | undefined;
|
|
13
|
-
function removeInternalProperties<T extends object>(value: T, retaining?: string[]): T;
|
|
14
|
-
function isObject<T = object>(value: unknown): value is T;
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
declare namespace util {
|
|
2
|
+
const IMPORTS: Record<string, string | undefined>;
|
|
3
|
+
function loadPlugins<T = unknown>(name: string | unknown[], plugins?: unknown[]): T[];
|
|
4
|
+
function replaceAll(source: string, valueOf: (name: string) => string, opening?: string, closing?: string): string;
|
|
5
|
+
function concatString(values: string[] | string | undefined, newline?: string): string;
|
|
6
|
+
function splitEnclosing(value: string, pattern?: string | RegExp, options?: { trim?: boolean; start?: number; startWith?: number; count?: number } | boolean | number, opening?: string, closing?: string): string[];
|
|
7
|
+
function appendSuffix(filename: string, value: string, separator?: string): string;
|
|
8
|
+
function getIndent(value: string, spaces?: number): string;
|
|
9
|
+
function getNewline(value: string): string;
|
|
10
|
+
function getHashData(value: string): [string, number];
|
|
11
|
+
function hasValue(target: string | string[] | undefined, ...values: string[]): boolean;
|
|
12
|
+
function getModuleName(err: unknown): string | undefined;
|
|
13
|
+
function removeInternalProperties<T extends object>(value: T, retaining?: string[]): T;
|
|
14
|
+
function isObject<T = object>(value: unknown): value is T;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
export = util;
|