@stencil/angular-output-target 0.8.1 → 0.8.2
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/generate-angular-component.js +16 -2
- package/dist/index.cjs.js +16 -2
- package/dist/index.js +16 -2
- package/package.json +1 -1
|
@@ -70,6 +70,7 @@ export class ${tagNameAsPascal} {
|
|
|
70
70
|
* @returns The sanitized event type as a string.
|
|
71
71
|
*/
|
|
72
72
|
const formatOutputType = (componentClassName, event) => {
|
|
73
|
+
const prefix = `I${componentClassName}`;
|
|
73
74
|
/**
|
|
74
75
|
* The original attribute contains the original type defined by the devs.
|
|
75
76
|
* This regexp normalizes the reference, by removing linebreaks,
|
|
@@ -78,11 +79,24 @@ const formatOutputType = (componentClassName, event) => {
|
|
|
78
79
|
return Object.entries(event.complexType.references)
|
|
79
80
|
.filter(([_, refObject]) => refObject.location === 'local' || refObject.location === 'import')
|
|
80
81
|
.reduce((type, [src, dst]) => {
|
|
81
|
-
|
|
82
|
+
let renamedType = type;
|
|
83
|
+
if (!type.startsWith(prefix)) {
|
|
84
|
+
renamedType = `I${componentClassName}${type}`;
|
|
85
|
+
}
|
|
82
86
|
return (renamedType
|
|
83
87
|
.replace(new RegExp(`^${src}$`, 'g'), `${dst}`)
|
|
84
88
|
// Capture all instances of the `src` field surrounded by non-word characters on each side and join them.
|
|
85
|
-
.replace(new RegExp(`([^\\w])${src}([^\\w])`, 'g'), (v, p1, p2) =>
|
|
89
|
+
.replace(new RegExp(`([^\\w])${src}([^\\w])`, 'g'), (v, p1, p2) => {
|
|
90
|
+
if ((dst === null || dst === void 0 ? void 0 : dst.location) === 'import') {
|
|
91
|
+
/**
|
|
92
|
+
* Replaces a complex type reference within a generic type.
|
|
93
|
+
* For example, remapping a type like `EventEmitter<CustomEvent<MyEvent<T>>>` to
|
|
94
|
+
* `EventEmitter<CustomEvent<IMyComponentMyEvent<IMyComponentT>>>`.
|
|
95
|
+
*/
|
|
96
|
+
return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
|
|
97
|
+
}
|
|
98
|
+
return [p1, dst, p2].join('');
|
|
99
|
+
}));
|
|
86
100
|
}, event.complexType.original
|
|
87
101
|
.replace(/\n/g, ' ')
|
|
88
102
|
.replace(/\s{2,}/g, ' ')
|
package/dist/index.cjs.js
CHANGED
|
@@ -215,6 +215,7 @@ export class ${tagNameAsPascal} {
|
|
|
215
215
|
* @returns The sanitized event type as a string.
|
|
216
216
|
*/
|
|
217
217
|
const formatOutputType = (componentClassName, event) => {
|
|
218
|
+
const prefix = `I${componentClassName}`;
|
|
218
219
|
/**
|
|
219
220
|
* The original attribute contains the original type defined by the devs.
|
|
220
221
|
* This regexp normalizes the reference, by removing linebreaks,
|
|
@@ -223,11 +224,24 @@ const formatOutputType = (componentClassName, event) => {
|
|
|
223
224
|
return Object.entries(event.complexType.references)
|
|
224
225
|
.filter(([_, refObject]) => refObject.location === 'local' || refObject.location === 'import')
|
|
225
226
|
.reduce((type, [src, dst]) => {
|
|
226
|
-
|
|
227
|
+
let renamedType = type;
|
|
228
|
+
if (!type.startsWith(prefix)) {
|
|
229
|
+
renamedType = `I${componentClassName}${type}`;
|
|
230
|
+
}
|
|
227
231
|
return (renamedType
|
|
228
232
|
.replace(new RegExp(`^${src}$`, 'g'), `${dst}`)
|
|
229
233
|
// Capture all instances of the `src` field surrounded by non-word characters on each side and join them.
|
|
230
|
-
.replace(new RegExp(`([^\\w])${src}([^\\w])`, 'g'), (v, p1, p2) =>
|
|
234
|
+
.replace(new RegExp(`([^\\w])${src}([^\\w])`, 'g'), (v, p1, p2) => {
|
|
235
|
+
if ((dst === null || dst === void 0 ? void 0 : dst.location) === 'import') {
|
|
236
|
+
/**
|
|
237
|
+
* Replaces a complex type reference within a generic type.
|
|
238
|
+
* For example, remapping a type like `EventEmitter<CustomEvent<MyEvent<T>>>` to
|
|
239
|
+
* `EventEmitter<CustomEvent<IMyComponentMyEvent<IMyComponentT>>>`.
|
|
240
|
+
*/
|
|
241
|
+
return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
|
|
242
|
+
}
|
|
243
|
+
return [p1, dst, p2].join('');
|
|
244
|
+
}));
|
|
231
245
|
}, event.complexType.original
|
|
232
246
|
.replace(/\n/g, ' ')
|
|
233
247
|
.replace(/\s{2,}/g, ' ')
|
package/dist/index.js
CHANGED
|
@@ -207,6 +207,7 @@ export class ${tagNameAsPascal} {
|
|
|
207
207
|
* @returns The sanitized event type as a string.
|
|
208
208
|
*/
|
|
209
209
|
const formatOutputType = (componentClassName, event) => {
|
|
210
|
+
const prefix = `I${componentClassName}`;
|
|
210
211
|
/**
|
|
211
212
|
* The original attribute contains the original type defined by the devs.
|
|
212
213
|
* This regexp normalizes the reference, by removing linebreaks,
|
|
@@ -215,11 +216,24 @@ const formatOutputType = (componentClassName, event) => {
|
|
|
215
216
|
return Object.entries(event.complexType.references)
|
|
216
217
|
.filter(([_, refObject]) => refObject.location === 'local' || refObject.location === 'import')
|
|
217
218
|
.reduce((type, [src, dst]) => {
|
|
218
|
-
|
|
219
|
+
let renamedType = type;
|
|
220
|
+
if (!type.startsWith(prefix)) {
|
|
221
|
+
renamedType = `I${componentClassName}${type}`;
|
|
222
|
+
}
|
|
219
223
|
return (renamedType
|
|
220
224
|
.replace(new RegExp(`^${src}$`, 'g'), `${dst}`)
|
|
221
225
|
// Capture all instances of the `src` field surrounded by non-word characters on each side and join them.
|
|
222
|
-
.replace(new RegExp(`([^\\w])${src}([^\\w])`, 'g'), (v, p1, p2) =>
|
|
226
|
+
.replace(new RegExp(`([^\\w])${src}([^\\w])`, 'g'), (v, p1, p2) => {
|
|
227
|
+
if ((dst === null || dst === void 0 ? void 0 : dst.location) === 'import') {
|
|
228
|
+
/**
|
|
229
|
+
* Replaces a complex type reference within a generic type.
|
|
230
|
+
* For example, remapping a type like `EventEmitter<CustomEvent<MyEvent<T>>>` to
|
|
231
|
+
* `EventEmitter<CustomEvent<IMyComponentMyEvent<IMyComponentT>>>`.
|
|
232
|
+
*/
|
|
233
|
+
return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
|
|
234
|
+
}
|
|
235
|
+
return [p1, dst, p2].join('');
|
|
236
|
+
}));
|
|
223
237
|
}, event.complexType.original
|
|
224
238
|
.replace(/\n/g, ' ')
|
|
225
239
|
.replace(/\s{2,}/g, ' ')
|