@stencil/angular-output-target 0.6.1-dev.11662151255.17ea4066 → 0.6.1-dev.11664502361.139bc7c5

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.
@@ -41,8 +41,8 @@ export const createAngularComponentDefinition = (tagName, inputs, outputs, metho
41
41
  const output = `@ProxyCmp({${proxyCmpOptions.join(',')}\n})
42
42
  @Component({
43
43
  selector: '${tagName}',
44
- template: '<ng-content></ng-content>',
45
44
  changeDetection: ChangeDetectionStrategy.OnPush,
45
+ template: '<ng-content></ng-content>',
46
46
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
47
47
  inputs: [${formattedInputs}],
48
48
  })
@@ -105,20 +105,23 @@ const createDocComment = (doc) => {
105
105
  * @returns The component interface type definition as a string.
106
106
  */
107
107
  export const createComponentTypeDefinition = (tagNameAsPascal, events, componentCorePackage, includeImportCustomElements = false, customElementsDir) => {
108
- const typeDefinition = `${createComponentEventTypeImports(tagNameAsPascal, events, {
108
+ const publicEvents = events.filter((ev) => !ev.internal);
109
+ const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, {
109
110
  componentCorePackage,
110
111
  includeImportCustomElements,
111
112
  customElementsDir,
112
- })}
113
-
114
- export interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {
115
- ${events
116
- .map((event) => {
113
+ });
114
+ const eventTypes = publicEvents.map((event) => {
117
115
  const comment = createDocComment(event.docs);
118
116
  return `${comment.length > 0 ? ` ${comment}` : ''}
119
117
  ${event.name}: EventEmitter<CustomEvent<${formatOutputType(tagNameAsPascal, event)}>>;`;
120
- })
121
- .join('\n')}
122
- }`;
118
+ });
119
+ const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`;
120
+ const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') +
121
+ `${interfaceDeclaration}${eventTypes.length === 0
122
+ ? '}'
123
+ : `
124
+ ${eventTypes.join('\n')}
125
+ }`}`;
123
126
  return typeDefinition;
124
127
  };
package/dist/index.cjs.js CHANGED
@@ -172,8 +172,8 @@ const createAngularComponentDefinition = (tagName, inputs, outputs, methods, inc
172
172
  const output = `@ProxyCmp({${proxyCmpOptions.join(',')}\n})
173
173
  @Component({
174
174
  selector: '${tagName}',
175
- template: '<ng-content></ng-content>',
176
175
  changeDetection: ChangeDetectionStrategy.OnPush,
176
+ template: '<ng-content></ng-content>',
177
177
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
178
178
  inputs: [${formattedInputs}],
179
179
  })
@@ -236,21 +236,24 @@ const createDocComment = (doc) => {
236
236
  * @returns The component interface type definition as a string.
237
237
  */
238
238
  const createComponentTypeDefinition = (tagNameAsPascal, events, componentCorePackage, includeImportCustomElements = false, customElementsDir) => {
239
- const typeDefinition = `${createComponentEventTypeImports(tagNameAsPascal, events, {
239
+ const publicEvents = events.filter((ev) => !ev.internal);
240
+ const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, {
240
241
  componentCorePackage,
241
242
  includeImportCustomElements,
242
243
  customElementsDir,
243
- })}
244
-
245
- export interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {
246
- ${events
247
- .map((event) => {
244
+ });
245
+ const eventTypes = publicEvents.map((event) => {
248
246
  const comment = createDocComment(event.docs);
249
247
  return `${comment.length > 0 ? ` ${comment}` : ''}
250
248
  ${event.name}: EventEmitter<CustomEvent<${formatOutputType(tagNameAsPascal, event)}>>;`;
251
- })
252
- .join('\n')}
253
- }`;
249
+ });
250
+ const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`;
251
+ const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') +
252
+ `${interfaceDeclaration}${eventTypes.length === 0
253
+ ? '}'
254
+ : `
255
+ ${eventTypes.join('\n')}
256
+ }`}`;
254
257
  return typeDefinition;
255
258
  };
256
259
 
@@ -329,23 +332,6 @@ const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
329
332
  const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>';
