@prostojs/rewrite 0.1.1 → 0.2.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/README.md +356 -238
- package/dist/index.cjs +815 -3940
- package/dist/index.d.ts +14 -13
- package/dist/index.mjs +814 -3939
- package/package.json +81 -84
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParsedNode, Node } from '@prostojs/parser';
|
|
2
2
|
import { Minimatch } from 'minimatch';
|
|
3
3
|
|
|
4
4
|
interface TRewriteNodeType<T extends {
|
|
@@ -16,7 +16,7 @@ type TStringNodeData = {
|
|
|
16
16
|
interface TStringExpressionData extends TRewriteNodeType<TStringExpressionData> {
|
|
17
17
|
expression: string;
|
|
18
18
|
}
|
|
19
|
-
type TRewriteCodeFactory<T
|
|
19
|
+
type TRewriteCodeFactory<T> = (node: ParsedNode<T>, level?: number) => string;
|
|
20
20
|
interface TValueNodeCustomData {
|
|
21
21
|
quote: string;
|
|
22
22
|
}
|
|
@@ -52,7 +52,7 @@ interface TProstoRewriter {
|
|
|
52
52
|
}
|
|
53
53
|
type TProstoRewriteContext = Record<string, unknown>;
|
|
54
54
|
interface TRewriteCommonOptions {
|
|
55
|
-
|
|
55
|
+
exprDelimiters: [string, string];
|
|
56
56
|
blockOperation: string;
|
|
57
57
|
directive: string;
|
|
58
58
|
}
|
|
@@ -96,19 +96,19 @@ interface TRewriteDirOptions {
|
|
|
96
96
|
renameFile?: (filename: string) => string;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
declare function
|
|
99
|
+
declare function genFunc(code: string): (context?: TProstoRewriteContext) => string;
|
|
100
|
+
/** @deprecated Use genFunc instead */
|
|
101
|
+
declare const genSafeFunc: typeof genFunc;
|
|
100
102
|
declare function pushString(s: string): string;
|
|
101
|
-
declare function renderCode(
|
|
102
|
-
declare function getRewriter(rootNode:
|
|
103
|
-
declare function getStringExpressionRewriter(interpolationDelimiters?: [string, string]):
|
|
104
|
-
genRewriteCode: (source: string) => string;
|
|
105
|
-
genRewriteFunction: (source: string) => (context?: TProstoRewriteContext) => string;
|
|
106
|
-
printAsTree: (source: string) => void;
|
|
107
|
-
rewrite: (source: string, context?: TProstoRewriteContext) => string;
|
|
108
|
-
};
|
|
103
|
+
declare function renderCode(parsed: ParsedNode, level?: number): string;
|
|
104
|
+
declare function getRewriter(rootNode: Node, debug?: boolean): TProstoRewriter;
|
|
105
|
+
declare function getStringExpressionRewriter(interpolationDelimiters?: [string, string]): TProstoRewriter;
|
|
109
106
|
|
|
110
107
|
declare class ProstoRewrite {
|
|
111
108
|
protected options: TRewriteOptions;
|
|
109
|
+
private _mixedRewriter?;
|
|
110
|
+
private _textRewriter?;
|
|
111
|
+
private _htmlRewriter?;
|
|
112
112
|
constructor(options?: TRewriteOptionsPublic);
|
|
113
113
|
get mixedRewriter(): {
|
|
114
114
|
text: TProstoRewriter;
|
|
@@ -122,4 +122,5 @@ declare class ProstoRewrite {
|
|
|
122
122
|
private debug;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
export { ProstoRewrite,
|
|
125
|
+
export { ProstoRewrite, genFunc, genSafeFunc, getRewriter, getStringExpressionRewriter, pushString, renderCode };
|
|
126
|
+
export type { TAttrNodeCustomData, THTMLBlockDescr, THTMLBlockOperations, TProstoRewriteContext, TProstoRewriter, TRewriteCodeFactory, TRewriteCommonOptions, TRewriteDirOptions, TRewriteFileOptions, TRewriteHtmlOptions, TRewriteMode, TRewriteNodeType, TRewriteOptions, TRewriteOptionsPublic, TRewriteTextOptions, TStringExpressionData, TStringNodeData, TTagNodeCustomData, TValueNodeCustomData };
|