Complete Email Sortierer implementation with Appwrite and Stripe integration

This commit is contained in:
2026-01-14 20:02:16 +01:00
commit 95349af50b
3355 changed files with 644802 additions and 0 deletions

20
server/node_modules/@acemir/cssom/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) Nikita Vasilyev
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

64
server/node_modules/@acemir/cssom/README.mdown generated vendored Normal file
View File

@@ -0,0 +1,64 @@
# CSSOM
CSSOM.js is a CSS parser written in pure JavaScript. It is also a partial implementation of [CSS Object Model](http://dev.w3.org/csswg/cssom/).
CSSOM.parse("body {color: black}")
-> {
cssRules: [
{
selectorText: "body",
style: {
0: "color",
color: "black",
length: 1
}
}
]
}
## [Parser demo](https://acemir.github.io/CSSOM/docs/parse.html)
Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63+.
Doesn't work in IE < 9 because of unsupported getters/setters.
To use CSSOM.js in the browser you might want to build a one-file version that exposes a single `CSSOM` global variable:
➤ git clone https://github.com/acemir/CSSOM.git
➤ cd CSSOM
➤ node build.js
build/CSSOM.js is done
To use it with Node.js or any other CommonJS loader:
➤ npm install @acemir/cssom
## Dont use it if...
You parse CSS to mungle, minify or reformat code like this:
```css
div {
background: gray;
background: linear-gradient(to bottom, white 0%, black 100%);
}
```
This pattern is often used to give browsers that dont understand linear gradients a fallback solution (e.g. gray color in the example).
In CSSOM, `background: gray` [gets overwritten](http://nv.github.io/CSSOM/docs/parse.html#css=div%20%7B%0A%20%20%20%20%20%20background%3A%20gray%3B%0A%20%20%20%20background%3A%20linear-gradient(to%20bottom%2C%20white%200%25%2C%20black%20100%25)%3B%0A%7D).
It does **NOT** get preserved.
If you do CSS mungling, minification, or image inlining, considere using one of the following:
* [postcss](https://github.com/postcss/postcss)
* [reworkcss/css](https://github.com/reworkcss/css)
* [csso](https://github.com/css/csso)
* [mensch](https://github.com/brettstimmerman/mensch)
## [Tests](https://acemir.github.io/CSSOM/spec/)
To run tests locally:
➤ git submodule init
➤ git submodule update

6611
server/node_modules/@acemir/cssom/build/CSSOM.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule
};
///CommonJS
/**
* @constructor
* @see https://www.w3.org/TR/css-conditional-3/#the-cssconditionrule-interface
*/
CSSOM.CSSConditionRule = function CSSConditionRule() {
CSSOM.CSSGroupingRule.call(this);
this.__conditionText = '';
};
CSSOM.CSSConditionRule.prototype = Object.create(CSSOM.CSSGroupingRule.prototype);
CSSOM.CSSConditionRule.prototype.constructor = CSSOM.CSSConditionRule;
Object.setPrototypeOf(CSSOM.CSSConditionRule, CSSOM.CSSGroupingRule);
Object.defineProperty(CSSOM.CSSConditionRule.prototype, "conditionText", {
get: function () {
return this.__conditionText;
}
});
//.CommonJS
exports.CSSConditionRule = CSSOM.CSSConditionRule;
///CommonJS

View File

@@ -0,0 +1,70 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
CSSConditionRule: require("./CSSConditionRule").CSSConditionRule,
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-contain-3/
* @see https://www.w3.org/TR/css-contain-3/
*/
CSSOM.CSSContainerRule = function CSSContainerRule() {
CSSOM.CSSConditionRule.call(this);
};
CSSOM.CSSContainerRule.prototype = Object.create(CSSOM.CSSConditionRule.prototype);
CSSOM.CSSContainerRule.prototype.constructor = CSSOM.CSSContainerRule;
Object.setPrototypeOf(CSSOM.CSSContainerRule, CSSOM.CSSConditionRule);
Object.defineProperty(CSSOM.CSSContainerRule.prototype, "type", {
value: 17,
writable: false
});
Object.defineProperties(CSSOM.CSSContainerRule.prototype, {
"cssText": {
get: function() {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@container " + this.conditionText + values;
}
},
"containerName": {
get: function() {
var parts = this.conditionText.trim().split(/\s+/);
if (parts.length > 1 && parts[0] !== '(' && !parts[0].startsWith('(')) {
return parts[0];
}
return "";
}
},
"containerQuery": {
get: function() {
var parts = this.conditionText.trim().split(/\s+/);
if (parts.length > 1 && parts[0] !== '(' && !parts[0].startsWith('(')) {
return parts.slice(1).join(' ');
}
return this.conditionText;
}
},
});
//.CommonJS
exports.CSSContainerRule = CSSOM.CSSContainerRule;
///CommonJS

View File

@@ -0,0 +1,57 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-counter-styles/#the-csscounterstylerule-interface
*/
CSSOM.CSSCounterStyleRule = function CSSCounterStyleRule() {
CSSOM.CSSRule.call(this);
this.name = "";
this.__props = "";
};
CSSOM.CSSCounterStyleRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSCounterStyleRule.prototype.constructor = CSSOM.CSSCounterStyleRule;
Object.setPrototypeOf(CSSOM.CSSCounterStyleRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSCounterStyleRule.prototype, "type", {
value: 11,
writable: false
});
Object.defineProperty(CSSOM.CSSCounterStyleRule.prototype, "cssText", {
get: function() {
// FIXME : Implement real cssText generation based on properties
return "@counter-style " + this.name + " { " + this.__props + " }";
}
});
/**
* NON-STANDARD
* Rule text parser.
* @param {string} cssText
*/
Object.defineProperty(CSSOM.CSSCounterStyleRule.prototype, "parse", {
value: function(cssText) {
// Extract the name from "@counter-style <name> { ... }"
var match = cssText.match(/@counter-style\s+([^\s{]+)\s*\{([^]*)\}/);
if (match) {
this.name = match[1];
// Get the text inside the brackets and clean it up
var propsText = match[2];
this.__props = propsText.trim().replace(/\n/g, " ").replace(/(['"])(?:\\.|[^\\])*?\1|(\s{2,})/g, function (match, quote) {
return quote ? match : ' ';
});
}
}
});
//.CommonJS
exports.CSSCounterStyleRule = CSSOM.CSSCounterStyleRule;
///CommonJS

View File

@@ -0,0 +1,48 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
MatcherList: require("./MatcherList").MatcherList
};
///CommonJS
/**
* @constructor
* @see https://developer.mozilla.org/en/CSS/@-moz-document
* @deprecated This rule is a non-standard Mozilla-specific extension and is not part of any official CSS specification.
*/
CSSOM.CSSDocumentRule = function CSSDocumentRule() {
CSSOM.CSSRule.call(this);
this.matcher = new CSSOM.MatcherList();
this.cssRules = new CSSOM.CSSRuleList();
};
CSSOM.CSSDocumentRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSDocumentRule.prototype.constructor = CSSOM.CSSDocumentRule;
Object.setPrototypeOf(CSSOM.CSSDocumentRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "type", {
value: 10,
writable: false
});
//FIXME
//CSSOM.CSSDocumentRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSDocumentRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "cssText", {
get: function() {
var cssTexts = [];
for (var i=0, length=this.cssRules.length; i < length; i++) {
cssTexts.push(this.cssRules[i].cssText);
}
return "@-moz-document " + this.matcher.matcherText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
}
});
//.CommonJS
exports.CSSDocumentRule = CSSOM.CSSDocumentRule;
///CommonJS

View File

@@ -0,0 +1,62 @@
//.CommonJS
var CSSOM = {
CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
CSSRule: require("./CSSRule").CSSRule
};
// Use cssstyle if available
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}
///CommonJS
/**
* @constructor
* @see http://dev.w3.org/csswg/cssom/#css-font-face-rule
*/
CSSOM.CSSFontFaceRule = function CSSFontFaceRule() {
CSSOM.CSSRule.call(this);
this.__style = new CSSOM.CSSStyleDeclaration();
this.__style.parentRule = this;
};
CSSOM.CSSFontFaceRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSFontFaceRule.prototype.constructor = CSSOM.CSSFontFaceRule;
Object.setPrototypeOf(CSSOM.CSSFontFaceRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "type", {
value: 5,
writable: false
});
//FIXME
//CSSOM.CSSFontFaceRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSFontFaceRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "style", {
get: function() {
return this.__style;
},
set: function(value) {
if (typeof value === "string") {
this.__style.cssText = value;
} else {
this.__style = value;
}
}
});
// http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSFontFaceRule.cpp
Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "cssText", {
get: function() {
return "@font-face {" + (this.style.cssText ? " " + this.style.cssText : "") + " }";
}
});
//.CommonJS
exports.CSSFontFaceRule = CSSOM.CSSFontFaceRule;
///CommonJS

View File

@@ -0,0 +1,165 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
parse: require('./parse').parse
};
var errorUtils = require("./errorUtils").errorUtils;
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/cssom/#the-cssgroupingrule-interface
*/
CSSOM.CSSGroupingRule = function CSSGroupingRule() {
CSSOM.CSSRule.call(this);
this.__cssRules = new CSSOM.CSSRuleList();
};
CSSOM.CSSGroupingRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSGroupingRule.prototype.constructor = CSSOM.CSSGroupingRule;
Object.setPrototypeOf(CSSOM.CSSGroupingRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSGroupingRule.prototype, "cssRules", {
get: function() {
return this.__cssRules;
}
});
/**
* Used to insert a new CSS rule to a list of CSS rules.
*
* @example
* cssGroupingRule.cssText
* -> "body{margin:0;}"
* cssGroupingRule.insertRule("img{border:none;}", 1)
* -> 1
* cssGroupingRule.cssText
* -> "body{margin:0;}img{border:none;}"
*
* @param {string} rule
* @param {number} [index]
* @see https://www.w3.org/TR/cssom-1/#dom-cssgroupingrule-insertrule
* @return {number} The index within the grouping rule's collection of the newly inserted rule.
*/
CSSOM.CSSGroupingRule.prototype.insertRule = function insertRule(rule, index) {
if (rule === undefined && index === undefined) {
errorUtils.throwMissingArguments(this, 'insertRule', this.constructor.name);
}
if (index === void 0) {
index = 0;
}
index = Number(index);
if (index < 0) {
index = 4294967296 + index;
}
if (index > this.cssRules.length) {
errorUtils.throwIndexError(this, 'insertRule', this.constructor.name, index, this.cssRules.length);
}
var ruleToParse = processedRuleToParse = String(rule);
ruleToParse = ruleToParse.trim().replace(/^\/\*[\s\S]*?\*\/\s*/, "");
var isNestedSelector = this.constructor.name === "CSSStyleRule";
if (isNestedSelector === false) {
var currentRule = this;
while (currentRule.parentRule) {
currentRule = currentRule.parentRule;
if (currentRule.constructor.name === "CSSStyleRule") {
isNestedSelector = true;
break;
}
}
}
if (isNestedSelector) {
processedRuleToParse = 's { n { } ' + ruleToParse + '}';
}
var isScopeRule = this.constructor.name === "CSSScopeRule";
if (isScopeRule) {
if (isNestedSelector) {
processedRuleToParse = 's { ' + '@scope {' + ruleToParse + '}}';
} else {
processedRuleToParse = '@scope {' + ruleToParse + '}';
}
}
var parsedRules = new CSSOM.CSSRuleList();
CSSOM.parse(processedRuleToParse, {
styleSheet: this.parentStyleSheet,
cssRules: parsedRules
});
if (isScopeRule) {
if (isNestedSelector) {
parsedRules = parsedRules[0].cssRules[0].cssRules;
} else {
parsedRules = parsedRules[0].cssRules
}
}
if (isNestedSelector) {
parsedRules = parsedRules[0].cssRules.slice(1);
}
if (parsedRules.length !== 1) {
if (isNestedSelector && parsedRules.length === 0 && ruleToParse.indexOf('@font-face') === 0) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': " +
"Only conditional nested group rules, style rules, @scope rules, @apply rules, and nested declaration rules may be nested.",
'HierarchyRequestError');
} else {
errorUtils.throwParseError(this, 'insertRule', this.constructor.name, ruleToParse, 'SyntaxError');
}
}
var cssRule = parsedRules[0];
if (cssRule.constructor.name === 'CSSNestedDeclarations' && cssRule.style.length === 0) {
errorUtils.throwParseError(this, 'insertRule', this.constructor.name, ruleToParse, 'SyntaxError');
}
// Check for rules that cannot be inserted inside a CSSGroupingRule
if (cssRule.constructor.name === 'CSSImportRule' || cssRule.constructor.name === 'CSSNamespaceRule') {
var ruleKeyword = cssRule.constructor.name === 'CSSImportRule' ? '@import' : '@namespace';
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': " +
"'" + ruleKeyword + "' rules cannot be inserted inside a group rule.",
'HierarchyRequestError');
}
// Check for CSSLayerStatementRule (@layer statement rules)
if (cssRule.constructor.name === 'CSSLayerStatementRule') {
errorUtils.throwParseError(this, 'insertRule', this.constructor.name, ruleToParse, 'SyntaxError');
}
cssRule.__parentRule = this;
this.cssRules.splice(index, 0, cssRule);
return index;
};
/**
* Used to delete a rule from the grouping rule.
*
* cssGroupingRule.cssText
* -> "img{border:none;}body{margin:0;}"
* cssGroupingRule.deleteRule(0)
* cssGroupingRule.cssText
* -> "body{margin:0;}"
*
* @param {number} index within the grouping rule's rule list of the rule to remove.
* @see https://www.w3.org/TR/cssom-1/#dom-cssgroupingrule-deleterule
*/
CSSOM.CSSGroupingRule.prototype.deleteRule = function deleteRule(index) {
if (index === undefined) {
errorUtils.throwMissingArguments(this, 'deleteRule', this.constructor.name);
}
index = Number(index);
if (index < 0) {
index = 4294967296 + index;
}
if (index >= this.cssRules.length) {
errorUtils.throwIndexError(this, 'deleteRule', this.constructor.name, index, this.cssRules.length);
}
this.cssRules[index].__parentRule = null;
this.cssRules[index].__parentStyleSheet = null;
this.cssRules.splice(index, 1);
};
//.CommonJS
exports.CSSGroupingRule = CSSOM.CSSGroupingRule;
///CommonJS

