Package com.vaadin.flow.polymer2lit
Class FrontendConverter
java.lang.Object
com.vaadin.flow.polymer2lit.FrontendConverter
- All Implemented Interfaces:
AutoCloseable
A converter that converts Polymer-based
*.js source files to Lit.
Effectively, this is a wrapper around the convert.ts script.-
Constructor Summary
ConstructorsConstructorDescriptionFrontendConverter(com.vaadin.flow.server.frontend.FrontendTools frontendTools) Creates a converter that runs the bundledconvert.jsscript with the Node.js executable provided by the given tools. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanconvertFile(Path filePath, boolean useLit1, boolean disableOptionalChaining) Converts a single Polymer-based*.jsfile to Lit in place.
-
Constructor Details
-
FrontendConverter
public FrontendConverter(com.vaadin.flow.server.frontend.FrontendTools frontendTools) throws IOException Creates a converter that runs the bundledconvert.jsscript with the Node.js executable provided by the given tools.The script is unpacked into a temporary directory that is removed again by
close(), so the converter has to be closed after use.- Parameters:
frontendTools- the tools used to locate the Node.js executable- Throws:
IOException- if the temporary directory or the script copy cannot be created
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
convertFile
public boolean convertFile(Path filePath, boolean useLit1, boolean disableOptionalChaining) throws IOException, InterruptedException, com.vaadin.flow.internal.FrontendUtils.CommandExecutionException Converts a single Polymer-based*.jsfile to Lit in place.Files that do not contain
PolymerElementare left untouched.- Parameters:
filePath- the file to convertuseLit1-trueto generate Lit 1 compatible output,falseto target the current Lit versiondisableOptionalChaining-trueto avoid the optional chaining operator in the generated output, for tooling that cannot parse it- Returns:
trueif the file was converted,falseif it is not a Polymer file- Throws:
IOException- if the file cannot be read or writtenInterruptedException- if waiting for the converter process is interruptedcom.vaadin.flow.internal.FrontendUtils.CommandExecutionException- if the converter process fails
-