Comparing version 1.1.2 to 2.0.0
@@ -18,20 +18,34 @@ "use strict"; | ||
exports.convert = void 0; | ||
const compiler_dom_1 = require("@vue/compiler-dom"); | ||
const construct_tree_1 = __importDefault(require("hyntax/lib/construct-tree")); | ||
const tokenize_1 = __importDefault(require("hyntax/lib/tokenize")); | ||
const ast_helpers_1 = require("./ast-helpers"); | ||
const compile_ast_1 = require("./compile-ast"); | ||
const convert_ast_1 = require("./convert-ast"); | ||
function buildAst(html) { | ||
const convert_ast_1 = require("./html/convert-ast"); | ||
const convert_ast_2 = require("./vue/convert-ast"); | ||
function buildHtmlAst(html) { | ||
return construct_tree_1.default(tokenize_1.default(html).tokens).ast; | ||
} | ||
function buildVueAst(html) { | ||
return compiler_dom_1.parse(html); | ||
} | ||
const setupDefaultOptions = (_a) => { | ||
var { attrComma = true } = _a, options = __rest(_a, ["attrComma"]); | ||
return (Object.assign({ attrSep: attrComma ? ', ' : ' ', bodyLess: false, doubleQuotes: true, encode: true, inlineCSS: false, symbol: ' ' }, options)); | ||
return (Object.assign({ attrSep: attrComma ? ', ' : ' ', bodyLess: false, doubleQuotes: true, encode: true, inlineCSS: false, symbol: ' ', parser: 'html' }, options)); | ||
}; | ||
function convert(html, options = {}) { | ||
const definedOptions = setupDefaultOptions(options); | ||
const ast = buildAst(html); | ||
const convertedAst = convert_ast_1.convertAst(ast, definedOptions); | ||
return compile_ast_1.compileAst(convertedAst, definedOptions); | ||
// eslint-disable-next-line functional/no-let | ||
let convertedAst; | ||
if (definedOptions.parser === 'html') { | ||
const ast = buildHtmlAst(html); | ||
convertedAst = convert_ast_1.convertHtmlAst(ast); | ||
} | ||
else { | ||
const ast = buildVueAst(html); | ||
convertedAst = convert_ast_2.converVueAst(ast); | ||
} | ||
return compile_ast_1.compileAst(options.bodyLess ? convertedAst : ast_helpers_1.wrapIntoBase(convertedAst), definedOptions); | ||
} | ||
exports.convert = convert; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxl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UFNLElBQ1gsT0FBTyxFQUNWLENBQUE7Q0FBQSxDQUFDO0FBRUgsU0FBZ0IsT0FBTyxDQUFDLElBQVksRUFBRSxVQUFrQyxFQUFFO0lBQ3hFLE1BQU0sY0FBYyxHQUFHLG1CQUFtQixDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3BELDZDQUE2QztJQUM3QyxJQUFJLFlBQThCLENBQUM7SUFDbkMsSUFBSSxjQUFjLENBQUMsTUFBTSxLQUFLLE1BQU0sRUFBRTtRQUNwQyxNQUFNLEdBQUcsR0FBRyxZQUFZLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDL0IsWUFBWSxHQUFHLDRCQUFjLENBQUMsR0FBRyxDQUFDLENBQUM7S0FDcEM7U0FBTTtRQUNMLE1BQU0sR0FBRyxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUM5QixZQUFZLEdBQUcsMEJBQVksQ0FBQyxHQUFHLENBQUMsQ0FBQztLQUNsQztJQUNELE9BQU8sd0JBQVUsQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLDBCQUFZLENBQUMsWUFBWSxDQUFDLEVBQUUsY0FBYyxDQUFDLENBQUM7QUFDbEcsQ0FBQztBQVpELDBCQVlDIn0= |
@@ -49,2 +49,3 @@ export declare enum Node { | ||
readonly symbol: string; | ||
readonly parser: 'html' | 'vue'; | ||
}; | ||
@@ -58,2 +59,3 @@ export declare type ConvertOptions = { | ||
readonly symbol: string; | ||
readonly parser: 'html' | 'vue'; | ||
}; | ||
@@ -60,0 +62,0 @@ export declare type IndentOptions = { |
@@ -12,19 +12,33 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
}; | ||
import { parse } from '@vue/compiler-dom'; | ||
import constructTree from 'hyntax/lib/construct-tree'; | ||
import tokenize from 'hyntax/lib/tokenize'; | ||
import { wrapIntoBase } from './ast-helpers'; | ||
import { compileAst } from './compile-ast'; | ||
import { convertAst } from './convert-ast'; | ||
function buildAst(html) { | ||
import { convertHtmlAst } from './html/convert-ast'; | ||
import { converVueAst } from './vue/convert-ast'; | ||
function buildHtmlAst(html) { | ||
return constructTree(tokenize(html).tokens).ast; | ||
} | ||
function buildVueAst(html) { | ||
return parse(html); | ||
} | ||
const setupDefaultOptions = (_a) => { | ||
var { attrComma = true } = _a, options = __rest(_a, ["attrComma"]); | ||
return (Object.assign({ attrSep: attrComma ? ', ' : ' ', bodyLess: false, doubleQuotes: true, encode: true, inlineCSS: false, symbol: ' ' }, options)); | ||
return (Object.assign({ attrSep: attrComma ? ', ' : ' ', bodyLess: false, doubleQuotes: true, encode: true, inlineCSS: false, symbol: ' ', parser: 'html' }, options)); | ||
}; | ||
export function convert(html, options = {}) { | ||
const definedOptions = setupDefaultOptions(options); | ||
const ast = buildAst(html); | ||
const convertedAst = convertAst(ast, definedOptions); | ||
return compileAst(convertedAst, definedOptions); | ||
// eslint-disable-next-line functional/no-let | ||
let convertedAst; | ||
if (definedOptions.parser === 'html') { | ||
const ast = buildHtmlAst(html); | ||
convertedAst = convertHtmlAst(ast); | ||
} | ||
else { | ||
const ast = buildVueAst(html); | ||
convertedAst = converVueAst(ast); | ||
} | ||
return compileAst(options.bodyLess ? convertedAst : wrapIntoBase(convertedAst), definedOptions); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udmVydC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9saWIvY29udmVydC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLE9BQU8sYUFBYSxNQUFNLDJCQUEyQixDQUFDO0FBQ3RELE9BQU8sUUFBUSxNQUFNLHFCQUFxQixDQUFDO0FBRTNDLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0MsT0FBTyxFQUF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QUUsSUFBSSxFQUNaLE1BQU0sRUFBRSxNQUFNLElBQ1gsT0FBTyxFQUNWLENBQUE7Q0FBQSxDQUFDO0FBRUgsTUFBTSxVQUFVLE9BQU8sQ0FBQyxJQUFZLEVBQUUsVUFBa0MsRUFBRTtJQUN4RSxNQUFNLGNBQWMsR0FBRyxtQkFBbUIsQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUNwRCw2Q0FBNkM7SUFDN0MsSUFBSSxZQUE4QixDQUFDO0lBQ25DLElBQUksY0FBYyxDQUFDLE1BQU0sS0FBSyxNQUFNLEVBQUU7UUFDcEMsTUFBTSxHQUFHLEdBQUcsWUFBWSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQy9CLFlBQVksR0FBRyxjQUFjLENBQUMsR0FBRyxDQUFDLENBQUM7S0FDcEM7U0FBTTtRQUNMLE1BQU0sR0FBRyxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUM5QixZQUFZLEdBQUcsWUFBWSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0tBQ2xDO0lBQ0QsT0FBTyxVQUFVLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxZQUFZLENBQUMsWUFBWSxDQUFDLEVBQUUsY0FBYyxDQUFDLENBQUM7QUFDbEcsQ0FBQyJ9 |
@@ -49,2 +49,3 @@ export declare enum Node { | ||
readonly symbol: string; | ||
readonly parser: 'html' | 'vue'; | ||
}; | ||
@@ -58,2 +59,3 @@ export declare type ConvertOptions = { | ||
readonly symbol: string; | ||
readonly parser: 'html' | 'vue'; | ||
}; | ||
@@ -60,0 +62,0 @@ export declare type IndentOptions = { |
@@ -5,2 +5,9 @@ # Changelog | ||
## [2.0.0](https://github.com/dimensi/xhtml2pug/compare/v1.1.2...v2.0.0) (2022-01-01) | ||
### Features | ||
* add vue parser ([7525f44](https://github.com/dimensi/xhtml2pug/commit/7525f447f9c1770dd71ec9417bd7325beab0b4f3)) | ||
### [1.1.2](https://github.com/dimensi/xhtml2pug/compare/v1.1.1...v1.1.2) (2021-01-31) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "xhtml2pug", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "library for convert html2pug", | ||
@@ -52,2 +52,3 @@ "main": "build/main/index.js", | ||
"dependencies": { | ||
"@vue/compiler-dom": "^3.2.26", | ||
"html-entities": "^2.1.0", | ||
@@ -54,0 +55,0 @@ "hyntax": "^1.1.9" |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
111689
44
1237
3
3
+ Added@vue/compiler-dom@^3.2.26
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Added@vue/compiler-core@3.5.13(transitive)
+ Added@vue/compiler-dom@3.5.13(transitive)
+ Added@vue/shared@3.5.13(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedestree-walker@2.0.2(transitive)
+ Addedsource-map-js@1.2.1(transitive)