@stencil/angular-output-target
Advanced tools
Comparing version 0.6.1-dev.11662577182.1c45c8de to 0.6.1-dev.11664502361.139bc7c5
@@ -108,3 +108,3 @@ import { createComponentEventTypeImports, dashToPascalCase, formatToQuotedList } from './utils'; | ||
export const createComponentTypeDefinition = (tagNameAsPascal, events, componentCorePackage, includeImportCustomElements = false, customElementsDir) => { | ||
const publicEvents = events.filter(ev => !ev.internal); | ||
const publicEvents = events.filter((ev) => !ev.internal); | ||
const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, { | ||
@@ -115,4 +115,3 @@ componentCorePackage, | ||
}); | ||
const eventTypes = publicEvents | ||
.map((event) => { | ||
const eventTypes = publicEvents.map((event) => { | ||
const comment = createDocComment(event.docs); | ||
@@ -123,4 +122,6 @@ return `${comment.length > 0 ? ` ${comment}` : ''} | ||
const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`; | ||
const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') | ||
+ `${interfaceDeclaration}${eventTypes.length === 0 ? '}' : ` | ||
const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') + | ||
`${interfaceDeclaration}${eventTypes.length === 0 | ||
? '}' | ||
: ` | ||
${eventTypes.join('\n')} | ||
@@ -127,0 +128,0 @@ }`}`; |
@@ -239,3 +239,3 @@ 'use strict'; | ||
const createComponentTypeDefinition = (tagNameAsPascal, events, componentCorePackage, includeImportCustomElements = false, customElementsDir) => { | ||
const publicEvents = events.filter(ev => !ev.internal); | ||
const publicEvents = events.filter((ev) => !ev.internal); | ||
const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, { | ||
@@ -246,4 +246,3 @@ componentCorePackage, | ||
}); | ||
const eventTypes = publicEvents | ||
.map((event) => { | ||
const eventTypes = publicEvents.map((event) => { | ||
const comment = createDocComment(event.docs); | ||
@@ -254,4 +253,6 @@ return `${comment.length > 0 ? ` ${comment}` : ''} | ||
const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`; | ||
const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') | ||
+ `${interfaceDeclaration}${eventTypes.length === 0 ? '}' : ` | ||
const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') + | ||
`${interfaceDeclaration}${eventTypes.length === 0 | ||
? '}' | ||
: ` | ||
${eventTypes.join('\n')} | ||
@@ -337,19 +338,2 @@ }`}`; | ||
/** | ||
* Creates an Angular module declaration for a component wrapper. | ||
* @param componentTagName The tag name of the Stencil component. | ||
* @returns The Angular module declaration as a string. | ||
*/ | ||
const generateAngularModuleForComponent = (componentTagName) => { | ||
const tagNameAsPascal = dashToPascalCase(componentTagName); | ||
const componentClassName = `${tagNameAsPascal}`; | ||
const moduleClassName = `${tagNameAsPascal}Module`; | ||
const moduleDefinition = `@NgModule({ | ||
declarations: [${componentClassName}], | ||
exports: [${componentClassName}] | ||
}) | ||
export class ${moduleClassName} { }`; | ||
return moduleDefinition; | ||
}; | ||
async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) { | ||
@@ -386,7 +370,5 @@ const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components); | ||
function generateProxies(components, pkgData, outputTarget, rootDir) { | ||
var _a; | ||
const distTypesDir = path__default['default'].dirname(pkgData.types); | ||
const dtsFilePath = path__default['default'].join(rootDir, distTypesDir, GENERATED_DTS); | ||
const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts'); | ||
const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false; | ||
/** | ||
@@ -407,5 +389,2 @@ * The collection of named imports from @angular/core. | ||
const componentLibImports = ['ProxyCmp', 'proxyOutputs']; | ||
if (createSingleComponentAngularModules) { | ||
angularCoreImports.push('NgModule'); | ||
} | ||
const imports = `/* tslint:disable */ | ||
@@ -446,8 +425,2 @@ /* auto-generated angular directive proxies */ | ||
} | ||
if (createSingleComponentAngularModules) { | ||
// Generating Angular modules is only supported in the dist-custom-elements build | ||
if (!outputTarget.includeImportCustomElements) { | ||
throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.'); | ||
} | ||
} | ||
const proxyFileOutput = []; | ||
@@ -478,12 +451,7 @@ const filterInternalProps = (prop) => !prop.internal; | ||
* 1. The @Component decorated class | ||
* 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true) | ||
* 3. The component interface (using declaration merging for types). | ||
* 2. The component interface (using declaration merging for types). | ||
*/ | ||
const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements); | ||
const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName); | ||
const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir); | ||
proxyFileOutput.push(componentDefinition, '\n'); | ||
if (createSingleComponentAngularModules) { | ||
proxyFileOutput.push(moduleDefinition, '\n'); | ||
} | ||
proxyFileOutput.push(componentTypeDefinition, '\n'); | ||
@@ -490,0 +458,0 @@ } |
@@ -231,3 +231,3 @@ import path from 'path'; | ||
const createComponentTypeDefinition = (tagNameAsPascal, events, componentCorePackage, includeImportCustomElements = false, customElementsDir) => { | ||
const publicEvents = events.filter(ev => !ev.internal); | ||
const publicEvents = events.filter((ev) => !ev.internal); | ||
const eventTypeImports = createComponentEventTypeImports(tagNameAsPascal, publicEvents, { | ||
@@ -238,4 +238,3 @@ componentCorePackage, | ||
}); | ||
const eventTypes = publicEvents | ||
.map((event) => { | ||
const eventTypes = publicEvents.map((event) => { | ||
const comment = createDocComment(event.docs); | ||
@@ -246,4 +245,6 @@ return `${comment.length > 0 ? ` ${comment}` : ''} | ||
const interfaceDeclaration = `export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {`; | ||
const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') | ||
+ `${interfaceDeclaration}${eventTypes.length === 0 ? '}' : ` | ||
const typeDefinition = (eventTypeImports.length > 0 ? `${eventTypeImports + '\n\n'}` : '') + | ||
`${interfaceDeclaration}${eventTypes.length === 0 | ||
? '}' | ||
: ` | ||
${eventTypes.join('\n')} | ||
@@ -329,19 +330,2 @@ }`}`; | ||
/** | ||
* Creates an Angular module declaration for a component wrapper. | ||
* @param componentTagName The tag name of the Stencil component. | ||
* @returns The Angular module declaration as a string. | ||
*/ | ||
const generateAngularModuleForComponent = (componentTagName) => { | ||
const tagNameAsPascal = dashToPascalCase(componentTagName); | ||
const componentClassName = `${tagNameAsPascal}`; | ||
const moduleClassName = `${tagNameAsPascal}Module`; | ||
const moduleDefinition = `@NgModule({ | ||
declarations: [${componentClassName}], | ||
exports: [${componentClassName}] | ||
}) | ||
export class ${moduleClassName} { }`; | ||
return moduleDefinition; | ||
}; | ||
async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) { | ||
@@ -378,7 +362,5 @@ const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components); | ||
function generateProxies(components, pkgData, outputTarget, rootDir) { | ||
var _a; | ||
const distTypesDir = path.dirname(pkgData.types); | ||
const dtsFilePath = path.join(rootDir, distTypesDir, GENERATED_DTS); | ||
const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts'); | ||
const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false; | ||
/** | ||
@@ -399,5 +381,2 @@ * The collection of named imports from @angular/core. | ||
const componentLibImports = ['ProxyCmp', 'proxyOutputs']; | ||
if (createSingleComponentAngularModules) { | ||
angularCoreImports.push('NgModule'); | ||
} | ||
const imports = `/* tslint:disable */ | ||
@@ -438,8 +417,2 @@ /* auto-generated angular directive proxies */ | ||
} | ||
if (createSingleComponentAngularModules) { | ||
// Generating Angular modules is only supported in the dist-custom-elements build | ||
if (!outputTarget.includeImportCustomElements) { | ||
throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.'); | ||
} | ||
} | ||
const proxyFileOutput = []; | ||
@@ -470,12 +443,7 @@ const filterInternalProps = (prop) => !prop.internal; | ||
* 1. The @Component decorated class | ||
* 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true) | ||
* 3. The component interface (using declaration merging for types). | ||
* 2. The component interface (using declaration merging for types). | ||
*/ | ||
const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements); | ||
const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName); | ||
const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir); | ||
proxyFileOutput.push(componentDefinition, '\n'); | ||
if (createSingleComponentAngularModules) { | ||
proxyFileOutput.push(moduleDefinition, '\n'); | ||
} | ||
proxyFileOutput.push(componentTypeDefinition, '\n'); | ||
@@ -482,0 +450,0 @@ } |
@@ -6,3 +6,2 @@ import path from 'path'; | ||
import generateValueAccessors from './generate-value-accessors'; | ||
import { generateAngularModuleForComponent } from './generate-angular-modules'; | ||
export async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) { | ||
@@ -39,7 +38,5 @@ const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components); | ||
export function generateProxies(components, pkgData, outputTarget, rootDir) { | ||
var _a; | ||
const distTypesDir = path.dirname(pkgData.types); | ||
const dtsFilePath = path.join(rootDir, distTypesDir, GENERATED_DTS); | ||
const componentsTypeFile = relativeImport(outputTarget.proxyDeclarationFile, dtsFilePath, '.d.ts'); | ||
const createSingleComponentAngularModules = (_a = outputTarget.createSingleComponentAngularModules) !== null && _a !== void 0 ? _a : false; | ||
/** | ||
@@ -60,5 +57,2 @@ * The collection of named imports from @angular/core. | ||
const componentLibImports = ['ProxyCmp', 'proxyOutputs']; | ||
if (createSingleComponentAngularModules) { | ||
angularCoreImports.push('NgModule'); | ||
} | ||
const imports = `/* tslint:disable */ | ||
@@ -99,8 +93,2 @@ /* auto-generated angular directive proxies */ | ||
} | ||
if (createSingleComponentAngularModules) { | ||
// Generating Angular modules is only supported in the dist-custom-elements build | ||
if (!outputTarget.includeImportCustomElements) { | ||
throw new Error('Generating single component Angular modules requires the "includeImportCustomElements" option to be set to true.'); | ||
} | ||
} | ||
const proxyFileOutput = []; | ||
@@ -131,12 +119,7 @@ const filterInternalProps = (prop) => !prop.internal; | ||
* 1. The @Component decorated class | ||
* 2. Optionally the @NgModule decorated class (if createSingleComponentAngularModules is true) | ||
* 3. The component interface (using declaration merging for types). | ||
* 2. The component interface (using declaration merging for types). | ||
*/ | ||
const componentDefinition = createAngularComponentDefinition(cmpMeta.tagName, inputs, outputs, methods, includeImportCustomElements); | ||
const moduleDefinition = generateAngularModuleForComponent(cmpMeta.tagName); | ||
const componentTypeDefinition = createComponentTypeDefinition(tagNameAsPascal, cmpMeta.events, componentCorePackage, includeImportCustomElements, customElementsDir); | ||
proxyFileOutput.push(componentDefinition, '\n'); | ||
if (createSingleComponentAngularModules) { | ||
proxyFileOutput.push(moduleDefinition, '\n'); | ||
} | ||
proxyFileOutput.push(componentTypeDefinition, '\n'); | ||
@@ -143,0 +126,0 @@ } |
@@ -22,6 +22,2 @@ export interface OutputTargetAngular { | ||
customElementsDir?: string; | ||
/** | ||
* `true` to generate a single component Angular module for each component. | ||
*/ | ||
createSingleComponentAngularModules?: boolean; | ||
} | ||
@@ -28,0 +24,0 @@ export declare type ValueAccessorTypes = 'text' | 'radio' | 'select' | 'number' | 'boolean'; |
{ | ||
"name": "@stencil/angular-output-target", | ||
"version": "0.6.1-dev.11662577182.1c45c8de", | ||
"version": "0.6.1-dev.11664502361.139bc7c5", | ||
"description": "Angular output target for @stencil/core components.", | ||
@@ -61,3 +61,3 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"gitHead": "c45c8deb595afb1d5321159783c838fb7131f087" | ||
"gitHead": "39bc7c5aab00038b7b440f51d510010f506a1c54" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87370
27
1751