330
333
  const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`;
331
334
 
332
- /**
333
- * Creates an Angular module declaration for a component wrapper.
334
- * @param componentTagName The tag name of the Stencil component.
335
- * @returns The Angular module declaration as a string.
336
- */
337
- const generateAngularModuleForComponent = (componentTagName) => {
338
- const tagNameAsPascal = dashToPascalCase(componentTagName);
339
- const componentClassName = `${tagNameAsPascal}`;
340
- const moduleClassName = `${tagNameAsPascal}Module`;
341
- const moduleDefinition = `@NgModule({
342
- declarations: [${componentClassName}],
343
- exports: [${componentClassName}]
344
- })
345
- export class ${moduleClassName} { }`;
346
- return moduleDefinition;
347
- };
348
-
349
335
  async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
350
336
  const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
351
337
  const rootDir = config.rootDir;
@@ -377,11 +363,9 @@ async function copyResources$1(config, outputTarget) {
377
363
  ], srcDirectory);
378
364
  }
379
365
  function generateProxies(components, pkgData, outputTarget, rootDir) {
380
- var _a;
381
366
  const distTypesDir = path__default['default'].dirname(pkgData.types);
382
367
  const dtsFilePath = path__default['default'].join(rootDir, distTypesDir, GENERATED_DTS);
383
368
  const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts');
384
- const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false;
385
369
  /**
386
370
  * The collection of named imports from @angular/core.
387
371
  */
@@ -397,9 +381,6 @@ function generateProxies(components, pkgData, outputTarget, rootDir) {
397
381
  * The collection of named imports from the angular-component-lib/utils.
398
382
  */
399
383
  const componentLibImports = ['ProxyCmp', 'proxyOutputs'];
400
- if (createSingleComponentAngularModules) {
401
- angularCoreImports.push('NgModule');
402
- }
403
384
  const imports = `/* tslint:disable */
404
385
  /* auto-generated angular directive proxies */
405
386
  ${createImportStatement(angularCoreImports, '@angular/core')}
@@ -435,12 +416,6 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
435
416
  });
436
417
  sourceImports = cmpImports.join('\n');
437
418
  }
438
- if (createSingleComponentAngularModules) {
439
- // Generating Angular modules is only supported in the dist-custom-elements build
440
- if (!outputTarget.includeImportCustomElements) {
441
- throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.');
442
- }
443
- }
444
419
  const proxyFileOutput = [];
445
420
  const filterInternalProps = (prop) => !prop.internal;
446
421
  const mapPropName = (prop) => prop.name;
@@ -466,13 +441,12 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
466
441
  /**
467
442
  * For each component, we need to generate:
468
443
  * 1. The @Component decorated class
469
- * 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true)
470
- * 3. The component interface (using declaration merging for types).
444
+ * 2. The component interface (using declaration merging for types).
471
445
  */
472
446
  const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements);
473
- const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName);
474
447
  const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir);
475
- proxyFileOutput.push(componentDefinition, '\n', createSingleComponentAngularModules ? moduleDefinition : '', '\n', componentTypeDefinition, '\n');
448
+ proxyFileOutput.push(componentDefinition, '\n');
449
+ proxyFileOutput.push(componentTypeDefinition, '\n');
476
450
  }
477
451
  const final = [imports, typeImports, sourceImports, ...proxyFileOutput];
478
452
  return final.join('\n') + '\n';
package/dist/index.js CHANGED
@@ -164,8 +164,8 @@ const createAngularComponentDefinition = (tagName, inputs, outputs, methods, inc
164
164
  const output = `@ProxyCmp({${proxyCmpOptions.join(',')}\n})
165
165
  @Component({
166
166
  selector: '${tagName}',
167
- template: '<ng-content></ng-content>',
168
167
  changeDetection: ChangeDetectionStrategy.OnPush,
168
+ template: '<ng-content></ng-content>',
169
169
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
170
170
  inputs: [${formattedInputs}],
171
171
  })
@@ -228,21 +228,24 @@ const createDocComment = (doc) => {
228
228
  * @returns The component interface type definition as a string.
229
229
  */
230
230
  const createComponentTypeDefinition = (tagNameAsPascal, events, componentCorePackage, includeImportCustomElements = false, customElementsDir) => {
231
- const typeDefinition = `${createComponentEventTypeImports(tagNameAsPascal, events, {
231
+ const publicEvents = events.filter((ev) => !ev.internal);
232
+ const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, {
232
233
  componentCorePackage,
233
234
  includeImportCustomElements,
234
235
  customElementsDir,
235
- })}
236
-
237
- export interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {
238
- ${events
239
- .map((event) => {
236
+ });
237
+ const eventTypes = publicEvents.map((event) => {
240
238
  const comment = createDocComment(event.docs);
241
239
  return `${comment.length > 0 ? ` ${comment}` : ''}
242
240
  ${event.name}: EventEmitter<CustomEvent<${formatOutputType(tagNameAsPascal, event)}>>;`;
243
- })
244
- .join('\n')}
245
- }`;
241
+ });
242
+ const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`;
243
+ const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') +
244
+ `${interfaceDeclaration}${eventTypes.length === 0
245
+ ? '}'
246
+ : `
247
+ ${eventTypes.join('\n')}
248
+ }`}`;
246
249
  return typeDefinition;
247
250
  };
