🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

18
node_modules/sass-formatter/dist/config.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
export interface SassFormatterConfig {
/**Enable debug messages */
debug: boolean;
/**delete rows that are empty. */
deleteEmptyRows: boolean;
/**@deprecated*/
deleteWhitespace: boolean;
/**Convert css or scss to sass */
convert: boolean;
/**set the space after the colon of a property to one.*/
setPropertySpace: boolean;
tabSize: number;
/**insert spaces or tabs. */
insertSpaces: boolean;
/**Defaults to LF*/
lineEnding: 'LF' | 'CRLF';
}
export declare const defaultSassFormatterConfig: SassFormatterConfig;

13
node_modules/sass-formatter/dist/config.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
exports.__esModule = true;
exports.defaultSassFormatterConfig = void 0;
exports.defaultSassFormatterConfig = {
insertSpaces: true,
tabSize: 2,
convert: true,
debug: false,
deleteEmptyRows: true,
deleteWhitespace: true,
setPropertySpace: true,
lineEnding: 'LF'
};

View file

@ -0,0 +1,3 @@
import { SassTextLine } from '../sassTextLine';
import { FormattingState } from '../state';
export declare function FormatAtForwardOrAtUse(line: SassTextLine, STATE: FormattingState): string;

View file

@ -0,0 +1,22 @@
"use strict";
exports.__esModule = true;
exports.FormatAtForwardOrAtUse = void 0;
var format_convert_1 = require("./format.convert");
var utility_1 = require("../utility");
var logger_1 = require("../logger");
function FormatAtForwardOrAtUse(line, STATE) {
if (utility_1.convertLine(line, STATE)) {
var convertRes = format_convert_1.convertScssOrCss(line.get(), STATE);
line.set(convertRes.text);
}
line.set(line.get().trimStart());
logger_1.PushDebugInfo({
title: '@forward or @use',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: line.get(),
debug: STATE.CONFIG.debug
});
return line.get();
}
exports.FormatAtForwardOrAtUse = FormatAtForwardOrAtUse;

View file

@ -0,0 +1,2 @@
import { FormattingState } from '../state';
export declare function FormatHandleBlockComment(text: string, STATE: FormattingState): string;

View file

@ -0,0 +1,11 @@
"use strict";
exports.__esModule = true;
exports.FormatHandleBlockComment = void 0;
var utility_1 = require("../utility");
function FormatHandleBlockComment(text, STATE) {
if (/^[\t ]*\/\*/.test(text)) {
return utility_1.replaceSpacesOrTabs(text, STATE);
}
return utility_1.replaceWithOffset(text, utility_1.getIndentationOffset(text, STATE.CONTEXT.blockCommentDistance + 1, STATE.CONFIG.tabSize).offset, STATE);
}
exports.FormatHandleBlockComment = FormatHandleBlockComment;

View file

@ -0,0 +1,6 @@
import { FormattingState } from '../state';
/** converts scss/css to sass. */
export declare function convertScssOrCss(text: string, STATE: FormattingState): {
lastSelector: string;
text: string;
};

View file

