@stencil/angular-output-target
Advanced tools
Comparing version 0.0.1-dev.11724437043.1612ee70 to 0.0.1-dev.11725543716.1fa90560
@@ -1,2 +0,2 @@ | ||
import type { OutputTargetAngular } from './types'; | ||
import { OutputTargetAngular, OutputType } from './types'; | ||
import type { CompilerCtx, ComponentCompilerMeta, Config } from '@stencil/core/internal'; | ||
@@ -8,2 +8,2 @@ export interface ValueAccessor { | ||
export default function generateValueAccessors(compilerCtx: CompilerCtx, components: ComponentCompilerMeta[], outputTarget: OutputTargetAngular, config: Config): Promise<void>; | ||
export declare function createValueAccessor(srcFileContents: string, valueAccessor: ValueAccessor): string; | ||
export declare function createValueAccessor(srcFileContents: string, valueAccessor: ValueAccessor, outputType?: OutputType): string; |
import { EOL } from 'os'; | ||
import path from 'path'; | ||
import { OutputTypes } from './utils'; | ||
export default async function generateValueAccessors(compilerCtx, components, outputTarget, config) { | ||
@@ -28,3 +29,3 @@ if (!Array.isArray(outputTarget.valueAccessorConfigs) || outputTarget.valueAccessorConfigs.length === 0) { | ||
const srcFileContents = await compilerCtx.fs.readFile(srcFilePath); | ||
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType]); | ||
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType], outputTarget.outputType); | ||
await compilerCtx.fs.writeFile(targetFilePath, finalText); | ||
@@ -34,11 +35,12 @@ })); | ||
} | ||
export function createValueAccessor(srcFileContents, valueAccessor) { | ||
export function createValueAccessor(srcFileContents, valueAccessor, outputType) { | ||
const hostContents = valueAccessor.eventTargets.map((listItem) => VALUE_ACCESSOR_EVENTTARGETS.replace(VALUE_ACCESSOR_EVENT, listItem[0]).replace(VALUE_ACCESSOR_TARGETATTR, listItem[1])); | ||
return srcFileContents | ||
.replace(VALUE_ACCESSOR_SELECTORS, valueAccessor.elementSelectors.join(', ')) | ||
.replace(VALUE_ACCESSOR_EVENTTARGETS, hostContents.join(`,${EOL}`)); | ||
.replace(VALUE_ACCESSOR_EVENTTARGETS, hostContents.join(`,${EOL}`)) | ||
.replace(VALUE_ACCESSOR_STANDALONE, outputType && outputType === OutputTypes.Standalone ? ',standalone: true' : ''); | ||
} | ||
function copyResources(config, resourcesFilesToCopy, directory) { | ||
if (!config.sys || !config.sys.copy) { | ||
throw new Error('stencil is not properly intialized at this step. Notify the developer'); | ||
throw new Error('stencil is not properly initialized at this step. Notify the developer'); | ||
} | ||
@@ -58,2 +60,3 @@ const copyTasks = resourcesFilesToCopy.map((rf) => { | ||
const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>'; | ||
const VALUE_ACCESSOR_STANDALONE = '<VALUE_ACCESSOR_STANDALONE>'; | ||
const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`; |
@@ -360,3 +360,3 @@ 'use strict'; | ||
const srcFileContents = await compilerCtx.fs.readFile(srcFilePath); | ||
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType]); | ||
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType], outputTarget.outputType); | ||
await compilerCtx.fs.writeFile(targetFilePath, finalText); | ||
@@ -366,11 +366,12 @@ })); | ||
} | ||
function createValueAccessor(srcFileContents, valueAccessor) { | ||
function createValueAccessor(srcFileContents, valueAccessor, outputType) { | ||
const hostContents = valueAccessor.eventTargets.map((listItem) => VALUE_ACCESSOR_EVENTTARGETS.replace(VALUE_ACCESSOR_EVENT, listItem[0]).replace(VALUE_ACCESSOR_TARGETATTR, listItem[1])); | ||
return srcFileContents | ||
.replace(VALUE_ACCESSOR_SELECTORS, valueAccessor.elementSelectors.join(', ')) | ||
.replace(VALUE_ACCESSOR_EVENTTARGETS, hostContents.join(`,${os.EOL}`)); | ||
.replace(VALUE_ACCESSOR_EVENTTARGETS, hostContents.join(`,${os.EOL}`)) | ||
.replace(VALUE_ACCESSOR_STANDALONE, outputType && outputType === OutputTypes.Standalone ? ',standalone: true' : ''); | ||
} | ||
function copyResources$1(config, resourcesFilesToCopy, directory) { | ||
if (!config.sys || !config.sys.copy) { | ||
throw new Error('stencil is not properly intialized at this step. Notify the developer'); | ||
throw new Error('stencil is not properly initialized at this step. Notify the developer'); | ||
} | ||
@@ -390,2 +391,3 @@ const copyTasks = resourcesFilesToCopy.map((rf) => { | ||
const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>'; | ||
const VALUE_ACCESSOR_STANDALONE = '<VALUE_ACCESSOR_STANDALONE>'; | ||
const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`; | ||
@@ -392,0 +394,0 @@ |
@@ -352,3 +352,3 @@ import path from 'path'; | ||
const srcFileContents = await compilerCtx.fs.readFile(srcFilePath); | ||
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType]); | ||
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType], outputTarget.outputType); | ||
await compilerCtx.fs.writeFile(targetFilePath, finalText); | ||
@@ -358,11 +358,12 @@ })); | ||
} | ||
function createValueAccessor(srcFileContents, valueAccessor) { | ||
function createValueAccessor(srcFileContents, valueAccessor, outputType) { | ||
const hostContents = valueAccessor.eventTargets.map((listItem) => VALUE_ACCESSOR_EVENTTARGETS.replace(VALUE_ACCESSOR_EVENT, listItem[0]).replace(VALUE_ACCESSOR_TARGETATTR, listItem[1])); | ||
return srcFileContents | ||
.replace(VALUE_ACCESSOR_SELECTORS, valueAccessor.elementSelectors.join(', ')) | ||
.replace(VALUE_ACCESSOR_EVENTTARGETS, hostContents.join(`,${EOL}`)); | ||
.replace(VALUE_ACCESSOR_EVENTTARGETS, hostContents.join(`,${EOL}`)) | ||
.replace(VALUE_ACCESSOR_STANDALONE, outputType && outputType === OutputTypes.Standalone ? ',standalone: true' : ''); | ||
} | ||
function copyResources$1(config, resourcesFilesToCopy, directory) { | ||
if (!config.sys || !config.sys.copy) { | ||
throw new Error('stencil is not properly intialized at this step. Notify the developer'); | ||
throw new Error('stencil is not properly initialized at this step. Notify the developer'); | ||
} | ||
@@ -382,2 +383,3 @@ const copyTasks = resourcesFilesToCopy.map((rf) => { | ||
const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>'; | ||
const VALUE_ACCESSOR_STANDALONE = '<VALUE_ACCESSOR_STANDALONE>'; | ||
const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.target.<VALUE_ACCESSOR_TARGETATTR>)'`; | ||
@@ -384,0 +386,0 @@ |
{ | ||
"name": "@stencil/angular-output-target", | ||
"version": "0.0.1-dev.11724437043.1612ee70", | ||
"version": "0.0.1-dev.11725543716.1fa90560", | ||
"description": "Angular output target for @stencil/core components.", | ||
@@ -67,3 +67,3 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"gitHead": "612ee706d141dd58ae9a6bcc1a029df6ee919c8a" | ||
"gitHead": "fa90560e48946ff872ee54461813e5df8b4b2026" | ||
} |
@@ -18,3 +18,3 @@ import { Directive, ElementRef } from '@angular/core'; | ||
} | ||
] | ||
]<VALUE_ACCESSOR_STANDALONE> | ||
}) | ||
@@ -21,0 +21,0 @@ export class BooleanValueAccessor extends ValueAccessor { |
@@ -18,3 +18,3 @@ import { Directive, ElementRef } from '@angular/core'; | ||
} | ||
] | ||
]<VALUE_ACCESSOR_STANDALONE> | ||
}) | ||
@@ -21,0 +21,0 @@ export class NumericValueAccessor extends ValueAccessor { |
@@ -18,3 +18,3 @@ import { Directive, ElementRef } from '@angular/core'; | ||
} | ||
] | ||
]<VALUE_ACCESSOR_STANDALONE> | ||
}) | ||
@@ -21,0 +21,0 @@ export class RadioValueAccessor extends ValueAccessor { |
@@ -18,3 +18,3 @@ import { Directive, ElementRef } from '@angular/core'; | ||
} | ||
] | ||
]<VALUE_ACCESSOR_STANDALONE> | ||
}) | ||
@@ -21,0 +21,0 @@ export class SelectValueAccessor extends ValueAccessor { |
@@ -18,3 +18,3 @@ import { Directive, ElementRef } from '@angular/core'; | ||
} | ||
] | ||
]<VALUE_ACCESSOR_STANDALONE> | ||
}) | ||
@@ -21,0 +21,0 @@ export class TextValueAccessor extends ValueAccessor { |
104883
2043