@stencil/angular-output-target 0.6.1-dev.11662577182.1c45c8de → 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.
@@ -105,21 +105,22 @@ 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 publicEvents = events.filter(ev => !ev.internal);
108
+ const publicEvents = events.filter((ev) => !ev.internal);
109
109
  const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, {
110
110
  componentCorePackage,
111
111
  includeImportCustomElements,
112
112
  customElementsDir,
113
113
  });
114
- const eventTypes = publicEvents
115
- .map((event) => {
114
+ const eventTypes = publicEvents.map((event) => {
116
115
  const comment = createDocComment(event.docs);
117
116
  return `${comment.length > 0 ? ` ${comment}` : ''}
118
117
  ${event.name}: EventEmitter<CustomEvent<${formatOutputType(tagNameAsPascal, event)}>>;`;
119
118
  });
120
119
  const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`;
121
- const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '')
122
- + `${interfaceDeclaration}${eventTypes.length === 0 ? '}' : `
120
+ const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') +
121
+ `${interfaceDeclaration}${eventTypes.length === 0
122
+ ? '}'
123
+ : `
123
124
  ${eventTypes.join('\n')}
124
125
  }`}`;
125
126
  return typeDefinition;
package/dist/index.cjs.js CHANGED
@@ -236,21 +236,22 @@ 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 publicEvents = events.filter(ev => !ev.internal);
239
+ const publicEvents = events.filter((ev) => !ev.internal);
240
240
  const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, {
241
241
  componentCorePackage,
242
242
  includeImportCustomElements,
243
243
  customElementsDir,
244
244
  });
245
- const eventTypes = publicEvents
246
- .map((event) => {
245
+ const eventTypes = publicEvents.map((event) => {
247
246
  const comment = createDocComment(event.docs);
248
247
  return `${comment.length > 0 ? ` ${comment}` : ''}
249
248
  ${event.name}: EventEmitter<CustomEvent<${formatOutputType(tagNameAsPascal, event)}>>;`;
250
249
  });
251
250
  const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`;
252
- const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '')
253
- + `${interfaceDeclaration}${eventTypes.length === 0 ? '}' : `
251
+ const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') +
252
+ `${interfaceDeclaration}${eventTypes.length === 0
253
+ ? '}'
254
+ : `
254
255
  ${eventTypes.join('\n')}
255
256
  }`}`;
256
257
  return typeDefinition;
@@ -331,23 +332,6 @@ const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
331
332
  const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>';
332
333
  const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`;
333
334
 
334
- /**
335
- * Creates an Angular module declaration for a component wrapper.
336
- * @param componentTagName The tag name of the Stencil component.
337
- * @returns The Angular module declaration as a string.
338
- */
339
- const generateAngularModuleForComponent = (componentTagName) => {
340
- const tagNameAsPascal = dashToPascalCase(componentTagName);
341
- const componentClassName = `${tagNameAsPascal}`;
342
- const moduleClassName = `${tagNameAsPascal}Module`;
343
- const moduleDefinition = `@NgModule({
344
- declarations: [${componentClassName}],
345
- exports: [${componentClassName}]
346
- })
347
- export class ${moduleClassName} { }`;
348
- return moduleDefinition;
349
- };
350
-
351
335
  async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
352
336
  const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
353
337
  const rootDir = config.rootDir;
@@ -379,11 +363,9 @@ async function copyResources$1(config, outputTarget) {
379
363
  ], srcDirectory);
380
364
  }
381
365
  function generateProxies(components, pkgData, outputTarget, rootDir) {
382
- var _a;
383
366
  const distTypesDir = path__default['default'].dirname(pkgData.types);
384
367
  const dtsFilePath = path__default['default'].join(rootDir, distTypesDir, GENERATED_DTS);
385
368
  const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts');
386
- const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false;
387
369
  /**
388
370
  * The collection of named imports from @angular/core.
389
371
  */
@@ -399,9 +381,6 @@ function generateProxies(components, pkgData, outputTarget, rootDir) {
399
381
  * The collection of named imports from the angular-component-lib/utils.
400
382
  */
401
383
  const componentLibImports = ['ProxyCmp', 'proxyOutputs'];
402
- if (createSingleComponentAngularModules) {
403
- angularCoreImports.push('NgModule');
404
- }
405
384
  const imports = `/* tslint:disable */
406
385
  /* auto-generated angular directive proxies */
407
386
  ${createImportStatement(angularCoreImports, '@angular/core')}
@@ -437,12 +416,6 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
437
416
  });
438
417
  sourceImports = cmpImports.join('\n');
439
418
  }
440
- if (createSingleComponentAngularModules) {
441
- // Generating Angular modules is only supported in the dist-custom-elements build
442
- if (!outputTarget.includeImportCustomElements) {
443
- throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.');
444
- }
445
- }
446
419
  const proxyFileOutput = [];
447
420
  const filterInternalProps = (prop) => !prop.internal;
448
421
  const mapPropName = (prop) => prop.name;
@@ -468,16 +441,11 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
468
441
  /**
469
442
  * For each component, we need to generate:
470
443
  * 1. The @Component decorated class
471
- * 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true)
472
- * 3. The component interface (using declaration merging for types).
444
+ * 2. The component interface (using declaration merging for types).
473
445
  */
474
446
  const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements);
475
- const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName);
476
447
  const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir);
477
448
  proxyFileOutput.push(componentDefinition, '\n');
