@stencil/angular-output-target 0.2.0 → 0.2.1-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.
@@ -18,9 +18,6 @@ export const createComponentDefinition = (componentCorePackage, distTypesDir, ro
18
18
  if (inputs.length > 0) {
19
19
  directiveOpts.push(`inputs: ['${inputs.join(`', '`)}']`);
20
20
  }
21
- if (outputs.length > 0) {
22
- directiveOpts.push(`outputs: ['${outputs.map((output) => output.name).join(`', '`)}']`);
23
- }
24
21
  const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);
25
22
  const outputsInterface = new Set();
26
23
  const outputReferenceRemap = {};
@@ -36,19 +33,14 @@ export const createComponentDefinition = (componentCorePackage, distTypesDir, ro
36
33
  }
37
34
  });
38
35
  });
39
- const lines = [
40
- '',
41
- `${[...outputsInterface].join('\n')}
42
- export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {}
43
- ${getProxyCmp(inputs, methods)}
44
- @Component({
45
- ${directiveOpts.join(',\n ')}
46
- })
47
- export class ${tagNameAsPascal} {`,
36
+ const componentEvents = [
37
+ '' // Empty first line
48
38
  ];
49
39
  // Generate outputs
50
- outputs.forEach((output) => {
51
- lines.push(` /** ${output.docs.text} ${output.docs.tags.map((tag) => `@${tag.name} ${tag.text}`)}*/`);
40
+ outputs.forEach((output, index) => {
41
+ componentEvents.push(` /**
42
+ * ${output.docs.text} ${output.docs.tags.map((tag) => `@${tag.name} ${tag.text}`)}
43
+ */`);
52
44
  /**
53
45
  * The original attribute contains the original type defined by the devs.
54
46
  * This regexp normalizes the reference, by removing linebreaks,
@@ -62,8 +54,23 @@ export class ${tagNameAsPascal} {`,
62
54
  .replace(/\n/g, ' ')
63
55
  .replace(/\s{2,}/g, ' ')
64
56
  .replace(/,\s*/g, ', '));
65
- lines.push(` ${output.name}!: EventEmitter<CustomEvent<${outputTypeRemapped.trim()}>>;`);
57
+ componentEvents.push(` ${output.name}: EventEmitter<CustomEvent<${outputTypeRemapped.trim()}>>;`);
58
+ if (index === outputs.length - 1) {
59
+ // Empty line to push end `}` to new line
60
+ componentEvents.push('\n');
61
+ }
66
62
  });
63
+ const lines = [
64
+ '',
65
+ `${[...outputsInterface].join('\n')}
66
+ export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {${componentEvents.length > 1 ? componentEvents.join('\n') : ''}}
67
+
68
+ ${getProxyCmp(inputs, methods)}
69
+ @Component({
70
+ ${directiveOpts.join(',\n ')}
71
+ })
72
+ export class ${tagNameAsPascal} {`,
73
+ ];
67
74
  lines.push(' protected el: HTMLElement;');
68
75
  lines.push(` constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
69
76
  c.detach();
package/dist/index.cjs.js CHANGED
@@ -107,9 +107,6 @@ const createComponentDefinition = (componentCorePackage, distTypesDir, rootDir)
107
107
  if (inputs.length > 0) {
108
108
  directiveOpts.push(`inputs: ['${inputs.join(`', '`)}']`);
109
109
  }
110
- if (outputs.length > 0) {
111
- directiveOpts.push(`outputs: ['${outputs.map((output) => output.name).join(`', '`)}']`);
112
- }
113
110
  const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);
114
111
  const outputsInterface = new Set();
115
112
  const outputReferenceRemap = {};
@@ -125,19 +122,14 @@ const createComponentDefinition = (componentCorePackage, distTypesDir, rootDir)
125
122
  }
126
123
  });
127
124
  });
128
- const lines = [
129
- '',
130
- `${[...outputsInterface].join('\n')}
131
- export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {}
132
- ${getProxyCmp(inputs, methods)}
133
- @Component({
134
- ${directiveOpts.join(',\n ')}
135
- })
136
- export class ${tagNameAsPascal} {`,
125
+ const componentEvents = [
126
+ '' // Empty first line
137
127
  ];
138
128
  // Generate outputs
139
- outputs.forEach((output) => {
140
- lines.push(` /** ${output.docs.text} ${output.docs.tags.map((tag) => `@${tag.name} ${tag.text}`)}*/`);
129
+ outputs.forEach((output, index) => {
130
+ componentEvents.push(` /**
131
+ * ${output.docs.text} ${output.docs.tags.map((tag) => `@${tag.name} ${tag.text}`)}
132
+ */`);
141
133
  /**
142
134
  * The original attribute contains the original type defined by the devs.
143
135
  * This regexp normalizes the reference, by removing linebreaks,
@@ -151,8 +143,23 @@ export class ${tagNameAsPascal} {`,
151
143
  .replace(/\n/g, ' ')
152
144
  .replace(/\s{2,}/g, ' ')
153
145
  .replace(/,\s*/g, ', '));
154
- lines.push(` ${output.name}!: EventEmitter<CustomEvent<${outputTypeRemapped.trim()}>>;`);
146
+ componentEvents.push(` ${output.name}: EventEmitter<CustomEvent<${outputTypeRemapped.trim()}>>;`);
147
+ if (index === outputs.length - 1) {
148
+ // Empty line to push end `}` to new line
149
+ componentEvents.push('\n');
150
+ }
155
151
  });
