New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@atlaspack/transformer-html

Package Overview
Dependencies
Maintainers
0
Versions
306
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaspack/transformer-html - npm Package Compare versions

Comparing version

to
2.12.1-dev.3443

test/HTMLTransformer.test.js

32

lib/HTMLTransformer.js

@@ -7,2 +7,4 @@ "use strict";

exports.default = void 0;
exports.parseHTML = parseHTML;
exports.transformerOpts = void 0;
function _plugin() {

@@ -60,3 +62,15 @@ const data = require("@atlaspack/plugin");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = exports.default = new (_plugin().Transformer)({
function parseHTML(code, xmlMode) {
return {
type: 'posthtml',
version: '0.4.1',
program: (0, _posthtmlParser().parser)(code, {
lowerCaseTags: true,
lowerCaseAttributeNames: true,
sourceLocations: true,
xmlMode
})
};
}
const transformerOpts = exports.transformerOpts = {
canReuseAST({

@@ -70,12 +84,5 @@ ast

}) {
return {
type: 'posthtml',
version: '0.4.1',
program: (0, _posthtmlParser().parser)(await asset.getCode(), {
lowerCaseTags: true,
lowerCaseAttributeNames: true,
sourceLocations: true,
xmlMode: asset.type === 'xhtml'
})
};
const code = await asset.getCode();
const xmlMode = asset.type === 'xhtml';
return parseHTML(code, xmlMode);
},

@@ -159,3 +166,4 @@ async transform({

}
});
};
var _default = exports.default = new (_plugin().Transformer)(transformerOpts);
function findFirstMatch(ast, expressions) {

@@ -162,0 +170,0 @@ let found;

{
"name": "@atlaspack/transformer-html",
"version": "2.12.1-dev.3401+b483af77f",
"license": "MIT",
"version": "2.12.1-dev.3443+d1170cfc7",
"license": "(MIT OR Apache-2.0)",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "mocha"
},
"repository": {

@@ -16,8 +19,8 @@ "type": "git",

"node": ">= 16.0.0",
"parcel": "^2.12.1-dev.3401+b483af77f"
"parcel": "^2.12.1-dev.3443+d1170cfc7"
},
"dependencies": {
"@atlaspack/diagnostic": "2.12.1-dev.3401+b483af77f",
"@atlaspack/plugin": "2.12.1-dev.3401+b483af77f",
"@atlaspack/rust": "2.12.1-dev.3401+b483af77f",
"@atlaspack/diagnostic": "2.12.1-dev.3443+d1170cfc7",
"@atlaspack/plugin": "2.12.1-dev.3443+d1170cfc7",
"@atlaspack/rust": "2.12.1-dev.3443+d1170cfc7",
"nullthrows": "^1.1.1",

@@ -30,3 +33,6 @@ "posthtml": "^0.16.5",

},
"gitHead": "b483af77f02d1258c8dad156e097b94f83671d8e"
"devDependencies": {
"@atlaspack/core": "2.12.1-dev.3443+d1170cfc7"
},
"gitHead": "d1170cfc79beb290b2a066f472f68f71f7d7cb23"
}
// @flow
import {Transformer} from '@atlaspack/plugin';
import type {AST} from '@atlaspack/types';
import type {AST, Transformer as TransformerOpts} from '@atlaspack/types';
import {parser as parse} from 'posthtml-parser';

@@ -15,3 +15,16 @@ import nullthrows from 'nullthrows';

export default (new Transformer({
export function parseHTML(code: string, xmlMode: boolean): AST {
return {
type: 'posthtml',
version: '0.4.1',
program: parse(code, {
lowerCaseTags: true,
lowerCaseAttributeNames: true,
sourceLocations: true,
xmlMode,
}),
};
}
export const transformerOpts: TransformerOpts<void> = {
canReuseAST({ast}) {

@@ -22,12 +35,5 @@ return ast.type === 'posthtml' && semver.satisfies(ast.version, '^0.4.0');

async parse({asset}) {
return {
type: 'posthtml',
version: '0.4.1',
program: parse(await asset.getCode(), {
lowerCaseTags: true,
lowerCaseAttributeNames: true,
sourceLocations: true,
xmlMode: asset.type === 'xhtml',
}),
};
const code = await asset.getCode();
const xmlMode = asset.type === 'xhtml';
return parseHTML(code, xmlMode);
},

@@ -111,3 +117,4 @@

},
}): Transformer);
};
export default (new Transformer(transformerOpts): Transformer);

@@ -114,0 +121,0 @@ function findFirstMatch(