Base UI
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled

This commit is contained in:
2026-06-25 11:15:13 +07:00
parent c539fe47af
commit cc038a7372
20561 changed files with 1811255 additions and 41 deletions
+440
View File
@@ -0,0 +1,440 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unescapeValue = unescapeValue;
var cssesc_1 = __importDefault(require("cssesc"));
var unesc_1 = __importDefault(require("../util/unesc"));
var namespace_1 = __importDefault(require("./namespace"));
var types_1 = require("./types");
var deprecate = require("util-deprecate");
var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
var warnOfDeprecatedValueAssignment = deprecate(function () { }, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " +
"Call attribute.setValue() instead.");
var warnOfDeprecatedQuotedAssignment = deprecate(function () { }, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
var warnOfDeprecatedConstructor = deprecate(function () { }, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
function unescapeValue(value) {
var deprecatedUsage = false;
var quoteMark = null;
var unescaped = value;
var m = unescaped.match(WRAPPED_IN_QUOTES);
if (m) {
quoteMark = m[1];
unescaped = m[2];
}
unescaped = (0, unesc_1.default)(unescaped);
if (unescaped !== value) {
deprecatedUsage = true;
}
return {
deprecatedUsage: deprecatedUsage,
unescaped: unescaped,
quoteMark: quoteMark,
};
}
function handleDeprecatedContructorOpts(opts) {
if (opts.quoteMark !== undefined) {
return opts;
}
if (opts.value === undefined) {
return opts;
}
warnOfDeprecatedConstructor();
var _a = unescapeValue(opts.value), quoteMark = _a.quoteMark, unescaped = _a.unescaped;
if (!opts.raws) {
opts.raws = {};
}
if (opts.raws.value === undefined) {
opts.raws.value = opts.value;
}
opts.value = unescaped;
opts.quoteMark = quoteMark;
return opts;
}
var Attribute = /** @class */ (function (_super) {
__extends(Attribute, _super);
function Attribute(opts) {
if (opts === void 0) { opts = {}; }
var _this = _super.call(this, handleDeprecatedContructorOpts(opts)) || this;
_this.type = types_1.ATTRIBUTE;
_this.raws = _this.raws || {};
Object.defineProperty(_this.raws, "unquoted", {
get: deprecate(function () { return _this.value; }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
set: deprecate(function () { return _this.value; }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now."),
});
_this._constructed = true;
return _this;
}
/**
* Returns the Attribute's value quoted such that it would be legal to use
* in the value of a css file. The original value's quotation setting
* used for stringification is left unchanged. See `setValue(value, options)`
* if you want to control the quote settings of a new value for the attribute.
*
* You can also change the quotation used for the current value by setting quoteMark.
*
* Options:
* * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
* option is not set, the original value for quoteMark will be used. If
* indeterminate, a double quote is used. The legal values are:
* * `null` - the value will be unquoted and characters will be escaped as necessary.
* * `'` - the value will be quoted with a single quote and single quotes are escaped.
* * `"` - the value will be quoted with a double quote and double quotes are escaped.
* * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
* over the quoteMark option value.
* * smart {boolean} - if true, will select a quote mark based on the value
* and the other options specified here. See the `smartQuoteMark()`
* method.
**/
Attribute.prototype.getQuotedValue = function (options) {
if (options === void 0) { options = {}; }
var quoteMark = this._determineQuoteMark(options);
var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
var escaped = (0, cssesc_1.default)(this._value, cssescopts);
return escaped;
};
Attribute.prototype._determineQuoteMark = function (options) {
return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
};
/**
* Set the unescaped value with the specified quotation options. The value
* provided must not include any wrapping quote marks -- those quotes will
* be interpreted as part of the value and escaped accordingly.
*/
Attribute.prototype.setValue = function (value, options) {
if (options === void 0) { options = {}; }
this._value = value;
this._quoteMark = this._determineQuoteMark(options);
this._syncRawValue();
};
/**
* Intelligently select a quoteMark value based on the value's contents. If
* the value is a legal CSS ident, it will not be quoted. Otherwise a quote
* mark will be picked that minimizes the number of escapes.
*
* If there's no clear winner, the quote mark from these options is used,
* then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
* true). If the quoteMark is unspecified, a double quote is used.
*
* @param options This takes the quoteMark and preferCurrentQuoteMark options
* from the quoteValue method.
*/
Attribute.prototype.smartQuoteMark = function (options) {
var v = this.value;
var numSingleQuotes = v.replace(/[^']/g, "").length;
var numDoubleQuotes = v.replace(/[^"]/g, "").length;
if (numSingleQuotes + numDoubleQuotes === 0) {
var escaped = (0, cssesc_1.default)(v, { isIdentifier: true });
if (escaped === v) {
return Attribute.NO_QUOTE;
}
else {
var pref = this.preferredQuoteMark(options);
if (pref === Attribute.NO_QUOTE) {
// pick a quote mark that isn't none and see if it's smaller
var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
var opts = CSSESC_QUOTE_OPTIONS[quote];
var quoteValue = (0, cssesc_1.default)(v, opts);
if (quoteValue.length < escaped.length) {
return quote;
}
}
return pref;
}
}
else if (numDoubleQuotes === numSingleQuotes) {
return this.preferredQuoteMark(options);
}
else if (numDoubleQuotes < numSingleQuotes) {
return Attribute.DOUBLE_QUOTE;
}
else {
return Attribute.SINGLE_QUOTE;
}
};
/**
* Selects the preferred quote mark based on the options and the current quote mark value.
* If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
* instead.
*/
Attribute.prototype.preferredQuoteMark = function (options) {
var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
if (quoteMark === undefined) {
quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
}
if (quoteMark === undefined) {
quoteMark = Attribute.DOUBLE_QUOTE;
}
return quoteMark;
};
Object.defineProperty(Attribute.prototype, "quoted", {
get: function () {
var qm = this.quoteMark;
return qm === "'" || qm === '"';
},
set: function (value) {
warnOfDeprecatedQuotedAssignment();
},
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "quoteMark", {
/**
* returns a single (`'`) or double (`"`) quote character if the value is quoted.
* returns `null` if the value is not quoted.
* returns `undefined` if the quotation state is unknown (this can happen when
* the attribute is constructed without specifying a quote mark.)
*/
get: function () {
return this._quoteMark;
},
/**
* Set the quote mark to be used by this attribute's value.
* If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
* value is updated accordingly.
*
* @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
*/
set: function (quoteMark) {
if (!this._constructed) {
this._quoteMark = quoteMark;
return;
}
if (this._quoteMark !== quoteMark) {
this._quoteMark = quoteMark;
this._syncRawValue();
}
},
enumerable: false,
configurable: true
});
Attribute.prototype._syncRawValue = function () {
var rawValue = (0, cssesc_1.default)(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
if (rawValue === this._value) {
if (this.raws) {
delete this.raws.value;
}
}
else {
this.raws.value = rawValue;
}
};
Object.defineProperty(Attribute.prototype, "qualifiedAttribute", {
get: function () {
return this.qualifiedName(this.raws.attribute || this.attribute);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "insensitiveFlag", {
get: function () {
return this.insensitive ? "i" : "";
},
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "value", {
get: function () {
return this._value;
},
/**
* Before 3.0, the value had to be set to an escaped value including any wrapped
* quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
* is unescaped during parsing and any quote marks are removed.
*
* Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
* a deprecation warning is raised when the new value contains any characters that would
* require escaping (including if it contains wrapped quotes).
*
* Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
* how the new value is quoted.
*/
set: function (v) {
if (this._constructed) {
var _a = unescapeValue(v), deprecatedUsage = _a.deprecatedUsage, unescaped = _a.unescaped, quoteMark = _a.quoteMark;
if (deprecatedUsage) {
warnOfDeprecatedValueAssignment();
}
if (unescaped === this._value && quoteMark === this._quoteMark) {
return;
}
this._value = unescaped;
this._quoteMark = quoteMark;
this._syncRawValue();
}
else {
this._value = v;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "insensitive", {
get: function () {
return this._insensitive;
},
/**
* Set the case insensitive flag.
* If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
* of the attribute is updated accordingly.
*
* @param {true | false} insensitive true if the attribute should match case-insensitively.
*/
set: function (insensitive) {
if (!insensitive) {
this._insensitive = false;
// "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
// When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
if (this.raws && (this.raws.insensitiveFlag === "I" || this.raws.insensitiveFlag === "i")) {
this.raws.insensitiveFlag = undefined;
}
}
this._insensitive = insensitive;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "attribute", {
get: function () {
return this._attribute;
},
set: function (name) {
this._handleEscapes("attribute", name);
this._attribute = name;
},
enumerable: false,
configurable: true
});
Attribute.prototype._handleEscapes = function (prop, value) {
if (this._constructed) {
var escaped = (0, cssesc_1.default)(value, { isIdentifier: true });
if (escaped !== value) {
this.raws[prop] = escaped;
}
else {
delete this.raws[prop];
}
}
};
Attribute.prototype._spacesFor = function (name) {
var attrSpaces = { before: "", after: "" };
var spaces = this.spaces[name] || {};
var rawSpaces = (this.raws.spaces && this.raws.spaces[name]) || {};
return Object.assign(attrSpaces, spaces, rawSpaces);
};
Attribute.prototype._stringFor = function (name, spaceName, concat) {
if (spaceName === void 0) { spaceName = name; }
if (concat === void 0) { concat = defaultAttrConcat; }
var attrSpaces = this._spacesFor(spaceName);
return concat(this.stringifyProperty(name), attrSpaces);
};
/**
* returns the offset of the attribute part specified relative to the
* start of the node of the output string.
*
* * "ns" - alias for "namespace"
* * "namespace" - the namespace if it exists.
* * "attribute" - the attribute name
* * "attributeNS" - the start of the attribute or its namespace
* * "operator" - the match operator of the attribute
* * "value" - The value (string or identifier)
* * "insensitive" - the case insensitivity flag;
* @param part One of the possible values inside an attribute.
* @returns -1 if the name is invalid or the value doesn't exist in this attribute.
*/
Attribute.prototype.offsetOf = function (name) {
var count = 1;
var attributeSpaces = this._spacesFor("attribute");
count += attributeSpaces.before.length;
if (name === "namespace" || name === "ns") {
return this.namespace ? count : -1;
}
if (name === "attributeNS") {
return count;
}
count += this.namespaceString.length;
if (this.namespace) {
count += 1;
}
if (name === "attribute") {
return count;
}
count += this.stringifyProperty("attribute").length;
count += attributeSpaces.after.length;
var operatorSpaces = this._spacesFor("operator");
count += operatorSpaces.before.length;
var operator = this.stringifyProperty("operator");
if (name === "operator") {
return operator ? count : -1;
}
count += operator.length;
count += operatorSpaces.after.length;
var valueSpaces = this._spacesFor("value");
count += valueSpaces.before.length;
var value = this.stringifyProperty("value");
if (name === "value") {
return value ? count : -1;
}
count += value.length;
count += valueSpaces.after.length;
var insensitiveSpaces = this._spacesFor("insensitive");
count += insensitiveSpaces.before.length;
if (name === "insensitive") {
return this.insensitive ? count : -1;
}
return -1;
};
Attribute.prototype.toString = function () {
var _this = this;
var selector = [this.rawSpaceBefore, "["];
selector.push(this._stringFor("qualifiedAttribute", "attribute"));
if (this.operator && (this.value || this.value === "")) {
selector.push(this._stringFor("operator"));
selector.push(this._stringFor("value"));
selector.push(this._stringFor("insensitiveFlag", "insensitive", function (attrValue, attrSpaces) {
if (attrValue.length > 0 &&
!_this.quoted &&
attrSpaces.before.length === 0 &&
!(_this.spaces.value && _this.spaces.value.after)) {
attrSpaces.before = " ";
}
return defaultAttrConcat(attrValue, attrSpaces);
}));
}
selector.push("]");
selector.push(this.rawSpaceAfter);
return selector.join("");
};
Attribute.NO_QUOTE = null;
Attribute.SINGLE_QUOTE = "'";
Attribute.DOUBLE_QUOTE = '"';
return Attribute;
}(namespace_1.default));
exports.default = Attribute;
var CSSESC_QUOTE_OPTIONS = (_a = {
"'": { quotes: "single", wrap: true },
'"': { quotes: "double", wrap: true }
},
_a[null] = { isIdentifier: true },
_a);
function defaultAttrConcat(attrValue, attrSpaces) {
return "".concat(attrSpaces.before).concat(attrValue).concat(attrSpaces.after);
}
//# sourceMappingURL=attribute.js.map
+59
View File
@@ -0,0 +1,59 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var cssesc_1 = __importDefault(require("cssesc"));
var util_1 = require("../util");
var node_1 = __importDefault(require("./node"));
var types_1 = require("./types");
var ClassName = /** @class */ (function (_super) {
__extends(ClassName, _super);
function ClassName(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.CLASS;
_this._constructed = true;
return _this;
}
Object.defineProperty(ClassName.prototype, "value", {
get: function () {
return this._value;
},
set: function (v) {
if (this._constructed) {
var escaped = (0, cssesc_1.default)(v, { isIdentifier: true });
if (escaped !== v) {
(0, util_1.ensureObject)(this, "raws");
this.raws.value = escaped;
}
else if (this.raws) {
delete this.raws.value;
}
}
this._value = v;
},
enumerable: false,
configurable: true
});
ClassName.prototype.valueToString = function () {
return "." + _super.prototype.valueToString.call(this);
};
return ClassName;
}(node_1.default));
exports.default = ClassName;
//# sourceMappingURL=className.js.map
+33
View File
@@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var node_1 = __importDefault(require("./node"));
var types_1 = require("./types");
var Combinator = /** @class */ (function (_super) {
__extends(Combinator, _super);
function Combinator(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.COMBINATOR;
return _this;
}
return Combinator;
}(node_1.default));
exports.default = Combinator;
//# sourceMappingURL=combinator.js.map
+33
View File
@@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var node_1 = __importDefault(require("./node"));
var types_1 = require("./types");
var Comment = /** @class */ (function (_super) {
__extends(Comment, _super);
function Comment(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.COMMENT;
return _this;
}
return Comment;
}(node_1.default));
exports.default = Comment;
//# sourceMappingURL=comment.js.map
+43
View File
@@ -0,0 +1,43 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.universal = exports.tag = exports.string = exports.selector = exports.root = exports.pseudo = exports.nesting = exports.id = exports.comment = exports.combinator = exports.className = exports.attribute = void 0;
var attribute_1 = __importDefault(require("./attribute"));
var className_1 = __importDefault(require("./className"));
var combinator_1 = __importDefault(require("./combinator"));
var comment_1 = __importDefault(require("./comment"));
var id_1 = __importDefault(require("./id"));
var nesting_1 = __importDefault(require("./nesting"));
var pseudo_1 = __importDefault(require("./pseudo"));
var root_1 = __importDefault(require("./root"));
var selector_1 = __importDefault(require("./selector"));
var string_1 = __importDefault(require("./string"));
var tag_1 = __importDefault(require("./tag"));
var universal_1 = __importDefault(require("./universal"));
var attribute = function (opts) { return new attribute_1.default(opts); };
exports.attribute = attribute;
var className = function (opts) { return new className_1.default(opts); };
exports.className = className;
var combinator = function (opts) { return new combinator_1.default(opts); };
exports.combinator = combinator;
var comment = function (opts) { return new comment_1.default(opts); };
exports.comment = comment;
var id = function (opts) { return new id_1.default(opts); };
exports.id = id;
var nesting = function (opts) { return new nesting_1.default(opts); };
exports.nesting = nesting;
var pseudo = function (opts) { return new pseudo_1.default(opts); };
exports.pseudo = pseudo;
var root = function (opts) { return new root_1.default(opts); };
exports.root = root;
var selector = function (opts) { return new selector_1.default(opts); };
exports.selector = selector;
var string = function (opts) { return new string_1.default(opts); };
exports.string = string;
var tag = function (opts) { return new tag_1.default(opts); };
exports.tag = tag;
var universal = function (opts) { return new universal_1.default(opts); };
exports.universal = universal;
//# sourceMappingURL=constructors.js.map
+433
View File
@@ -0,0 +1,433 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../util");
var node_1 = __importDefault(require("./node"));
var types = __importStar(require("./types"));
var Container = /** @class */ (function (_super) {
__extends(Container, _super);
function Container(opts) {
var _this = _super.call(this, opts) || this;
if (!_this.nodes) {
_this.nodes = [];
}
return _this;
}
Container.prototype.append = function (selector) {
selector.parent = this;
this.nodes.push(selector);
return this;
};
Container.prototype.prepend = function (selector) {
selector.parent = this;
this.nodes.unshift(selector);
for (var id in this.indexes) {
this.indexes[id]++;
}
return this;
};
Container.prototype.at = function (index) {
return this.nodes[index];
};
Container.prototype.index = function (child) {
if (typeof child === "number") {
return child;
}
return this.nodes.indexOf(child);
};
Object.defineProperty(Container.prototype, "first", {
get: function () {
return this.at(0);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Container.prototype, "last", {
get: function () {
return this.at(this.length - 1);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Container.prototype, "length", {
get: function () {
return this.nodes.length;
},
enumerable: false,
configurable: true
});
Container.prototype.removeChild = function (child) {
child = this.index(child);
this.at(child).parent = undefined;
this.nodes.splice(child, 1);
var index;
for (var id in this.indexes) {
index = this.indexes[id];
if (index >= child) {
this.indexes[id] = index - 1;
}
}
return this;
};
Container.prototype.removeAll = function () {
var e_1, _a;
try {
for (var _b = __values(this.nodes), _c = _b.next(); !_c.done; _c = _b.next()) {
var node = _c.value;
node.parent = undefined;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
this.nodes = [];
return this;
};
Container.prototype.empty = function () {
return this.removeAll();
};
Container.prototype.insertAfter = function (oldNode, newNode) {
var _a;
newNode.parent = this;
var oldIndex = this.index(oldNode);
var resetNode = [];
for (var i = 2; i < arguments.length; i++) {
resetNode.push(arguments[i]);
}
(_a = this.nodes).splice.apply(_a, __spreadArray([oldIndex + 1, 0, newNode], __read(resetNode), false));
newNode.parent = this;
var index;
for (var id in this.indexes) {
index = this.indexes[id];
if (oldIndex < index) {
this.indexes[id] = index + arguments.length - 1;
}
}
return this;
};
Container.prototype.insertBefore = function (oldNode, newNode) {
var _a;
newNode.parent = this;
var oldIndex = this.index(oldNode);
var resetNode = [];
for (var i = 2; i < arguments.length; i++) {
resetNode.push(arguments[i]);
}
(_a = this.nodes).splice.apply(_a, __spreadArray([oldIndex, 0, newNode], __read(resetNode), false));
newNode.parent = this;
var index;
for (var id in this.indexes) {
index = this.indexes[id];
if (index >= oldIndex) {
this.indexes[id] = index + arguments.length - 1;
}
}
return this;
};
Container.prototype._findChildAtPosition = function (line, col) {
var found = undefined;
this.each(function (node) {
if (node.atPosition) {
var foundChild = node.atPosition(line, col);
if (foundChild) {
found = foundChild;
return false;
}
}
else if (node.isAtPosition(line, col)) {
found = node;
return false;
}
});
return found;
};
/**
* Return the most specific node at the line and column number given.
* The source location is based on the original parsed location, locations aren't
* updated as selector nodes are mutated.
*
* Note that this location is relative to the location of the first character
* of the selector, and not the location of the selector in the overall document
* when used in conjunction with postcss.
*
* If not found, returns undefined.
* @param {number} line The line number of the node to find. (1-based index)
* @param {number} col The column number of the node to find. (1-based index)
*/
Container.prototype.atPosition = function (line, col) {
if (this.isAtPosition(line, col)) {
return this._findChildAtPosition(line, col) || this;
}
else {
return undefined;
}
};
Container.prototype._inferEndPosition = function () {
if (this.last && this.last.source && this.last.source.end) {
this.source = this.source || {};
this.source.end = this.source.end || {};
Object.assign(this.source.end, this.last.source.end);
}
};
Container.prototype.each = function (callback) {
if (!this.lastEach) {
this.lastEach = 0;
}
if (!this.indexes) {
this.indexes = {};
}
this.lastEach++;
var id = this.lastEach;
this.indexes[id] = 0;
if (!this.length) {
return undefined;
}
var index, result;
while (this.indexes[id] < this.length) {
index = this.indexes[id];
result = callback(this.at(index), index);
if (result === false) {
break;
}
this.indexes[id] += 1;
}
delete this.indexes[id];
if (result === false) {
return false;
}
};
Container.prototype.walk = function (callback, depth) {
if (depth === void 0) { depth = 0; }
// Bound recursion so a pathologically deep node tree raises a catchable
// error instead of overflowing the call stack (CVE-2026-9358 / CWE-674).
if (depth > util_1.MAX_NESTING_DEPTH) {
throw new Error("Cannot walk selector: nesting depth exceeds the maximum of ".concat(util_1.MAX_NESTING_DEPTH, "."));
}
return this.each(function (node, i) {
var result = callback(node, i);
if (result !== false && node.length) {
result = node.walk(callback, depth + 1);
}
if (result === false) {
return false;
}
});
};
Container.prototype.walkAttributes = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.ATTRIBUTE) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkClasses = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.CLASS) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkCombinators = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.COMBINATOR) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkComments = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.COMMENT) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkIds = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.ID) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkNesting = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.NESTING) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkPseudos = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.PSEUDO) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkTags = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.TAG) {
return callback.call(_this, selector);
}
});
};
Container.prototype.walkUniversals = function (callback) {
var _this = this;
return this.walk(function (selector) {
if (selector.type === types.UNIVERSAL) {
return callback.call(_this, selector);
}
});
};
Container.prototype.split = function (callback) {
var _this = this;
var current = [];
return this.reduce(function (memo, node, index) {
var split = callback.call(_this, node);
current.push(node);
if (split) {
memo.push(current);
current = [];
}
else if (index === _this.length - 1) {
memo.push(current);
}
return memo;
}, []);
};
Container.prototype.map = function (callback) {
return this.nodes.map(callback);
};
Container.prototype.reduce = function (callback, memo) {
return this.nodes.reduce(callback, memo);
};
Container.prototype.every = function (callback) {
return this.nodes.every(callback);
};
Container.prototype.some = function (callback) {
return this.nodes.some(callback);
};
Container.prototype.filter = function (callback) {
return this.nodes.filter(callback);
};
Container.prototype.sort = function (callback) {
return this.nodes.sort(callback);
};
Container.prototype.toString = function (options) {
if (options === void 0) { options = {}; }
return this._stringify(options, 0, (0, util_1.resolveMaxNestingDepth)(options.maxNestingDepth));
};
Container.prototype._stringify = function (options, depth, max) {
var _this = this;
return this.map(function (child) { return _this._stringifyChild(child, options, depth, max); }).join("");
};
// Serialize a child node. Historically `toString` used `this.map(String)`,
// which leniently coerced anything — including raw arrays inserted via
// `replaceWith(array)` / `insertBefore` / `insertAfter` (e.g. Tailwind's
// `:merge()` expansion). Fall back to `String(child)` for values that are not
// parser nodes so that behaviour is preserved.
Container.prototype._stringifyChild = function (child, options, depth, max) {
return typeof child._stringify === "function"
? child._stringify(options, depth, max)
: String(child);
};
return Container;
}(node_1.default));
exports.default = Container;
//# sourceMappingURL=container.js.map
+61
View File
@@ -0,0 +1,61 @@
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isUniversal = exports.isTag = exports.isString = exports.isSelector = exports.isRoot = exports.isPseudo = exports.isNesting = exports.isIdentifier = exports.isComment = exports.isCombinator = exports.isClassName = exports.isAttribute = void 0;
exports.isNode = isNode;
exports.isPseudoElement = isPseudoElement;
exports.isPseudoClass = isPseudoClass;
exports.isContainer = isContainer;
exports.isNamespace = isNamespace;
var types_1 = require("./types");
var IS_TYPE = (_a = {},
_a[types_1.ATTRIBUTE] = true,
_a[types_1.CLASS] = true,
_a[types_1.COMBINATOR] = true,
_a[types_1.COMMENT] = true,
_a[types_1.ID] = true,
_a[types_1.NESTING] = true,
_a[types_1.PSEUDO] = true,
_a[types_1.ROOT] = true,
_a[types_1.SELECTOR] = true,
_a[types_1.STRING] = true,
_a[types_1.TAG] = true,
_a[types_1.UNIVERSAL] = true,
_a);
function isNode(node) {
return typeof node === "object" && IS_TYPE[node.type];
}
function isNodeType(type, node) {
return isNode(node) && node.type === type;
}
exports.isAttribute = isNodeType.bind(null, types_1.ATTRIBUTE);
exports.isClassName = isNodeType.bind(null, types_1.CLASS);
exports.isCombinator = isNodeType.bind(null, types_1.COMBINATOR);
exports.isComment = isNodeType.bind(null, types_1.COMMENT);
exports.isIdentifier = isNodeType.bind(null, types_1.ID);
exports.isNesting = isNodeType.bind(null, types_1.NESTING);
exports.isPseudo = isNodeType.bind(null, types_1.PSEUDO);
exports.isRoot = isNodeType.bind(null, types_1.ROOT);
exports.isSelector = isNodeType.bind(null, types_1.SELECTOR);
exports.isString = isNodeType.bind(null, types_1.STRING);
exports.isTag = isNodeType.bind(null, types_1.TAG);
exports.isUniversal = isNodeType.bind(null, types_1.UNIVERSAL);
function isPseudoElement(node) {
return ((0, exports.isPseudo)(node) &&
node.value &&
(node.value.startsWith("::") ||
node.value.toLowerCase() === ":before" ||
node.value.toLowerCase() === ":after" ||
node.value.toLowerCase() === ":first-letter" ||
node.value.toLowerCase() === ":first-line"));
}
function isPseudoClass(node) {
return (0, exports.isPseudo)(node) && !isPseudoElement(node);
}
function isContainer(node) {
return !!(isNode(node) && node.walk);
}
function isNamespace(node) {
return (0, exports.isAttribute)(node) || (0, exports.isTag)(node);
}
//# sourceMappingURL=guards.js.map
+36
View File
@@ -0,0 +1,36 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var node_1 = __importDefault(require("./node"));
var types_1 = require("./types");
var ID = /** @class */ (function (_super) {
__extends(ID, _super);
function ID(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.ID;
return _this;
}
ID.prototype.valueToString = function () {
return "#" + _super.prototype.valueToString.call(this);
};
return ID;
}(node_1.default));
exports.default = ID;
//# sourceMappingURL=id.js.map
+20
View File
@@ -0,0 +1,20 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./types"), exports);
__exportStar(require("./constructors"), exports);
__exportStar(require("./guards"), exports);
//# sourceMappingURL=index.js.map
+96
View File
@@ -0,0 +1,96 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var cssesc_1 = __importDefault(require("cssesc"));
var util_1 = require("../util");
var node_1 = __importDefault(require("./node"));
var Namespace = /** @class */ (function (_super) {
__extends(Namespace, _super);
function Namespace() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(Namespace.prototype, "namespace", {
get: function () {
return this._namespace;
},
set: function (namespace) {
if (namespace === true || namespace === "*" || namespace === "&") {
this._namespace = namespace;
if (this.raws) {
delete this.raws.namespace;
}
return;
}
var escaped = (0, cssesc_1.default)(namespace, { isIdentifier: true });
this._namespace = namespace;
if (escaped !== namespace) {
(0, util_1.ensureObject)(this, "raws");
this.raws.namespace = escaped;
}
else if (this.raws) {
delete this.raws.namespace;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Namespace.prototype, "ns", {
get: function () {
return this._namespace;
},
set: function (namespace) {
this.namespace = namespace;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Namespace.prototype, "namespaceString", {
get: function () {
if (this.namespace) {
var ns = this.stringifyProperty("namespace");
if (ns === true) {
return "";
}
else {
return ns;
}
}
else {
return "";
}
},
enumerable: false,
configurable: true
});
Namespace.prototype.qualifiedName = function (value) {
if (this.namespace) {
return "".concat(this.namespaceString, "|").concat(value);
}
else {
return value;
}
};
Namespace.prototype.valueToString = function () {
return this.qualifiedName(_super.prototype.valueToString.call(this));
};
return Namespace;
}(node_1.default));
exports.default = Namespace;
//# sourceMappingURL=namespace.js.map
+34
View File
@@ -0,0 +1,34 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var node_1 = __importDefault(require("./node"));
var types_1 = require("./types");
var Nesting = /** @class */ (function (_super) {
__extends(Nesting, _super);
function Nesting(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.NESTING;
_this.value = "&";
return _this;
}
return Nesting;
}(node_1.default));
exports.default = Nesting;
//# sourceMappingURL=nesting.js.map
+195
View File
@@ -0,0 +1,195 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../util");
var cloneNode = function (obj, parent, depth) {
if (depth === void 0) { depth = 0; }
// Bound recursion so a pathologically deep node tree raises a catchable
// error instead of overflowing the call stack (CVE-2026-9358 / CWE-674).
if (depth > util_1.MAX_NESTING_DEPTH) {
throw new Error("Cannot clone selector: nesting depth exceeds the maximum of ".concat(util_1.MAX_NESTING_DEPTH, "."));
}
if (typeof obj !== "object" || obj === null) {
return obj;
}
var cloned = new obj.constructor();
for (var i in obj) {
if (!obj.hasOwnProperty(i)) {
continue;
}
var value = obj[i];
var type = typeof value;
if (i === "parent" && type === "object") {
if (parent) {
cloned[i] = parent;
}
}
else if (value instanceof Array) {
cloned[i] = value.map(function (j) { return cloneNode(j, cloned, depth + 1); });
}
else {
cloned[i] = cloneNode(value, cloned, depth + 1);
}
}
return cloned;
};
var Node = /** @class */ (function () {
function Node(opts) {
if (opts === void 0) { opts = {}; }
Object.assign(this, opts);
this.spaces = this.spaces || {};
this.spaces.before = this.spaces.before || "";
this.spaces.after = this.spaces.after || "";
}
Node.prototype.remove = function () {
if (this.parent) {
this.parent.removeChild(this);
}
this.parent = undefined;
return this;
};
Node.prototype.replaceWith = function () {
if (this.parent) {
for (var index in arguments) {
this.parent.insertBefore(this, arguments[index]);
}
this.remove();
}
return this;
};
Node.prototype.next = function () {
return this.parent.at(this.parent.index(this) + 1);
};
Node.prototype.prev = function () {
return this.parent.at(this.parent.index(this) - 1);
};
Node.prototype.clone = function (overrides) {
if (overrides === void 0) { overrides = {}; }
var cloned = cloneNode(this);
for (var name in overrides) {
cloned[name] = overrides[name];
}
return cloned;
};
/**
* Some non-standard syntax doesn't follow normal escaping rules for css.
* This allows non standard syntax to be appended to an existing property
* by specifying the escaped value. By specifying the escaped value,
* illegal characters are allowed to be directly inserted into css output.
* @param {string} name the property to set
* @param {any} value the unescaped value of the property
* @param {string} valueEscaped optional. the escaped value of the property.
*/
Node.prototype.appendToPropertyAndEscape = function (name, value, valueEscaped) {
if (!this.raws) {
this.raws = {};
}
var originalValue = this[name];
var originalEscaped = this.raws[name];
this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
if (originalEscaped || valueEscaped !== value) {
this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
}
else {
delete this.raws[name]; // delete any escaped value that was created by the setter.
}
};
/**
* Some non-standard syntax doesn't follow normal escaping rules for css.
* This allows the escaped value to be specified directly, allowing illegal
* characters to be directly inserted into css output.
* @param {string} name the property to set
* @param {any} value the unescaped value of the property
* @param {string} valueEscaped the escaped value of the property.
*/
Node.prototype.setPropertyAndEscape = function (name, value, valueEscaped) {
if (!this.raws) {
this.raws = {};
}
this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
this.raws[name] = valueEscaped;
};
/**
* When you want a value to passed through to CSS directly. This method
* deletes the corresponding raw value causing the stringifier to fallback
* to the unescaped value.
* @param {string} name the property to set.
* @param {any} value The value that is both escaped and unescaped.
*/
Node.prototype.setPropertyWithoutEscape = function (name, value) {
this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
if (this.raws) {
delete this.raws[name];
}
};
/**
*
* @param {number} line The number (starting with 1)
* @param {number} column The column number (starting with 1)
*/
Node.prototype.isAtPosition = function (line, column) {
if (this.source && this.source.start && this.source.end) {
if (this.source.start.line > line) {
return false;
}
if (this.source.end.line < line) {
return false;
}
if (this.source.start.line === line && this.source.start.column > column) {
return false;
}
if (this.source.end.line === line && this.source.end.column < column) {
return false;
}
return true;
}
return undefined;
};
Node.prototype.stringifyProperty = function (name) {
return (this.raws && this.raws[name]) || this[name];
};
Object.defineProperty(Node.prototype, "rawSpaceBefore", {
get: function () {
var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
if (rawSpace === undefined) {
rawSpace = this.spaces && this.spaces.before;
}
return rawSpace || "";
},
set: function (raw) {
(0, util_1.ensureObject)(this, "raws", "spaces");
this.raws.spaces.before = raw;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Node.prototype, "rawSpaceAfter", {
get: function () {
var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
if (rawSpace === undefined) {
rawSpace = this.spaces.after;
}
return rawSpace || "";
},
set: function (raw) {
(0, util_1.ensureObject)(this, "raws", "spaces");
this.raws.spaces.after = raw;
},
enumerable: false,
configurable: true
});
Node.prototype.valueToString = function () {
return String(this.stringifyProperty("value"));
};
Node.prototype.toString = function () {
return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join("");
};
// Internal recursion entry point used by Container serialization. Leaf
// nodes don't recurse, so they ignore the depth/limit and stringify
// themselves. Containers override this to thread the nesting depth.
Node.prototype._stringify = function () {
return this.toString();
};
return Node;
}());
exports.default = Node;
//# sourceMappingURL=node.js.map
+45
View File
@@ -0,0 +1,45 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var container_1 = __importDefault(require("./container"));
var types_1 = require("./types");
var Pseudo = /** @class */ (function (_super) {
__extends(Pseudo, _super);
function Pseudo(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.PSEUDO;
return _this;
}
Pseudo.prototype._stringify = function (options, depth, max) {
var _this = this;
if (depth >= max) {
throw new Error("Cannot serialize selector: nesting depth exceeds the maximum of ".concat(max, "."));
}
var params = this.length
? "(" +
this.map(function (child) { return _this._stringifyChild(child, options, depth + 1, max); }).join(",") +
")"
: "";
return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join("");
};
return Pseudo;
}(container_1.default));
exports.default = Pseudo;
//# sourceMappingURL=pseudo.js.map
+56
View File
@@ -0,0 +1,56 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var container_1 = __importDefault(require("./container"));
var types_1 = require("./types");
var Root = /** @class */ (function (_super) {
__extends(Root, _super);
function Root(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.ROOT;
return _this;
}
Root.prototype._stringify = function (options, depth, max) {
var _this = this;
var str = this.reduce(function (memo, selector) {
memo.push(_this._stringifyChild(selector, options, depth, max));
return memo;
}, []).join(",");
return this.trailingComma ? str + "," : str;
};
Root.prototype.error = function (message, options) {
if (this._error) {
return this._error(message, options);
}
else {
return new Error(message);
}
};
Object.defineProperty(Root.prototype, "errorGenerator", {
set: function (handler) {
this._error = handler;
},
enumerable: false,
configurable: true
});
return Root;
}(container_1.default));
exports.default = Root;
//# sourceMappingURL=root.js.map
+33
View File
@@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var container_1 = __importDefault(require("./container"));
var types_1 = require("./types");
var Selector = /** @class */ (function (_super) {
__extends(Selector, _super);
function Selector(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.SELECTOR;
return _this;
}
return Selector;
}(container_1.default));
exports.default = Selector;
//# sourceMappingURL=selector.js.map
+33
View File
@@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var node_1 = __importDefault(require("./node"));
var types_1 = require("./types");
var String = /** @class */ (function (_super) {
__extends(String, _super);
function String(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.STRING;
return _this;
}
return String;
}(node_1.default));
exports.default = String;
//# sourceMappingURL=string.js.map
+33
View File
@@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var namespace_1 = __importDefault(require("./namespace"));
var types_1 = require("./types");
var Tag = /** @class */ (function (_super) {
__extends(Tag, _super);
function Tag(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.TAG;
return _this;
}
return Tag;
}(namespace_1.default));
exports.default = Tag;
//# sourceMappingURL=tag.js.map
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UNIVERSAL = exports.ATTRIBUTE = exports.CLASS = exports.COMBINATOR = exports.COMMENT = exports.ID = exports.NESTING = exports.PSEUDO = exports.ROOT = exports.SELECTOR = exports.STRING = exports.TAG = void 0;
exports.TAG = "tag";
exports.STRING = "string";
exports.SELECTOR = "selector";
exports.ROOT = "root";
exports.PSEUDO = "pseudo";
exports.NESTING = "nesting";
exports.ID = "id";
exports.COMMENT = "comment";
exports.COMBINATOR = "combinator";
exports.CLASS = "class";
exports.ATTRIBUTE = "attribute";
exports.UNIVERSAL = "universal";
//# sourceMappingURL=types.js.map
+34
View File
@@ -0,0 +1,34 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var namespace_1 = __importDefault(require("./namespace"));
var types_1 = require("./types");
var Universal = /** @class */ (function (_super) {
__extends(Universal, _super);
function Universal(opts) {
var _this = _super.call(this, opts) || this;
_this.type = types_1.UNIVERSAL;
_this.value = "*";
return _this;
}
return Universal;
}(namespace_1.default));
exports.default = Universal;
//# sourceMappingURL=universal.js.map