54
server/node_modules/@acemir/cssom/lib/CSSHostRule.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList
};
///CommonJS
/**
* @constructor
* @see http://www.w3.org/TR/shadow-dom/#host-at-rule
* @see http://html5index.org/Shadow%20DOM%20-%20CSSHostRule.html
* @deprecated This rule was part of early Shadow DOM drafts but was removed in favor of the more flexible :host and :host-context() pseudo-classes in modern CSS for Web Components.
*/
CSSOM.CSSHostRule = function CSSHostRule() {
CSSOM.CSSRule.call(this);
this.cssRules = new CSSOM.CSSRuleList();
};
CSSOM.CSSHostRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSHostRule.prototype.constructor = CSSOM.CSSHostRule;
Object.setPrototypeOf(CSSOM.CSSHostRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSHostRule.prototype, "type", {
value: 1001,
writable: false
});
//FIXME
//CSSOM.CSSHostRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSHostRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
Object.defineProperty(CSSOM.CSSHostRule.prototype, "cssText", {
get: function() {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@host" + values;
}
});
//.CommonJS
exports.CSSHostRule = CSSOM.CSSHostRule;
///CommonJS

267
server/node_modules/@acemir/cssom/lib/CSSImportRule.js generated vendored Normal file
View File

@@ -0,0 +1,267 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
MediaList: require("./MediaList").MediaList
};
var regexPatterns = require("./regexPatterns").regexPatterns;
///CommonJS
/**
* @constructor
* @see http://dev.w3.org/csswg/cssom/#cssimportrule
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSImportRule
*/
CSSOM.CSSImportRule = function CSSImportRule() {
CSSOM.CSSRule.call(this);
this.__href = "";
this.__media = new CSSOM.MediaList();
this.__layerName = null;
this.__supportsText = null;
this.__styleSheet = new CSSOM.CSSStyleSheet();
};
CSSOM.CSSImportRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSImportRule.prototype.constructor = CSSOM.CSSImportRule;
Object.setPrototypeOf(CSSOM.CSSImportRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSImportRule.prototype, "type", {
value: 3,
writable: false
});
Object.defineProperty(CSSOM.CSSImportRule.prototype, "cssText", {
get: function() {
var mediaText = this.media.mediaText;
return "@import url(\"" + this.href.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + "\")" + (this.layerName !== null ? " layer" + (this.layerName && "(" + this.layerName + ")") : "" ) + (this.supportsText ? " supports(" + this.supportsText + ")" : "" ) + (mediaText ? " " + mediaText : "") + ";";
}
});
Object.defineProperty(CSSOM.CSSImportRule.prototype, "href", {
get: function() {
return this.__href;
}
});
Object.defineProperty(CSSOM.CSSImportRule.prototype, "media", {
get: function() {
return this.__media;
},
set: function(value) {
if (typeof value === "string") {
this.__media.mediaText = value;
} else {
this.__media = value;
}
}
});
Object.defineProperty(CSSOM.CSSImportRule.prototype, "layerName", {
get: function() {
return this.__layerName;
}
});
Object.defineProperty(CSSOM.CSSImportRule.prototype, "supportsText", {
get: function() {
return this.__supportsText;
}
});
Object.defineProperty(CSSOM.CSSImportRule.prototype, "styleSheet", {
get: function() {
return this.__styleSheet;
}
});
/**
* NON-STANDARD
* Rule text parser.
* @param {string} cssText
*/
Object.defineProperty(CSSOM.CSSImportRule.prototype, "parse", {
value: function(cssText) {
var i = 0;
/**
* @import url(partial.css) screen, handheld;
* || |
* after-import media
* |
* url
*/
var state = '';
var buffer = '';
var index;
var layerRegExp = regexPatterns.layerRegExp;
var layerRuleNameRegExp = regexPatterns.layerRuleNameRegExp;
var doubleOrMoreSpacesRegExp = regexPatterns.doubleOrMoreSpacesRegExp;
/**
* Extracts the content inside supports() handling nested parentheses.
* @param {string} text - The text to parse
* @returns {object|null} - {content: string, endIndex: number} or null if not found
*/
function extractSupportsContent(text) {
var supportsIndex = text.indexOf('supports(');
if (supportsIndex !== 0) {
return null;
}
var depth = 0;
var start = supportsIndex + 'supports('.length;
var i = start;
for (; i < text.length; i++) {
if (text[i] === '(') {
depth++;
} else if (text[i] === ')') {
if (depth === 0) {
// Found the closing parenthesis for supports()
return {
content: text.slice(start, i),
endIndex: i
};
}
depth--;
}
}
return null; // Unbalanced parentheses
}
for (var character; (character = cssText.charAt(i)); i++) {
switch (character) {
case ' ':
case '\t':
case '\r':
case '\n':
case '\f':
if (state === 'after-import') {
state = 'url';
} else {
buffer += character;
}
break;
case '@':
if (!state && cssText.indexOf('@import', i) === i) {
state = 'after-import';
i += 'import'.length;
buffer = '';
}
break;
case 'u':
if (state === 'media') {
buffer += character;
}
if (state === 'url' && cssText.indexOf('url(', i) === i) {
index = cssText.indexOf(')', i + 1);
if (index === -1) {
throw i + ': ")" not found';
}
i += 'url('.length;
var url = cssText.slice(i, index);
if (url[0] === url[url.length - 1]) {
if (url[0] === '"' || url[0] === "'") {
url = url.slice(1, -1);
}
}
this.__href = url;
i = index;
state = 'media';
}
break;
case '"':
if (state === 'after-import' || state === 'url') {
index = cssText.indexOf('"', i + 1);
if (!index) {
throw i + ": '\"' not found";
}
this.__href = cssText.slice(i + 1, index);
i = index;
state = 'media';
}
break;
case "'":
if (state === 'after-import' || state === 'url') {
index = cssText.indexOf("'", i + 1);
if (!index) {
throw i + ': "\'" not found';
}
this.__href = cssText.slice(i + 1, index);
i = index;
state = 'media';
}
break;
case ';':
if (state === 'media') {
if (buffer) {
var bufferTrimmed = buffer.trim();
if (bufferTrimmed.indexOf('layer') === 0) {
var layerMatch = bufferTrimmed.match(layerRegExp);
if (layerMatch) {
var layerName = layerMatch[1].trim();
if (layerName.match(layerRuleNameRegExp) !== null) {
this.__layerName = layerMatch[1].trim();
bufferTrimmed = bufferTrimmed.replace(layerRegExp, '')
.replace(doubleOrMoreSpacesRegExp, ' ') // Replace double or more spaces with single space
.trim();
} else {
// REVIEW: In the browser, an empty layer() is not processed as a unamed layer
// and treats the rest of the string as mediaText, ignoring the parse of supports()
if (bufferTrimmed) {
this.media.mediaText = bufferTrimmed;
return;
}
}
} else {
this.__layerName = "";
bufferTrimmed = bufferTrimmed.substring('layer'.length).trim()
}
}
var supportsResult = extractSupportsContent(bufferTrimmed);
if (supportsResult) {
// REVIEW: In the browser, an empty supports() invalidates and ignores the entire @import rule
this.__supportsText = supportsResult.content.trim();
// Remove the entire supports(...) from the buffer
bufferTrimmed = bufferTrimmed.slice(0, 0) + bufferTrimmed.slice(supportsResult.endIndex + 1);
bufferTrimmed = bufferTrimmed.replace(doubleOrMoreSpacesRegExp, ' ').trim();
}
// REVIEW: In the browser, any invalid media is replaced with 'not all'
if (bufferTrimmed) {
this.media.mediaText = bufferTrimmed;
}
}
}
break;
default:
if (state === 'media') {
buffer += character;
}
break;
}
}
}
});
//.CommonJS
exports.CSSImportRule = CSSOM.CSSImportRule;
///CommonJS

View File

@@ -0,0 +1,63 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration
};
// Use cssstyle if available
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}
///CommonJS
/**
* @constructor
* @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframeRule
*/
CSSOM.CSSKeyframeRule = function CSSKeyframeRule() {
CSSOM.CSSRule.call(this);
this.keyText = '';
this.__style = new CSSOM.CSSStyleDeclaration();
this.__style.parentRule = this;
};
CSSOM.CSSKeyframeRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule;
Object.setPrototypeOf(CSSOM.CSSKeyframeRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "type", {
value: 8,
writable: false
});
//FIXME
//CSSOM.CSSKeyframeRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSKeyframeRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "style", {
get: function() {
return this.__style;
},
set: function(value) {
if (typeof value === "string") {
this.__style.cssText = value;
} else {
this.__style = value;
}
}
});
// http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframeRule.cpp
Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "cssText", {
get: function() {
return this.keyText + " {" + (this.style.cssText ? " " + this.style.cssText : "") + " }";
}
});
//.CommonJS
exports.CSSKeyframeRule = CSSOM.CSSKeyframeRule;
///CommonJS

View File