@ -0,0 +1,94 @@
"use strict";
exports.__esModule = true;
exports.convertScssOrCss = void 0;
var regex_1 = require("../regex/regex");
var logger_1 = require("../logger");
var utility_1 = require("../utility");
var format_property_1 = require("./format.property");
/** converts scss/css to sass. */
function convertScssOrCss(text, STATE) {
var isMultiple = regex_1.isMoreThanOneClassOrId(text);
var lastSelector = STATE.CONTEXT.convert.lastSelector;
// if NOT interpolated class, id or partial
if (!/[\t ]*[#.%]\{.*?}/.test(text)) {
if (lastSelector && new RegExp('^.*' + regex_1.escapeRegExp(lastSelector)).test(text)) {
/*istanbul ignore if */
if (STATE.CONFIG.debug)
logger_1.SetConvertData({ type: 'LAST SELECTOR', text: text });
return {
lastSelector: lastSelector,
text: utility_1.replaceWithOffset(removeInvalidChars(text.replaceAll(lastSelector, '&')).trimEnd(), STATE.CONFIG.tabSize, STATE)
};
}
else if (regex_1.isCssOneLiner(text)) {
/*istanbul ignore if */
if (STATE.CONFIG.debug)
logger_1.SetConvertData({ type: 'ONE LINER', text: text });
var split = text.split('{');
var properties = split[1].split(';');
// Set isProp to true so that it Sets the property space.
STATE.LOCAL_CONTEXT.isProp = true;
var selector = split[0].trim();
return {
lastSelector: selector,
text: selector.concat('\n', properties
.map(function (v) {
return utility_1.replaceWithOffset(format_property_1.setPropertyValueSpaces(STATE, removeInvalidChars(v)).trim(), STATE.CONFIG.tabSize, STATE);
})
.join('\n')).trimEnd()
};
}
else if (regex_1.isCssPseudo(text) && !isMultiple) {
/*istanbul ignore if */
if (STATE.CONFIG.debug)
logger_1.SetConvertData({ type: 'PSEUDO', text: text });
return {
lastSelector: lastSelector,
text: removeInvalidChars(text).trimEnd()
};
}
else if (regex_1.isCssSelector(text)) {
/*istanbul ignore if */
if (STATE.CONFIG.debug)
logger_1.SetConvertData({ type: 'SELECTOR', text: text });
lastSelector = removeInvalidChars(text).trimEnd();
return { text: lastSelector, lastSelector: lastSelector };
}
}
/*istanbul ignore if */
if (STATE.CONFIG.debug)
logger_1.SetConvertData({ type: 'DEFAULT', text: text });
return { text: removeInvalidChars(text).trimEnd(), lastSelector: lastSelector };
}
exports.convertScssOrCss = convertScssOrCss;
function removeInvalidChars(text) {
var newText = '';
var isInQuotes = false;
var isInComment = false;
var isInInterpolation = false;
var quoteChar = '';
for (var i = 0; i < text.length; i++) {
var char = text[i];
if (!isInQuotes && char === '/' && text[i + 1] === '/') {
isInComment = true;
}
else if (/['"]/.test(char)) {
if (!isInQuotes || char === quoteChar) {
isInQuotes = !isInQuotes;
if (isInQuotes) {
quoteChar = char;
}
}
}
else if (/#/.test(char) && /{/.test(text[i + 1])) {
isInInterpolation = true;
}
else if (isInInterpolation && /}/.test(text[i - 1])) {
isInInterpolation = false;
}
if (!/[;\{\}]/.test(char) || isInQuotes || isInComment || isInInterpolation) {
newText += char;
}
}
return newText;
}

View file

@ -0,0 +1,3 @@
import { SassTextLine } from '../sassTextLine';
import { FormattingState } from '../state';
export declare function FormatBlockHeader(line: SassTextLine, STATE: FormattingState): string;

View file

@ -0,0 +1,102 @@
"use strict";
exports.__esModule = true;
exports.FormatBlockHeader = void 0;
var logger_1 = require("../logger");
var regex_1 = require("../regex/regex");
var utility_1 = require("../utility");
var format_convert_1 = require("./format.convert");
function FormatBlockHeader(line, STATE) {
var replaceSpaceOrTabs = false;
var hasBeenConverted = false;
var edit = line.get();
// First Convert then set Offset.
if (STATE.CONFIG.convert &&
regex_1.isScssOrCss(line.get()) &&
!regex_1.isComment(line.get())) {
var convertRes = format_convert_1.convertScssOrCss(line.get(), STATE);
STATE.CONTEXT.convert.lastSelector = convertRes.lastSelector;
line.set(convertRes.text);
STATE.LOCAL_CONTEXT.indentation = utility_1.getIndentationOffset(line.get(), STATE.CONTEXT.indentation, STATE.CONFIG.tabSize);
hasBeenConverted = true;
}
// Set offset.
var offset = STATE.LOCAL_CONTEXT.isAdjacentSelector && STATE.CONTEXT.wasLastLineSelector
? STATE.CONTEXT.lastSelectorIndentation - STATE.LOCAL_CONTEXT.indentation.distance
: utility_1.getBlockHeaderOffset(STATE.LOCAL_CONTEXT.indentation.distance, STATE.CONFIG.tabSize, STATE.CONTEXT.indentation, STATE.LOCAL_CONTEXT.isReset);
if (STATE.LOCAL_CONTEXT.isElse && STATE.CONTEXT["if"].isIn) {
offset = (STATE.CONTEXT["if"].indentation - STATE.CONFIG.tabSize) - STATE.LOCAL_CONTEXT.indentation.distance;
}
else if (!STATE.LOCAL_CONTEXT.isIf) {
STATE.CONTEXT.keyframes.isIn =
STATE.LOCAL_CONTEXT.isAtKeyframes || STATE.LOCAL_CONTEXT.isAtKeyframesPoint;
}
STATE.CONTEXT.allowSpace = false;
if (!hasBeenConverted && STATE.LOCAL_CONTEXT.isClassOrIdSelector) {
STATE.CONTEXT.convert.lastSelector = '';
}
STATE.CONTEXT.convert.wasLastLineCss = hasBeenConverted;
if (STATE.CONTEXT.firstCommaHeader.exists) {
offset = STATE.CONTEXT.firstCommaHeader.distance - STATE.LOCAL_CONTEXT.indentation.distance;
}
if (line.get().trim().endsWith(',')) {
if (STATE.CONTEXT.firstCommaHeader.exists !== true) {
STATE.CONTEXT.firstCommaHeader.distance = STATE.LOCAL_CONTEXT.indentation.distance + offset;
}
STATE.CONTEXT.firstCommaHeader.exists = true;
}
else {
STATE.CONTEXT.firstCommaHeader.exists = false;
}
// Convert Spaces to tabs or vice versa depending on the config.
if (STATE.CONFIG.insertSpaces ? /\t/g.test(line.get()) : / /g.test(line.get())) {
line.set(utility_1.replaceSpacesOrTabs(line.get(), STATE));
replaceSpaceOrTabs = true;
}
// Set edit or just return the line text.
if (offset !== 0) {
edit = utility_1.replaceWithOffset(line.get(), offset, STATE).trimRight();
logger_1.PushDebugInfo({
title: 'BLOCK HEADER: MOVE',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: edit,
debug: STATE.CONFIG.debug,
replaceSpaceOrTabs: replaceSpaceOrTabs,
offset: offset
});
}
else {
edit = line.get().trimRight();
logger_1.PushDebugInfo({
title: 'BLOCK HEADER: DEFAULT',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: edit,
debug: STATE.CONFIG.debug,
replaceSpaceOrTabs: replaceSpaceOrTabs
});
}
STATE.CONTEXT.lastSelectorIndentation = Math.max(STATE.LOCAL_CONTEXT.indentation.distance + offset, 0);
if (STATE.LOCAL_CONTEXT.isReset) {
STATE.CONTEXT.indentation = Math.max(0, STATE.LOCAL_CONTEXT.indentation.distance + offset);
}
else {
STATE.CONTEXT.indentation = Math.max(0, STATE.LOCAL_CONTEXT.indentation.distance +
offset + // keep in mind that +offset can decrease the number.
STATE.CONFIG.tabSize);
}
if (STATE.LOCAL_CONTEXT.isAtKeyframes) {
STATE.CONTEXT.keyframes.indentation = STATE.CONTEXT.indentation;
}
if (STATE.LOCAL_CONTEXT.isIf) {
STATE.CONTEXT["if"].indentation = STATE.CONTEXT.indentation;
STATE.CONTEXT["if"].isIn = true;
}
else {
STATE.CONTEXT["if"].isIn = false;
}
STATE.CONTEXT.wasLastHeaderIncludeMixin = STATE.LOCAL_CONTEXT.isInclude;
STATE.CONTEXT.wasLastHeaderNestedProp = STATE.LOCAL_CONTEXT.isNestPropHead;
return edit;
}
exports.FormatBlockHeader = FormatBlockHeader;

View file

@ -0,0 +1,4 @@
import { SassTextLine } from '../sassTextLine';
import { FormattingState } from '../state';
export declare function FormatProperty(line: SassTextLine, STATE: FormattingState): string;
export declare function setPropertyValueSpaces(STATE: FormattingState, text: string): string;

View file

@ -0,0 +1,109 @@
"use strict";
exports.__esModule = true;
exports.setPropertyValueSpaces = exports.FormatProperty = void 0;
var logger_1 = require("../logger");
var regex_1 = require("../regex/regex");
var utility_1 = require("../utility");
var format_convert_1 = require("./format.convert");
function FormatProperty(line, STATE) {
var convert = false;
var replaceSpaceOrTabs = false;
var edit = line.get();
var isComment = regex_1.isComment(line.get());
line.set(setPropertyValueSpaces(STATE, line.get()));
if (utility_1.convertLine(line, STATE)) {
var convertRes = format_convert_1.convertScssOrCss(line.get(), STATE);
line.set(convertRes.text);
convert = true;
}
// Set Context Vars
STATE.CONTEXT.convert.wasLastLineCss = convert;
var move = STATE.LOCAL_CONTEXT.indentation.offset !== 0 && !isComment;
if (!move && canReplaceSpacesOrTabs(STATE, line.get())) {
line.set(utility_1.replaceSpacesOrTabs(line.get(), STATE).trimRight());
replaceSpaceOrTabs = true;
}
// Return
if (move) {
var offset = STATE.LOCAL_CONTEXT.indentation.offset;
var distance = STATE.LOCAL_CONTEXT.indentation.distance;
if (STATE.CONTEXT.wasLastHeaderIncludeMixin || STATE.CONTEXT.wasLastHeaderNestedProp) {
if (distance >= STATE.CONTEXT.indentation - STATE.CONFIG.tabSize) {
offset = utility_1.getBlockHeaderOffset(distance, STATE.CONFIG.tabSize, STATE.CONTEXT.indentation, false);
}
else {
offset = (STATE.CONTEXT.indentation - STATE.CONFIG.tabSize) - distance;
STATE.CONTEXT.wasLastHeaderIncludeMixin = false;
STATE.CONTEXT.wasLastHeaderNestedProp = false;
STATE.CONTEXT.indentation = STATE.CONTEXT.indentation - STATE.CONFIG.tabSize;
}
}
else if (STATE.LOCAL_CONTEXT.isVariable || STATE.LOCAL_CONTEXT.isImport) {
offset = utility_1.getBlockHeaderOffset(distance, STATE.CONFIG.tabSize, STATE.CONTEXT.indentation, false);
}
edit = utility_1.replaceWithOffset(line.get(), offset, STATE).trimRight();
logger_1.PushDebugInfo({
title: 'PROPERTY: MOVE',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: edit,
debug: STATE.CONFIG.debug,
offset: offset,
originalOffset: STATE.LOCAL_CONTEXT.indentation.offset,
replaceSpaceOrTabs: replaceSpaceOrTabs
});
}
else {
edit = line.get().trimRight();
logger_1.PushDebugInfo({
title: 'PROPERTY: DEFAULT',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: edit,
debug: STATE.CONFIG.debug,
replaceSpaceOrTabs: replaceSpaceOrTabs
});
}
if (STATE.CONTEXT.keyframes.isIn && STATE.LOCAL_CONTEXT.isAtKeyframesPoint) {
STATE.CONTEXT.indentation = Math.max(0, STATE.CONTEXT.indentation + STATE.CONFIG.tabSize);
}
return edit;
}
exports.FormatProperty = FormatProperty;
function canReplaceSpacesOrTabs(STATE, text) {
return STATE.CONFIG.insertSpaces
? /\t/g.test(text)
: new RegExp(' '.repeat(STATE.CONFIG.tabSize), 'g').test(text);
}
function setPropertyValueSpaces(STATE, text) {
if (text &&
(!STATE.LOCAL_CONTEXT.isHtmlTag &&
(STATE.LOCAL_CONTEXT.isProp || STATE.LOCAL_CONTEXT.isInterpolatedProp || STATE.LOCAL_CONTEXT.isVariable) &&
STATE.CONFIG.setPropertySpace)) {
var newPropValue = '';
var _a = text.split(/:(.*)/), propName = _a[0], propValue = _a[1];
var wasLastCharSpace = true;
for (var i = 0; i < propValue.length; i++) {
var char = propValue[i];
switch (char) {
case ' ':
if (!wasLastCharSpace) {
newPropValue += char;
wasLastCharSpace = true;
}
break;
case '.':
wasLastCharSpace = true;
newPropValue += char;
break;
default:
wasLastCharSpace = false;
newPropValue += char;
break;
}
}
return propName.trimEnd() + ":" + (propValue ? ' ' + newPropValue : '');
}
return text;
}
exports.setPropertyValueSpaces = setPropertyValueSpaces;

12
node_modules/sass-formatter/dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,12 @@
import { SassFormatterConfig } from './config';
export { defaultSassFormatterConfig, SassFormatterConfig } from './config';
export declare class SassFormatter {
static Format(text: string, config?: Partial<SassFormatterConfig>): string;
private static formatLine;
private static handleCommentBlock;
private static handleEmptyLine;
private static isBlockHeader;
private static isProperty;
/** Adds new Line If not first line. */
private static addNewLine;
}

257
node_modules/sass-formatter/dist/index.js generated vendored Normal file
View file

@ -0,0 +1,257 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
exports.__esModule = true;
exports.SassFormatter = exports.defaultSassFormatterConfig = void 0;
var format_atForwardOrAtUse_1 = require("./formatters/format.atForwardOrAtUse");
var format_blockComment_1 = require("./formatters/format.blockComment");
var format_header_1 = require("./formatters/format.header");
var format_property_1 = require("./formatters/format.property");
var logger_1 = require("./logger");
var regex_1 = require("./regex/regex");
var sassTextLine_1 = require("./sassTextLine");
var state_1 = require("./state");
var utility_1 = require("./utility");
var config_1 = require("./config");
__createBinding(exports, config_1, "defaultSassFormatterConfig");
var SassFormatter = /** @class */ (function () {
function SassFormatter() {
}
SassFormatter.Format = function (text, config) {
var STATE = new state_1.FormattingState();
STATE.lines = text.split(/\r?\n/);
STATE.CONFIG = __assign(__assign({}, STATE.CONFIG), config);
STATE.LINE_ENDING = STATE.CONFIG.lineEnding === 'LF' ? '\n' : '\r\n';
for (var i = 0; i < STATE.lines.length; i++) {
STATE.currentLine = i;
this.formatLine(new sassTextLine_1.SassTextLine(STATE.lines[i]), STATE);
}
if (!STATE.RESULT.endsWith(STATE.LINE_ENDING)) {
this.addNewLine(STATE);
}
if (STATE.CONFIG.debug) {
logger_1.LogDebugResult(STATE.RESULT);
logger_1.ResetDebugLog();
}
return STATE.RESULT;
};
SassFormatter.formatLine = function (line, STATE) {
if (regex_1.isBlockCommentStart(line.get())) {
STATE.CONTEXT.isInBlockComment = true;
STATE.CONTEXT.blockCommentDistance = regex_1.getDistance(line.get(), STATE.CONFIG.tabSize);
}
else if (STATE.CONTEXT.isInBlockComment &&
STATE.CONTEXT.blockCommentDistance >= regex_1.getDistance(line.get(), STATE.CONFIG.tabSize)) {
STATE.CONTEXT.isInBlockComment = false;
STATE.CONTEXT.blockCommentDistance = 0;
}
if (STATE.CONTEXT.ignoreLine) {
STATE.CONTEXT.ignoreLine = false;
this.addNewLine(STATE);
STATE.RESULT += line.get();
logger_1.PushDebugInfo({
title: 'IGNORED',
lineNumber: STATE.currentLine,
oldLineText: line.get(),
debug: STATE.CONFIG.debug,
newLineText: 'NULL'
});
}
else if (STATE.CONTEXT.isInBlockComment) {
this.handleCommentBlock(STATE, line);
}
else {
if (regex_1.isIgnore(line.get())) {
STATE.CONTEXT.ignoreLine = true;
this.addNewLine(STATE);
STATE.RESULT += line.get();
logger_1.PushDebugInfo({
title: 'IGNORE',
lineNumber: STATE.currentLine,
oldLineText: line.get(),
debug: STATE.CONFIG.debug,
newLineText: 'NULL'
});
}
else {
if (regex_1.isSassSpace(line.get())) {
STATE.CONTEXT.allowSpace = true;
}
// ####### Empty Line #######
if (line.isEmptyOrWhitespace ||
(STATE.CONFIG.convert ? regex_1.isBracketOrWhitespace(line.get()) : false)) {
this.handleEmptyLine(STATE, line);
}
else {
STATE.setLocalContext({
isAtKeyframesPoint: utility_1.isKeyframePointAndSetIndentation(line, STATE),
indentation: utility_1.getIndentationOffset(line.get(), STATE.CONTEXT.indentation, STATE.CONFIG.tabSize),
isIf: /[\t ]*@if/i.test(line.get()),
isElse: /[\t ]*@else/i.test(line.get()),
isAtKeyframes: regex_1.isKeyframes(line.get()),
isReset: regex_1.isReset(line.get()),
isAnd: regex_1.isAnd(line.get()),
isProp: regex_1.isProperty(line.get()),
isAdjacentSelector: regex_1.isAdjacentSelector(line.get()),
isHtmlTag: regex_1.isHtmlTag(line.get().trim().split(' ')[0]),
isClassOrIdSelector: regex_1.isClassOrId(line.get()),
isAtExtend: regex_1.isAtExtend(line.get()),
isInterpolatedProp: regex_1.isInterpolatedProperty(line.get()),
isInclude: regex_1.isInclude(line.get()),
isVariable: regex_1.isVar(line.get()),
isImport: regex_1.isAtImport(line.get()),
isNestPropHead: /^[\t ]* \S*[\t ]*:[\t ]*\{?$/.test(line.get())
});
if (STATE.CONFIG.debug) {
if (/\/\/[\t ]*info[\t ]*$/.test(line.get())) {
logger_1.SetDebugLOCAL_CONTEXT(STATE.LOCAL_CONTEXT);
}
}
// ####### Is @forward or @use #######
if (regex_1.isAtForwardOrAtUse(line.get())) {
this.addNewLine(STATE);
STATE.RESULT += format_atForwardOrAtUse_1.FormatAtForwardOrAtUse(line, STATE);
}
// ####### Block Header #######
else if (this.isBlockHeader(line, STATE)) {
this.addNewLine(STATE);
STATE.RESULT += format_header_1.FormatBlockHeader(line, STATE);
}
// ####### Properties or Vars #######
else if (this.isProperty(STATE)) {
STATE.CONTEXT.firstCommaHeader.exists = false;
this.addNewLine(STATE);
STATE.RESULT += format_property_1.FormatProperty(line, STATE);
}
else {
logger_1.PushDebugInfo({
title: 'NO CHANGE',
lineNumber: STATE.currentLine,
oldLineText: line.get(),
debug: STATE.CONFIG.debug,
newLineText: 'NULL'
});
this.addNewLine(STATE);
STATE.RESULT += line.get();
}
// set CONTEXT Variables
STATE.CONTEXT.wasLastLineSelector =
STATE.LOCAL_CONTEXT.isClassOrIdSelector ||
STATE.LOCAL_CONTEXT.isAdjacentSelector ||
STATE.LOCAL_CONTEXT.isHtmlTag;
}
}
}
};
SassFormatter.handleCommentBlock = function (STATE, line) {
this.addNewLine(STATE);
var edit = format_blockComment_1.FormatHandleBlockComment(line.get(), STATE);
STATE.RESULT += edit;
if (regex_1.isBlockCommentEnd(line.get())) {
STATE.CONTEXT.isInBlockComment = false;
}
logger_1.PushDebugInfo({
title: 'COMMENT BLOCK',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: edit,
debug: STATE.CONFIG.debug
});
};
SassFormatter.handleEmptyLine = function (STATE, line) {
STATE.CONTEXT.firstCommaHeader.exists = false;
var pass = true; // its not useless, trust me.
/*istanbul ignore else */
if (STATE.CONFIG.deleteEmptyRows && !STATE.CONTEXT.isLastLine) {
var nextLine = new sassTextLine_1.SassTextLine(STATE.lines[STATE.currentLine + 1]);
var compact = !regex_1.isProperty(nextLine.get());
var nextLineWillBeDeleted = STATE.CONFIG.convert
? regex_1.isBracketOrWhitespace(nextLine.get())
: false;
if ((compact && !STATE.CONTEXT.allowSpace && nextLine.isEmptyOrWhitespace) ||
(compact && !STATE.CONTEXT.allowSpace && nextLineWillBeDeleted)) {
logger_1.PushDebugInfo({
title: 'EMPTY LINE: DELETE',
nextLine: nextLine,
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: 'DELETED',
debug: STATE.CONFIG.debug
});
pass = false;
}
}
if (line.get().length > 0 && pass) {
logger_1.PushDebugInfo({
title: 'EMPTY LINE: WHITESPACE',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: 'NEWLINE',
debug: STATE.CONFIG.debug
});
this.addNewLine(STATE);
}
else if (pass) {
logger_1.PushDebugInfo({
title: 'EMPTY LINE',
lineNumber: STATE.currentLine,
oldLineText: STATE.lines[STATE.currentLine],
newLineText: 'NEWLINE',
debug: STATE.CONFIG.debug
});
this.addNewLine(STATE);
}
};
SassFormatter.isBlockHeader = function (line, STATE) {
return (!STATE.LOCAL_CONTEXT.isInterpolatedProp &&
!STATE.LOCAL_CONTEXT.isAtExtend &&
!STATE.LOCAL_CONTEXT.isImport &&
(STATE.LOCAL_CONTEXT.isAdjacentSelector ||
STATE.LOCAL_CONTEXT.isReset ||
STATE.LOCAL_CONTEXT.isAnd ||
(STATE.LOCAL_CONTEXT.isHtmlTag && !/^[\t ]*style[\t ]*:/.test(line.get())) ||
STATE.LOCAL_CONTEXT.isInclude ||
STATE.LOCAL_CONTEXT.isNestPropHead ||
regex_1.isPseudo(line.get()) ||
regex_1.isSelectorOperator(line.get()) ||
regex_1.isStar(line.get()) ||
regex_1.isBracketSelector(line.get()) ||
regex_1.isCssSelector(line.get())) // adds all lines that start with [@.#%=]
);
};
SassFormatter.isProperty = function (STATE) {
return (STATE.LOCAL_CONTEXT.isImport ||
STATE.LOCAL_CONTEXT.isAtExtend ||
STATE.LOCAL_CONTEXT.isVariable ||
STATE.LOCAL_CONTEXT.isInterpolatedProp ||
STATE.LOCAL_CONTEXT.isProp ||
STATE.LOCAL_CONTEXT.isAtKeyframesPoint);
};
/** Adds new Line If not first line. */
SassFormatter.addNewLine = function (STATE) {
if (!STATE.CONTEXT.isFirstLine) {
STATE.RESULT += STATE.LINE_ENDING;
}
else {
STATE.CONTEXT.isFirstLine = false;
}
};
return SassFormatter;
}());
exports.SassFormatter = SassFormatter;

21
node_modules/sass-formatter/dist/logger.d.ts generated vendored Normal file
View file

@ -0,0 +1,21 @@
import { SassTextLine } from './sassTextLine';
export interface LogFormatInfo {
title: string;
debug: boolean;
lineNumber: number;
oldLineText: string;
newLineText?: string;
offset?: number;
originalOffset?: number;
replaceSpaceOrTabs?: boolean;
nextLine?: SassTextLine;
}
export interface LogConvertData {
type: string;
text: string;
}
export declare function LogDebugResult(result: string): void;
export declare function ResetDebugLog(): void;
export declare function SetDebugLOCAL_CONTEXT(data: any): void;
export declare function SetConvertData(data: LogConvertData): void;
export declare function PushDebugInfo(info: LogFormatInfo): void;

121
node_modules/sass-formatter/dist/logger.js generated vendored Normal file
View file

@ -0,0 +1,121 @@
"use strict";
exports.__esModule = true;
exports.PushDebugInfo = exports.SetConvertData = exports.SetDebugLOCAL_CONTEXT = exports.ResetDebugLog = exports.LogDebugResult = void 0;
var suf_log_1 = require("suf-log");
suf_log_1.SetEnvironment('node');
var colon = suf_log_1.styler(':', '#777');
// const quote = styler('"', '#f64');
var pipe = suf_log_1.styler('|', '#f64');
var TEXT = function (text) { return suf_log_1.styler(text, '#eee'); };
var NUMBER = function (number) { return suf_log_1.styler(number.toString(), '#f03'); };
var BOOL = function (bool) { return suf_log_1.styler(bool.toString(), bool ? '#4f6' : '#f03'); };
function LogDebugResult(result) {
var data = StoreLog.logs;
var out = suf_log_1.styler('FORMAT', { "font-weight": 'bold', color: '#0af' });
for (var i = 0; i < data.length; i++) {
out += '\n';
out += InfoLogHelper(data[i]);
}
out += "\n" + pipe + suf_log_1.styler(replaceWhitespace(result.replace(/\n/g, '|\n|')), '#c76') + pipe;
console.log(out);
}
exports.LogDebugResult = LogDebugResult;
function ResetDebugLog() {
StoreLog.reset();
}
exports.ResetDebugLog = ResetDebugLog;
var StoreLog = /** @class */ (function () {
function StoreLog() {
}
StoreLog.resetTemp = function () {
this.tempConvertData = undefined;
this.tempLOCAL_CONTEXT = undefined;
};
StoreLog.reset = function () {
this.resetTemp();
this.logs = [];
};
StoreLog.logs = [];
return StoreLog;
}());
function SetDebugLOCAL_CONTEXT(data) {
StoreLog.tempLOCAL_CONTEXT = data;
}
exports.SetDebugLOCAL_CONTEXT = SetDebugLOCAL_CONTEXT;
function SetConvertData(data) {
StoreLog.tempConvertData = data;
}
exports.SetConvertData = SetConvertData;
function PushDebugInfo(info) {
if (info.debug) {
StoreLog.logs.push({
info: info,
convertData: StoreLog.tempConvertData,
LOCAL_CONTEXT: StoreLog.tempLOCAL_CONTEXT
});
}
StoreLog.resetTemp();
}
exports.PushDebugInfo = PushDebugInfo;
function InfoLogHelper(data) {
var convertData = data.convertData, info = data.info, LOCAL_CONTEXT = data.LOCAL_CONTEXT;
var notProvided = null;
var title = suf_log_1.styler(info.title, '#cc0');
var lineNumber = "" + TEXT('Line Number') + colon + " " + NUMBER(info.lineNumber);
var offset = info.offset !== undefined ? "" + TEXT('Offset') + colon + " " + NUMBER(info.offset) : '';
var originalOffset = info.originalOffset !== undefined ? "" + TEXT('Original Offset') + colon + " " + NUMBER(info.originalOffset) : '';
var nextLine = info.nextLine !== undefined
? JSON.stringify(info.nextLine)
.replace(/[{}]/g, '')
.replace(/:/g, ': ')
.replace(/,/g, ', ')
.replace(/".*?"/g, function (s) {
return suf_log_1.styler(s, '#c76');
})
: notProvided;
var replace = info.replaceSpaceOrTabs !== undefined ? BOOL(info.replaceSpaceOrTabs) : notProvided;
var CONVERT = convertData
? "\n " + TEXT('Convert') + " " + colon + " " + suf_log_1.styler(convertData.type, '#f64')
: '';
var newText = info.newLineText ? "\n " + TEXT('New') + " " + colon + " " + suf_log_1.styler(replaceWhitespace(info.newLineText.replace(/\n/g, '\\n')), '#0af') : '';
switch (info.newLineText) {
case 'DELETED':
return " " + title + " " + lineNumber + " " + TEXT('Next Line') + colon + " " + nextLine;
case 'NEWLINE':
case 'NULL':
return " " + title + " " + lineNumber;
default:
var data_1 = '';
data_1 +=
nextLine !== null ? "\n " + TEXT('Next Line') + " " + colon + " " + nextLine : '';
data_1 +=
replace !== null ? "\n " + TEXT('Replace') + " " + colon + " " + replace : '';
if (LOCAL_CONTEXT) {
data_1 += "\n " + suf_log_1.styler('LOCAL_CONTEXT', '#f64') + " " + suf_log_1.styler('{', '#777');
for (var key in LOCAL_CONTEXT) {
if (Object.prototype.hasOwnProperty.call(LOCAL_CONTEXT, key)) {
var val = LOCAL_CONTEXT[key];
data_1 += "\n " + suf_log_1.styler(key, '#777') + colon + " " + parseValue(val);
}
}
data_1 += suf_log_1.styler('\n }', '#777');
}
return " " + title + " " + lineNumber + " " + offset + " " + originalOffset + "\n " + TEXT('Old') + " " + colon + " " + suf_log_1.styler(replaceWhitespace(info.oldLineText), '#d75') + newText + CONVERT + data_1;
}
}
function replaceWhitespace(text) {
return text.replace(/ /g, '·').replace(/\t/g, '⟶');
}
function parseValue(val) {
var type = typeof val;
if (type === 'boolean') {
return BOOL(val);
}
else if (type === 'string') {
return suf_log_1.styler(val, '#f64');
}
else if (type === 'object') {
return suf_log_1.styler(JSON.stringify(val), '#0af');
}
return val;
}

64
node_modules/sass-formatter/dist/regex/regex.d.ts generated vendored Normal file
View file

@ -0,0 +1,64 @@
export declare function escapeRegExp(text: string): string;
/** Check whether text is a variable: `/^[\t ]*(\$|--)\S+[\t ]*:.*/
export declare function isVar(text: string): boolean;
/** Check whether text @import: `/^[\t ]*@import/` */
export declare function isAtImport(text: string): boolean;
/** Check whether text is a \*: `/^[\t ]*?\*\/` */
export declare function isStar(text: string): boolean;
/** Check whether text is a css selector: `/^[\t ]*[{}]?[\t ]*[#\.%@=]/` */
export declare function isCssSelector(text: string): boolean;
/**Check whether text is class, id or placeholder: `/^[\t ]*[#\.%]/` */
export declare function isClassOrId(text: string): boolean;
/**Check whether text starts with one of [>\~]: `/^[\t ]*[>~]/` */
export declare function isSelectorOperator(text: string): boolean;
/**`/^[\t ]*\+[\t ]+/` */
export declare function isAdjacentSelector(text: string): boolean;
/**Check whether text is class, id or placeholder: `/^[\t ]*\r?\n?$/` */
export declare function isEmptyOrWhitespace(text: string): boolean;
/** Check whether text is a property: `^[\t ]*[\w\-]+[\t ]*:` */
export declare function isProperty(text: string): boolean;
/** Check whether text starts with &: `/^[\t ]*&/` */
export declare function isAnd(text: string): boolean;
/** Check whether text is a extend: `/^[\t ]*@extend/` */
export declare function isAtExtend(text: string): boolean;
/** Check whether text is include mixin statement */
export declare function isInclude(text: string): boolean;
/** Check whether text is a @keyframes: `/^[\t ]*@keyframes/` */
export declare function isKeyframes(text: string): boolean;
/** Check whether text is a Pseudo selector: `/^[\t ]*\\?::?/`. */
export declare function isPseudo(text: string): boolean;
/** Check whether text is bracket selector: `/^[\t ]*\[[\w=\-*"' ]*\]/`*/
export declare function isBracketSelector(text: string): boolean;
/** Check whether text starts with an html tag. */
export declare function isHtmlTag(text: string): boolean;
/** Check whether text starts with a self closing html tag. */
export declare function isVoidHtmlTag(text: string): boolean;
/** Check whether text starts with //R: `/^[\t ]*\/?\/\/ *R *$/` */
export declare function isReset(text: string): boolean;
/** Check whether text starts with //I: `/^[\t ]*\/?\/\/ *I *$/` */
export declare function isIgnore(text: string): boolean;
/** Check whether text starts with //S: `/^[\t ]*\/?\/\/ *S *$/` */
export declare function isSassSpace(text: string): boolean;
/** Returns true if the string has brackets or semicolons at the end, comments get ignored. */
export declare function isScssOrCss(text: string): boolean;
/** `/^[\t ]*[&.#%].*:/` */
export declare function isCssPseudo(text: string): boolean;
/** `/^[\t ]*[&.#%][\w-]*(?!#)[\t ]*\{.*[;\}][\t ]*$/` */
export declare function isCssOneLiner(text: string): boolean;
/** `/^[\t ]*::?[\w\-]+\(.*\)/` */
/** `/^[\t ]*(\/\/|\/\*)/` */
export declare function isComment(text: string): boolean;
/** `/^[\t ]*(\/\*)/` */
export declare function isBlockCommentStart(text: string): boolean;
/** `/[\t ]*(\*\/)/` */
export declare function isBlockCommentEnd(text: string): boolean;
/** `/^[\t ]*[\.#%].* ?, *[\.#%].*\/` */
export declare function isMoreThanOneClassOrId(text: string): boolean;
/** `/^[\t ]*[}{]+[\t }{]*$/` */
export declare function isBracketOrWhitespace(text: string): boolean;
/** `/[\t ]*@forward|[\t ]*@use/` */
export declare function isAtForwardOrAtUse(text: string): boolean;
export declare function isInterpolatedProperty(text: string): boolean;
export declare function hasPropertyValueSpace(text: string): boolean;
/** returns the distance between the beginning and the first char. */
export declare function getDistance(text: string, tabSize: number): number;

186
node_modules/sass-formatter/dist/regex/regex.js generated vendored Normal file
View file

@ -0,0 +1,186 @@
"use strict";
exports.__esModule = true;
exports.getDistance = exports.hasPropertyValueSpace = exports.isInterpolatedProperty = exports.isAtForwardOrAtUse = exports.isBracketOrWhitespace = exports.isMoreThanOneClassOrId = exports.isBlockCommentEnd = exports.isBlockCommentStart = exports.isComment = exports.isCssOneLiner = exports.isCssPseudo = exports.isScssOrCss = exports.isSassSpace = exports.isIgnore = exports.isReset = exports.isVoidHtmlTag = exports.isHtmlTag = exports.isBracketSelector = exports.isPseudo = exports.isKeyframes = exports.isInclude = exports.isAtExtend = exports.isAnd = exports.isProperty = exports.isEmptyOrWhitespace = exports.isAdjacentSelector = exports.isSelectorOperator = exports.isClassOrId = exports.isCssSelector = exports.isStar = exports.isAtImport = exports.isVar = exports.escapeRegExp = void 0;
function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
exports.escapeRegExp = escapeRegExp;
/** Check whether text is a variable: `/^[\t ]*(\$|--)\S+[\t ]*:.*/
function isVar(text) {
return /^[\t ]*(\$|--)\S+[\t ]*:.*/.test(text);
}
exports.isVar = isVar;
/** Check whether text @import: `/^[\t ]*@import/` */
function isAtImport(text) {
return /^[\t ]*@import/.test(text);
}
exports.isAtImport = isAtImport;
/** Check whether text is a \*: `/^[\t ]*?\*\/` */
function isStar(text) {
return /^[\t ]*?\*/.test(text);
}
exports.isStar = isStar;
/** Check whether text is a css selector: `/^[\t ]*[{}]?[\t ]*[#\.%@=]/` */
function isCssSelector(text) {
return /^[\t ]*[{}]?[\t ]*[#\.%@=]/.test(text);
}
exports.isCssSelector = isCssSelector;
/**Check whether text is class, id or placeholder: `/^[\t ]*[#\.%]/` */
function isClassOrId(text) {
return /^[\t ]*[#\.%]/.test(text);
}
exports.isClassOrId = isClassOrId;
/**Check whether text starts with one of [>\~]: `/^[\t ]*[>~]/` */
function isSelectorOperator(text) {
return /^[\t ]*[>~]/.test(text);
}
exports.isSelectorOperator = isSelectorOperator;
/**`/^[\t ]*\+[\t ]+/` */
function isAdjacentSelector(text) {
return /^[\t ]*\+[\t ]+/.test(text);
}
exports.isAdjacentSelector = isAdjacentSelector;
/**Check whether text is class, id or placeholder: `/^[\t ]*\r?\n?$/` */
function isEmptyOrWhitespace(text) {
return /^[\t ]*\r?\n?$/.test(text);
}
exports.isEmptyOrWhitespace = isEmptyOrWhitespace;
/** Check whether text is a property: `^[\t ]*[\w\-]+[\t ]*:` */
function isProperty(text) {
// if (empty) {
// return !/^[\t ]*[\w\-]+ *: *\S+/.test(text);
// }
return /^[\t ]*[\w\-]+[\t ]*:/.test(text);
}
exports.isProperty = isProperty;
/** Check whether text starts with &: `/^[\t ]*&/` */
function isAnd(text) {
return /^[\t ]*&/.test(text);
}
exports.isAnd = isAnd;
/** Check whether text is a extend: `/^[\t ]*@extend/` */
function isAtExtend(text) {
return /^[\t ]*@extend/.test(text);
}
exports.isAtExtend = isAtExtend;
/** Check whether text is include mixin statement */
function isInclude(text) {
return /^[\t ]*(@include|\+\w)/.test(text);
}
exports.isInclude = isInclude;
/** Check whether text is a @keyframes: `/^[\t ]*@keyframes/` */
function isKeyframes(text) {
return /^[\t ]*@keyframes/.test(text);
}
exports.isKeyframes = isKeyframes;
/** Check whether text is a Pseudo selector: `/^[\t ]*\\?::?/`. */
function isPseudo(text) {
return /^[\t ]*\\?::?/.test(text);
}
exports.isPseudo = isPseudo;
/** Check whether text is bracket selector: `/^[\t ]*\[[\w=\-*"' ]*\]/`*/
function isBracketSelector(text) {
return /^[\t ]*\[[\w=\-*"' ]*\]/.test(text);
}
exports.isBracketSelector = isBracketSelector;
/** Check whether text starts with an html tag. */
function isHtmlTag(text) {
return /^[\t ]*(a|abbr|address|area|article|aside|audio|b|base|bdi|bdo|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|data|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|i|iframe|img|picture|input|ins|kbd|keygen|label|legend|li|link|main|map|mark|menu|menuitem|meta|meter|nav|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rb|rp|rt|rtc|ruby|s|samp|script|section|select|small|source|span|strong|style|sub|summary|sup|svg|table|tbody|td|template|textarea|tfoot|th|thead|time|title|tr|track|u|ul|var|video|wbr|path|circle|ellipse|line|polygon|polyline|rect|text|slot|h[1-6]?)((:|::|,|\.|#|\[)[\^:$#{}()\w\-\[\]='",\.# +\/]*)?$/.test(text);
}
exports.isHtmlTag = isHtmlTag;
/** Check whether text starts with a self closing html tag. */
function isVoidHtmlTag(text) {
return /^[\t ]*(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr|command|keygen|menuitem|path)((:|::|,|\.|#|\[)[:$#{}()\w\-\[\]='",\.# ]*)?$/.test(text);
}
exports.isVoidHtmlTag = isVoidHtmlTag;
/** Check whether text starts with //R: `/^[\t ]*\/?\/\/ *R *$/` */
function isReset(text) {
return /^[\t ]*\/?\/\/ *R *$/.test(text);
}
exports.isReset = isReset;
/** Check whether text starts with //I: `/^[\t ]*\/?\/\/ *I *$/` */
function isIgnore(text) {
return /^[\t ]*\/?\/\/ *I *$/.test(text);
}
exports.isIgnore = isIgnore;
/** Check whether text starts with //S: `/^[\t ]*\/?\/\/ *S *$/` */
function isSassSpace(text) {
return /^[\t ]*\/?\/\/ *S *$/.test(text);
}
exports.isSassSpace = isSassSpace;
/** Returns true if the string has brackets or semicolons at the end, comments get ignored. */
function isScssOrCss(text) {
// Check if has brackets at the end and ignore comments.
return /[;\{\}][\t ]*(\/\/.*)?$/.test(text);
}
exports.isScssOrCss = isScssOrCss;
/** `/^[\t ]*[&.#%].*:/` */
function isCssPseudo(text) {
return /^[\t ]*[&.#%].*:/.test(text);
}
exports.isCssPseudo = isCssPseudo;
/** `/^[\t ]*[&.#%][\w-]*(?!#)[\t ]*\{.*[;\}][\t ]*$/` */
function isCssOneLiner(text) {
return /^[\t ]*[&.#%][\w-]*(?!#)[\t ]*\{.*[;\}][\t ]*$/.test(text);
}
exports.isCssOneLiner = isCssOneLiner;
/** `/^[\t ]*::?[\w\-]+\(.*\)/` */
// export function isPseudoWithParenthesis(text: string) {
// return /^[\t ]*::?[\w\-]+\(.*\)/.test(text);
// }
/** `/^[\t ]*(\/\/|\/\*)/` */
function isComment(text) {
return /^[\t ]*(\/\/|\/\*)/.test(text);
}
exports.isComment = isComment;
/** `/^[\t ]*(\/\*)/` */
function isBlockCommentStart(text) {
return /^[\t ]*(\/\*)/.test(text);
}
exports.isBlockCommentStart = isBlockCommentStart;
/** `/[\t ]*(\*\/)/` */
function isBlockCommentEnd(text) {
return /[\t ]*(\*\/)/.test(text);
}
exports.isBlockCommentEnd = isBlockCommentEnd;
/** `/^[\t ]*[\.#%].* ?, *[\.#%].*\/` */
function isMoreThanOneClassOrId(text) {
return /^[\t ]*[\.#%].* ?, *[\.#%].*/.test(text);
}
exports.isMoreThanOneClassOrId = isMoreThanOneClassOrId;
/** `/^[\t ]*[}{]+[\t }{]*$/` */
function isBracketOrWhitespace(text) {
return /^[\t ]*[}{]+[\t }{]*$/.test(text);
}
exports.isBracketOrWhitespace = isBracketOrWhitespace;
/** `/[\t ]*@forward|[\t ]*@use/` */
function isAtForwardOrAtUse(text) {
return /[\t ]*@forward|[\t ]*@use/.test(text);
}
exports.isAtForwardOrAtUse = isAtForwardOrAtUse;
function isInterpolatedProperty(text) {
return /^[\t ]*[\w-]*#\{.*?\}[\w-]*:(?!:)/.test(text);
}
exports.isInterpolatedProperty = isInterpolatedProperty;
function hasPropertyValueSpace(text) {
return /^[\t ]*([\w ]+|[\w ]*#\{.*?\}[\w ]*): [^ ]/.test(text);
}
exports.hasPropertyValueSpace = hasPropertyValueSpace;
/** returns the distance between the beginning and the first char. */
function getDistance(text, tabSize) {
var count = 0;
for (var i = 0; i < text.length; i++) {
var char = text[i];
if (char !== ' ' && char !== '\t') {
break;
}
if (char === '\t') {
count += tabSize;
}
else {
count++;
}
}
return count;
}
exports.getDistance = getDistance;

9
node_modules/sass-formatter/dist/sassTextLine.d.ts generated vendored Normal file
View file

@ -0,0 +1,9 @@
export declare class SassTextLine {
private text;
isEmptyOrWhitespace: boolean;
constructor(text: string);
/**Sets the text of the line. */
set(text: string): void;
/**Gets the text of the line. */
get(): string;
}

20
node_modules/sass-formatter/dist/sassTextLine.js generated vendored Normal file
View file

@ -0,0 +1,20 @@
"use strict";
exports.__esModule = true;
exports.SassTextLine = void 0;
var regex_1 = require("./regex/regex");
var SassTextLine = /** @class */ (function () {
function SassTextLine(text) {
this.text = text;
this.isEmptyOrWhitespace = regex_1.isEmptyOrWhitespace(text);
}
/**Sets the text of the line. */
SassTextLine.prototype.set = function (text) {
this.text = text;
};
/**Gets the text of the line. */
SassTextLine.prototype.get = function () {
return this.text;
};
return SassTextLine;
}());
exports.SassTextLine = SassTextLine;

101
node_modules/sass-formatter/dist/state.d.ts generated vendored Normal file
View file

@ -0,0 +1,101 @@
import { SassFormatterConfig } from './config';
interface FormatContext {
isFirstLine: boolean;
isLastLine: boolean;
isInBlockComment: boolean;
wasLastHeaderIncludeMixin: boolean;
wasLastHeaderNestedProp: boolean;
blockCommentDistance: number;
/**
* The Formatter ignores whitespace until the next selector.
*/
allowSpace: boolean;
/**
* The Formatter Skips one line.
*/
ignoreLine: boolean;
/**
* true if the last line was a selector.
*/
wasLastLineSelector: boolean;
convert: {
lastSelector: string;
wasLastLineCss: boolean;
};
keyframes: {
/**true if in @keyframes body. */
isIn: boolean;
/** the indentation level of the keyframes declaration. */
indentation: number;
};
if: {
/**true if in @if body. */
isIn: boolean;
/** the indentation level of the @if declaration. */
indentation: number;
};
/**
* Indentation level of the last selector
*/
lastSelectorIndentation: number;
/**
* if `.class` is at line 0 and has an indentation level of 0,
* then this property should be set to the current `tabSize`.
*
* so that the properties get the correct indentation level.
*/
indentation: number;
/**
* used if there is there are multiple selectors, example line 0 has
* `.class1,` and line 1 has `#someId` this stores the distance of the first selector (`.class1` in this example)
* so that the indentation of the following selectors gets set to the indentation of the first selector.
*/
firstCommaHeader: {
/**
* distance of the first selector.
*/
distance: number;
/**
* true previous selector ends with a comma
*/ exists: boolean;
};
}
/**
* This is the context for each line.
*/
export interface StateLocalContext {
isReset: boolean;
isAnd: boolean;
isProp: boolean;
indentation: {
offset: number;
distance: number;
};
isAtExtend: boolean;
isClassOrIdSelector: boolean;
isHtmlTag: boolean;
isIf: boolean;
isElse: boolean;
isAtKeyframes: boolean;
isAtKeyframesPoint: boolean;
isAdjacentSelector: boolean;
isInterpolatedProp: boolean;
isInclude: boolean;
isVariable: boolean;
isImport: boolean;
isNestPropHead: boolean;
}
export declare class FormattingState {
lines: string[];
/** Current line index. */
currentLine: number;
LINE_ENDING: '\n' | '\r\n';
/** Formatting Result */
RESULT: string;
/** Context For Each Line. */
LOCAL_CONTEXT: StateLocalContext;
CONTEXT: FormatContext;
CONFIG: SassFormatterConfig;
setLocalContext(context: StateLocalContext): void;
}
export {};

69
node_modules/sass-formatter/dist/state.js generated vendored Normal file
View file

@ -0,0 +1,69 @@
"use strict";
exports.__esModule = true;
exports.FormattingState = void 0;
var config_1 = require("./config");
var FormattingState = /** @class */ (function () {
function FormattingState() {
this.lines = [];
/** Current line index. */
this.currentLine = 0;
this.LINE_ENDING = '\n';
/** Formatting Result */
this.RESULT = '';
/** Context For Each Line. */
this.LOCAL_CONTEXT = {
isAdjacentSelector: false,
isHtmlTag: false,
isReset: false,
indentation: {
distance: 0,
offset: 0
},
isAtExtend: false,
isAnd: false,
isClassOrIdSelector: false,
isIf: false,
isElse: false,
isAtKeyframes: false,
isAtKeyframesPoint: false,
isProp: false,
isInterpolatedProp: false,
isInclude: false,
isVariable: false,
isImport: false,
isNestPropHead: false
};
this.CONTEXT = {
"if": {
isIn: false,
indentation: 0
},
blockCommentDistance: 0,
wasLastHeaderIncludeMixin: false,
wasLastHeaderNestedProp: false,
isFirstLine: true,
isLastLine: false,
allowSpace: false,
isInBlockComment: false,
ignoreLine: false,
lastSelectorIndentation: 0,
wasLastLineSelector: false,
convert: {
lastSelector: '',
wasLastLineCss: false
},
keyframes: {
isIn: false,
indentation: 0
},
indentation: 0,
firstCommaHeader: { exists: false, distance: 0 }
};
this.CONFIG = config_1.defaultSassFormatterConfig;
}
FormattingState.prototype.setLocalContext = function (context) {
this.LOCAL_CONTEXT = context;
};
return FormattingState;
}());
exports.FormattingState = FormattingState;

16
node_modules/sass-formatter/dist/utility.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
import { SassTextLine } from './sassTextLine';
import { FormattingState } from './state';
/** returns the relative distance that the class or id should be at. */
export declare function getBlockHeaderOffset(distance: number, tabSize: number, current: number, ignoreCurrent: boolean): number;
/**
* adds or removes whitespace based on the given offset, a positive value adds whitespace a negative value removes it.
*/
export declare function replaceWithOffset(text: string, offset: number, STATE: FormattingState): string;
/** returns the difference between the current indentation and the indentation of the given text. */
export declare function getIndentationOffset(text: string, indentation: number, tabSize: number): {
offset: number;
distance: number;
};
export declare function replaceSpacesOrTabs(text: string, STATE: FormattingState, insertSpaces?: boolean): string;
export declare function convertLine(line: SassTextLine, STATE: FormattingState): boolean;
export declare function isKeyframePointAndSetIndentation(line: SassTextLine, STATE: FormattingState): boolean;

68
node_modules/sass-formatter/dist/utility.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
"use strict";
exports.__esModule = true;
exports.isKeyframePointAndSetIndentation = exports.convertLine = exports.replaceSpacesOrTabs = exports.getIndentationOffset = exports.replaceWithOffset = exports.getBlockHeaderOffset = void 0;
var regex_1 = require("./regex/regex");
/** returns the relative distance that the class or id should be at. */
function getBlockHeaderOffset(distance, tabSize, current, ignoreCurrent) {
if (distance === 0) {
return 0;
}
if (tabSize * Math.round(distance / tabSize - 0.1) > current && !ignoreCurrent) {
return current - distance;
}
return tabSize * Math.round(distance / tabSize - 0.1) - distance;
}
exports.getBlockHeaderOffset = getBlockHeaderOffset;
/**
* adds or removes whitespace based on the given offset, a positive value adds whitespace a negative value removes it.
*/
function replaceWithOffset(text, offset, STATE) {
if (offset < 0) {
text = text
.replace(/\t/g, ' '.repeat(STATE.CONFIG.tabSize))
.replace(new RegExp("^ {" + Math.abs(offset) + "}"), '');
if (!STATE.CONFIG.insertSpaces) {
text = replaceSpacesOrTabs(text, STATE, false);
}
}
else {
text = text.replace(/^/, STATE.CONFIG.insertSpaces ? ' '.repeat(offset) : '\t'.repeat(offset / STATE.CONFIG.tabSize));
}
return text;
}
exports.replaceWithOffset = replaceWithOffset;
/** returns the difference between the current indentation and the indentation of the given text. */
function getIndentationOffset(text, indentation, tabSize) {
var distance = regex_1.getDistance(text, tabSize);
return { offset: indentation - distance, distance: distance };
}
exports.getIndentationOffset = getIndentationOffset;
function isKeyframePoint(text, isAtKeyframe) {
if (isAtKeyframe === false) {
return false;
}
return /^[\t ]*\d+%/.test(text) || /^[\t ]*from[\t ]*$|^[\t ]*to[\t ]*$/.test(text);
}
function replaceSpacesOrTabs(text, STATE, insertSpaces) {
if (insertSpaces !== undefined ? insertSpaces : STATE.CONFIG.insertSpaces) {
return text.replace(/\t/g, ' '.repeat(STATE.CONFIG.tabSize));
}
else {
return text.replace(new RegExp(' '.repeat(STATE.CONFIG.tabSize), 'g'), '\t');
}
}
exports.replaceSpacesOrTabs = replaceSpacesOrTabs;
function convertLine(line, STATE) {
return (STATE.CONFIG.convert &&
regex_1.isScssOrCss(line.get()) &&
!regex_1.isComment(line.get()));
}
exports.convertLine = convertLine;
function isKeyframePointAndSetIndentation(line, STATE) {
var isAtKeyframesPoint = isKeyframePoint(line.get(), STATE.CONTEXT.keyframes.isIn);
if (STATE.CONTEXT.keyframes.isIn && isAtKeyframesPoint) {
STATE.CONTEXT.indentation = Math.max(0, STATE.CONTEXT.keyframes.indentation);
}
return isAtKeyframesPoint;
}
exports.isKeyframePointAndSetIndentation = isKeyframePointAndSetIndentation;