wuchale 0.23.4 → 0.24.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.
- package/dist/adapter-utils/mixed-visitor.d.ts +21 -14
- package/dist/adapter-utils/mixed-visitor.js +110 -101
- package/dist/adapter-vanilla/index.js +8 -6
- package/dist/adapter-vanilla/inertvisitors.d.ts +31 -0
- package/dist/adapter-vanilla/inertvisitors.js +86 -0
- package/dist/adapter-vanilla/transformer.d.ts +67 -95
- package/dist/adapter-vanilla/transformer.js +288 -241
- package/dist/adapters.d.ts +16 -12
- package/dist/adapters.js +33 -13
- package/dist/ai/gemini.js +1 -1
- package/dist/ai/index.js +3 -1
- package/dist/bundlers/vite.d.ts +1 -1
- package/dist/bundlers/vite.js +3 -3
- package/dist/cli/check.js +1 -1
- package/dist/cli/index.js +12 -5
- package/dist/cli/status.js +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.js +2 -2
- package/dist/handler/files.d.ts +11 -13
- package/dist/handler/files.js +37 -44
- package/dist/handler/index.d.ts +7 -4
- package/dist/handler/index.js +85 -62
- package/dist/handler/state.d.ts +10 -11
- package/dist/handler/state.js +40 -28
- package/dist/handler/url.d.ts +10 -13
- package/dist/handler/url.js +51 -80
- package/dist/hub.d.ts +1 -1
- package/dist/hub.js +16 -14
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/load-utils/index.d.ts +6 -8
- package/dist/load-utils/index.js +11 -11
- package/dist/load-utils/pure.d.ts +2 -2
- package/dist/load-utils/server.d.ts +3 -3
- package/dist/load-utils/server.js +4 -7
- package/dist/pofile.d.ts +5 -5
- package/dist/pofile.js +23 -35
- package/dist/storage.d.ts +6 -3
- package/dist/storage.js +98 -0
- package/dist/url.d.ts +12 -10
- package/dist/url.js +206 -31
- package/package.json +4 -5
- package/src/adapter-vanilla/loaders/bundle.js +1 -1
- package/src/adapter-vanilla/loaders/server.js +3 -3
- package/src/adapter-vanilla/loaders/vite.js +2 -2
- package/src/adapter-vanilla/loaders/vite.ssr.js +3 -3
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type HeuristicDetails, type HeuristicDetailsBase, type HeuristicFunc,
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
|
+
import { type HeuristicDetails, type HeuristicDetailsBase, type HeuristicFunc, IndexTracker, type Message } from '../adapters.js';
|
|
3
3
|
import { type CommentDirectives, type RuntimeVars } from './index.js';
|
|
4
4
|
type NestedRanges = [number, number, boolean][];
|
|
5
|
-
type
|
|
6
|
-
vars: () => RuntimeVars;
|
|
5
|
+
type VisitVolatileCtx<A> = {
|
|
7
6
|
mstr: MagicString;
|
|
7
|
+
index: IndexTracker;
|
|
8
|
+
inCompoundText: boolean;
|
|
9
|
+
addCtx: A;
|
|
10
|
+
};
|
|
11
|
+
type VisitNestedCtx<A> = Omit<VisitVolatileCtx<A>, 'inCompoundText'>;
|
|
12
|
+
type VisitFunc<MixNodeT, AddCtx> = (node: MixNodeT, ctx: VisitVolatileCtx<AddCtx>) => Message[];
|
|
13
|
+
type InitProps<MixNodeT, AddCtx extends object, TxtT extends MixNodeT, ComT extends MixNodeT, ExprT extends MixNodeT> = {
|
|
14
|
+
vars: () => RuntimeVars;
|
|
15
|
+
content: string;
|
|
8
16
|
getRange: (node: MixNodeT) => {
|
|
9
17
|
start: number;
|
|
10
18
|
end: number;
|
|
@@ -16,18 +24,15 @@ type InitProps<MixNodeT, TxtT extends MixNodeT, ComT extends MixNodeT, ExprT ext
|
|
|
16
24
|
canHaveChildren: (node: MixNodeT) => boolean;
|
|
17
25
|
getTextContent: (node: TxtT) => string;
|
|
18
26
|
getCommentData: (node: ComT) => string;
|
|
19
|
-
visitFunc:
|
|
20
|
-
visitExpressionTag: (node: ExprT) => Message[];
|
|
27
|
+
visitFunc: VisitFunc<MixNodeT, AddCtx>;
|
|
21
28
|
fullHeuristicDetails: (details: HeuristicDetailsBase) => HeuristicDetails;
|
|
22
29
|
checkHeuristic: HeuristicFunc;
|
|
23
30
|
wrapNested: (msgInfo: Message, hasExprs: boolean, nestedRanges: NestedRanges, lastChildEnd: number) => void;
|
|
24
|
-
index: IndexTracker;
|
|
25
31
|
};
|
|
26
32
|
export type MixedScope = 'markup' | 'attribute';
|
|
27
|
-
type VisitProps<NodeT> = {
|
|
33
|
+
type VisitProps<NodeT, AddCtx> = VisitVolatileCtx<AddCtx> & {
|
|
28
34
|
children: NodeT[];
|
|
29
35
|
commentDirectives: CommentDirectives;
|
|
30
|
-
inCompoundText: boolean;
|
|
31
36
|
scope: MixedScope;
|
|
32
37
|
element: string;
|
|
33
38
|
attribute?: string;
|
|
@@ -36,11 +41,13 @@ type VisitProps<NodeT> = {
|
|
|
36
41
|
* e.g. components in jsx to prevent `[object Object]` being rendered. */
|
|
37
42
|
useComponent?: boolean;
|
|
38
43
|
};
|
|
39
|
-
|
|
40
|
-
export declare class MixedVisitor<MixNodeT, TxtT extends MixNodeT, ComT extends MixNodeT, ExprT extends MixNodeT> {
|
|
44
|
+
export declare class MixedVisitor<MixNodeT, AddCtx extends object, TxtT extends MixNodeT, ComT extends MixNodeT, ExprT extends MixNodeT> {
|
|
41
45
|
#private;
|
|
42
|
-
constructor(props: InitProps<MixNodeT, TxtT, ComT, ExprT>);
|
|
43
|
-
separatelyVisitChildren: (props: VisitProps<MixNodeT>) =>
|
|
44
|
-
|
|
46
|
+
constructor(props: InitProps<MixNodeT, AddCtx, TxtT, ComT, ExprT>);
|
|
47
|
+
separatelyVisitChildren: (props: VisitProps<MixNodeT, AddCtx>) => Message[];
|
|
48
|
+
visitNested(props: VisitProps<MixNodeT, AddCtx>, ctx: VisitNestedCtx<AddCtx>, asCompound: true): Message[];
|
|
49
|
+
visitNested(props: VisitProps<MixNodeT, AddCtx>, ctx: VisitNestedCtx<AddCtx>, asCompound: false): boolean;
|
|
50
|
+
visit: (props: VisitProps<MixNodeT, AddCtx>) => Message[];
|
|
51
|
+
static withCtxRestore<MixNodeT, AddCtx>(transformer: VisitVolatileCtx<AddCtx>, visitChild: (child: MixNodeT) => Message[]): VisitFunc<MixNodeT, AddCtx>;
|
|
45
52
|
}
|
|
46
53
|
export {};
|
|
@@ -1,56 +1,25 @@
|
|
|
1
1
|
// Shared logic between adapters for handling nested / mixed elements within elements / fragments
|
|
2
|
-
import
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import { getKey, IndexTracker, newMessage, } from '../adapters.js';
|
|
3
4
|
import { commentPrefix, nonWhitespaceText, restoreCommentDirectives, updateCommentDirectives, varNames, } from './index.js';
|
|
5
|
+
const noopIndex = new IndexTracker(true);
|
|
6
|
+
const noopMstr = new Proxy(new MagicString(''), {
|
|
7
|
+
get: (target, p) => {
|
|
8
|
+
if (typeof target[p] === 'function') {
|
|
9
|
+
return () => { };
|
|
10
|
+
}
|
|
11
|
+
return target[p];
|
|
12
|
+
},
|
|
13
|
+
});
|
|
4
14
|
export class MixedVisitor {
|
|
5
15
|
#props;
|
|
6
16
|
constructor(props) {
|
|
7
17
|
this.#props = props;
|
|
8
18
|
}
|
|
9
19
|
separatelyVisitChildren = (props) => {
|
|
10
|
-
let hasTextChild = false;
|
|
11
|
-
let hasNonTextChild = false;
|
|
12
|
-
let heurStr = '';
|
|
13
|
-
let hasCommentDirectives = false;
|
|
14
|
-
for (const child of props.children) {
|
|
15
|
-
if (this.#props.isText(child)) {
|
|
16
|
-
const strContent = this.#props.getTextContent(child);
|
|
17
|
-
if (!strContent.trim()) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
hasTextChild = true;
|
|
21
|
-
heurStr += strContent;
|
|
22
|
-
}
|
|
23
|
-
else if (this.#props.isComment(child)) {
|
|
24
|
-
if (this.#props.getCommentData(child).trim().startsWith(commentPrefix)) {
|
|
25
|
-
hasCommentDirectives = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else if (!this.#props.leaveInPlace(child)) {
|
|
29
|
-
hasNonTextChild = true;
|
|
30
|
-
heurStr += `#`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
heurStr = heurStr.trimEnd();
|
|
34
|
-
const msg = newMessage({
|
|
35
|
-
msgStr: [heurStr],
|
|
36
|
-
details: this.#props.fullHeuristicDetails({
|
|
37
|
-
scope: props.scope,
|
|
38
|
-
element: props.element,
|
|
39
|
-
attribute: props.attribute,
|
|
40
|
-
}),
|
|
41
|
-
});
|
|
42
|
-
const heurMsgType = this.#props.checkHeuristic(msg);
|
|
43
|
-
if (heurMsgType || props.commentDirectives.unit) {
|
|
44
|
-
const hasCompoundText = hasTextChild && hasNonTextChild;
|
|
45
|
-
if (props.inCompoundText || props.commentDirectives.unit || (hasCompoundText && !hasCommentDirectives)) {
|
|
46
|
-
return [false, hasTextChild, hasCompoundText, heurMsgType || 'message', []];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// can't be extracted as one; visit each separately if markup
|
|
50
20
|
const msgs = [];
|
|
51
|
-
const res = [true, false, false, heurMsgType || 'message', msgs];
|
|
52
21
|
if (props.scope !== 'markup') {
|
|
53
|
-
return
|
|
22
|
+
return msgs;
|
|
54
23
|
}
|
|
55
24
|
const commentDirectivesOrig = { ...props.commentDirectives };
|
|
56
25
|
let lastVisitIsComment = false;
|
|
@@ -67,7 +36,12 @@ export class MixedVisitor {
|
|
|
67
36
|
break;
|
|
68
37
|
}
|
|
69
38
|
if (props.commentDirectives.forceType !== false) {
|
|
70
|
-
msgs.push(...this.#props.visitFunc(child,
|
|
39
|
+
msgs.push(...this.#props.visitFunc(child, {
|
|
40
|
+
mstr: props.mstr,
|
|
41
|
+
index: props.index,
|
|
42
|
+
addCtx: props.addCtx,
|
|
43
|
+
inCompoundText: false,
|
|
44
|
+
}));
|
|
71
45
|
}
|
|
72
46
|
if (!lastVisitIsComment) {
|
|
73
47
|
continue;
|
|
@@ -75,26 +49,25 @@ export class MixedVisitor {
|
|
|
75
49
|
restoreCommentDirectives(props.commentDirectives, commentDirectivesOrig);
|
|
76
50
|
lastVisitIsComment = false;
|
|
77
51
|
}
|
|
78
|
-
return
|
|
52
|
+
return msgs;
|
|
79
53
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (visitedSeparately) {
|
|
86
|
-
return separateTxts;
|
|
87
|
-
}
|
|
54
|
+
visitNested(props, ctx, asCompound) {
|
|
55
|
+
let hasTextChild = false;
|
|
56
|
+
let hasNonTextChild = false;
|
|
57
|
+
let hasCommentDirectives = false;
|
|
58
|
+
let hasTextDescendants = false;
|
|
88
59
|
let msgStr = '';
|
|
89
60
|
let iArg = 0;
|
|
90
61
|
let iTag = 0;
|
|
91
62
|
const lastChildEnd = this.#props.getRange(props.children.slice(-1)[0]).end;
|
|
92
63
|
const childrenNestedRanges = [];
|
|
93
|
-
let hasTextDescendants = false;
|
|
94
64
|
const msgs = [];
|
|
95
65
|
const placeholders = [];
|
|
96
66
|
for (const child of props.children) {
|
|
97
67
|
if (this.#props.isComment(child)) {
|
|
68
|
+
if (this.#props.getCommentData(child).trim().startsWith(commentPrefix)) {
|
|
69
|
+
hasCommentDirectives = true;
|
|
70
|
+
}
|
|
98
71
|
continue;
|
|
99
72
|
}
|
|
100
73
|
const chRange = this.#props.getRange(child);
|
|
@@ -112,45 +85,47 @@ export class MixedVisitor {
|
|
|
112
85
|
// whitespace
|
|
113
86
|
continue;
|
|
114
87
|
}
|
|
88
|
+
hasTextChild = true;
|
|
115
89
|
msgStr += msgInfo.msgStr;
|
|
116
90
|
if (endWh) {
|
|
117
91
|
msgStr += ' ';
|
|
118
92
|
}
|
|
119
|
-
|
|
93
|
+
ctx.mstr.remove(chRange.start, chRange.end);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (this.#props.leaveInPlace(child)) {
|
|
97
|
+
msgs.push(...this.#props.visitFunc(child, { ...ctx, inCompoundText: this.#props.canHaveChildren(child) }));
|
|
120
98
|
continue;
|
|
121
99
|
}
|
|
100
|
+
hasNonTextChild = true;
|
|
122
101
|
if (this.#props.isExpression(child)) {
|
|
123
|
-
msgs.push(...this.#props.
|
|
124
|
-
if (!hasCompoundText) {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
102
|
+
msgs.push(...this.#props.visitFunc(child, { ...ctx, inCompoundText: props.inCompoundText }));
|
|
127
103
|
msgStr += `{${iArg}}`;
|
|
128
|
-
placeholders.push([iArg, this.#props.
|
|
104
|
+
placeholders.push([iArg.toString(), this.#props.content.slice(chRange.start + 1, chRange.end - 1)]);
|
|
129
105
|
let moveStart = chRange.start;
|
|
130
106
|
if (iArg > 0) {
|
|
131
|
-
|
|
107
|
+
ctx.mstr.update(chRange.start, chRange.start + 1, ', ');
|
|
132
108
|
}
|
|
133
109
|
else {
|
|
134
110
|
moveStart++;
|
|
135
|
-
|
|
111
|
+
ctx.mstr.remove(chRange.start, chRange.start + 1);
|
|
136
112
|
}
|
|
137
|
-
|
|
138
|
-
|
|
113
|
+
ctx.mstr.move(moveStart, chRange.end - 1, lastChildEnd);
|
|
114
|
+
ctx.mstr.remove(chRange.end - 1, chRange.end);
|
|
139
115
|
iArg++;
|
|
140
116
|
continue;
|
|
141
117
|
}
|
|
142
|
-
if (this.#props.leaveInPlace(child)) {
|
|
143
|
-
msgs.push(...this.#props.visitFunc(child, this.#props.canHaveChildren(child)));
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
118
|
// elements, components and other things as well
|
|
147
119
|
const canHaveChildren = this.#props.canHaveChildren(child);
|
|
148
|
-
const childMsgs = this.#props.visitFunc(child,
|
|
120
|
+
const childMsgs = this.#props.visitFunc(child, { ...ctx, inCompoundText: asCompound });
|
|
149
121
|
let nestedNeedsCtx = false;
|
|
150
122
|
let chTxt = '';
|
|
151
123
|
for (const msgInfo of childMsgs) {
|
|
152
124
|
if (canHaveChildren && msgInfo.details.scope === props.scope) {
|
|
153
125
|
chTxt += msgInfo.msgStr[0];
|
|
126
|
+
for (const [num, cont] of msgInfo.placeholders) {
|
|
127
|
+
placeholders.push([`${iTag}.${num}`, cont]);
|
|
128
|
+
}
|
|
154
129
|
hasTextDescendants = true;
|
|
155
130
|
nestedNeedsCtx = true;
|
|
156
131
|
}
|
|
@@ -170,17 +145,28 @@ export class MixedVisitor {
|
|
|
170
145
|
iTag++;
|
|
171
146
|
msgStr += chTxt;
|
|
172
147
|
}
|
|
173
|
-
msgStr = msgStr.trim();
|
|
174
|
-
if (!msgStr) {
|
|
175
|
-
return msgs;
|
|
176
|
-
}
|
|
177
148
|
const msgInfo = newMessage({
|
|
178
|
-
msgStr: [msgStr],
|
|
179
|
-
details: this.#props.fullHeuristicDetails({
|
|
149
|
+
msgStr: [msgStr.trim()],
|
|
150
|
+
details: this.#props.fullHeuristicDetails({
|
|
151
|
+
scope: props.scope,
|
|
152
|
+
element: props.element,
|
|
153
|
+
attribute: props.attribute,
|
|
154
|
+
}),
|
|
180
155
|
context: props.commentDirectives.context,
|
|
156
|
+
placeholders,
|
|
181
157
|
});
|
|
182
|
-
|
|
183
|
-
msgInfo.
|
|
158
|
+
const heurMsgType = this.#props.checkHeuristic(msgInfo);
|
|
159
|
+
msgInfo.type = heurMsgType || 'message';
|
|
160
|
+
const canBeCompound = props.inCompoundText ||
|
|
161
|
+
props.commentDirectives.unit ||
|
|
162
|
+
(hasTextChild && hasNonTextChild && !hasCommentDirectives);
|
|
163
|
+
const allChecksPassed = props.commentDirectives.unit || (canBeCompound && heurMsgType);
|
|
164
|
+
if (!asCompound) {
|
|
165
|
+
return allChecksPassed;
|
|
166
|
+
}
|
|
167
|
+
if (!allChecksPassed) {
|
|
168
|
+
return msgs;
|
|
169
|
+
}
|
|
184
170
|
if (hasTextChild || hasTextDescendants) {
|
|
185
171
|
msgs.push(msgInfo);
|
|
186
172
|
}
|
|
@@ -189,34 +175,57 @@ export class MixedVisitor {
|
|
|
189
175
|
}
|
|
190
176
|
if (((props.useComponent ?? true) && props.scope === 'markup' && iArg > 0) || childrenNestedRanges.length > 0) {
|
|
191
177
|
this.#props.wrapNested(msgInfo, iArg > 0, childrenNestedRanges, lastChildEnd);
|
|
178
|
+
return msgs;
|
|
179
|
+
}
|
|
180
|
+
// no need for component use
|
|
181
|
+
let begin = '{';
|
|
182
|
+
let end = ')}';
|
|
183
|
+
if (props.inCompoundText) {
|
|
184
|
+
begin += `${this.#props.vars().rtTransCtx}(${this.#props.vars().nestCtx}`;
|
|
192
185
|
}
|
|
193
186
|
else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (props.inCompoundText) {
|
|
198
|
-
begin += `${this.#props.vars().rtTransCtx}(${this.#props.vars().nestCtx}`;
|
|
187
|
+
if (msgInfo.type === 'url') {
|
|
188
|
+
begin += `${varNames.urlLocalize}(`;
|
|
189
|
+
end = `), ${this.#props.vars().rtLocale}${end}`;
|
|
199
190
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
begin += `${this.#props.vars().rtTrans}(${this.#props.index.get(getKey(msgInfo.msgStr, msgInfo.context))}`;
|
|
206
|
-
}
|
|
207
|
-
if (iArg > 0) {
|
|
208
|
-
begin += ', [';
|
|
209
|
-
end = `]${end}`;
|
|
210
|
-
}
|
|
211
|
-
if (props.scope === 'attribute' && `'"`.includes(this.#props.mstr.original[lastChildEnd])) {
|
|
212
|
-
const firstChild = props.children[0];
|
|
213
|
-
const { start } = this.#props.getRange(firstChild);
|
|
214
|
-
this.#props.mstr.remove(start - 1, start);
|
|
215
|
-
this.#props.mstr.remove(lastChildEnd, lastChildEnd + 1);
|
|
216
|
-
}
|
|
217
|
-
this.#props.mstr.appendLeft(lastChildEnd, begin);
|
|
218
|
-
this.#props.mstr.appendRight(lastChildEnd, end);
|
|
191
|
+
begin += `${this.#props.vars().rtTrans}(${props.index.get(getKey(msgInfo.msgStr, msgInfo.context))}`;
|
|
192
|
+
}
|
|
193
|
+
if (iArg > 0) {
|
|
194
|
+
begin += ', [';
|
|
195
|
+
end = `]${end}`;
|
|
219
196
|
}
|
|
197
|
+
if (props.scope === 'attribute' && `'"`.includes(this.#props.content[lastChildEnd])) {
|
|
198
|
+
const firstChild = props.children[0];
|
|
199
|
+
const { start } = this.#props.getRange(firstChild);
|
|
200
|
+
ctx.mstr.remove(start - 1, start);
|
|
201
|
+
ctx.mstr.remove(lastChildEnd, lastChildEnd + 1);
|
|
202
|
+
}
|
|
203
|
+
ctx.mstr.appendLeft(lastChildEnd, begin);
|
|
204
|
+
ctx.mstr.appendRight(lastChildEnd, end);
|
|
220
205
|
return msgs;
|
|
206
|
+
}
|
|
207
|
+
visit = (props) => {
|
|
208
|
+
if (props.children.length === 0) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
if (!this.visitNested(props, { mstr: noopMstr, index: noopIndex, addCtx: { ...props.addCtx } }, false)) {
|
|
212
|
+
return this.separatelyVisitChildren(props);
|
|
213
|
+
}
|
|
214
|
+
return this.visitNested(props, { mstr: props.mstr, index: props.index, addCtx: props.addCtx }, true); // really modify
|
|
221
215
|
};
|
|
216
|
+
static withCtxRestore(transformer, visitChild) {
|
|
217
|
+
return (child, ctx) => {
|
|
218
|
+
const prevCtx = {
|
|
219
|
+
inCompoundText: transformer.inCompoundText,
|
|
220
|
+
mstr: transformer.mstr,
|
|
221
|
+
index: transformer.index,
|
|
222
|
+
addCtx: transformer.addCtx,
|
|
223
|
+
};
|
|
224
|
+
Object.assign(transformer, ctx);
|
|
225
|
+
const msgs = visitChild(child);
|
|
226
|
+
// restore
|
|
227
|
+
Object.assign(transformer, prevCtx);
|
|
228
|
+
return msgs;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
222
231
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// $$ cd .. && npm run test
|
|
2
2
|
import { loaderPathResolver } from '../adapter-utils/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultHeuristicFuncOnly } from '../adapters.js';
|
|
4
4
|
import { fillDefaults } from '../config.js';
|
|
5
5
|
import { pofile } from '../pofile.js';
|
|
6
6
|
import { Transformer } from './transformer.js';
|
|
@@ -15,9 +15,11 @@ export const defaultArgs = {
|
|
|
15
15
|
storage: pofile(),
|
|
16
16
|
patterns: [pluralPattern],
|
|
17
17
|
heuristic: defaultHeuristicFuncOnly,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
loading: {
|
|
19
|
+
direct: false,
|
|
20
|
+
granular: false,
|
|
21
|
+
group: [],
|
|
22
|
+
},
|
|
21
23
|
loader: 'vite',
|
|
22
24
|
runtime: {
|
|
23
25
|
initReactive: ({ nested }) => (nested ? null : false),
|
|
@@ -51,9 +53,9 @@ export function getDefaultLoaderPath(loader, bundle) {
|
|
|
51
53
|
export const adapter = (args = defaultArgs) => {
|
|
52
54
|
const { heuristic, patterns, runtime, loader, ...rest } = fillDefaults(args, defaultArgs);
|
|
53
55
|
return {
|
|
54
|
-
transform:
|
|
56
|
+
transform: ctx => new Transformer(ctx, heuristic, patterns, runtime).transform(),
|
|
55
57
|
loaderExts: ['.js', '.ts'],
|
|
56
|
-
defaultLoaderPath: getDefaultLoaderPath(loader, rest.
|
|
58
|
+
defaultLoaderPath: getDefaultLoaderPath(loader, rest.loading.direct),
|
|
57
59
|
runtime,
|
|
58
60
|
...rest,
|
|
59
61
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Message } from '../adapters.js';
|
|
2
|
+
export default class {
|
|
3
|
+
visitEmptyStatement(): Message[];
|
|
4
|
+
visitArrayPattern(): Message[];
|
|
5
|
+
visitBreakStatement(): Message[];
|
|
6
|
+
visitCatchClause(): Message[];
|
|
7
|
+
visitClassBody(): Message[];
|
|
8
|
+
visitClassExpression(): Message[];
|
|
9
|
+
visitContinueStatement(): Message[];
|
|
10
|
+
visitDebuggerStatement(): Message[];
|
|
11
|
+
visitExportAllDeclaration(): Message[];
|
|
12
|
+
visitExportSpecifier(): Message[];
|
|
13
|
+
visitIdentifier(): Message[];
|
|
14
|
+
visitImportAttribute(): Message[];
|
|
15
|
+
visitImportDeclaration(): Message[];
|
|
16
|
+
visitImportDefaultSpecifier(): Message[];
|
|
17
|
+
visitImportExpression(): Message[];
|
|
18
|
+
visitImportNamespaceSpecifier(): Message[];
|
|
19
|
+
visitImportSpecifier(): Message[];
|
|
20
|
+
visitMetaProperty(): Message[];
|
|
21
|
+
visitMethodDefinition(): Message[];
|
|
22
|
+
visitPrivateIdentifier(): Message[];
|
|
23
|
+
visitPropertyDefinition(): Message[];
|
|
24
|
+
visitStaticBlock(): Message[];
|
|
25
|
+
visitSuper(): Message[];
|
|
26
|
+
visitTemplateElement(): Message[];
|
|
27
|
+
visitThisExpression(): Message[];
|
|
28
|
+
visitThrowStatement(): Message[];
|
|
29
|
+
visitUpdateExpression(): Message[];
|
|
30
|
+
visitWithStatement(): Message[];
|
|
31
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export default class {
|
|
2
|
+
visitEmptyStatement() {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
visitArrayPattern() {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
visitBreakStatement() {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
visitCatchClause() {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
visitClassBody() {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
visitClassExpression() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
visitContinueStatement() {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
visitDebuggerStatement() {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
visitExportAllDeclaration() {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
visitExportSpecifier() {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
visitIdentifier() {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
visitImportAttribute() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
visitImportDeclaration() {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
visitImportDefaultSpecifier() {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
visitImportExpression() {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
visitImportNamespaceSpecifier() {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
visitImportSpecifier() {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
visitMetaProperty() {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
visitMethodDefinition() {
|
|
57
|
+
return [];
|
|
58
|
+
} // handled inside visitClassDeclaration
|
|
59
|
+
visitPrivateIdentifier() {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
visitPropertyDefinition() {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
visitStaticBlock() {
|
|
66
|
+
return [];
|
|
67
|
+
} // handled inside visitClassDeclaration
|
|
68
|
+
visitSuper() {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
visitTemplateElement() {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
visitThisExpression() {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
visitThrowStatement() {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
visitUpdateExpression() {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
visitWithStatement() {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
}
|