@@ -0,0 +1,247 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
parse: require("./parse").parse
};
var errorUtils = require("./errorUtils").errorUtils;
///CommonJS
/**
* @constructor
* @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframesRule
*/
CSSOM.CSSKeyframesRule = function CSSKeyframesRule() {
CSSOM.CSSRule.call(this);
this.name = '';
this.cssRules = new CSSOM.CSSRuleList();
// Set up initial indexed access
this._setupIndexedAccess();
// Override cssRules methods after initial setup, store references as non-enumerable properties
var self = this;
var originalPush = this.cssRules.push;
var originalSplice = this.cssRules.splice;
// Create non-enumerable method overrides
Object.defineProperty(this.cssRules, 'push', {
value: function() {
var result = originalPush.apply(this, arguments);
self._setupIndexedAccess();
return result;
},
writable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(this.cssRules, 'splice', {
value: function() {
var result = originalSplice.apply(this, arguments);
self._setupIndexedAccess();
return result;
},
writable: true,
enumerable: false,
configurable: true
});
};
CSSOM.CSSKeyframesRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSKeyframesRule.prototype.constructor = CSSOM.CSSKeyframesRule;
Object.setPrototypeOf(CSSOM.CSSKeyframesRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSKeyframesRule.prototype, "type", {
value: 7,
writable: false
});
// http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframesRule.cpp
Object.defineProperty(CSSOM.CSSKeyframesRule.prototype, "cssText", {
get: function() {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
var cssWideKeywords = ['initial', 'inherit', 'revert', 'revert-layer', 'unset', 'none'];
var processedName = cssWideKeywords.includes(this.name) ? '"' + this.name + '"' : this.name;
return "@" + (this._vendorPrefix || '') + "keyframes " + processedName + values;
}
});
/**
* Appends a new keyframe rule to the list of keyframes.
*
* @param {string} rule - The keyframe rule string to append (e.g., "50% { opacity: 0.5; }")
* @see https://www.w3.org/TR/css-animations-1/#dom-csskeyframesrule-appendrule
*/
CSSOM.CSSKeyframesRule.prototype.appendRule = function appendRule(rule) {
if (arguments.length === 0) {
errorUtils.throwMissingArguments(this, 'appendRule', 'CSSKeyframesRule');
}
var parsedRule;
try {
// Parse the rule string as a keyframe rule
var tempStyleSheet = CSSOM.parse("@keyframes temp { " + rule + " }");
if (tempStyleSheet.cssRules.length > 0 && tempStyleSheet.cssRules[0].cssRules.length > 0) {
parsedRule = tempStyleSheet.cssRules[0].cssRules[0];
} else {
throw new Error("Failed to parse keyframe rule");
}
} catch (e) {
errorUtils.throwParseError(this, 'appendRule', 'CSSKeyframesRule', rule);
}
parsedRule.__parentRule = this;
this.cssRules.push(parsedRule);
};
/**
* Deletes a keyframe rule that matches the specified key.
*
* @param {string} select - The keyframe selector to delete (e.g., "50%", "from", "to")
* @see https://www.w3.org/TR/css-animations-1/#dom-csskeyframesrule-deleterule
*/
CSSOM.CSSKeyframesRule.prototype.deleteRule = function deleteRule(select) {
if (arguments.length === 0) {
errorUtils.throwMissingArguments(this, 'deleteRule', 'CSSKeyframesRule');
}
var normalizedSelect = this._normalizeKeyText(select);
for (var i = 0; i < this.cssRules.length; i++) {
var rule = this.cssRules[i];
if (this._normalizeKeyText(rule.keyText) === normalizedSelect) {
rule.__parentRule = null;
this.cssRules.splice(i, 1);
return;
}
}
};
/**
* Finds and returns the keyframe rule that matches the specified key.
* When multiple rules have the same key, returns the last one.
*
* @param {string} select - The keyframe selector to find (e.g., "50%", "from", "to")
* @return {CSSKeyframeRule|null} The matching keyframe rule, or null if not found
* @see https://www.w3.org/TR/css-animations-1/#dom-csskeyframesrule-findrule
*/
CSSOM.CSSKeyframesRule.prototype.findRule = function findRule(select) {
if (arguments.length === 0) {
errorUtils.throwMissingArguments(this, 'findRule', 'CSSKeyframesRule');
}
var normalizedSelect = this._normalizeKeyText(select);
// Iterate backwards to find the last matching rule
for (var i = this.cssRules.length - 1; i >= 0; i--) {
var rule = this.cssRules[i];
if (this._normalizeKeyText(rule.keyText) === normalizedSelect) {
return rule;
}
}
return null;
};
/**
* Normalizes keyframe selector text for comparison.
* Handles "from" -> "0%" and "to" -> "100%" conversions and trims whitespace.
*
* @private
* @param {string} keyText - The keyframe selector text to normalize
* @return {string} The normalized keyframe selector text
*/
CSSOM.CSSKeyframesRule.prototype._normalizeKeyText = function _normalizeKeyText(keyText) {
if (!keyText) return '';
var normalized = keyText.toString().trim().toLowerCase();
// Convert keywords to percentages for comparison
if (normalized === 'from') {
return '0%';
} else if (normalized === 'to') {
return '100%';
}
return normalized;
};
/**
* Makes CSSKeyframesRule iterable over its cssRules.
* Allows for...of loops and other iterable methods.
*/
if (typeof Symbol !== 'undefined' && Symbol.iterator) {
CSSOM.CSSKeyframesRule.prototype[Symbol.iterator] = function() {
var index = 0;
var cssRules = this.cssRules;
return {
next: function() {
if (index < cssRules.length) {
return { value: cssRules[index++], done: false };
} else {
return { done: true };
}
}
};
};
}
/**
* Adds indexed getters for direct access to cssRules by index.
* This enables rule[0], rule[1], etc. access patterns.
* Works in environments where Proxy is not available (like jsdom).
*/
CSSOM.CSSKeyframesRule.prototype._setupIndexedAccess = function() {
// Remove any existing indexed properties
for (var i = 0; i < 1000; i++) { // reasonable upper limit
if (this.hasOwnProperty(i)) {
delete this[i];
} else {
break;
}
}
// Add indexed getters for current cssRules
for (var i = 0; i < this.cssRules.length; i++) {
(function(index) {
Object.defineProperty(this, index, {
get: function() {
return this.cssRules[index];
},
enumerable: false,
configurable: true
});
}.call(this, i));
}
// Update length property
Object.defineProperty(this, 'length', {
get: function() {
return this.cssRules.length;
},
enumerable: false,
configurable: true
});
};
//.CommonJS
exports.CSSKeyframesRule = CSSOM.CSSKeyframesRule;
///CommonJS

View File

@@ -0,0 +1,49 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-cascade-5/#csslayerblockrule
*/
CSSOM.CSSLayerBlockRule = function CSSLayerBlockRule() {
CSSOM.CSSGroupingRule.call(this);
this.name = "";
};
CSSOM.CSSLayerBlockRule.prototype = Object.create(CSSOM.CSSGroupingRule.prototype);
CSSOM.CSSLayerBlockRule.prototype.constructor = CSSOM.CSSLayerBlockRule;
Object.setPrototypeOf(CSSOM.CSSLayerBlockRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSLayerBlockRule.prototype, "type", {
value: 18,
writable: false
});
Object.defineProperties(CSSOM.CSSLayerBlockRule.prototype, {
cssText: {
get: function () {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@layer" + (this.name ? " " + this.name : "") + values;
}
},
});
//.CommonJS
exports.CSSLayerBlockRule = CSSOM.CSSLayerBlockRule;
///CommonJS

View File

@@ -0,0 +1,36 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-cascade-5/#csslayerstatementrule
*/
CSSOM.CSSLayerStatementRule = function CSSLayerStatementRule() {
CSSOM.CSSRule.call(this);
this.nameList = [];
};
CSSOM.CSSLayerStatementRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSLayerStatementRule.prototype.constructor = CSSOM.CSSLayerStatementRule;
Object.setPrototypeOf(CSSOM.CSSLayerStatementRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSLayerStatementRule.prototype, "type", {
value: 0,
writable: false
});
Object.defineProperties(CSSOM.CSSLayerStatementRule.prototype, {
cssText: {
get: function () {
return "@layer " + this.nameList.join(", ") + ";";
}
},
});
//.CommonJS
exports.CSSLayerStatementRule = CSSOM.CSSLayerStatementRule;
///CommonJS

74
server/node_modules/@acemir/cssom/lib/CSSMediaRule.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
CSSConditionRule: require("./CSSConditionRule").CSSConditionRule,
MediaList: require("./MediaList").MediaList
};
///CommonJS
/**
* @constructor
* @see http://dev.w3.org/csswg/cssom/#cssmediarule
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSMediaRule
*/
CSSOM.CSSMediaRule = function CSSMediaRule() {
CSSOM.CSSConditionRule.call(this);
this.__media = new CSSOM.MediaList();
};
CSSOM.CSSMediaRule.prototype = Object.create(CSSOM.CSSConditionRule.prototype);
CSSOM.CSSMediaRule.prototype.constructor = CSSOM.CSSMediaRule;
Object.setPrototypeOf(CSSOM.CSSMediaRule, CSSOM.CSSConditionRule);
Object.defineProperty(CSSOM.CSSMediaRule.prototype, "type", {
value: 4,
writable: false
});
// https://opensource.apple.com/source/WebCore/WebCore-7611.1.21.161.3/css/CSSMediaRule.cpp
Object.defineProperties(CSSOM.CSSMediaRule.prototype, {
"media": {
get: function() {
return this.__media;
},
set: function(value) {
if (typeof value === "string") {
this.__media.mediaText = value;
} else {
this.__media = value;
}
},
configurable: true,
enumerable: true
},
"conditionText": {
get: function() {
return this.media.mediaText;
}
},
"cssText": {
get: function() {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@media " + this.media.mediaText + values;
}
}
});
//.CommonJS
exports.CSSMediaRule = CSSOM.CSSMediaRule;
///CommonJS

View File

@@ -0,0 +1,103 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/cssom/#the-cssnamespacerule-interface
*/
CSSOM.CSSNamespaceRule = function CSSNamespaceRule() {
CSSOM.CSSRule.call(this);
this.__prefix = "";
this.__namespaceURI = "";
};
CSSOM.CSSNamespaceRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSNamespaceRule.prototype.constructor = CSSOM.CSSNamespaceRule;
Object.setPrototypeOf(CSSOM.CSSNamespaceRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "type", {
value: 10,
writable: false
});
Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
get: function() {
return "@namespace" + (this.prefix && " " + this.prefix) + " url(\"" + this.namespaceURI + "\");";
}
});
Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "prefix", {
get: function() {
return this.__prefix;
}
});
Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "namespaceURI", {
get: function() {
return this.__namespaceURI;
}
});
/**
* NON-STANDARD
* Rule text parser.
* @param {string} cssText
*/
Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "parse", {
value: function(cssText) {
var newPrefix = "";
var newNamespaceURI = "";
// Remove @namespace and trim
var text = cssText.trim();
if (text.indexOf('@namespace') === 0) {
text = text.slice('@namespace'.length).trim();
}
// Remove trailing semicolon if present
if (text.charAt(text.length - 1) === ';') {
text = text.slice(0, -1).trim();
}
// Regex to match valid namespace syntax:
// 1. [optional prefix] url("...") or [optional prefix] url('...') or [optional prefix] url() or [optional prefix] url(unquoted)
// 2. [optional prefix] "..." or [optional prefix] '...'
// The prefix must be a valid CSS identifier (letters, digits, hyphens, underscores, starting with letter or underscore)
var re = /^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\s+)?(?:url\(\s*(?:(['"])(.*?)\2\s*|([^)]*?))\s*\)|(['"])(.*?)\5)$/;
var match = text.match(re);
if (match) {
// If prefix is present
if (match[1]) {
newPrefix = match[1];
}
// If url(...) form with quotes
if (typeof match[3] !== "undefined") {
newNamespaceURI = match[3];
}
// If url(...) form without quotes
else if (typeof match[4] !== "undefined") {
newNamespaceURI = match[4].trim();
}
// If quoted string form
else if (typeof match[6] !== "undefined") {
newNamespaceURI = match[6];
}
this.__prefix = newPrefix;
this.__namespaceURI = newNamespaceURI;
} else {
throw new DOMException("Invalid @namespace rule", "InvalidStateError");
}
}
});
//.CommonJS
exports.CSSNamespaceRule = CSSOM.CSSNamespaceRule;
///CommonJS

View File

@@ -0,0 +1,56 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration
};
// Use cssstyle if available
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-nesting-1/
*/
CSSOM.CSSNestedDeclarations = function CSSNestedDeclarations() {
CSSOM.CSSRule.call(this);
this.__style = new CSSOM.CSSStyleDeclaration();
this.__style.parentRule = this;
};
CSSOM.CSSNestedDeclarations.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSNestedDeclarations.prototype.constructor = CSSOM.CSSNestedDeclarations;
Object.setPrototypeOf(CSSOM.CSSNestedDeclarations, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSNestedDeclarations.prototype, "type", {
value: 0,
writable: false
});
Object.defineProperty(CSSOM.CSSNestedDeclarations.prototype, "style", {
get: function() {
return this.__style;
},
set: function(value) {
if (typeof value === "string") {
this.__style.cssText = value;
} else {
this.__style = value;
}
}
});
Object.defineProperty(CSSOM.CSSNestedDeclarations.prototype, "cssText", {
get: function () {
return this.style.cssText;
}
});
//.CommonJS
exports.CSSNestedDeclarations = CSSOM.CSSNestedDeclarations;
///CommonJS

58
server/node_modules/@acemir/cssom/lib/CSSOM.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
var CSSOM = {
/**
* Creates and configures a new CSSOM instance with the specified options.
*
* @param {Object} opts - Configuration options for the CSSOM instance
* @param {Object} [opts.globalObject] - Optional global object to be assigned to CSSOM objects prototype
* @returns {Object} A new CSSOM instance with the applied configuration
* @description
* This method creates a new instance of CSSOM and optionally
* configures CSSStyleSheet with a global object reference. When a globalObject is provided
* and CSSStyleSheet exists on the instance, it creates a new CSSStyleSheet constructor
* using a factory function and assigns the globalObject to its prototype's __globalObject property.
*/
setup: function (opts) {
var instance = Object.create(this);
if (opts.globalObject) {
if (instance.CSSStyleSheet) {
var factoryCSSStyleSheet = createFunctionFactory(instance.CSSStyleSheet);
var CSSStyleSheet = factoryCSSStyleSheet();
CSSStyleSheet.prototype.__globalObject = opts.globalObject;
instance.CSSStyleSheet = CSSStyleSheet;
}
}
return instance;
}
};
function createFunctionFactory(fn) {
return function() {
// Create a new function that delegates to the original
var newFn = function() {
return fn.apply(this, arguments);
};
// Copy prototype chain
Object.setPrototypeOf(newFn, Object.getPrototypeOf(fn));
// Copy own properties
for (var key in fn) {
if (Object.prototype.hasOwnProperty.call(fn, key)) {
newFn[key] = fn[key];
}
}
// Clone the .prototype object for constructor-like behavior
if (fn.prototype) {
newFn.prototype = Object.create(fn.prototype);
}
return newFn;
};
}
//.CommonJS
module.exports = CSSOM;
///CommonJS

125
server/node_modules/@acemir/cssom/lib/CSSPageRule.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
//.CommonJS
var CSSOM = {
CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
};
var regexPatterns = require("./regexPatterns").regexPatterns;
// Use cssstyle if available
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/cssom/#the-csspagerule-interface
*/
CSSOM.CSSPageRule = function CSSPageRule() {
CSSOM.CSSGroupingRule.call(this);
this.__style = new CSSOM.CSSStyleDeclaration();
this.__style.parentRule = this;
};
CSSOM.CSSPageRule.prototype = Object.create(CSSOM.CSSGroupingRule.prototype);
CSSOM.CSSPageRule.prototype.constructor = CSSOM.CSSPageRule;
Object.setPrototypeOf(CSSOM.CSSPageRule, CSSOM.CSSGroupingRule);
Object.defineProperty(CSSOM.CSSPageRule.prototype, "type", {
value: 6,
writable: false
});
Object.defineProperty(CSSOM.CSSPageRule.prototype, "selectorText", {
get: function() {
return this.__selectorText;
},
set: function(value) {
if (typeof value === "string") {
var trimmedValue = value.trim();
// Empty selector is valid for @page
if (trimmedValue === '') {
this.__selectorText = '';
return;
}
var atPageRuleSelectorRegExp = regexPatterns.atPageRuleSelectorRegExp;
var cssCustomIdentifierRegExp = regexPatterns.cssCustomIdentifierRegExp;
var match = trimmedValue.match(atPageRuleSelectorRegExp);
if (match) {
var pageName = match[1] || '';
var pseudoPages = match[2] || '';
// Validate page name if present
if (pageName) {
// Page name can be an identifier or a string
if (!cssCustomIdentifierRegExp.test(pageName)) {
return;
}
}
// Validate pseudo-pages if present
if (pseudoPages) {
var pseudos = pseudoPages.split(':').filter(function(p) { return p; });
var validPseudos = ['left', 'right', 'first', 'blank'];
var allValid = true;
for (var j = 0; j < pseudos.length; j++) {
if (validPseudos.indexOf(pseudos[j].toLowerCase()) === -1) {
allValid = false;
break;
}
}
if (!allValid) {
return; // Invalid pseudo-page, do nothing
}
}
this.__selectorText = pageName + pseudoPages.toLowerCase();
}
}
}
});
Object.defineProperty(CSSOM.CSSPageRule.prototype, "style", {
get: function() {
return this.__style;
},
set: function(value) {
if (typeof value === "string") {
this.__style.cssText = value;
} else {
this.__style = value;
}
}
});
Object.defineProperty(CSSOM.CSSPageRule.prototype, "cssText", {
get: function() {
var values = "";
if (this.cssRules.length) {
var valuesArr = [" {"];
this.style.cssText && valuesArr.push(this.style.cssText);
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
values = valuesArr.join("\n ") + "\n}";
} else {
values = " {" + (this.style.cssText ? " " + this.style.cssText : "") + " }";
}
return "@page" + (this.selectorText ? " " + this.selectorText : "") + values;
}
});
//.CommonJS
exports.CSSPageRule = CSSOM.CSSPageRule;
///CommonJS

View File

@@ -0,0 +1,122 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule
};
///CommonJS
/**
* @constructor
* @see https://drafts.css-houdini.org/css-properties-values-api/#the-css-property-rule-interface
*/
CSSOM.CSSPropertyRule = function CSSPropertyRule() {
CSSOM.CSSRule.call(this);
this.__name = "";
this.__syntax = "";
this.__inherits = false;
this.__initialValue = null;
};
CSSOM.CSSPropertyRule.prototype = Object.create(CSSOM.CSSRule.prototype);
CSSOM.CSSPropertyRule.prototype.constructor = CSSOM.CSSPropertyRule;
Object.setPrototypeOf(CSSOM.CSSPropertyRule, CSSOM.CSSRule);
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "type", {
value: 0,
writable: false
});
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "cssText", {
get: function() {
var text = "@property " + this.name + " {";
if (this.syntax !== "") {
text += " syntax: \"" + this.syntax.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + "\";";
}
text += " inherits: " + (this.inherits ? "true" : "false") + ";";
if (this.initialValue !== null) {
text += " initial-value: " + this.initialValue + ";";
}
text += " }";
return text;
}
});
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "name", {
get: function() {
return this.__name;
}
});
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "syntax", {
get: function() {
return this.__syntax;
}
});
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "inherits", {
get: function() {
return this.__inherits;
}
});
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "initialValue", {
get: function() {
return this.__initialValue;
}
});
/**
* NON-STANDARD
* Rule text parser.
* @param {string} cssText
* @returns {boolean} True if the rule is valid and was parsed successfully
*/
Object.defineProperty(CSSOM.CSSPropertyRule.prototype, "parse", {
value: function(cssText) {
// Extract the name from "@property <name> { ... }"
var match = cssText.match(/@property\s+(--[^\s{]+)\s*\{([^]*)\}/);
if (!match) {
return false;
}
this.__name = match[1];
var bodyText = match[2];
// Parse syntax descriptor (REQUIRED)
var syntaxMatch = bodyText.match(/syntax\s*:\s*(['"])([^]*?)\1\s*;/);
if (!syntaxMatch) {
return false; // syntax is required
}
this.__syntax = syntaxMatch[2];
// Syntax cannot be empty
if (this.__syntax === "") {
return false;
}
// Parse inherits descriptor (REQUIRED)
var inheritsMatch = bodyText.match(/inherits\s*:\s*(true|false)\s*;/);
if (!inheritsMatch) {
return false; // inherits is required
}
this.__inherits = inheritsMatch[1] === "true";
// Parse initial-value descriptor (OPTIONAL, but required if syntax is not "*")
var initialValueMatch = bodyText.match(/initial-value\s*:\s*([^;]+);/);
if (initialValueMatch) {
this.__initialValue = initialValueMatch[1].trim();
} else {
// If syntax is not "*", initial-value is required
if (this.__syntax !== "*") {
return false;
}
}
return true; // Successfully parsed
}
});
//.CommonJS
exports.CSSPropertyRule = CSSOM.CSSPropertyRule;
///CommonJS

92
server/node_modules/@acemir/cssom/lib/CSSRule.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
//.CommonJS
var CSSOM = {};
///CommonJS
/**
* @constructor
* @see http://dev.w3.org/csswg/cssom/#the-cssrule-interface
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule
*/
CSSOM.CSSRule = function CSSRule() {
this.__parentRule = null;
this.__parentStyleSheet = null;
};
CSSOM.CSSRule.UNKNOWN_RULE = 0; // obsolete
CSSOM.CSSRule.STYLE_RULE = 1;
CSSOM.CSSRule.CHARSET_RULE = 2; // obsolete
CSSOM.CSSRule.IMPORT_RULE = 3;
CSSOM.CSSRule.MEDIA_RULE = 4;
CSSOM.CSSRule.FONT_FACE_RULE = 5;
CSSOM.CSSRule.PAGE_RULE = 6;
CSSOM.CSSRule.KEYFRAMES_RULE = 7;
CSSOM.CSSRule.KEYFRAME_RULE = 8;
CSSOM.CSSRule.MARGIN_RULE = 9;
CSSOM.CSSRule.NAMESPACE_RULE = 10;
CSSOM.CSSRule.COUNTER_STYLE_RULE = 11;
CSSOM.CSSRule.SUPPORTS_RULE = 12;
CSSOM.CSSRule.DOCUMENT_RULE = 13;
CSSOM.CSSRule.FONT_FEATURE_VALUES_RULE = 14;
CSSOM.CSSRule.VIEWPORT_RULE = 15;
CSSOM.CSSRule.REGION_STYLE_RULE = 16;
CSSOM.CSSRule.CONTAINER_RULE = 17;
CSSOM.CSSRule.LAYER_BLOCK_RULE = 18;
CSSOM.CSSRule.STARTING_STYLE_RULE = 1002;
Object.defineProperties(CSSOM.CSSRule.prototype, {
constructor: { value: CSSOM.CSSRule },
cssRule: {
value: "",
configurable: true,
enumerable: true
},
cssText: {
get: function() {
// Default getter: subclasses should override this
return "";
},
set: function(cssText) {
return cssText;
}
},
parentRule: {
get: function() {
return this.__parentRule
}
},
parentStyleSheet: {
get: function() {
return this.__parentStyleSheet
}
},
UNKNOWN_RULE: { value: 0, enumerable: true }, // obsolet
STYLE_RULE: { value: 1, enumerable: true },
CHARSET_RULE: { value: 2, enumerable: true }, // obsolet
IMPORT_RULE: { value: 3, enumerable: true },
MEDIA_RULE: { value: 4, enumerable: true },
FONT_FACE_RULE: { value: 5, enumerable: true },
PAGE_RULE: { value: 6, enumerable: true },
KEYFRAMES_RULE: { value: 7, enumerable: true },
KEYFRAME_RULE: { value: 8, enumerable: true },
MARGIN_RULE: { value: 9, enumerable: true },
NAMESPACE_RULE: { value: 10, enumerable: true },
COUNTER_STYLE_RULE: { value: 11, enumerable: true },
SUPPORTS_RULE: { value: 12, enumerable: true },
DOCUMENT_RULE: { value: 13, enumerable: true },
FONT_FEATURE_VALUES_RULE: { value: 14, enumerable: true },
VIEWPORT_RULE: { value: 15, enumerable: true },
REGION_STYLE_RULE: { value: 16, enumerable: true },
CONTAINER_RULE: { value: 17, enumerable: true },
LAYER_BLOCK_RULE: { value: 18, enumerable: true },
STARTING_STYLE_RULE: { value: 1002, enumerable: true },
});
//.CommonJS
exports.CSSRule = CSSOM.CSSRule;
///CommonJS

26
server/node_modules/@acemir/cssom/lib/CSSRuleList.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
//.CommonJS
var CSSOM = {};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/cssom/#the-cssrulelist-interface
*/
CSSOM.CSSRuleList = function CSSRuleList(){
var arr = new Array();
Object.setPrototypeOf(arr, CSSOM.CSSRuleList.prototype);
return arr;
};
CSSOM.CSSRuleList.prototype = Object.create(Array.prototype);
CSSOM.CSSRuleList.prototype.constructor = CSSOM.CSSRuleList;
CSSOM.CSSRuleList.prototype.item = function(index) {
return this[index] || null;
};
//.CommonJS
exports.CSSRuleList = CSSOM.CSSRuleList;
///CommonJS

61
server/node_modules/@acemir/cssom/lib/CSSScopeRule.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-cascade-6/#cssscoperule
*/
CSSOM.CSSScopeRule = function CSSScopeRule() {
CSSOM.CSSGroupingRule.call(this);
this.__start = null;
this.__end = null;
};
CSSOM.CSSScopeRule.prototype = Object.create(CSSOM.CSSGroupingRule.prototype);
CSSOM.CSSScopeRule.prototype.constructor = CSSOM.CSSScopeRule;
Object.setPrototypeOf(CSSOM.CSSScopeRule, CSSOM.CSSGroupingRule);
Object.defineProperties(CSSOM.CSSScopeRule.prototype, {
type: {
value: 0,
writable: false,
},
cssText: {
get: function () {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@scope" + (this.start ? " (" + this.start + ")" : "") + (this.end ? " to (" + this.end + ")" : "") + values;
},
configurable: true,
enumerable: true,
},
start: {
get: function () {
return this.__start;
}
},
end: {
get: function () {
return this.__end;
}
}
});
//.CommonJS
exports.CSSScopeRule = CSSOM.CSSScopeRule;
///CommonJS

View File

@@ -0,0 +1,52 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule
};
///CommonJS
/**
* @constructor
* @see http://www.w3.org/TR/shadow-dom/#host-at-rule
*/
CSSOM.CSSStartingStyleRule = function CSSStartingStyleRule() {
CSSOM.CSSGroupingRule.call(this);
};
CSSOM.CSSStartingStyleRule.prototype = Object.create(CSSOM.CSSGroupingRule.prototype);
CSSOM.CSSStartingStyleRule.prototype.constructor = CSSOM.CSSStartingStyleRule;
Object.setPrototypeOf(CSSOM.CSSStartingStyleRule, CSSOM.CSSGroupingRule);
Object.defineProperty(CSSOM.CSSStartingStyleRule.prototype, "type", {
value: 1002,
writable: false
});
//FIXME
//CSSOM.CSSStartingStyleRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSStartingStyleRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
Object.defineProperty(CSSOM.CSSStartingStyleRule.prototype, "cssText", {
get: function() {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@starting-style" + values;
}
});
//.CommonJS
exports.CSSStartingStyleRule = CSSOM.CSSStartingStyleRule;
///CommonJS

View File

@@ -0,0 +1,164 @@
//.CommonJS
var CSSOM = {};
var regexPatterns = require("./regexPatterns").regexPatterns;
///CommonJS
/**
* @constructor
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
*/
CSSOM.CSSStyleDeclaration = function CSSStyleDeclaration(){
this.length = 0;
this.parentRule = null;
// NON-STANDARD
this._importants = {};
};
CSSOM.CSSStyleDeclaration.prototype = {
constructor: CSSOM.CSSStyleDeclaration,
/**
*
* @param {string} name
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-getPropertyValue
* @return {string} the value of the property if it has been explicitly set for this declaration block.
* Returns the empty string if the property has not been set.
*/
getPropertyValue: function(name) {
return this[name] || "";
},
/**
*
* @param {string} name
* @param {string} value
* @param {string} [priority=null] "important" or null
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-setProperty
*/
setProperty: function(name, value, priority, parseErrorHandler)
{
// NOTE: Check viability to add a validation for css values or use a dependency like csstree-validator
var basicStylePropertyValueValidationRegExp = regexPatterns.basicStylePropertyValueValidationRegExp
if (basicStylePropertyValueValidationRegExp.test(value)) {
parseErrorHandler && parseErrorHandler('Invalid CSSStyleDeclaration property (name = "' + name + '", value = "' + value + '")');
} else if (this[name]) {
// Property already exist. Overwrite it.
var index = Array.prototype.indexOf.call(this, name);
if (index < 0) {
this[this.length] = name;
this.length++;
}
// If the priority value of the incoming property is "important",
// or the value of the existing property is not "important",
// then remove the existing property and rewrite it.
if (priority || !this._importants[name]) {
this.removeProperty(name);
this[this.length] = name;
this.length++;
this[name] = value + '';
this._importants[name] = priority;
}
} else {
// New property.
this[this.length] = name;
this.length++;
this[name] = value + '';
this._importants[name] = priority;
}
},
/**
*
* @param {string} name
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-removeProperty
* @return {string} the value of the property if it has been explicitly set for this declaration block.
* Returns the empty string if the property has not been set or the property name does not correspond to a known CSS property.
*/
removeProperty: function(name) {
if (!(name in this)) {
return "";
}
var index = Array.prototype.indexOf.call(this, name);
if (index < 0) {
return "";
}
var prevValue = this[name];
this[name] = "";
// That's what WebKit and Opera do
Array.prototype.splice.call(this, index, 1);
// That's what Firefox does
//this[index] = ""
return prevValue;
},
getPropertyCSSValue: function() {
//FIXME
},
/**
*
* @param {String} name
*/
getPropertyPriority: function(name) {
return this._importants[name] || "";
},
/**
* element.style.overflow = "auto"
* element.style.getPropertyShorthand("overflow-x")
* -> "overflow"
*/
getPropertyShorthand: function() {
//FIXME
},
isPropertyImplicit: function() {
//FIXME
},
// Doesn't work in IE < 9
get cssText(){
var properties = [];
for (var i=0, length=this.length; i < length; ++i) {
var name = this[i];
var value = this.getPropertyValue(name);
var priority = this.getPropertyPriority(name);
if (priority) {
priority = " !" + priority;
}
properties[i] = name + ": " + value + priority + ";";
}
return properties.join(" ");
},
set cssText(text){
var i, name;
for (i = this.length; i--;) {
name = this[i];
this[name] = "";
}
Array.prototype.splice.call(this, 0, this.length);
this._importants = {};
var dummyRule = CSSOM.parse('#bogus{' + text + '}').cssRules[0].style;
var length = dummyRule.length;
for (i = 0; i < length; ++i) {
name = dummyRule[i];
this.setProperty(dummyRule[i], dummyRule.getPropertyValue(name), dummyRule.getPropertyPriority(name));
}
}
};
//.CommonJS
exports.CSSStyleDeclaration = CSSOM.CSSStyleDeclaration;
CSSOM.parse = require('./parse').parse; // Cannot be included sooner due to the mutual dependency between parse.js and CSSStyleDeclaration.js
///CommonJS

109
server/node_modules/@acemir/cssom/lib/CSSStyleRule.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
//.CommonJS
var CSSOM = {
CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
};
var regexPatterns = require("./regexPatterns").regexPatterns;
// Use cssstyle if available
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}
///CommonJS
/**
* @constructor
* @see http://dev.w3.org/csswg/cssom/#cssstylerule
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleRule
*/
CSSOM.CSSStyleRule = function CSSStyleRule() {
CSSOM.CSSGroupingRule.call(this);
this.__selectorText = "";
this.__style = new CSSOM.CSSStyleDeclaration();
this.__style.parentRule = this;
};
CSSOM.CSSStyleRule.prototype = Object.create(CSSOM.CSSGroupingRule.prototype);
CSSOM.CSSStyleRule.prototype.constructor = CSSOM.CSSStyleRule;
Object.setPrototypeOf(CSSOM.CSSStyleRule, CSSOM.CSSGroupingRule);
Object.defineProperty(CSSOM.CSSStyleRule.prototype, "type", {
value: 1,
writable: false
});
Object.defineProperty(CSSOM.CSSStyleRule.prototype, "selectorText", {
get: function() {
return this.__selectorText;
},
set: function(value) {
if (typeof value === "string") {
// Don't trim if the value ends with a hex escape sequence followed by space
// (e.g., ".\31 " where the space is part of the escape terminator)
var endsWithHexEscapeRegExp = regexPatterns.endsWithHexEscapeRegExp;
var endsWithEscape = endsWithHexEscapeRegExp.test(value);
var trimmedValue = endsWithEscape ? value.replace(/\s+$/, ' ').trimStart() : value.trim();
if (trimmedValue === '') {
return;
}
// TODO: Setting invalid selectorText should be ignored
// There are some validations already on lib/parse.js
// but the same validations should be applied here.
// Check if we can move these validation logic to a shared function.
this.__selectorText = trimmedValue;
}
},
configurable: true
});
Object.defineProperty(CSSOM.CSSStyleRule.prototype, "style", {
get: function() {
return this.__style;
},
set: function(value) {
if (typeof value === "string") {
this.__style.cssText = value;
} else {
this.__style = value;
}
},
configurable: true
});
Object.defineProperty(CSSOM.CSSStyleRule.prototype, "cssText", {
get: function() {
var text;
if (this.selectorText) {
var values = "";
if (this.cssRules.length) {
var valuesArr = [" {"];
this.style.cssText && valuesArr.push(this.style.cssText);
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
values = valuesArr.join("\n ") + "\n}";
} else {
values = " {" + (this.style.cssText ? " " + this.style.cssText : "") + " }";
}
text = this.selectorText + values;
} else {
text = "";
}
return text;
}
});
//.CommonJS
exports.CSSStyleRule = CSSOM.CSSStyleRule;
///CommonJS

371
server/node_modules/@acemir/cssom/lib/CSSStyleSheet.js generated vendored Normal file
View File

@@ -0,0 +1,371 @@
//.CommonJS
var CSSOM = {
MediaList: require("./MediaList").MediaList,
StyleSheet: require("./StyleSheet").StyleSheet,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSStyleRule: require("./CSSStyleRule").CSSStyleRule,
};
var errorUtils = require("./errorUtils").errorUtils;
///CommonJS
/**
* @constructor
* @param {CSSStyleSheetInit} [opts] - CSSStyleSheetInit options.
* @param {string} [opts.baseURL] - The base URL of the stylesheet.
* @param {boolean} [opts.disabled] - The disabled attribute of the stylesheet.
* @param {MediaList | string} [opts.media] - The media attribute of the stylesheet.
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet
*/
CSSOM.CSSStyleSheet = function CSSStyleSheet(opts) {
CSSOM.StyleSheet.call(this);
this.__constructed = true;
this.__cssRules = new CSSOM.CSSRuleList();
this.__ownerRule = null;
if (opts && typeof opts === "object") {
if (opts.baseURL && typeof opts.baseURL === "string") {
this.__baseURL = opts.baseURL;
}
if (opts.media && typeof opts.media === "string") {
this.media.mediaText = opts.media;
}
if (typeof opts.disabled === "boolean") {
this.disabled = opts.disabled;
}
}
};
CSSOM.CSSStyleSheet.prototype = Object.create(CSSOM.StyleSheet.prototype);
CSSOM.CSSStyleSheet.prototype.constructor = CSSOM.CSSStyleSheet;
Object.setPrototypeOf(CSSOM.CSSStyleSheet, CSSOM.StyleSheet);
Object.defineProperty(CSSOM.CSSStyleSheet.prototype, "cssRules", {
get: function() {
return this.__cssRules;
}
});
Object.defineProperty(CSSOM.CSSStyleSheet.prototype, "rules", {
get: function() {
return this.__cssRules;
}
});
Object.defineProperty(CSSOM.CSSStyleSheet.prototype, "ownerRule", {
get: function() {
return this.__ownerRule;
}
});
/**
* Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.
*
* sheet = new Sheet("body {margin: 0}")
* sheet.toString()
* -> "body{margin:0;}"
* sheet.insertRule("img {border: none}", 0)
* -> 0
* sheet.toString()
* -> "img{border:none;}body{margin:0;}"
*
* @param {string} rule
* @param {number} [index=0]
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet-insertRule
* @return {number} The index within the style sheet's rule collection of the newly inserted rule.
*/
CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
if (rule === undefined && index === undefined) {
errorUtils.throwMissingArguments(this, 'insertRule', this.constructor.name);
}
if (index === void 0) {
index = 0;
}
index = Number(index);
if (index < 0) {
index = 4294967296 + index;
}
if (index > this.cssRules.length) {
errorUtils.throwIndexError(this, 'insertRule', this.constructor.name, index, this.cssRules.length);
}
var ruleToParse = String(rule);
var parseErrors = [];
var parsedSheet = CSSOM.parse(ruleToParse, undefined, function(err) {
parseErrors.push(err);
} );
if (parsedSheet.cssRules.length !== 1) {
errorUtils.throwParseError(this, 'insertRule', this.constructor.name, ruleToParse, 'SyntaxError');
}
var cssRule = parsedSheet.cssRules[0];
// Helper function to find the last index of a specific rule constructor
function findLastIndexOfConstructor(rules, constructorName) {
for (var i = rules.length - 1; i >= 0; i--) {
if (rules[i].constructor.name === constructorName) {
return i;
}
}
return -1;
}
// Helper function to find the first index of a rule that's NOT of specified constructors
function findFirstNonConstructorIndex(rules, constructorNames) {
for (var i = 0; i < rules.length; i++) {
if (constructorNames.indexOf(rules[i].constructor.name) === -1) {
return i;
}
}
return rules.length;
}
// Validate rule ordering based on CSS specification
if (cssRule.constructor.name === 'CSSImportRule') {
if (this.__constructed === true) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Can't insert @import rules into a constructed stylesheet.",
'SyntaxError');
}
// @import rules cannot be inserted after @layer rules that already exist
// They can only be inserted at the beginning or after other @import rules
var firstLayerIndex = findFirstNonConstructorIndex(this.cssRules, ['CSSImportRule']);
if (firstLayerIndex < this.cssRules.length && this.cssRules[firstLayerIndex].constructor.name === 'CSSLayerStatementRule' && index > firstLayerIndex) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Failed to insert the rule.",
'HierarchyRequestError');
}
// Also cannot insert after @namespace or other rules
var firstNonImportIndex = findFirstNonConstructorIndex(this.cssRules, ['CSSImportRule']);
if (index > firstNonImportIndex && firstNonImportIndex < this.cssRules.length &&
this.cssRules[firstNonImportIndex].constructor.name !== 'CSSLayerStatementRule') {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Failed to insert the rule.",
'HierarchyRequestError');
}
} else if (cssRule.constructor.name === 'CSSNamespaceRule') {
// @namespace rules can come after @layer and @import, but before any other rules
// They cannot come before @import rules
var firstImportIndex = -1;
for (var i = 0; i < this.cssRules.length; i++) {
if (this.cssRules[i].constructor.name === 'CSSImportRule') {
firstImportIndex = i;
break;
}
}
var firstNonImportNamespaceIndex = findFirstNonConstructorIndex(this.cssRules, [
'CSSLayerStatementRule',
'CSSImportRule',
'CSSNamespaceRule'
]);
// Cannot insert before @import rules
if (firstImportIndex !== -1 && index <= firstImportIndex) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Failed to insert the rule.",
'HierarchyRequestError');
}
// Cannot insert if there are already non-special rules
if (firstNonImportNamespaceIndex < this.cssRules.length) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Failed to insert the rule.",
'InvalidStateError');
}
// Cannot insert after other types of rules
if (index > firstNonImportNamespaceIndex) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Failed to insert the rule.",
'HierarchyRequestError');
}
} else if (cssRule.constructor.name === 'CSSLayerStatementRule') {
// @layer statement rules can be inserted anywhere before @import and @namespace
// No additional restrictions beyond what's already handled
} else {
// Any other rule cannot be inserted before @import and @namespace
var firstNonSpecialRuleIndex = findFirstNonConstructorIndex(this.cssRules, [
'CSSLayerStatementRule',
'CSSImportRule',
'CSSNamespaceRule'
]);
if (index < firstNonSpecialRuleIndex) {
errorUtils.throwError(this, 'DOMException',
"Failed to execute 'insertRule' on '" + this.constructor.name + "': Failed to insert the rule.",
'HierarchyRequestError');
}
if (parseErrors.filter(function(error) { return !error.isNested; }).length !== 0) {
errorUtils.throwParseError(this, 'insertRule', this.constructor.name, ruleToParse, 'SyntaxError');
}
}
cssRule.__parentStyleSheet = this;
this.cssRules.splice(index, 0, cssRule);
return index;
};
CSSOM.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index) {
if (index === void 0) {
index = this.cssRules.length;
}
this.insertRule(selector + "{" + styleBlock + "}", index);
return -1;
};
/**
* Used to delete a rule from the style sheet.
*
* sheet = new Sheet("img{border:none} body{margin:0}")
* sheet.toString()
* -> "img{border:none;}body{margin:0;}"
* sheet.deleteRule(0)
* sheet.toString()
* -> "body{margin:0;}"
*
* @param {number} index within the style sheet's rule list of the rule to remove.
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet-deleteRule
*/
CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
if (index === undefined) {
errorUtils.throwMissingArguments(this, 'deleteRule', this.constructor.name);
}
index = Number(index);
if (index < 0) {
index = 4294967296 + index;
}
if (index >= this.cssRules.length) {
errorUtils.throwIndexError(this, 'deleteRule', this.constructor.name, index, this.cssRules.length);
}
if (this.cssRules[index]) {
if (this.cssRules[index].constructor.name == "CSSNamespaceRule") {
var shouldContinue = this.cssRules.every(function (rule) {
return ['CSSImportRule','CSSLayerStatementRule','CSSNamespaceRule'].indexOf(rule.constructor.name) !== -1
});
if (!shouldContinue) {
errorUtils.throwError(this, 'DOMException', "Failed to execute 'deleteRule' on '" + this.constructor.name + "': Failed to delete rule.", "InvalidStateError");
}
}
if (this.cssRules[index].constructor.name == "CSSImportRule") {
this.cssRules[index].styleSheet.__parentStyleSheet = null;
}
this.cssRules[index].__parentStyleSheet = null;
}
this.cssRules.splice(index, 1);
};
CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
if (index === void 0) {
index = 0;
}
this.deleteRule(index);
};
/**
* Replaces the rules of a {@link CSSStyleSheet}
*
* @returns a promise
* @see https://www.w3.org/TR/cssom-1/#dom-cssstylesheet-replace
*/
CSSOM.CSSStyleSheet.prototype.replace = function(text) {
var _Promise;
if (this.__globalObject && this.__globalObject['Promise']) {
_Promise = this.__globalObject['Promise'];
} else {
_Promise = Promise;
}
var _setTimeout;
if (this.__globalObject && this.__globalObject['setTimeout']) {
_setTimeout = this.__globalObject['setTimeout'];
} else {
_setTimeout = setTimeout;
}
var sheet = this;
return new _Promise(function (resolve, reject) {
// If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
if (!sheet.__constructed || sheet.__disallowModification) {
reject(errorUtils.createError(sheet, 'DOMException',
"Failed to execute 'replaceSync' on '" + sheet.constructor.name + "': Not allowed.",
'NotAllowedError'));
}
// Set the disallow modification flag.
sheet.__disallowModification = true;
// In parallel, do these steps:
_setTimeout(function() {
// Let rules be the result of running parse a stylesheet's contents from text.
var rules = new CSSOM.CSSRuleList();
CSSOM.parse(text, { styleSheet: sheet, cssRules: rules });
// If rules contains one or more @import rules, remove those rules from rules.
var i = 0;
while (i < rules.length) {
if (rules[i].constructor.name === 'CSSImportRule') {
rules.splice(i, 1);
} else {
i++;
}
}
// Set sheet's CSS rules to rules.
sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
// Unset sheets disallow modification flag.
delete sheet.__disallowModification;
// Resolve promise with sheet.
resolve(sheet);
})
});
}
/**
* Synchronously replaces the rules of a {@link CSSStyleSheet}
*
* @see https://www.w3.org/TR/cssom-1/#dom-cssstylesheet-replacesync
*/
CSSOM.CSSStyleSheet.prototype.replaceSync = function(text) {
var sheet = this;
// If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
if (!sheet.__constructed || sheet.__disallowModification) {
errorUtils.throwError(sheet, 'DOMException',
"Failed to execute 'replaceSync' on '" + sheet.constructor.name + "': Not allowed.",
'NotAllowedError');
}
// Let rules be the result of running parse a stylesheet's contents from text.
var rules = new CSSOM.CSSRuleList();
CSSOM.parse(text, { styleSheet: sheet, cssRules: rules });
// If rules contains one or more @import rules, remove those rules from rules.
var i = 0;
while (i < rules.length) {
if (rules[i].constructor.name === 'CSSImportRule') {
rules.splice(i, 1);
} else {
i++;
}
}
// Set sheet's CSS rules to rules.
sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
}
/**
* NON-STANDARD
* @return {string} serialize stylesheet
*/
CSSOM.CSSStyleSheet.prototype.toString = function() {
var result = "";
var rules = this.cssRules;
for (var i=0; i<rules.length; i++) {
result += rules[i].cssText + "\n";
}
return result;
};
//.CommonJS
exports.CSSStyleSheet = CSSOM.CSSStyleSheet;
CSSOM.parse = require('./parse').parse; // Cannot be included sooner due to the mutual dependency between parse.js and CSSStyleSheet.js
///CommonJS

