@stylable/code-formatter
Advanced tools
Comparing version 5.6.1 to 5.7.0
import { CSSBeautifyOptions } from 'js-beautify'; | ||
import { FormatOptions } from './format-css'; | ||
export declare function formatDocumentExperimental(source: string, options: Partial<FormatOptions>): string; | ||
export declare function getDocumentFormatting(content: string, offset?: { | ||
@@ -3,0 +5,0 @@ start: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDocumentFormatting = void 0; | ||
exports.getDocumentFormatting = exports.formatDocumentExperimental = void 0; | ||
const index_internal_1 = require("@stylable/core/dist/index-internal"); | ||
const js_beautify_1 = require("js-beautify"); | ||
const format_css_1 = require("./format-css"); | ||
/* new experimental formatter */ | ||
function formatDocumentExperimental(source, options) { | ||
// ToDo: support range | ||
let targetCss = source; | ||
try { | ||
targetCss = (0, format_css_1.formatCSS)(source, options); | ||
} | ||
catch (e) { | ||
// return unchanged source on error | ||
} | ||
return targetCss; | ||
} | ||
exports.formatDocumentExperimental = formatDocumentExperimental; | ||
/* format with js-prettify */ | ||
function getDocumentFormatting(content, offset, options) { | ||
@@ -7,0 +22,0 @@ const offsetStart = (offset === null || offset === void 0 ? void 0 : offset.start) || 0; |
@@ -1,2 +0,3 @@ | ||
export { getDocumentFormatting } from './formatter'; | ||
export { formatDocumentExperimental, getDocumentFormatting } from './formatter'; | ||
export { formatCSS } from './format-css'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDocumentFormatting = void 0; | ||
exports.formatCSS = exports.getDocumentFormatting = exports.formatDocumentExperimental = void 0; | ||
var formatter_1 = require("./formatter"); | ||
Object.defineProperty(exports, "formatDocumentExperimental", { enumerable: true, get: function () { return formatter_1.formatDocumentExperimental; } }); | ||
Object.defineProperty(exports, "getDocumentFormatting", { enumerable: true, get: function () { return formatter_1.getDocumentFormatting; } }); | ||
var format_css_1 = require("./format-css"); | ||
Object.defineProperty(exports, "formatCSS", { enumerable: true, get: function () { return format_css_1.formatCSS; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@stylable/code-formatter", | ||
"version": "5.6.1", | ||
"version": "5.7.0", | ||
"description": "A code formatting utility for Stylable stylesheets", | ||
@@ -10,4 +10,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@stylable/core": "^5.6.1", | ||
"js-beautify": "^1.14.7" | ||
"@stylable/core": "^5.7.0", | ||
"@tokey/css-value-parser": "^0.1.2", | ||
"js-beautify": "^1.14.7", | ||
"postcss": "^8.4.21" | ||
}, | ||
@@ -14,0 +16,0 @@ "files": [ |
import { safeParse } from '@stylable/core/dist/index-internal'; | ||
import { css, CSSBeautifyOptions } from 'js-beautify'; | ||
import type { Root } from 'postcss'; | ||
import { formatCSS, FormatOptions } from './format-css'; | ||
/* new experimental formatter */ | ||
export function formatDocumentExperimental(source: string, options: Partial<FormatOptions>) { | ||
// ToDo: support range | ||
let targetCss = source; | ||
try { | ||
targetCss = formatCSS(source, options); | ||
} catch (e) { | ||
// return unchanged source on error | ||
} | ||
return targetCss; | ||
} | ||
/* format with js-prettify */ | ||
export function getDocumentFormatting( | ||
@@ -6,0 +22,0 @@ content: string, |
@@ -1,1 +0,2 @@ | ||
export { getDocumentFormatting } from './formatter'; | ||
export { formatDocumentExperimental, getDocumentFormatting } from './formatter'; | ||
export { formatCSS } from './format-css'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
86329
18
1502
4
1
+ Addedpostcss@^8.4.21
Updated@stylable/core@^5.7.0