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