View File

@@ -0,0 +1,48 @@
//.CommonJS
var CSSOM = {
CSSRule: require("./CSSRule").CSSRule,
CSSRuleList: require("./CSSRuleList").CSSRuleList,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
CSSConditionRule: require("./CSSConditionRule").CSSConditionRule
};
///CommonJS
/**
* @constructor
* @see https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface
*/
CSSOM.CSSSupportsRule = function CSSSupportsRule() {
CSSOM.CSSConditionRule.call(this);
};
CSSOM.CSSSupportsRule.prototype = Object.create(CSSOM.CSSConditionRule.prototype);
CSSOM.CSSSupportsRule.prototype.constructor = CSSOM.CSSSupportsRule;
Object.setPrototypeOf(CSSOM.CSSSupportsRule, CSSOM.CSSConditionRule);
Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "type", {
value: 12,
writable: false
});
Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "cssText", {
get: function() {
var values = "";
var valuesArr = [" {"];
if (this.cssRules.length) {
valuesArr.push(this.cssRules.reduce(function(acc, rule){
if (rule.cssText !== "") {
acc.push(rule.cssText);
}
return acc;
}, []).join("\n "));
}
values = valuesArr.join("\n ") + "\n}";
return "@supports " + this.conditionText + values;
}
});
//.CommonJS
exports.CSSSupportsRule = CSSOM.CSSSupportsRule;
///CommonJS