248
251
 
@@ -321,23 +324,6 @@ const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
321
324
  const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>';
322
325
  const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`;
323
326
 
324
- /**
325
- * Creates an Angular module declaration for a component wrapper.
326
- * @param componentTagName The tag name of the Stencil component.
327
- * @returns The Angular module declaration as a string.
328
- */
329
- const generateAngularModuleForComponent = (componentTagName) => {
330
- const tagNameAsPascal = dashToPascalCase(componentTagName);
331
- const componentClassName = `${tagNameAsPascal}`;
332
- const moduleClassName = `${tagNameAsPascal}Module`;
333
- const moduleDefinition = `@NgModule({
334
- declarations: [${componentClassName}],
335
- exports: [${componentClassName}]
336
- })
337
- export class ${moduleClassName} { }`;
338
- return moduleDefinition;
339
- };
340
-
341
327
  async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
342
328
  const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
343
329
  const rootDir = config.rootDir;
@@ -369,11 +355,9 @@ async function copyResources$1(config, outputTarget) {
369
355
  ], srcDirectory);
370
356
  }
371
357
  function generateProxies(components, pkgData, outputTarget, rootDir) {
372
- var _a;
373
358
  const distTypesDir = path.dirname(pkgData.types);
374
359
  const dtsFilePath = path.join(rootDir, distTypesDir, GENERATED_DTS);
375
360
  const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts');
376
- const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false;
377
361
  /**
378
362
  * The collection of named imports from @angular/core.
379
363
  */
@@ -389,9 +373,6 @@ function generateProxies(components, pkgData, outputTarget, rootDir) {
389
373
  * The collection of named imports from the angular-component-lib/utils.
390
374
  */
391
375
  const componentLibImports = ['ProxyCmp', 'proxyOutputs'];
392
- if (createSingleComponentAngularModules) {
393
- angularCoreImports.push('NgModule');
394
- }
395
376
  const imports = `/* tslint:disable */
396
377
  /* auto-generated angular directive proxies */
397
378
  ${createImportStatement(angularCoreImports, '@angular/core')}
@@ -427,12 +408,6 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
427
408
  });
428
409
  sourceImports = cmpImports.join('\n');
429
410
  }
430
- if (createSingleComponentAngularModules) {
431
- // Generating Angular modules is only supported in the dist-custom-elements build
432
- if (!outputTarget.includeImportCustomElements) {
433
- throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.');
434
- }
435
- }
436
411
  const proxyFileOutput = [];
437
412
  const filterInternalProps = (prop) => !prop.internal;
438
413
  const mapPropName = (prop) => prop.name;
@@ -458,13 +433,12 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
458
433
  /**
459
434
  * For each component, we need to generate:
460
435
  * 1. The @Component decorated class
461
- * 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true)
462
- * 3. The component interface (using declaration merging for types).
436
+ * 2. The component interface (using declaration merging for types).
463
437
  */
464
438
  const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements);
465
- const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName);
466
439
  const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir);
467
- proxyFileOutput.push(componentDefinition, '\n', createSingleComponentAngularModules ? moduleDefinition : '', '\n', componentTypeDefinition, '\n');
440
+ proxyFileOutput.push(componentDefinition, '\n');
441
+ proxyFileOutput.push(componentTypeDefinition, '\n');
468
442
  }
469
443
  const final = [imports, typeImports, sourceImports, ...proxyFileOutput];
470
444
  return final.join('\n') + '\n';
@@ -3,7 +3,6 @@ import { relativeImport, normalizePath, sortBy, readPackageJson, dashToPascalCas
3
3
  import { createAngularComponentDefinition, createComponentTypeDefinition } from './generate-angular-component';
4
4
  import { generateAngularDirectivesFile } from './generate-angular-directives-file';
5
5
  import generateValueAccessors from './generate-value-accessors';
6
- import { generateAngularModuleForComponent } from './generate-angular-modules';
7
6
  export async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
8
7
  const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
9
8
  const rootDir = config.rootDir;
@@ -35,11 +34,9 @@ async function copyResources(config, outputTarget) {
35
34
  ], srcDirectory);
36
35
  }
