@intlify/bundle-utils 3.1.1 → 3.2.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/CHANGELOG.md +138 -0
- package/lib/check.d.ts +1 -0
- package/lib/check.js +14 -1
- package/lib/codegen.d.ts +2 -1
- package/lib/codegen.js +2 -1
- package/lib/json.js +26 -5
- package/lib/yaml.js +26 -5
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
|
|
2
|
+
## @intlify/bundle-utils@3.2.0 (2022-09-27)
|
|
3
|
+
|
|
4
|
+
#### :star: Features
|
|
5
|
+
* [#185](https://github.com/intlify/bundle-tools/pull/185) feat: add vue-i18n-bridge install checking ([@kazupon](https://github.com/kazupon))
|
|
6
|
+
|
|
7
|
+
#### Committers: 1
|
|
8
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## @intlify/bundle-utils@3.1.2 (2022-09-19)
|
|
12
|
+
|
|
13
|
+
#### :zap: Improvement Features
|
|
14
|
+
* [#178](https://github.com/intlify/bundle-tools/pull/178) fix(bundle-utils): improve compile error handling ([@kazupon](https://github.com/kazupon))
|
|
15
|
+
|
|
16
|
+
#### Committers: 1
|
|
17
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## @intlify/bundle-utils@3.1.1 (2022-09-19)
|
|
21
|
+
|
|
22
|
+
#### :bug: Bug Fixes
|
|
23
|
+
* [#177](https://github.com/intlify/bundle-tools/pull/177) fix(bundle-utils): fix wrong error callbacking and error handling improvement ([@kazupon](https://github.com/kazupon))
|
|
24
|
+
|
|
25
|
+
#### Committers: 1
|
|
26
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## @intlify/bundle-utils@3.1.0 (2022-05-06)
|
|
30
|
+
|
|
31
|
+
#### :zap: Improvement Features
|
|
32
|
+
* [#116](https://github.com/intlify/bundle-tools/pull/116) improvement(bundle-utils): support ESM exporting on bridge ([@kazupon](https://github.com/kazupon))
|
|
33
|
+
|
|
34
|
+
#### Committers: 1
|
|
35
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## @intlify/bundle-utils@3.0.0 (2022-04-05)
|
|
39
|
+
|
|
40
|
+
#### :star: Features
|
|
41
|
+
* [#101](https://github.com/intlify/bundle-tools/pull/101) feat(bundle-utils): pinned intlify related module next version ([@kazupon](https://github.com/kazupon))
|
|
42
|
+
|
|
43
|
+
#### Committers: 1
|
|
44
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## @intlify/bundle-utils@2.2.2 (2022-04-05)
|
|
48
|
+
|
|
49
|
+
#### :zap: Improvement Features
|
|
50
|
+
* [#100](https://github.com/intlify/bundle-tools/pull/100) fix(bundle-utils): pinned latest stable version ([@kazupon](https://github.com/kazupon))
|
|
51
|
+
|
|
52
|
+
#### Committers: 1
|
|
53
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## @intlify/bundle-utils@2.2.1 (2022-03-22)
|
|
57
|
+
|
|
58
|
+
#### :bug: Bug Fixes
|
|
59
|
+
* [#98](https://github.com/intlify/bundle-tools/pull/98) fix(bundle-utils): fix nested array code generation ([@kazupon](https://github.com/kazupon))
|
|
60
|
+
|
|
61
|
+
#### Committers: 1
|
|
62
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## @intlify/bundle-utils@2.2.1 (2022-03-22)
|
|
66
|
+
|
|
67
|
+
#### :bug: Bug Fixes
|
|
68
|
+
* [#98](https://github.com/intlify/bundle-tools/pull/98) fix(bundle-utils): fix nested array code generation ([@kazupon](https://github.com/kazupon))
|
|
69
|
+
|
|
70
|
+
#### Committers: 1
|
|
71
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## @intlify/bundle-utils@2.2.0 (2021-12-16)
|
|
75
|
+
|
|
76
|
+
#### :zap: Improvement Features
|
|
77
|
+
* [#75](https://github.com/intlify/bundle-tools/pull/75) Add vue-class-components support via loader option ([@SniperJoe](https://github.com/SniperJoe))
|
|
78
|
+
|
|
79
|
+
#### Committers: 1
|
|
80
|
+
- [@SniperJoe](https://github.com/SniperJoe)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## @intlify/bundle-utils@2.1.0 (2021-11-10)
|
|
84
|
+
|
|
85
|
+
#### :zap: Improvement Features
|
|
86
|
+
* [#67](https://github.com/intlify/bundle-tools/pull/67) fix: add vite and vue-i18n as peerDependencies ([@AlexandreBonaventure](https://github.com/AlexandreBonaventure))
|
|
87
|
+
|
|
88
|
+
#### Committers: 1
|
|
89
|
+
- Alexandre Bonaventure Geissmann ([@AlexandreBonaventure](https://github.com/AlexandreBonaventure))
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## @intlify/bundle-utils@2.0.0 (2021-10-24)
|
|
93
|
+
|
|
94
|
+
#### :star: Features
|
|
95
|
+
* [#60](https://github.com/intlify/bundle-tools/pull/60) feat: change to intlify beta related deps ([@kazupon](https://github.com/kazupon))
|
|
96
|
+
|
|
97
|
+
#### Committers: 1
|
|
98
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## @intlify/bundle-utils@1.0.0 (2021-10-24)
|
|
102
|
+
|
|
103
|
+
#### :star: Features
|
|
104
|
+
* [#56](https://github.com/intlify/bundle-tools/pull/56) feat: bump to major version ([@kazupon](https://github.com/kazupon))
|
|
105
|
+
|
|
106
|
+
#### Committers: 1
|
|
107
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## @intlify/bundle-utils@0.3.0 (2021-09-29)
|
|
111
|
+
|
|
112
|
+
#### :star: Features
|
|
113
|
+
* [#47](https://github.com/intlify/bundle-tools/pull/47) feat: support vue i18n bridge ([@kazupon](https://github.com/kazupon))
|
|
114
|
+
|
|
115
|
+
#### Committers: 1
|
|
116
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## @intlify/bundle-utils@0.2.0 (2021-07-26)
|
|
120
|
+
|
|
121
|
+
#### :star: Features
|
|
122
|
+
* [#36](https://github.com/intlify/bundle-tools/pull/36) add install package checking ([@kazupon](https://github.com/kazupon))
|
|
123
|
+
|
|
124
|
+
#### Committers: 1
|
|
125
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## @intlify/bundle-utils@0.1.0 (2021-07-12)
|
|
129
|
+
|
|
130
|
+
#### :star: Features
|
|
131
|
+
* [#26](https://github.com/intlify/bundle-tools/pull/26) feat: bundle-utils basic implementation ([@kazupon](https://github.com/kazupon))
|
|
132
|
+
|
|
133
|
+
#### Committers: 1
|
|
134
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
135
|
+
|
|
136
|
+
## v0.0.0 (2021-07-13)
|
|
137
|
+
|
|
138
|
+
:tada: Initial release.
|
package/lib/check.d.ts
CHANGED
package/lib/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkInstallPackage = void 0;
|
|
3
|
+
exports.checkVueI18nBridgeInstallPackage = exports.checkInstallPackage = void 0;
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
5
|
function checkInstallPackage(pkg, debug) {
|
|
6
6
|
let installedVueI18n = false;
|
|
@@ -28,3 +28,16 @@ function checkInstallPackage(pkg, debug) {
|
|
|
28
28
|
throw new Error(`${pkg} requires 'vue-i18n' or 'petite-vue-i18n' to be present in the dependency tree.`);
|
|
29
29
|
}
|
|
30
30
|
exports.checkInstallPackage = checkInstallPackage;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
32
|
+
function checkVueI18nBridgeInstallPackage(debug) {
|
|
33
|
+
let ret = false;
|
|
34
|
+
try {
|
|
35
|
+
debug(`vue-i18n-bridge load path: ${require.resolve('vue-i18n-bridge')}`);
|
|
36
|
+
ret = true;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
debug(`cannot find 'vue-i18n-bridge'`, e);
|
|
40
|
+
}
|
|
41
|
+
return ret;
|
|
42
|
+
}
|
|
43
|
+
exports.checkVueI18nBridgeInstallPackage = checkVueI18nBridgeInstallPackage;
|
package/lib/codegen.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface CodeGenOptions {
|
|
|
37
37
|
onWarn?: (msg: string) => void;
|
|
38
38
|
onError?: (msg: string, extra?: {
|
|
39
39
|
source: string;
|
|
40
|
+
path: string;
|
|
40
41
|
code?: CompileError['code'];
|
|
41
42
|
domain?: CompileError['domain'];
|
|
42
43
|
location?: CompileError['location'];
|
|
@@ -71,5 +72,5 @@ export interface CodeGenResult<ASTNode> {
|
|
|
71
72
|
map?: RawSourceMap;
|
|
72
73
|
}
|
|
73
74
|
export declare function createCodeGenerator(options?: CodeGenOptions): CodeGenerator;
|
|
74
|
-
export declare function generateMessageFunction(msg: string, options: CodeGenOptions): CodeGenResult<ResourceNode>;
|
|
75
|
+
export declare function generateMessageFunction(msg: string, options: CodeGenOptions, path?: string[]): CodeGenResult<ResourceNode>;
|
|
75
76
|
export declare function mapLinesColumns(resMap: RawSourceMap, codeMaps: Map<string, RawSourceMap>, inSourceMap?: RawSourceMap): RawSourceMap | null;
|
package/lib/codegen.js
CHANGED
|
@@ -94,7 +94,7 @@ function advancePositionWithSource(pos, source, numberOfCharacters = source.leng
|
|
|
94
94
|
: numberOfCharacters - lastNewLinePos;
|
|
95
95
|
return pos;
|
|
96
96
|
}
|
|
97
|
-
function generateMessageFunction(msg, options) {
|
|
97
|
+
function generateMessageFunction(msg, options, path) {
|
|
98
98
|
const env = options.env != null ? options.env : 'development';
|
|
99
99
|
const onError = options.onError;
|
|
100
100
|
const errors = [];
|
|
@@ -103,6 +103,7 @@ function generateMessageFunction(msg, options) {
|
|
|
103
103
|
if (onError) {
|
|
104
104
|
const extra = {
|
|
105
105
|
source: msg,
|
|
106
|
+
path: path ? path.join('.') : '',
|
|
106
107
|
code: err.code,
|
|
107
108
|
domain: err.domain,
|
|
108
109
|
location: err.location
|
package/lib/json.js
CHANGED
|
@@ -56,6 +56,7 @@ function generate(targetSource, { type = 'plain', bridge = false, exportESM = fa
|
|
|
56
56
|
exports.generate = generate;
|
|
57
57
|
function generateNode(generator, node, options, injector) {
|
|
58
58
|
const propsCountStack = [];
|
|
59
|
+
const pathStack = [];
|
|
59
60
|
const itemsCountStack = [];
|
|
60
61
|
const { forceStringify } = generator.context();
|
|
61
62
|
const codeMaps = new Map();
|
|
@@ -97,6 +98,8 @@ function generateNode(generator, node, options, injector) {
|
|
|
97
98
|
propsCountStack.push(node.properties.length);
|
|
98
99
|
if (parent.type === 'JSONArrayExpression') {
|
|
99
100
|
const lastIndex = itemsCountStack.length - 1;
|
|
101
|
+
const currentCount = parent.elements.length - itemsCountStack[lastIndex];
|
|
102
|
+
pathStack.push(currentCount.toString());
|
|
100
103
|
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
|
|
101
104
|
}
|
|
102
105
|
break;
|
|
@@ -108,7 +111,8 @@ function generateNode(generator, node, options, injector) {
|
|
|
108
111
|
const value = node.value.value;
|
|
109
112
|
if ((0, shared_1.isString)(value)) {
|
|
110
113
|
generator.push(`${JSON.stringify(name)}: `);
|
|
111
|
-
|
|
114
|
+
pathStack.push(name.toString());
|
|
115
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
|
|
112
116
|
sourceMap && map != null && codeMaps.set(value, map);
|
|
113
117
|
generator.push(`${code}`, node.value, value);
|
|
114
118
|
}
|
|
@@ -116,12 +120,14 @@ function generateNode(generator, node, options, injector) {
|
|
|
116
120
|
if (forceStringify) {
|
|
117
121
|
const strValue = JSON.stringify(value);
|
|
118
122
|
generator.push(`${JSON.stringify(name)}: `);
|
|
119
|
-
|
|
123
|
+
pathStack.push(name.toString());
|
|
124
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
|
|
120
125
|
sourceMap && map != null && codeMaps.set(strValue, map);
|
|
121
126
|
generator.push(`${code}`, node.value, strValue);
|
|
122
127
|
}
|
|
123
128
|
else {
|
|
124
129
|
generator.push(`${JSON.stringify(name)}: ${JSON.stringify(value)}`);
|
|
130
|
+
pathStack.push(name.toString());
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
}
|
|
@@ -131,6 +137,7 @@ function generateNode(generator, node, options, injector) {
|
|
|
131
137
|
node.key.type === 'JSONIdentifier')) {
|
|
132
138
|
const name = node.key.type === 'JSONLiteral' ? node.key.value : node.key.name;
|
|
133
139
|
generator.push(`${JSON.stringify(name)}: `);
|
|
140
|
+
pathStack.push(name.toString());
|
|
134
141
|
}
|
|
135
142
|
const lastIndex = propsCountStack.length - 1;
|
|
136
143
|
propsCountStack[lastIndex] = --propsCountStack[lastIndex];
|
|
@@ -138,21 +145,30 @@ function generateNode(generator, node, options, injector) {
|
|
|
138
145
|
case 'JSONArrayExpression':
|
|
139
146
|
generator.push(`[`);
|
|
140
147
|
generator.indent();
|
|
148
|
+
if (parent.type === 'JSONArrayExpression') {
|
|
149
|
+
const lastIndex = itemsCountStack.length - 1;
|
|
150
|
+
const currentCount = parent.elements.length - itemsCountStack[lastIndex];
|
|
151
|
+
pathStack.push(currentCount.toString());
|
|
152
|
+
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
|
|
153
|
+
}
|
|
141
154
|
itemsCountStack.push(node.elements.length);
|
|
142
155
|
break;
|
|
143
156
|
case 'JSONLiteral':
|
|
144
157
|
if (parent.type === 'JSONArrayExpression') {
|
|
158
|
+
const lastIndex = itemsCountStack.length - 1;
|
|
159
|
+
const currentCount = parent.elements.length - itemsCountStack[lastIndex];
|
|
160
|
+
pathStack.push(currentCount.toString());
|
|
145
161
|
if (node.type === 'JSONLiteral') {
|
|
146
162
|
const value = node.value;
|
|
147
163
|
if ((0, shared_1.isString)(value)) {
|
|
148
|
-
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options);
|
|
164
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
|
|
149
165
|
sourceMap && map != null && codeMaps.set(value, map);
|
|
150
166
|
generator.push(`${code}`, node, value);
|
|
151
167
|
}
|
|
152
168
|
else {
|
|
153
169
|
if (forceStringify) {
|
|
154
170
|
const strValue = JSON.stringify(value);
|
|
155
|
-
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options);
|
|
171
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
|
|
156
172
|
sourceMap && map != null && codeMaps.set(strValue, map);
|
|
157
173
|
generator.push(`${code}`, node, strValue);
|
|
158
174
|
}
|
|
@@ -161,7 +177,6 @@ function generateNode(generator, node, options, injector) {
|
|
|
161
177
|
}
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
|
-
const lastIndex = itemsCountStack.length - 1;
|
|
165
180
|
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
|
|
166
181
|
}
|
|
167
182
|
break;
|
|
@@ -187,29 +202,34 @@ function generateNode(generator, node, options, injector) {
|
|
|
187
202
|
break;
|
|
188
203
|
case 'JSONObjectExpression':
|
|
189
204
|
if (propsCountStack[propsCountStack.length - 1] === 0) {
|
|
205
|
+
pathStack.pop();
|
|
190
206
|
propsCountStack.pop();
|
|
191
207
|
}
|
|
192
208
|
generator.deindent();
|
|
193
209
|
generator.push(`}`);
|
|
194
210
|
if (parent.type === 'JSONArrayExpression') {
|
|
195
211
|
if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
|
|
212
|
+
pathStack.pop();
|
|
196
213
|
generator.pushline(`,`);
|
|
197
214
|
}
|
|
198
215
|
}
|
|
199
216
|
break;
|
|
200
217
|
case 'JSONProperty':
|
|
201
218
|
if (propsCountStack[propsCountStack.length - 1] !== 0) {
|
|
219
|
+
pathStack.pop();
|
|
202
220
|
generator.pushline(`,`);
|
|
203
221
|
}
|
|
204
222
|
break;
|
|
205
223
|
case 'JSONArrayExpression':
|
|
206
224
|
if (itemsCountStack[itemsCountStack.length - 1] === 0) {
|
|
225
|
+
pathStack.pop();
|
|
207
226
|
itemsCountStack.pop();
|
|
208
227
|
}
|
|
209
228
|
generator.deindent();
|
|
210
229
|
generator.push(`]`);
|
|
211
230
|
if (parent.type === 'JSONArrayExpression') {
|
|
212
231
|
if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
|
|
232
|
+
pathStack.pop();
|
|
213
233
|
generator.pushline(`,`);
|
|
214
234
|
}
|
|
215
235
|
}
|
|
@@ -217,6 +237,7 @@ function generateNode(generator, node, options, injector) {
|
|
|
217
237
|
case 'JSONLiteral':
|
|
218
238
|
if (parent.type === 'JSONArrayExpression') {
|
|
219
239
|
if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
|
|
240
|
+
pathStack.pop();
|
|
220
241
|
generator.pushline(`,`);
|
|
221
242
|
}
|
|
222
243
|
else {
|
package/lib/yaml.js
CHANGED
|
@@ -46,6 +46,7 @@ function generate(targetSource, { type = 'plain', bridge = false, exportESM = fa
|
|
|
46
46
|
exports.generate = generate;
|
|
47
47
|
function generateNode(generator, node, options, injector) {
|
|
48
48
|
const propsCountStack = [];
|
|
49
|
+
const pathStack = [];
|
|
49
50
|
const itemsCountStack = [];
|
|
50
51
|
const { forceStringify } = generator.context();
|
|
51
52
|
const codeMaps = new Map();
|
|
@@ -86,6 +87,8 @@ function generateNode(generator, node, options, injector) {
|
|
|
86
87
|
propsCountStack.push(node.pairs.length);
|
|
87
88
|
if (parent.type === 'YAMLSequence') {
|
|
88
89
|
const lastIndex = itemsCountStack.length - 1;
|
|
90
|
+
const currentCount = parent.entries.length - itemsCountStack[lastIndex];
|
|
91
|
+
pathStack.push(currentCount.toString());
|
|
89
92
|
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
|
|
90
93
|
}
|
|
91
94
|
break;
|
|
@@ -98,7 +101,8 @@ function generateNode(generator, node, options, injector) {
|
|
|
98
101
|
const value = node.value.value;
|
|
99
102
|
if ((0, shared_1.isString)(value)) {
|
|
100
103
|
generator.push(`${JSON.stringify(name)}: `);
|
|
101
|
-
|
|
104
|
+
name && pathStack.push(name.toString());
|
|
105
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
|
|
102
106
|
sourceMap && map != null && codeMaps.set(value, map);
|
|
103
107
|
generator.push(`${code}`, node.value, value);
|
|
104
108
|
}
|
|
@@ -106,12 +110,14 @@ function generateNode(generator, node, options, injector) {
|
|
|
106
110
|
if (forceStringify) {
|
|
107
111
|
const strValue = JSON.stringify(value);
|
|
108
112
|
generator.push(`${JSON.stringify(name)}: `);
|
|
109
|
-
|
|
113
|
+
name && pathStack.push(name.toString());
|
|
114
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
|
|
110
115
|
sourceMap && map != null && codeMaps.set(strValue, map);
|
|
111
116
|
generator.push(`${code}`, node.value, strValue);
|
|
112
117
|
}
|
|
113
118
|
else {
|
|
114
119
|
generator.push(`${JSON.stringify(name)}: ${JSON.stringify(value)}`);
|
|
120
|
+
name && pathStack.push(name.toString());
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
}
|
|
@@ -122,6 +128,7 @@ function generateNode(generator, node, options, injector) {
|
|
|
122
128
|
node.key.type === 'YAMLScalar') {
|
|
123
129
|
const name = node.key.value;
|
|
124
130
|
generator.push(`${JSON.stringify(name)}: `);
|
|
131
|
+
name && pathStack.push(name.toString());
|
|
125
132
|
}
|
|
126
133
|
const lastIndex = propsCountStack.length - 1;
|
|
127
134
|
propsCountStack[lastIndex] = --propsCountStack[lastIndex];
|
|
@@ -129,21 +136,30 @@ function generateNode(generator, node, options, injector) {
|
|
|
129
136
|
case 'YAMLSequence':
|
|
130
137
|
generator.push(`[`);
|
|
131
138
|
generator.indent();
|
|
139
|
+
if (parent.type === 'YAMLSequence') {
|
|
140
|
+
const lastIndex = itemsCountStack.length - 1;
|
|
141
|
+
const currentCount = parent.entries.length - itemsCountStack[lastIndex];
|
|
142
|
+
pathStack.push(currentCount.toString());
|
|
143
|
+
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
|
|
144
|
+
}
|
|
132
145
|
itemsCountStack.push(node.entries.length);
|
|
133
146
|
break;
|
|
134
147
|
case 'YAMLScalar':
|
|
135
148
|
if (parent.type === 'YAMLSequence') {
|
|
149
|
+
const lastIndex = itemsCountStack.length - 1;
|
|
150
|
+
const currentCount = parent.entries.length - itemsCountStack[lastIndex];
|
|
151
|
+
pathStack.push(currentCount.toString());
|
|
136
152
|
if (node.type === 'YAMLScalar') {
|
|
137
153
|
const value = node.value;
|
|
138
154
|
if ((0, shared_1.isString)(value)) {
|
|
139
|
-
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options);
|
|
155
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
|
|
140
156
|
sourceMap && map != null && codeMaps.set(value, map);
|
|
141
157
|
generator.push(`${code}`, node, value);
|
|
142
158
|
}
|
|
143
159
|
else {
|
|
144
160
|
if (forceStringify) {
|
|
145
161
|
const strValue = JSON.stringify(value);
|
|
146
|
-
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options);
|
|
162
|
+
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
|
|
147
163
|
sourceMap && map != null && codeMaps.set(strValue, map);
|
|
148
164
|
generator.push(`${code}`, node, strValue);
|
|
149
165
|
}
|
|
@@ -152,7 +168,6 @@ function generateNode(generator, node, options, injector) {
|
|
|
152
168
|
}
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
|
-
const lastIndex = itemsCountStack.length - 1;
|
|
156
171
|
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
|
|
157
172
|
}
|
|
158
173
|
break;
|
|
@@ -178,29 +193,34 @@ function generateNode(generator, node, options, injector) {
|
|
|
178
193
|
break;
|
|
179
194
|
case 'YAMLMapping':
|
|
180
195
|
if (propsCountStack[propsCountStack.length - 1] === 0) {
|
|
196
|
+
pathStack.pop();
|
|
181
197
|
propsCountStack.pop();
|
|
182
198
|
}
|
|
183
199
|
generator.deindent();
|
|
184
200
|
generator.push(`}`);
|
|
185
201
|
if (parent.type === 'YAMLSequence') {
|
|
186
202
|
if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
|
|
203
|
+
pathStack.pop();
|
|
187
204
|
generator.pushline(`,`);
|
|
188
205
|
}
|
|
189
206
|
}
|
|
190
207
|
break;
|
|
191
208
|
case 'YAMLPair':
|
|
192
209
|
if (propsCountStack[propsCountStack.length - 1] !== 0) {
|
|
210
|
+
pathStack.pop();
|
|
193
211
|
generator.pushline(`,`);
|
|
194
212
|
}
|
|
195
213
|
break;
|
|
196
214
|
case 'YAMLSequence':
|
|
197
215
|
if (itemsCountStack[itemsCountStack.length - 1] === 0) {
|
|
216
|
+
pathStack.pop();
|
|
198
217
|
itemsCountStack.pop();
|
|
199
218
|
}
|
|
200
219
|
generator.deindent();
|
|
201
220
|
generator.push(`]`);
|
|
202
221
|
if (parent.type === 'YAMLSequence') {
|
|
203
222
|
if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
|
|
223
|
+
pathStack.pop();
|
|
204
224
|
generator.pushline(`,`);
|
|
205
225
|
}
|
|
206
226
|
}
|
|
@@ -208,6 +228,7 @@ function generateNode(generator, node, options, injector) {
|
|
|
208
228
|
case 'YAMLScalar':
|
|
209
229
|
if (parent.type === 'YAMLSequence') {
|
|
210
230
|
if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
|
|
231
|
+
pathStack.pop();
|
|
211
232
|
generator.pushline(`,`);
|
|
212
233
|
}
|
|
213
234
|
else {
|