478
- if (createSingleComponentAngularModules) {
479
- proxyFileOutput.push(moduleDefinition, '\n');
480
- }
481
449
  proxyFileOutput.push(componentTypeDefinition, '\n');
482
450
  }
483
451
  const final = [imports, typeImports, sourceImports, ...proxyFileOutput];
package/dist/index.js CHANGED
@@ -228,21 +228,22 @@ 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 publicEvents = events.filter(ev => !ev.internal);
231
+ const publicEvents = events.filter((ev) => !ev.internal);
232
232
  const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, {
233
233
  componentCorePackage,
234
234
  includeImportCustomElements,
235
235
  customElementsDir,
236
236
  });
237
- const eventTypes = publicEvents
238
- .map((event) => {
237
+ const eventTypes = publicEvents.map((event) => {
239
238
  const comment = createDocComment(event.docs);
240
239
  return `${comment.length > 0 ? ` ${comment}` : ''}
241
240
  ${event.name}: EventEmitter<CustomEvent<${formatOutputType(tagNameAsPascal, event)}>>;`;
242
241
  });
243
242
  const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`;
244
- const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '')
245
- + `${interfaceDeclaration}${eventTypes.length === 0 ? '}' : `
243
+ const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') +
244
+ `${interfaceDeclaration}${eventTypes.length === 0
245
+ ? '}'
246
+ : `
246
247
  ${eventTypes.join('\n')}
247
248
  }`}`;
248
249
  return typeDefinition;
@@ -323,23 +324,6 @@ const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
323
324
  const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>';
324
325
  const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`;
325
326
 
326
- /**
327
- * Creates an Angular module declaration for a component wrapper.
328
- * @param componentTagName The tag name of the Stencil component.
329
- * @returns The Angular module declaration as a string.
330
- */
331
- const generateAngularModuleForComponent = (componentTagName) => {
332
- const tagNameAsPascal = dashToPascalCase(componentTagName);
333
- const componentClassName = `${tagNameAsPascal}`;
334
- const moduleClassName = `${tagNameAsPascal}Module`;
335
- const moduleDefinition = `@NgModule({
336
- declarations: [${componentClassName}],
337
- exports: [${componentClassName}]
338
- })
339
- export class ${moduleClassName} { }`;
340
- return moduleDefinition;
341
- };
342
-
343
327
  async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
344
328
  const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
345
329
  const rootDir = config.rootDir;
@@ -371,11 +355,9 @@ async function copyResources$1(config, outputTarget) {
371
355
  ], srcDirectory);
372
356
  }
373
357
  function generateProxies(components, pkgData, outputTarget, rootDir) {
374
- var _a;
375
358
  const distTypesDir = path.dirname(pkgData.types);
376
359
  const dtsFilePath = path.join(rootDir, distTypesDir, GENERATED_DTS);
377
360
  const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts');
378
- const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false;
379
361
  /**
380
362
  * The collection of named imports from @angular/core.
381
363
  */
@@ -391,9 +373,6 @@ function generateProxies(components, pkgData, outputTarget, rootDir) {
391
373
  * The collection of named imports from the angular-component-lib/utils.
392
374
  */
393
375
  const componentLibImports = ['ProxyCmp', 'proxyOutputs'];
394
- if (createSingleComponentAngularModules) {
395
- angularCoreImports.push('NgModule');
396
- }
397
376
  const imports = `/* tslint:disable */
398
377
  /* auto-generated angular directive proxies */
399
378
  ${createImportStatement(angularCoreImports, '@angular/core')}
@@ -429,12 +408,6 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
429
408
  });
430
409
  sourceImports = cmpImports.join('\n');
431
410
  }
432
- if (createSingleComponentAngularModules) {
433
- // Generating Angular modules is only supported in the dist-custom-elements build
434
- if (!outputTarget.includeImportCustomElements) {
435
- throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.');
436
- }
437
- }
438
411
  const proxyFileOutput = [];
439
412
  const filterInternalProps = (prop) => !prop.internal;
440
413
  const mapPropName = (prop) => prop.name;
@@ -460,16 +433,11 @@ ${createImportStatement(componentLibImports, './angular-component-lib/utils')}\n
460
433
  /**
461
434
  * For each component, we need to generate:
462
435
  * 1. The @Component decorated class
463
- * 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true)
464
- * 3. The component interface (using declaration merging for types).
436
+ * 2. The component interface (using declaration merging for types).
465
437
  */
466
438
  const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements);
467
- const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName);
468
439
  const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir);
469
440
  proxyFileOutput.push(componentDefinition, '\n');
470
- if (createSingleComponentAngularModules) {
471
- proxyFileOutput.push(moduleDefinition, '\n');
472
- }
473
441
  proxyFileOutput.push(componentTypeDefinition, '\n');
474
442
  }
475
443
  const final = [imports, typeImports, sourceImports, ...proxyFileOutput];
@@ -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,16 +112,11 @@ ${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
119
  proxyFileOutput.push(componentDefinition, '\n');
134
- if (createSingleComponentAngularModules) {
135
- proxyFileOutput.push(moduleDefinition, '\n');
136
- }
137
120
  proxyFileOutput.push(componentTypeDefinition, '\n');
138
121
  }
139
122
  const final = [imports, typeImports, sourceImports, ...proxyFileOutput];
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.11662577182.1c45c8de",
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": "c45c8deb595afb1d5321159783c838fb7131f087"
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
- };