37
36
  export function generateProxies(components, pkgData, outputTarget, rootDir) {
38
- var _a;
39
37
  const distTypesDir = path.dirname(pkgData.types);
40
38
  const dtsFilePath = path.join(rootDir, distTypesDir, GENERATED_DTS);
41
39
  const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts');
42
- const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false;
43
40
  /**
44
41
  * The collection of named imports from @angular/core.
45
42
  */
@@ -55,9 +52,6 @@ export function generateProxies(components, pkgData, outputTarget, rootDir) {
55
52
  * The collection of named imports from the angular-component-lib/utils.
56
53
  */
57
54
  const componentLibImports = ['ProxyCmp', 'proxyOutputs'];
58
- if (createSingleComponentAngularModules) {
59
- angularCoreImports.push('NgModule');
60
- }
61
55
  const imports = `/* tslint:disable */
62
56
  /* auto-generated angular directive proxies */
63
57
  ${createImportStatement(angularCoreImports, '@angular/core')}
@@ -93,12 +87,6 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
93
87
  });
94
88
  sourceImports = cmpImports.join('\n');
95
89
  }
96
- if (createSingleComponentAngularModules) {
97
- // Generating Angular modules is only supported in the dist-custom-elements build
98
- if (!outputTarget.includeImportCustomElements) {
99
- throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.');
100
- }
101
- }
102
90
  const proxyFileOutput = [];
103
91
  const filterInternalProps = (prop) => !prop.internal;
104
92
  const mapPropName = (prop) => prop.name;
@@ -124,13 +112,12 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
124
112
  /**
125
113
  * For each component, we need to generate:
126
114
  * 1. The @Component decorated class
127
- * 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true)
128
- * 3. The component interface (using declaration merging for types).
115
+ * 2. The component interface (using declaration merging for types).
129
116
  */
130
117
  const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements);
131
- const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName);
132
118
  const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir);
133
- proxyFileOutput.push(componentDefinition, '\n', createSingleComponentAngularModules ? moduleDefinition : '', '\n', componentTypeDefinition, '\n');
119
+ proxyFileOutput.push(componentDefinition, '\n');
120
+ proxyFileOutput.push(componentTypeDefinition, '\n');
134
121
  }
135
122
  const final = [imports, typeImports, sourceImports, ...proxyFileOutput];
136
123
  return final.join('\n') + '\n';
package/dist/types.d.ts CHANGED
@@ -19,10 +19,6 @@ export interface OutputTargetAngular {
19
19
  excludeComponents?: string[];
20
20
  includeImportCustomElements?: boolean;
21
21
  customElementsDir?: string;
22
- /**
23
- * `true` to generate a single component Angular module for each component.
24
- */
25
- createSingleComponentAngularModules?: boolean;
26
22
  }
27
23
  export declare type ValueAccessorTypes = 'text' | 'radio' | 'select' | 'number' | 'boolean';
28
24
  export interface ValueAccessorConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/angular-output-target",
3
- "version": "0.6.1-dev.11662151255.17ea4066",
3
+ "version": "0.6.1-dev.11664502361.139bc7c5",
4
4
  "description": "Angular output target for @stencil/core components.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -58,5 +58,5 @@
58
58
  ],
59
59
  "testURL": "http://localhost"
60
60
  },
61
- "gitHead": "7ea40666153180bc16a62602feba11b767d8e396"
61
+ "gitHead": "39bc7c5aab00038b7b440f51d510010f506a1c54"
62
62
  }
@@ -1,6 +0,0 @@
1
- /**
2
- * Creates an Angular module declaration for a component wrapper.
3
- * @param componentTagName The tag name of the Stencil component.
4
- * @returns The Angular module declaration as a string.
5
- */
6
- export declare const generateAngularModuleForComponent: (componentTagName: string) => string;
@@ -1,17 +0,0 @@
1
- import { dashToPascalCase } from './utils';
2
- /**
3
- * Creates an Angular module declaration for a component wrapper.
4
- * @param componentTagName The tag name of the Stencil component.
5
- * @returns The Angular module declaration as a string.
6
- */
7
- export const generateAngularModuleForComponent = (componentTagName) => {
8
- const tagNameAsPascal = dashToPascalCase(componentTagName);
9
- const componentClassName = `${tagNameAsPascal}`;
10
- const moduleClassName = `${tagNameAsPascal}Module`;
11
- const moduleDefinition = `@NgModule({
12
- declarations: [${componentClassName}],
13
- exports: [${componentClassName}]
14
- })
15
- export class ${moduleClassName} { }`;
16
- return moduleDefinition;
17
- };