@intlify/message-compiler 9.3.0-beta.9 → 9.4.0

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