152
+ const lines = [
153
+ '',
154
+ `${[...outputsInterface].join('\n')}
155
+ export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {${componentEvents.length > 1 ? componentEvents.join('\n') : ''}}
156
+
157
+ ${getProxyCmp(inputs, methods)}
158
+ @Component({
159
+ ${directiveOpts.join(',\n ')}
160
+ })
161
+ export class ${tagNameAsPascal} {`,
162
+ ];
156
163
  lines.push(' protected el: HTMLElement;');
157
164
  lines.push(` constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
158
165
  c.detach();
package/dist/index.js CHANGED
@@ -98,9 +98,6 @@ const createComponentDefinition = (componentCorePackage, distTypesDir, rootDir)
98
98
  if (inputs.length > 0) {
99
99
  directiveOpts.push(`inputs: ['${inputs.join(`', '`)}']`);
100
100
  }
101
- if (outputs.length > 0) {
102
- directiveOpts.push(`outputs: ['${outputs.map((output) => output.name).join(`', '`)}']`);
103
- }
104
101
  const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);
105
102
  const outputsInterface = new Set();
106
103
  const outputReferenceRemap = {};
@@ -116,19 +113,14 @@ const createComponentDefinition = (componentCorePackage, distTypesDir, rootDir)
116
113
  }
117
114
  });
118
115
  });
119
- const lines = [
120
- '',
121
- `${[...outputsInterface].join('\n')}
122
- export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {}
123
- ${getProxyCmp(inputs, methods)}
124
- @Component({
125
- ${directiveOpts.join(',\n ')}
126
- })
127
- export class ${tagNameAsPascal} {`,
116
+ const componentEvents = [
117
+ '' // Empty first line
128
118
  ];
129
119
  // Generate outputs
130
- outputs.forEach((output) => {
131
- lines.push(` /** ${output.docs.text} ${output.docs.tags.map((tag) => `@${tag.name} ${tag.text}`)}*/`);
120
+ outputs.forEach((output, index) => {
121
+ componentEvents.push(` /**
122
+ * ${output.docs.text} ${output.docs.tags.map((tag) => `@${tag.name} ${tag.text}`)}
123
+ */`);
132
124
  /**
133
125
  * The original attribute contains the original type defined by the devs.
134
126
  * This regexp normalizes the reference, by removing linebreaks,
@@ -142,8 +134,23 @@ export class ${tagNameAsPascal} {`,
142
134
  .replace(/\n/g, ' ')
143
135
  .replace(/\s{2,}/g, ' ')
144
136
  .replace(/,\s*/g, ', '));
145
- lines.push(` ${output.name}!: EventEmitter<CustomEvent<${outputTypeRemapped.trim()}>>;`);
137
+ componentEvents.push(` ${output.name}: EventEmitter<CustomEvent<${outputTypeRemapped.trim()}>>;`);
138
+ if (index === outputs.length - 1) {
139
+ // Empty line to push end `}` to new line
140
+ componentEvents.push('\n');
141
+ }
146
142
  });
143
+ const lines = [
144
+ '',
145
+ `${[...outputsInterface].join('\n')}
146
+ export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {${componentEvents.length > 1 ? componentEvents.join('\n') : ''}}
147
+
148
+ ${getProxyCmp(inputs, methods)}
149
+ @Component({
150
+ ${directiveOpts.join(',\n ')}
151
+ })
152
+ export class ${tagNameAsPascal} {`,
153
+ ];
147
154
  lines.push(' protected el: HTMLElement;');
148
155
  lines.push(` constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
149
156
  c.detach();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/angular-output-target",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-0",
4
4
  "description": "Angular output target for @stencil/core components.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",