@intlify/message-compiler 12.0.0-alpha.2 → 12.0.0-alpha.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/dist/message-compiler.d.ts +189 -230
- package/dist/message-compiler.esm-browser.js +1216 -1481
- package/dist/message-compiler.esm-browser.prod.js +788 -6
- package/dist/message-compiler.esm-bundler.js +1 -1
- package/dist/message-compiler.global.js +1295 -1561
- package/dist/message-compiler.global.prod.js +803 -6
- package/dist/message-compiler.js +1200 -1464
- package/dist/message-compiler.node.js +1242 -1517
- package/package.json +38 -38
|
@@ -1,230 +1,189 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
export
|
|
190
|
-
type: NodeTypes.Plural;
|
|
191
|
-
cases: MessageNode[];
|
|
192
|
-
/* Excluded from this release type: c */
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export declare interface Position {
|
|
196
|
-
offset: number;
|
|
197
|
-
line: number;
|
|
198
|
-
column: number;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export declare interface ResourceNode extends Node_2 {
|
|
202
|
-
type: NodeTypes.Resource;
|
|
203
|
-
body: MessageNode | PluralNode;
|
|
204
|
-
/* Excluded from this release type: b */
|
|
205
|
-
cacheKey?: string;
|
|
206
|
-
helpers?: string[];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export declare interface SourceLocation {
|
|
210
|
-
start: Position;
|
|
211
|
-
end: Position;
|
|
212
|
-
source?: string;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export declare interface TextNode extends Node_2 {
|
|
216
|
-
type: NodeTypes.Text;
|
|
217
|
-
value?: string;
|
|
218
|
-
/* Excluded from this release type: v */
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export declare interface TokenizeOptions {
|
|
222
|
-
location?: boolean;
|
|
223
|
-
onError?: CompileErrorHandler;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export declare interface TransformOptions {
|
|
227
|
-
onError?: CompileErrorHandler;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export { }
|
|
1
|
+
import { RawSourceMap } from "source-map-js";
|
|
2
|
+
import { BaseError } from "@intlify/shared";
|
|
3
|
+
|
|
4
|
+
//#region temp/packages/message-compiler/src/location.d.ts
|
|
5
|
+
interface SourceLocation {
|
|
6
|
+
start: Position;
|
|
7
|
+
end: Position;
|
|
8
|
+
source?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const LOCATION_STUB: SourceLocation;
|
|
11
|
+
interface Position {
|
|
12
|
+
offset: number;
|
|
13
|
+
line: number;
|
|
14
|
+
column: number;
|
|
15
|
+
}
|
|
16
|
+
declare function createPosition(line: number, column: number, offset: number): Position;
|
|
17
|
+
declare function createLocation(start: Position, end: Position, source?: string): SourceLocation;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region temp/packages/message-compiler/src/nodes.d.ts
|
|
20
|
+
declare const enum NodeTypes {
|
|
21
|
+
Resource = 0,
|
|
22
|
+
Plural = 1,
|
|
23
|
+
Message = 2,
|
|
24
|
+
Text = 3,
|
|
25
|
+
Named = 4,
|
|
26
|
+
List = 5,
|
|
27
|
+
Linked = 6,
|
|
28
|
+
LinkedKey = 7,
|
|
29
|
+
LinkedModifier = 8,
|
|
30
|
+
Literal = 9,
|
|
31
|
+
}
|
|
32
|
+
type Identifier = string;
|
|
33
|
+
interface Node {
|
|
34
|
+
type: NodeTypes;
|
|
35
|
+
start?: number;
|
|
36
|
+
end?: number;
|
|
37
|
+
loc?: SourceLocation;
|
|
38
|
+
}
|
|
39
|
+
interface ResourceNode extends Node {
|
|
40
|
+
type: NodeTypes.Resource;
|
|
41
|
+
body: MessageNode | PluralNode;
|
|
42
|
+
cacheKey?: string;
|
|
43
|
+
helpers?: string[];
|
|
44
|
+
}
|
|
45
|
+
interface PluralNode extends Node {
|
|
46
|
+
type: NodeTypes.Plural;
|
|
47
|
+
cases: MessageNode[];
|
|
48
|
+
}
|
|
49
|
+
interface MessageNode extends Node {
|
|
50
|
+
type: NodeTypes.Message;
|
|
51
|
+
static?: string;
|
|
52
|
+
items: MessageElementNode[];
|
|
53
|
+
}
|
|
54
|
+
type MessageElementNode = TextNode | NamedNode | ListNode | LiteralNode | LinkedNode;
|
|
55
|
+
interface TextNode extends Node {
|
|
56
|
+
type: NodeTypes.Text;
|
|
57
|
+
value?: string;
|
|
58
|
+
}
|
|
59
|
+
interface NamedNode extends Node {
|
|
60
|
+
type: NodeTypes.Named;
|
|
61
|
+
key: Identifier;
|
|
62
|
+
modulo?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface ListNode extends Node {
|
|
65
|
+
type: NodeTypes.List;
|
|
66
|
+
index: number;
|
|
67
|
+
}
|
|
68
|
+
interface LiteralNode extends Node {
|
|
69
|
+
type: NodeTypes.Literal;
|
|
70
|
+
value?: string;
|
|
71
|
+
}
|
|
72
|
+
interface LinkedNode extends Node {
|
|
73
|
+
type: NodeTypes.Linked;
|
|
74
|
+
modifier?: LinkedModifierNode;
|
|
75
|
+
key: LinkedKeyNode | NamedNode | ListNode | LiteralNode;
|
|
76
|
+
}
|
|
77
|
+
interface LinkedKeyNode extends Node {
|
|
78
|
+
type: NodeTypes.LinkedKey;
|
|
79
|
+
value: string;
|
|
80
|
+
}
|
|
81
|
+
interface LinkedModifierNode extends Node {
|
|
82
|
+
type: NodeTypes.LinkedModifier;
|
|
83
|
+
value: Identifier;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region temp/packages/message-compiler/src/errors.d.ts
|
|
87
|
+
type CompileDomain = "tokenizer" | "parser" | "generator" | "transformer" | "optimizer" | "minifier";
|
|
88
|
+
interface CompileError extends BaseError, SyntaxError {
|
|
89
|
+
domain?: CompileDomain;
|
|
90
|
+
location?: SourceLocation;
|
|
91
|
+
}
|
|
92
|
+
interface CompileErrorOptions {
|
|
93
|
+
domain?: CompileDomain;
|
|
94
|
+
messages?: {
|
|
95
|
+
[code: number]: string;
|
|
96
|
+
};
|
|
97
|
+
args?: unknown[];
|
|
98
|
+
}
|
|
99
|
+
declare const CompileErrorCodes: {
|
|
100
|
+
readonly EXPECTED_TOKEN: 1;
|
|
101
|
+
readonly INVALID_TOKEN_IN_PLACEHOLDER: 2;
|
|
102
|
+
readonly UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3;
|
|
103
|
+
readonly UNKNOWN_ESCAPE_SEQUENCE: 4;
|
|
104
|
+
readonly INVALID_UNICODE_ESCAPE_SEQUENCE: 5;
|
|
105
|
+
readonly UNBALANCED_CLOSING_BRACE: 6;
|
|
106
|
+
readonly UNTERMINATED_CLOSING_BRACE: 7;
|
|
107
|
+
readonly EMPTY_PLACEHOLDER: 8;
|
|
108
|
+
readonly NOT_ALLOW_NEST_PLACEHOLDER: 9;
|
|
109
|
+
readonly INVALID_LINKED_FORMAT: 10;
|
|
110
|
+
readonly MUST_HAVE_MESSAGES_IN_PLURAL: 11;
|
|
111
|
+
readonly UNEXPECTED_EMPTY_LINKED_MODIFIER: 12;
|
|
112
|
+
readonly UNEXPECTED_EMPTY_LINKED_KEY: 13;
|
|
113
|
+
readonly UNEXPECTED_LEXICAL_ANALYSIS: 14;
|
|
114
|
+
readonly UNHANDLED_CODEGEN_NODE_TYPE: 15;
|
|
115
|
+
readonly UNHANDLED_MINIFIER_NODE_TYPE: 16;
|
|
116
|
+
};
|
|
117
|
+
declare const COMPILE_ERROR_CODES_EXTEND_POINT: number;
|
|
118
|
+
type CompileErrorCodes = (typeof CompileErrorCodes)[keyof typeof CompileErrorCodes];
|
|
119
|
+
declare function createCompileError<T extends number>(code: T, loc: SourceLocation | null, options?: CompileErrorOptions): CompileError;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region temp/packages/message-compiler/src/options.d.ts
|
|
122
|
+
type CompileErrorHandler = (error: CompileError) => void;
|
|
123
|
+
type CacheKeyHandler = (source: string) => string;
|
|
124
|
+
interface TokenizeOptions {
|
|
125
|
+
location?: boolean;
|
|
126
|
+
onError?: CompileErrorHandler;
|
|
127
|
+
}
|
|
128
|
+
interface ParserOptions {
|
|
129
|
+
location?: boolean;
|
|
130
|
+
onCacheKey?: (source: string) => string;
|
|
131
|
+
onError?: CompileErrorHandler;
|
|
132
|
+
}
|
|
133
|
+
interface TransformOptions {
|
|
134
|
+
onError?: CompileErrorHandler;
|
|
135
|
+
}
|
|
136
|
+
interface CodeGenOptions {
|
|
137
|
+
location?: boolean;
|
|
138
|
+
mode?: "normal" | "arrow";
|
|
139
|
+
breakLineCode?: "\n" | ";";
|
|
140
|
+
needIndent?: boolean;
|
|
141
|
+
onError?: CompileErrorHandler;
|
|
142
|
+
sourceMap?: boolean;
|
|
143
|
+
filename?: string;
|
|
144
|
+
}
|
|
145
|
+
type CompileOptions = {
|
|
146
|
+
optimize?: boolean;
|
|
147
|
+
mangle?: boolean;
|
|
148
|
+
jit?: boolean;
|
|
149
|
+
} & TransformOptions & CodeGenOptions & ParserOptions & TokenizeOptions;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region temp/packages/message-compiler/src/generator.d.ts
|
|
152
|
+
interface CodeGenResult {
|
|
153
|
+
code: string;
|
|
154
|
+
ast: ResourceNode;
|
|
155
|
+
map?: RawSourceMap;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region temp/packages/message-compiler/src/compiler.d.ts
|
|
159
|
+
type CompilerResult = CodeGenResult;
|
|
160
|
+
declare function baseCompile(source: string, options?: CompileOptions): CompilerResult;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region temp/packages/message-compiler/src/helpers.d.ts
|
|
163
|
+
declare const enum HelperNameMap {
|
|
164
|
+
LIST = "list",
|
|
165
|
+
NAMED = "named",
|
|
166
|
+
PLURAL = "plural",
|
|
167
|
+
LINKED = "linked",
|
|
168
|
+
MESSAGE = "message",
|
|
169
|
+
TYPE = "type",
|
|
170
|
+
INTERPOLATE = "interpolate",
|
|
171
|
+
NORMALIZE = "normalize",
|
|
172
|
+
VALUES = "values",
|
|
173
|
+
}
|
|
174
|
+
declare const detectHtmlTag: (source: string) => boolean;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region temp/packages/message-compiler/src/mangler.d.ts
|
|
177
|
+
declare function mangle(node: Node): void;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region temp/packages/message-compiler/src/optimizer.d.ts
|
|
180
|
+
declare function optimize(ast: ResourceNode): ResourceNode;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region temp/packages/message-compiler/src/parser.d.ts
|
|
183
|
+
interface Parser {
|
|
184
|
+
parse(source: string): ResourceNode;
|
|
185
|
+
}
|
|
186
|
+
declare const ERROR_DOMAIN = "parser";
|
|
187
|
+
declare function createParser(options?: ParserOptions): Parser;
|
|
188
|
+
//#endregion
|
|
189
|
+
export { COMPILE_ERROR_CODES_EXTEND_POINT, CacheKeyHandler, CodeGenOptions, CompileDomain, CompileError, CompileErrorCodes, CompileErrorHandler, CompileErrorOptions, CompileOptions, CompilerResult, ERROR_DOMAIN, HelperNameMap, Identifier, LOCATION_STUB, LinkedKeyNode, LinkedModifierNode, LinkedNode, ListNode, LiteralNode, MessageNode, NamedNode, Node, NodeTypes, Parser, ParserOptions, PluralNode, Position, ResourceNode, SourceLocation, TextNode, TokenizeOptions, TransformOptions, baseCompile, createCompileError, createLocation, createParser, createPosition, detectHtmlTag, mangle, optimize };
|