43
server/node_modules/@acemir/cssom/lib/CSSValue.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
//.CommonJS
var CSSOM = {};
///CommonJS
/**
* @constructor
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSValue
*
* TODO: add if needed
*/
CSSOM.CSSValue = function CSSValue() {
};
CSSOM.CSSValue.prototype = {
constructor: CSSOM.CSSValue,
// @see: http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSValue
set cssText(text) {
var name = this._getConstructorName();
throw new Error('DOMException: property "cssText" of "' + name + '" is readonly and can not be replaced with "' + text + '"!');
},
get cssText() {
var name = this._getConstructorName();
throw new Error('getter "cssText" of "' + name + '" is not implemented!');
},
_getConstructorName: function() {
var s = this.constructor.toString(),
c = s.match(/function\s([^\(]+)/),
name = c[1];
return name;
}
};
//.CommonJS
exports.CSSValue = CSSOM.CSSValue;
///CommonJS

View File

@@ -0,0 +1,346 @@
//.CommonJS
var CSSOM = {
CSSValue: require('./CSSValue').CSSValue
};
///CommonJS
/**
* @constructor
* @see http://msdn.microsoft.com/en-us/library/ms537634(v=vs.85).aspx
*
*/
CSSOM.CSSValueExpression = function CSSValueExpression(token, idx) {
this._token = token;
this._idx = idx;
};
CSSOM.CSSValueExpression.prototype = Object.create(CSSOM.CSSValue.prototype);
CSSOM.CSSValueExpression.prototype.constructor = CSSOM.CSSValueExpression;
Object.setPrototypeOf(CSSOM.CSSValueExpression, CSSOM.CSSValue);
/**
* parse css expression() value
*
* @return {Object}
* - error:
* or
* - idx:
* - expression:
*
* Example:
*
* .selector {
* zoom: expression(documentElement.clientWidth > 1000 ? '1000px' : 'auto');
* }
*/
CSSOM.CSSValueExpression.prototype.parse = function() {
var token = this._token,
idx = this._idx;
var character = '',
expression = '',
error = '',
info,
paren = [];
for (; ; ++idx) {
character = token.charAt(idx);
// end of token
if (character === '') {
error = 'css expression error: unfinished expression!';
break;
}
switch(character) {
case '(':
paren.push(character);
expression += character;
break;
case ')':
paren.pop(character);
expression += character;
break;
case '/':
if ((info = this._parseJSComment(token, idx))) { // comment?
if (info.error) {
error = 'css expression error: unfinished comment in expression!';
} else {
idx = info.idx;
// ignore the comment
}
} else if ((info = this._parseJSRexExp(token, idx))) { // regexp
idx = info.idx;
expression += info.text;
} else { // other
expression += character;
}
break;
case "'":
case '"':
info = this._parseJSString(token, idx, character);
if (info) { // string
idx = info.idx;
expression += info.text;
} else {
expression += character;
}
break;
default:
expression += character;
break;
}
if (error) {
break;
}
// end of expression
if (paren.length === 0) {
break;
}
}
var ret;
if (error) {
ret = {
error: error
};
} else {
ret = {
idx: idx,
expression: expression
};
}
return ret;
};
/**
*
* @return {Object|false}
* - idx:
* - text:
* or
* - error:
* or
* false
*
*/
CSSOM.CSSValueExpression.prototype._parseJSComment = function(token, idx) {
var nextChar = token.charAt(idx + 1),
text;
if (nextChar === '/' || nextChar === '*') {
var startIdx = idx,
endIdx,
commentEndChar;
if (nextChar === '/') { // line comment
commentEndChar = '\n';
} else if (nextChar === '*') { // block comment
commentEndChar = '*/';
}
endIdx = token.indexOf(commentEndChar, startIdx + 1 + 1);
if (endIdx !== -1) {
endIdx = endIdx + commentEndChar.length - 1;
text = token.substring(idx, endIdx + 1);
return {
idx: endIdx,
text: text
};
} else {
var error = 'css expression error: unfinished comment in expression!';
return {
error: error
};
}
} else {
return false;
}
};
/**
*
* @return {Object|false}
* - idx:
* - text:
* or
* false
*
*/
CSSOM.CSSValueExpression.prototype._parseJSString = function(token, idx, sep) {
var endIdx = this._findMatchedIdx(token, idx, sep),
text;
if (endIdx === -1) {
return false;
} else {
text = token.substring(idx, endIdx + sep.length);
return {
idx: endIdx,
text: text
};
}
};
/**
* parse regexp in css expression
*
* @return {Object|false}
* - idx:
* - regExp:
* or
* false
*/
/*
all legal RegExp
/a/
(/a/)
[/a/]
[12, /a/]
!/a/
+/a/
-/a/
* /a/
/ /a/
%/a/
===/a/
!==/a/
==/a/
!=/a/
>/a/
>=/a/
</a/
<=/a/
&/a/
|/a/
^/a/
~/a/
<</a/
>>/a/
>>>/a/
&&/a/
||/a/
?/a/
=/a/
,/a/
delete /a/
in /a/
instanceof /a/
new /a/
typeof /a/
void /a/
*/
CSSOM.CSSValueExpression.prototype._parseJSRexExp = function(token, idx) {
var before = token.substring(0, idx).replace(/\s+$/, ""),
legalRegx = [
/^$/,
/\($/,
/\[$/,
/\!$/,
/\+$/,
/\-$/,
/\*$/,
/\/\s+/,
/\%$/,
/\=$/,
/\>$/,
/<$/,
/\&$/,
/\|$/,
/\^$/,
/\~$/,
/\?$/,
/\,$/,
/delete$/,
/in$/,
/instanceof$/,
/new$/,
/typeof$/,
/void$/
];
var isLegal = legalRegx.some(function(reg) {
return reg.test(before);
});
if (!isLegal) {
return false;
} else {
var sep = '/';
// same logic as string
return this._parseJSString(token, idx, sep);
}
};
/**
*
* find next sep(same line) index in `token`
*
* @return {Number}
*
*/
CSSOM.CSSValueExpression.prototype._findMatchedIdx = function(token, idx, sep) {
var startIdx = idx,
endIdx;
var NOT_FOUND = -1;
while(true) {
endIdx = token.indexOf(sep, startIdx + 1);
if (endIdx === -1) { // not found
endIdx = NOT_FOUND;
break;
} else {
var text = token.substring(idx + 1, endIdx),
matched = text.match(/\\+$/);
if (!matched || matched[0] % 2 === 0) { // not escaped
break;
} else {
startIdx = endIdx;
}
}
}
// boundary must be in the same line(js sting or regexp)
var nextNewLineIdx = token.indexOf('\n', idx + 1);
if (nextNewLineIdx < endIdx) {
endIdx = NOT_FOUND;
}
return endIdx;
};
//.CommonJS
exports.CSSValueExpression = CSSOM.CSSValueExpression;
///CommonJS

62
server/node_modules/@acemir/cssom/lib/MatcherList.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
//.CommonJS
var CSSOM = {};
///CommonJS
/**
* @constructor
* @see https://developer.mozilla.org/en/CSS/@-moz-document
*/
CSSOM.MatcherList = function MatcherList(){
this.length = 0;
};
CSSOM.MatcherList.prototype = {
constructor: CSSOM.MatcherList,
/**
* @return {string}
*/
get matcherText() {
return Array.prototype.join.call(this, ", ");
},
/**
* @param {string} value
*/
set matcherText(value) {
// just a temporary solution, actually it may be wrong by just split the value with ',', because a url can include ','.
var values = value.split(",");
var length = this.length = values.length;
for (var i=0; i<length; i++) {
this[i] = values[i].trim();
}
},
/**
* @param {string} matcher
*/
appendMatcher: function(matcher) {
if (Array.prototype.indexOf.call(this, matcher) === -1) {
this[this.length] = matcher;
this.length++;
}
},
/**
* @param {string} matcher
*/
deleteMatcher: function(matcher) {
var index = Array.prototype.indexOf.call(this, matcher);
if (index !== -1) {
Array.prototype.splice.call(this, index, 1);
}
}
};
//.CommonJS
exports.MatcherList = CSSOM.MatcherList;
///CommonJS

78
server/node_modules/@acemir/cssom/lib/MediaList.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
//.CommonJS
var CSSOM = {};
///CommonJS
/**
* @constructor
* @see http://dev.w3.org/csswg/cssom/#the-medialist-interface
*/
CSSOM.MediaList = function MediaList(){
this.length = 0;
};
CSSOM.MediaList.prototype = {
constructor: CSSOM.MediaList,
/**
* @return {string}
*/
get mediaText() {
return Array.prototype.join.call(this, ", ");
},
/**
* @param {string} value
*/
set mediaText(value) {
if (typeof value === "string") {
var values = value.split(",").filter(function(text){
return !!text;
});
var length = this.length = values.length;
for (var i=0; i<length; i++) {
this[i] = values[i].trim();
}
} else if (value === null) {
var length = this.length;
for (var i = 0; i < length; i++) {
delete this[i];
}
this.length = 0;
}
},
/**
* @param {string} medium
*/
appendMedium: function(medium) {
if (Array.prototype.indexOf.call(this, medium) === -1) {
this[this.length] = medium;
this.length++;
}
},
/**
* @param {string} medium
*/
deleteMedium: function(medium) {
var index = Array.prototype.indexOf.call(this, medium);
if (index !== -1) {
Array.prototype.splice.call(this, index, 1);
}
},
item: function(index) {
return this[index] || null;
},
toString: function() {
return this.mediaText;
}
};
//.CommonJS
exports.MediaList = CSSOM.MediaList;
///CommonJS

62
server/node_modules/@acemir/cssom/lib/StyleSheet.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
//.CommonJS
var CSSOM = {
MediaList: require("./MediaList").MediaList
};
///CommonJS
/**
* @see http://dev.w3.org/csswg/cssom/#the-stylesheet-interface
*/
CSSOM.StyleSheet = function StyleSheet() {
this.__href = null;
this.__ownerNode = null;
this.__title = null;
this.__media = new CSSOM.MediaList();
this.__parentStyleSheet = null;
this.disabled = false;
};
Object.defineProperties(CSSOM.StyleSheet.prototype, {
type: {
get: function() {
return "text/css";
}
},
href: {
get: function() {
return this.__href;
}
},
ownerNode: {
get: function() {
return this.__ownerNode;
}
},
title: {
get: function() {
return this.__title;
}
},
media: {
get: function() {
return this.__media;
},
set: function(value) {
if (typeof value === "string") {
this.__media.mediaText = value;
} else {
this.__media = value;
}
}
},
parentStyleSheet: {
get: function() {
return this.__parentStyleSheet;
}
}
});
//.CommonJS
exports.StyleSheet = CSSOM.StyleSheet;
///CommonJS

105
server/node_modules/@acemir/cssom/lib/clone.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
//.CommonJS
var CSSOM = {
CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
CSSRule: require("./CSSRule").CSSRule,
CSSNestedDeclarations: require("./CSSNestedDeclarations").CSSNestedDeclarations,
CSSStyleRule: require("./CSSStyleRule").CSSStyleRule,
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
CSSConditionRule: require("./CSSConditionRule").CSSConditionRule,
CSSMediaRule: require("./CSSMediaRule").CSSMediaRule,
CSSContainerRule: require("./CSSContainerRule").CSSContainerRule,
CSSSupportsRule: require("./CSSSupportsRule").CSSSupportsRule,
CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
CSSKeyframeRule: require('./CSSKeyframeRule').CSSKeyframeRule,
CSSKeyframesRule: require('./CSSKeyframesRule').CSSKeyframesRule,
CSSScopeRule: require('./CSSScopeRule').CSSScopeRule,
CSSLayerBlockRule: require('./CSSLayerBlockRule').CSSLayerBlockRule,
CSSLayerStatementRule: require('./CSSLayerStatementRule').CSSLayerStatementRule
};
// Use cssstyle if available
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}
///CommonJS
/**
* Produces a deep copy of stylesheet — the instance variables of stylesheet are copied recursively.
* @param {CSSStyleSheet|CSSOM.CSSStyleSheet} stylesheet
* @nosideeffects
* @return {CSSOM.CSSStyleSheet}
*/
CSSOM.clone = function clone(stylesheet) {
var cloned = new CSSOM.CSSStyleSheet();
var rules = stylesheet.cssRules;
if (!rules) {
return cloned;
}
for (var i = 0, rulesLength = rules.length; i < rulesLength; i++) {
var rule = rules[i];
var ruleClone = cloned.cssRules[i] = new rule.constructor();
var style = rule.style;
if (style) {
var styleClone = ruleClone.style = new CSSOM.CSSStyleDeclaration();
for (var j = 0, styleLength = style.length; j < styleLength; j++) {
var name = styleClone[j] = style[j];
styleClone[name] = style[name];
styleClone._importants[name] = style.getPropertyPriority(name);
}
styleClone.length = style.length;
}
if (rule.hasOwnProperty('keyText')) {
ruleClone.keyText = rule.keyText;
}
if (rule.hasOwnProperty('selectorText')) {
ruleClone.selectorText = rule.selectorText;
}
if (rule.hasOwnProperty('mediaText')) {
ruleClone.mediaText = rule.mediaText;
}
if (rule.hasOwnProperty('supportsText')) {
ruleClone.supports = rule.supports;
}
if (rule.hasOwnProperty('conditionText')) {
ruleClone.conditionText = rule.conditionText;
}
if (rule.hasOwnProperty('layerName')) {
ruleClone.layerName = rule.layerName;
}
if (rule.hasOwnProperty('href')) {
ruleClone.href = rule.href;
}
if (rule.hasOwnProperty('name')) {
ruleClone.name = rule.name;
}
if (rule.hasOwnProperty('nameList')) {
ruleClone.nameList = rule.nameList;
}
if (rule.hasOwnProperty('cssRules')) {
ruleClone.cssRules = clone(rule).cssRules;
}
}
return cloned;
};
//.CommonJS
exports.clone = CSSOM.clone;
///CommonJS

View File

@@ -0,0 +1,5 @@
try {
CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
} catch (e) {
// ignore
}

119
server/node_modules/@acemir/cssom/lib/errorUtils.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
// Utility functions for CSSOM error handling
/**
* Gets the appropriate error constructor from the global object context.
* Tries to find the error constructor from parentStyleSheet.__globalObject,
* then from __globalObject, then falls back to the native constructor.
*
* @param {Object} context - The CSSOM object (rule, stylesheet, etc.)
* @param {string} errorType - The error type ('TypeError', 'RangeError', 'DOMException', etc.)
* @return {Function} The error constructor
*/
function getErrorConstructor(context, errorType) {
// Try parentStyleSheet.__globalObject first
if (context.parentStyleSheet && context.parentStyleSheet.__globalObject && context.parentStyleSheet.__globalObject[errorType]) {
return context.parentStyleSheet.__globalObject[errorType];
}
// Try __parentStyleSheet (alternative naming)
if (context.__parentStyleSheet && context.__parentStyleSheet.__globalObject && context.__parentStyleSheet.__globalObject[errorType]) {
return context.__parentStyleSheet.__globalObject[errorType];
}
// Try __globalObject on the context itself
if (context.__globalObject && context.__globalObject[errorType]) {
return context.__globalObject[errorType];
}
// Fall back to native constructor
return (typeof global !== 'undefined' && global[errorType]) ||
(typeof window !== 'undefined' && window[errorType]) ||
eval(errorType);
}
/**
* Creates an appropriate error with context-aware constructor.
*
* @param {Object} context - The CSSOM object (rule, stylesheet, etc.)
* @param {string} errorType - The error type ('TypeError', 'RangeError', 'DOMException', etc.)
* @param {string} message - The error message
* @param {string} [name] - Optional name for DOMException
*/
function createError(context, errorType, message, name) {
var ErrorConstructor = getErrorConstructor(context, errorType);
return new ErrorConstructor(message, name);
}
/**
* Creates and throws an appropriate error with context-aware constructor.
*
* @param {Object} context - The CSSOM object (rule, stylesheet, etc.)
* @param {string} errorType - The error type ('TypeError', 'RangeError', 'DOMException', etc.)
* @param {string} message - The error message
* @param {string} [name] - Optional name for DOMException
*/
function throwError(context, errorType, message, name) {
throw createError(context, errorType, message, name);
}
/**
* Throws a TypeError for missing required arguments.
*
* @param {Object} context - The CSSOM object
* @param {string} methodName - The method name (e.g., 'appendRule')
* @param {string} objectName - The object name (e.g., 'CSSKeyframesRule')
* @param {number} [required=1] - Number of required arguments
* @param {number} [provided=0] - Number of provided arguments
*/
function throwMissingArguments(context, methodName, objectName, required, provided) {
required = required || 1;
provided = provided || 0;
var message = "Failed to execute '" + methodName + "' on '" + objectName + "': " +
required + " argument" + (required > 1 ? "s" : "") + " required, but only " +
provided + " present.";
throwError(context, 'TypeError', message);
}
/**
* Throws a DOMException for parse errors.
*
* @param {Object} context - The CSSOM object
* @param {string} methodName - The method name
* @param {string} objectName - The object name
* @param {string} rule - The rule that failed to parse
* @param {string} [name='SyntaxError'] - The DOMException name
*/
function throwParseError(context, methodName, objectName, rule, name) {
var message = "Failed to execute '" + methodName + "' on '" + objectName + "': " +
"Failed to parse the rule '" + rule + "'.";
throwError(context, 'DOMException', message, name || 'SyntaxError');
}
/**
* Throws a DOMException for index errors.
*
* @param {Object} context - The CSSOM object
* @param {string} methodName - The method name
* @param {string} objectName - The object name
* @param {number} index - The invalid index
* @param {number} maxIndex - The maximum valid index
* @param {string} [name='IndexSizeError'] - The DOMException name
*/
function throwIndexError(context, methodName, objectName, index, maxIndex, name) {
var message = "Failed to execute '" + methodName + "' on '" + objectName + "': " +
"The index provided (" + index + ") is larger than the maximum index (" + maxIndex + ").";
throwError(context, 'DOMException', message, name || 'IndexSizeError');
}
var errorUtils = {
createError: createError,
getErrorConstructor: getErrorConstructor,
throwError: throwError,
throwMissingArguments: throwMissingArguments,
throwParseError: throwParseError,
throwIndexError: throwIndexError
};
//.CommonJS
exports.errorUtils = errorUtils;
///CommonJS

42
server/node_modules/@acemir/cssom/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
'use strict';
exports.setup = require('./CSSOM').setup;
require('./errorUtils');
require("./regexPatterns")
exports.CSSStyleDeclaration = require('./CSSStyleDeclaration').CSSStyleDeclaration;
require('./cssstyleTryCatchBlock');
exports.CSSRule = require('./CSSRule').CSSRule;
exports.CSSRuleList = require('./CSSRuleList').CSSRuleList;
exports.CSSNestedDeclarations = require('./CSSNestedDeclarations').CSSNestedDeclarations;
exports.CSSGroupingRule = require('./CSSGroupingRule').CSSGroupingRule;
exports.CSSCounterStyleRule = require('./CSSCounterStyleRule').CSSCounterStyleRule;
exports.CSSPropertyRule = require('./CSSPropertyRule').CSSPropertyRule;
exports.CSSConditionRule = require('./CSSConditionRule').CSSConditionRule;
exports.CSSStyleRule = require('./CSSStyleRule').CSSStyleRule;
exports.MediaList = require('./MediaList').MediaList;
exports.CSSMediaRule = require('./CSSMediaRule').CSSMediaRule;
exports.CSSContainerRule = require('./CSSContainerRule').CSSContainerRule;
exports.CSSSupportsRule = require('./CSSSupportsRule').CSSSupportsRule;
exports.CSSImportRule = require('./CSSImportRule').CSSImportRule;
exports.CSSNamespaceRule = require('./CSSNamespaceRule').CSSNamespaceRule;
exports.CSSFontFaceRule = require('./CSSFontFaceRule').CSSFontFaceRule;
exports.CSSHostRule = require('./CSSHostRule').CSSHostRule;
exports.CSSStartingStyleRule = require('./CSSStartingStyleRule').CSSStartingStyleRule;
exports.StyleSheet = require('./StyleSheet').StyleSheet;
exports.CSSStyleSheet = require('./CSSStyleSheet').CSSStyleSheet;
exports.CSSKeyframesRule = require('./CSSKeyframesRule').CSSKeyframesRule;
exports.CSSKeyframeRule = require('./CSSKeyframeRule').CSSKeyframeRule;
exports.MatcherList = require('./MatcherList').MatcherList;
exports.CSSDocumentRule = require('./CSSDocumentRule').CSSDocumentRule;
exports.CSSValue = require('./CSSValue').CSSValue;
exports.CSSValueExpression = require('./CSSValueExpression').CSSValueExpression;
exports.CSSScopeRule = require('./CSSScopeRule').CSSScopeRule;
exports.CSSLayerBlockRule = require('./CSSLayerBlockRule').CSSLayerBlockRule;
exports.CSSLayerStatementRule = require('./CSSLayerStatementRule').CSSLayerStatementRule;
exports.CSSPageRule = require('./CSSPageRule').CSSPageRule;
exports.parse = require('./parse').parse;
exports.clone = require('./clone').clone;

3332
server/node_modules/@acemir/cssom/lib/parse.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

162
server/node_modules/@acemir/cssom/lib/regexPatterns.js generated vendored Normal file
View File

@@ -0,0 +1,162 @@
// Shared regex patterns for CSS parsing and validation
// These patterns are compiled once and reused across multiple files for better performance
// Regex patterns for CSS parsing
var atKeyframesRegExp = /@(-(?:\w+-)+)?keyframes/g; // Match @keyframes and vendor-prefixed @keyframes
var beforeRulePortionRegExp = /{(?!.*{)|}(?!.*})|;(?!.*;)|\*\/(?!.*\*\/)/g; // Match the closest allowed character (a opening or closing brace, a semicolon or a comment ending) before the rule
var beforeRuleValidationRegExp = /^[\s{};]*(\*\/\s*)?$/; // Match that the portion before the rule is empty or contains only whitespace, semicolons, opening/closing braces, and optionally a comment ending (*/) followed by whitespace
var forwardRuleValidationRegExp = /(?:\s|\/\*|\{|\()/; // Match that the rule is followed by any whitespace, a opening comment, a condition opening parenthesis or a opening brace
var forwardImportRuleValidationRegExp = /(?:\s|\/\*|'|")/; // Match that the rule is followed by any whitespace, an opening comment, a single quote or double quote
var forwardRuleClosingBraceRegExp = /{[^{}]*}|}/; // Finds the next closing brace of a rule block
var forwardRuleSemicolonAndOpeningBraceRegExp = /^.*?({|;)/; // Finds the next semicolon or opening brace after the at-rule
// Regex patterns for CSS selector validation and parsing
var cssCustomIdentifierRegExp = /^(-?[_a-zA-Z]+(\.[_a-zA-Z]+)*[_a-zA-Z0-9-]*)$/; // Validates a css custom identifier
var startsWithCombinatorRegExp = /^\s*[>+~]/; // Checks if a selector starts with a CSS combinator (>, +, ~)
/**
* Parse `@page` selectorText for page name and pseudo-pages
* Valid formats:
* - (empty - no name, no pseudo-page)
* - `:left`, `:right`, `:first`, `:blank` (pseudo-page only)
* - `named` (named page only)
* - `named:first` (named page with single pseudo-page)
* - `named:first:left` (named page with multiple pseudo-pages)
*/
var atPageRuleSelectorRegExp = /^([^\s:]+)?((?::\w+)*)$/; // Validates @page rule selectors
// Regex patterns for CSSImportRule parsing
var layerRegExp = /layer\(([^)]*)\)/; // Matches layer() function in @import
var layerRuleNameRegExp = /^(-?[_a-zA-Z]+(\.[_a-zA-Z]+)*[_a-zA-Z0-9-]*)$/; // Validates layer name (same as custom identifier)
var doubleOrMoreSpacesRegExp = /\s{2,}/g; // Matches two or more consecutive whitespace characters
// Regex patterns for CSS escape sequences and identifiers
var startsWithHexEscapeRegExp = /^\\[0-9a-fA-F]/; // Checks if escape sequence starts with hex escape
var identStartCharRegExp = /[a-zA-Z_\u00A0-\uFFFF]/; // Valid identifier start character
var identCharRegExp = /^[a-zA-Z0-9_\-\u00A0-\uFFFF\\]/; // Valid identifier character
var specialCharsNeedEscapeRegExp = /[!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~\s]/; // Characters that need escaping
var combinatorOrSeparatorRegExp = /[\s>+~,()]/; // Selector boundaries and combinators
var afterHexEscapeSeparatorRegExp = /[\s>+~,(){}\[\]]/; // Characters that separate after hex escape
var trailingSpaceSeparatorRegExp = /[\s>+~,(){}]/; // Characters that allow trailing space
var endsWithHexEscapeRegExp = /\\[0-9a-fA-F]{1,6}\s+$/; // Matches selector ending with hex escape + space(s)
/**
* Regular expression to detect invalid characters in the value portion of a CSS style declaration.
*
* This regex matches a colon (:) that is not inside parentheses and not inside single or double quotes.
* It is used to ensure that the value part of a CSS property does not contain unexpected colons,
* which would indicate a malformed declaration (e.g., "color: foo:bar;" is invalid).
*
* The negative lookahead `(?![^(]*\))` ensures that the colon is not followed by a closing
* parenthesis without encountering an opening parenthesis, effectively ignoring colons inside
* function-like values (e.g., `url(data:image/png;base64,...)`).
*
* The lookahead `(?=(?:[^'"]|'[^']*'|"[^"]*")*$)` ensures that the colon is not inside single or double quotes,
* allowing colons within quoted strings (e.g., `content: ":";` or `background: url("foo:bar.png");`).
*
* Example:
* - `color: red;` // valid, does not match
* - `background: url(data:image/png;base64,...);` // valid, does not match
* - `content: ':';` // valid, does not match
* - `color: foo:bar;` // invalid, matches
*/
var basicStylePropertyValueValidationRegExp = /:(?![^(]*\))(?=(?:[^'"]|'[^']*'|"[^"]*")*$)/;
// Attribute selector pattern: matches attribute-name operator value
// Operators: =, ~=, |=, ^=, $=, *=
// Rewritten to avoid ReDoS by using greedy match and trimming in JavaScript
var attributeSelectorContentRegExp = /^([^\s=~|^$*]+)\s*(~=|\|=|\^=|\$=|\*=|=)\s*(.+)$/;
// Selector validation patterns
var pseudoElementRegExp = /::[a-zA-Z][\w-]*|:(before|after|first-line|first-letter)(?![a-zA-Z0-9_-])/; // Matches pseudo-elements
var invalidCombinatorLtGtRegExp = /<>/; // Invalid <> combinator
var invalidCombinatorDoubleGtRegExp = />>/; // Invalid >> combinator
var consecutiveCombinatorsRegExp = /[>+~]\s*[>+~]/; // Invalid consecutive combinators
var invalidSlottedRegExp = /(?:^|[\s>+~,\[])slotted\s*\(/i; // Invalid slotted() without ::
var invalidPartRegExp = /(?:^|[\s>+~,\[])part\s*\(/i; // Invalid part() without ::
var invalidCueRegExp = /(?:^|[\s>+~,\[])cue\s*\(/i; // Invalid cue() without ::
var invalidCueRegionRegExp = /(?:^|[\s>+~,\[])cue-region\s*\(/i; // Invalid cue-region() without ::
var invalidNestingPattern = /&(?![.\#\[:>\+~\s])[a-zA-Z]/; // Invalid & followed by type selector
var emptyPseudoClassRegExp = /:(?:is|not|where|has)\(\s*\)/; // Empty pseudo-class like :is()
var whitespaceNormalizationRegExp = /(['"])(?:\\.|[^\\])*?\1|(\r\n|\r|\n)/g; // Normalize newlines outside quotes
var newlineRemovalRegExp = /\n/g; // Remove all newlines
var whitespaceAndDotRegExp = /[\s.]/; // Matches whitespace or dot
var declarationOrOpenBraceRegExp = /[{;}]/; // Matches declaration separator or open brace
var ampersandRegExp = /&/; // Matches nesting selector
var hexEscapeSequenceRegExp = /^([0-9a-fA-F]{1,6})[ \t\r\n\f]?/; // Matches hex escape sequence (1-6 hex digits optionally followed by whitespace)
var attributeCaseFlagRegExp = /^(.+?)\s+([is])$/i; // Matches case-sensitivity flag at end of attribute value
var prependedAmpersandRegExp = /^&\s+[:\\.]/; // Matches prepended ampersand pattern (& followed by space and : or .)
var openBraceGlobalRegExp = /{/g; // Matches opening braces (global)
var closeBraceGlobalRegExp = /}/g; // Matches closing braces (global)
var scopePreludeSplitRegExp = /\s*\)\s*to\s+\(/; // Splits scope prelude by ") to ("
var leadingWhitespaceRegExp = /^\s+/; // Matches leading whitespace (used to implement a ES5-compliant alternative to trimStart())
var doubleQuoteRegExp = /"/g; // Match all double quotes (for escaping in attribute values)
var backslashRegExp = /\\/g; // Match all backslashes (for escaping in attribute values)
var regexPatterns = {
// Parsing patterns
atKeyframesRegExp: atKeyframesRegExp,
beforeRulePortionRegExp: beforeRulePortionRegExp,
beforeRuleValidationRegExp: beforeRuleValidationRegExp,
forwardRuleValidationRegExp: forwardRuleValidationRegExp,
forwardImportRuleValidationRegExp: forwardImportRuleValidationRegExp,
forwardRuleClosingBraceRegExp: forwardRuleClosingBraceRegExp,
forwardRuleSemicolonAndOpeningBraceRegExp: forwardRuleSemicolonAndOpeningBraceRegExp,
// Selector validation patterns
cssCustomIdentifierRegExp: cssCustomIdentifierRegExp,
startsWithCombinatorRegExp: startsWithCombinatorRegExp,
atPageRuleSelectorRegExp: atPageRuleSelectorRegExp,
// Parsing patterns used in CSSImportRule
layerRegExp: layerRegExp,
layerRuleNameRegExp: layerRuleNameRegExp,
doubleOrMoreSpacesRegExp: doubleOrMoreSpacesRegExp,
// Escape sequence and identifier patterns
startsWithHexEscapeRegExp: startsWithHexEscapeRegExp,
identStartCharRegExp: identStartCharRegExp,
identCharRegExp: identCharRegExp,
specialCharsNeedEscapeRegExp: specialCharsNeedEscapeRegExp,
combinatorOrSeparatorRegExp: combinatorOrSeparatorRegExp,
afterHexEscapeSeparatorRegExp: afterHexEscapeSeparatorRegExp,
trailingSpaceSeparatorRegExp: trailingSpaceSeparatorRegExp,
endsWithHexEscapeRegExp: endsWithHexEscapeRegExp,
// Basic style property value validation
basicStylePropertyValueValidationRegExp: basicStylePropertyValueValidationRegExp,
// Attribute selector patterns
attributeSelectorContentRegExp: attributeSelectorContentRegExp,
// Selector validation patterns
pseudoElementRegExp: pseudoElementRegExp,
invalidCombinatorLtGtRegExp: invalidCombinatorLtGtRegExp,
invalidCombinatorDoubleGtRegExp: invalidCombinatorDoubleGtRegExp,
consecutiveCombinatorsRegExp: consecutiveCombinatorsRegExp,
invalidSlottedRegExp: invalidSlottedRegExp,
invalidPartRegExp: invalidPartRegExp,
invalidCueRegExp: invalidCueRegExp,
invalidCueRegionRegExp: invalidCueRegionRegExp,
invalidNestingPattern: invalidNestingPattern,
emptyPseudoClassRegExp: emptyPseudoClassRegExp,
whitespaceNormalizationRegExp: whitespaceNormalizationRegExp,
newlineRemovalRegExp: newlineRemovalRegExp,
whitespaceAndDotRegExp: whitespaceAndDotRegExp,
declarationOrOpenBraceRegExp: declarationOrOpenBraceRegExp,
ampersandRegExp: ampersandRegExp,
hexEscapeSequenceRegExp: hexEscapeSequenceRegExp,
attributeCaseFlagRegExp: attributeCaseFlagRegExp,
prependedAmpersandRegExp: prependedAmpersandRegExp,
openBraceGlobalRegExp: openBraceGlobalRegExp,
closeBraceGlobalRegExp: closeBraceGlobalRegExp,
scopePreludeSplitRegExp: scopePreludeSplitRegExp,
leadingWhitespaceRegExp: leadingWhitespaceRegExp,
doubleQuoteRegExp: doubleQuoteRegExp,
backslashRegExp: backslashRegExp
};
//.CommonJS
exports.regexPatterns = regexPatterns;
///CommonJS

32
server/node_modules/@acemir/cssom/package.json generated vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"name": "@acemir/cssom",
"description": "CSS Object Model implementation and CSS parser",
"keywords": [
"CSS",
"CSSOM",
"parser",
"styleSheet"
],
"version": "0.9.31",
"author": "Nikita Vasilyev <me@elv1s.ru>",
"contributors": [
"Acemir Sousa Mendes <acemirsm@gmail.com>"
],
"repository": "acemir/CSSOM",
"files": [
"lib/",
"build/"
],
"browser": "./build/CSSOM.js",
"main": "./lib/index.js",
"license": "MIT",
"scripts": {
"build": "node build.js",
"release": "npm run build && changeset publish"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.2",
"@changesets/cli": "^2.29.8",
"@changesets/get-release-plan": "^4.0.14"
}
}