Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
9
node_modules/inline-style-parser/LICENSE
generated
vendored
Normal file
9
node_modules/inline-style-parser/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
229
node_modules/inline-style-parser/README.md
generated
vendored
Normal file
229
node_modules/inline-style-parser/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
# inline-style-parser
|
||||
|
||||
[](https://nodei.co/npm/inline-style-parser/)
|
||||
|
||||
[](https://www.npmjs.com/package/inline-style-parser)
|
||||
[](https://bundlephobia.com/package/inline-style-parser)
|
||||
[](https://github.com/remarkablemark/inline-style-parser/actions/workflows/build.yml)
|
||||
[](https://codecov.io/gh/remarkablemark/inline-style-parser)
|
||||
[](https://www.npmjs.com/package/inline-style-parser)
|
||||
|
||||
Inline style parser copied from [`css/lib/parse/index.js`](https://github.com/reworkcss/css/blob/v2.2.4/lib/parse/index.js):
|
||||
|
||||
```
|
||||
InlineStyleParser(string)
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const parse = require('inline-style-parser');
|
||||
|
||||
parse('color: #BADA55;');
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```js
|
||||
[ { type: 'declaration',
|
||||
property: 'color',
|
||||
value: '#BADA55',
|
||||
position: Position { start: [Object], end: [Object], source: undefined } } ]
|
||||
```
|
||||
|
||||
[JSFiddle](https://jsfiddle.net/remarkablemark/hcxbpwq8/) | [Replit](https://replit.com/@remarkablemark/inline-style-parser) | [Examples](https://github.com/remarkablemark/inline-style-parser/tree/master/examples)
|
||||
|
||||
## Installation
|
||||
|
||||
[NPM](https://www.npmjs.com/package/inline-style-parser):
|
||||
|
||||
```sh
|
||||
npm install inline-style-parser --save
|
||||
```
|
||||
|
||||
[Yarn](https://yarnpkg.com/package/inline-style-parser):
|
||||
|
||||
```sh
|
||||
yarn add inline-style-parser
|
||||
```
|
||||
|
||||
[CDN](https://unpkg.com/inline-style-parser/):
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/inline-style-parser@latest/dist/inline-style-parser.min.js"></script>
|
||||
<script>
|
||||
window.InlineStyleParser(/* string */);
|
||||
</script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Import with ES Modules:
|
||||
|
||||
```js
|
||||
import parse from 'inline-style-parser';
|
||||
```
|
||||
|
||||
Or require with CommonJS:
|
||||
|
||||
```js
|
||||
const parse = require('inline-style-parser');
|
||||
```
|
||||
|
||||
Parse single declaration:
|
||||
|
||||
```js
|
||||
parse('left: 0');
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
type: 'declaration',
|
||||
property: 'left',
|
||||
value: '0',
|
||||
position: {
|
||||
start: { line: 1, column: 1 },
|
||||
end: { line: 1, column: 8 },
|
||||
source: undefined
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Parse multiple declarations:
|
||||
|
||||
```js
|
||||
parse('left: 0; right: 100px;');
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
type: 'declaration',
|
||||
property: 'left',
|
||||
value: '0',
|
||||
position: {
|
||||
start: { line: 1, column: 1 },
|
||||
end: { line: 1, column: 8 },
|
||||
source: undefined
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'declaration',
|
||||
property: 'right',
|
||||
value: '100px',
|
||||
position: {
|
||||
start: { line: 1, column: 10 },
|
||||
end: { line: 1, column: 22 },
|
||||
source: undefined
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Parse declaration with missing value:
|
||||
|
||||
```js
|
||||
parse('top:');
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
type: 'declaration',
|
||||
property: 'top',
|
||||
value: '',
|
||||
position: {
|
||||
start: { line: 1, column: 1 },
|
||||
end: { line: 1, column: 5 },
|
||||
source: undefined
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Parse unknown declaration:
|
||||
|
||||
```js
|
||||
parse('answer: 42;');
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
type: 'declaration',
|
||||
property: 'answer',
|
||||
value: '42',
|
||||
position: {
|
||||
start: { line: 1, column: 1 },
|
||||
end: { line: 1, column: 11 },
|
||||
source: undefined
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Invalid declarations:
|
||||
|
||||
```js
|
||||
parse(''); // []
|
||||
parse(); // throws TypeError
|
||||
parse(1); // throws TypeError
|
||||
parse('width'); // throws Error
|
||||
parse('/*'); // throws Error
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Run tests:
|
||||
|
||||
```sh
|
||||
npm test
|
||||
```
|
||||
|
||||
Run tests in watch mode:
|
||||
|
||||
```sh
|
||||
npm run test:watch
|
||||
```
|
||||
|
||||
Run tests with coverage:
|
||||
|
||||
```sh
|
||||
npm run test:coverage
|
||||
```
|
||||
|
||||
Run tests in CI mode:
|
||||
|
||||
```sh
|
||||
npm run test:ci
|
||||
```
|
||||
|
||||
Lint files:
|
||||
|
||||
```sh
|
||||
npm run lint
|
||||
```
|
||||
|
||||
Fix lint errors:
|
||||
|
||||
```sh
|
||||
npm run lint:fix
|
||||
```
|
||||
|
||||
## Release
|
||||
|
||||
Release and publish are automated by [Release Please](https://github.com/googleapis/release-please).
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/remarkablemark/inline-style-parser/blob/master/LICENSE). See the [license](https://github.com/reworkcss/css/blob/v2.2.4/LICENSE) from the original project.
|
||||
274
node_modules/inline-style-parser/dist/inline-style-parser.js
generated
vendored
Normal file
274
node_modules/inline-style-parser/dist/inline-style-parser.js
generated
vendored
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.InlineStyleParser = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
function getDefaultExportFromCjs (x) {
|
||||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
||||
}
|
||||
|
||||
// http://www.w3.org/TR/CSS21/grammar.html
|
||||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
||||
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
||||
|
||||
var NEWLINE_REGEX = /\n/g;
|
||||
var WHITESPACE_REGEX = /^\s*/;
|
||||
|
||||
// declaration
|
||||
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
||||
var COLON_REGEX = /^:\s*/;
|
||||
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
||||
var SEMICOLON_REGEX = /^[;\s]*/;
|
||||
|
||||
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
||||
var TRIM_REGEX = /^\s+|\s+$/g;
|
||||
|
||||
// strings
|
||||
var NEWLINE = '\n';
|
||||
var FORWARD_SLASH = '/';
|
||||
var ASTERISK = '*';
|
||||
var EMPTY_STRING = '';
|
||||
|
||||
// types
|
||||
var TYPE_COMMENT = 'comment';
|
||||
var TYPE_DECLARATION = 'declaration';
|
||||
|
||||
/**
|
||||
* @param {String} style
|
||||
* @param {Object} [options]
|
||||
* @return {Object[]}
|
||||
* @throws {TypeError}
|
||||
* @throws {Error}
|
||||
*/
|
||||
var inlineStyleParser = function (style, options) {
|
||||
if (typeof style !== 'string') {
|
||||
throw new TypeError('First argument must be a string');
|
||||
}
|
||||
|
||||
if (!style) return [];
|
||||
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* Positional.
|
||||
*/
|
||||
var lineno = 1;
|
||||
var column = 1;
|
||||
|
||||
/**
|
||||
* Update lineno and column based on `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
*/
|
||||
function updatePosition(str) {
|
||||
var lines = str.match(NEWLINE_REGEX);
|
||||
if (lines) lineno += lines.length;
|
||||
var i = str.lastIndexOf(NEWLINE);
|
||||
column = ~i ? str.length - i : column + str.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark position and patch `node.position`.
|
||||
*
|
||||
* @return {Function}
|
||||
*/
|
||||
function position() {
|
||||
var start = { line: lineno, column: column };
|
||||
return function (node) {
|
||||
node.position = new Position(start);
|
||||
whitespace();
|
||||
return node;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Store position information for a node.
|
||||
*
|
||||
* @constructor
|
||||
* @property {Object} start
|
||||
* @property {Object} end
|
||||
* @property {undefined|String} source
|
||||
*/
|
||||
function Position(start) {
|
||||
this.start = start;
|
||||
this.end = { line: lineno, column: column };
|
||||
this.source = options.source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-enumerable source string.
|
||||
*/
|
||||
Position.prototype.content = style;
|
||||
|
||||
/**
|
||||
* Error `msg`.
|
||||
*
|
||||
* @param {String} msg
|
||||
* @throws {Error}
|
||||
*/
|
||||
function error(msg) {
|
||||
var err = new Error(
|
||||
options.source + ':' + lineno + ':' + column + ': ' + msg
|
||||
);
|
||||
err.reason = msg;
|
||||
err.filename = options.source;
|
||||
err.line = lineno;
|
||||
err.column = column;
|
||||
err.source = style;
|
||||
|
||||
if (options.silent) ; else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Match `re` and return captures.
|
||||
*
|
||||
* @param {RegExp} re
|
||||
* @return {undefined|Array}
|
||||
*/
|
||||
function match(re) {
|
||||
var m = re.exec(style);
|
||||
if (!m) return;
|
||||
var str = m[0];
|
||||
updatePosition(str);
|
||||
style = style.slice(str.length);
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse whitespace.
|
||||
*/
|
||||
function whitespace() {
|
||||
match(WHITESPACE_REGEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse comments.
|
||||
*
|
||||
* @param {Object[]} [rules]
|
||||
* @return {Object[]}
|
||||
*/
|
||||
function comments(rules) {
|
||||
var c;
|
||||
rules = rules || [];
|
||||
while ((c = comment())) {
|
||||
if (c !== false) {
|
||||
rules.push(c);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse comment.
|
||||
*
|
||||
* @return {Object}
|
||||
* @throws {Error}
|
||||
*/
|
||||
function comment() {
|
||||
var pos = position();
|
||||
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
||||
|
||||
var i = 2;
|
||||
while (
|
||||
EMPTY_STRING != style.charAt(i) &&
|
||||
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
||||
) {
|
||||
++i;
|
||||
}
|
||||
i += 2;
|
||||
|
||||
if (EMPTY_STRING === style.charAt(i - 1)) {
|
||||
return error('End of comment missing');
|
||||
}
|
||||
|
||||
var str = style.slice(2, i - 2);
|
||||
column += 2;
|
||||
updatePosition(str);
|
||||
style = style.slice(i);
|
||||
column += 2;
|
||||
|
||||
return pos({
|
||||
type: TYPE_COMMENT,
|
||||
comment: str
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse declaration.
|
||||
*
|
||||
* @return {Object}
|
||||
* @throws {Error}
|
||||
*/
|
||||
function declaration() {
|
||||
var pos = position();
|
||||
|
||||
// prop
|
||||
var prop = match(PROPERTY_REGEX);
|
||||
if (!prop) return;
|
||||
comment();
|
||||
|
||||
// :
|
||||
if (!match(COLON_REGEX)) return error("property missing ':'");
|
||||
|
||||
// val
|
||||
var val = match(VALUE_REGEX);
|
||||
|
||||
var ret = pos({
|
||||
type: TYPE_DECLARATION,
|
||||
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
||||
value: val
|
||||
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
|
||||
: EMPTY_STRING
|
||||
});
|
||||
|
||||
// ;
|
||||
match(SEMICOLON_REGEX);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse declarations.
|
||||
*
|
||||
* @return {Object[]}
|
||||
*/
|
||||
function declarations() {
|
||||
var decls = [];
|
||||
|
||||
comments(decls);
|
||||
|
||||
// declarations
|
||||
var decl;
|
||||
while ((decl = declaration())) {
|
||||
if (decl !== false) {
|
||||
decls.push(decl);
|
||||
comments(decls);
|
||||
}
|
||||
}
|
||||
|
||||
return decls;
|
||||
}
|
||||
|
||||
whitespace();
|
||||
return declarations();
|
||||
};
|
||||
|
||||
/**
|
||||
* Trim `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
*/
|
||||
function trim(str) {
|
||||
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
||||
}
|
||||
|
||||
var index = /*@__PURE__*/getDefaultExportFromCjs(inlineStyleParser);
|
||||
|
||||
return index;
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=inline-style-parser.js.map
|
||||
1
node_modules/inline-style-parser/dist/inline-style-parser.js.map
generated
vendored
Normal file
1
node_modules/inline-style-parser/dist/inline-style-parser.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/inline-style-parser/dist/inline-style-parser.min.js
generated
vendored
Normal file
2
node_modules/inline-style-parser/dist/inline-style-parser.min.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).InlineStyleParser=n()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,t=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,a="";function s(e){return e?e.replace(f,a):a}return e((function(e,f){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];f=f||{};var l=1,p=1;function h(e){var n=e.match(r);n&&(l+=n.length);var t=e.lastIndexOf("\n");p=~t?e.length-t:p+e.length}function m(){var e={line:l,column:p};return function(n){return n.position=new d(e),y(),n}}function d(e){this.start=e,this.end={line:l,column:p},this.source=f.source}function v(n){var r=new Error(f.source+":"+l+":"+p+": "+n);if(r.reason=n,r.filename=f.source,r.line=l,r.column=p,r.source=e,!f.silent)throw r}function g(n){var r=n.exec(e);if(r){var t=r[0];return h(t),e=e.slice(t.length),r}}function y(){g(t)}function w(e){var n;for(e=e||[];n=A();)!1!==n&&e.push(n);return e}function A(){var n=m();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;a!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,a===e.charAt(r-1))return v("End of comment missing");var t=e.slice(2,r-2);return p+=2,h(t),e=e.slice(r),p+=2,n({type:"comment",comment:t})}}function b(){var e=m(),r=g(o);if(r){if(A(),!g(i))return v("property missing ':'");var t=g(u),f=e({type:"declaration",property:s(r[0].replace(n,a)),value:t?s(t[0].replace(n,a)):a});return g(c),f}}return d.prototype.content=e,y(),function(){var e,n=[];for(w(n);e=b();)!1!==e&&(n.push(e),w(n));return n}()}))}));
|
||||
//# sourceMappingURL=inline-style-parser.min.js.map
|
||||
1
node_modules/inline-style-parser/dist/inline-style-parser.min.js.map
generated
vendored
Normal file
1
node_modules/inline-style-parser/dist/inline-style-parser.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
34
node_modules/inline-style-parser/index.d.ts
generated
vendored
Normal file
34
node_modules/inline-style-parser/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
interface Position {
|
||||
start: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
end: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export interface Declaration {
|
||||
type: 'declaration';
|
||||
property: string;
|
||||
value: string;
|
||||
position: Position;
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
type: 'comment';
|
||||
comment: string;
|
||||
position: Position;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
source?: string;
|
||||
silent?: boolean;
|
||||
}
|
||||
|
||||
export default function InlineStyleParser(
|
||||
style: string,
|
||||
options?: Options
|
||||
): (Declaration | Comment)[];
|
||||
261
node_modules/inline-style-parser/index.js
generated
vendored
Normal file
261
node_modules/inline-style-parser/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
// http://www.w3.org/TR/CSS21/grammar.html
|
||||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
||||
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
||||
|
||||
var NEWLINE_REGEX = /\n/g;
|
||||
var WHITESPACE_REGEX = /^\s*/;
|
||||
|
||||
// declaration
|
||||
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
||||
var COLON_REGEX = /^:\s*/;
|
||||
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
||||
var SEMICOLON_REGEX = /^[;\s]*/;
|
||||
|
||||
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
||||
var TRIM_REGEX = /^\s+|\s+$/g;
|
||||
|
||||
// strings
|
||||
var NEWLINE = '\n';
|
||||
var FORWARD_SLASH = '/';
|
||||
var ASTERISK = '*';
|
||||
var EMPTY_STRING = '';
|
||||
|
||||
// types
|
||||
var TYPE_COMMENT = 'comment';
|
||||
var TYPE_DECLARATION = 'declaration';
|
||||
|
||||
/**
|
||||
* @param {String} style
|
||||
* @param {Object} [options]
|
||||
* @return {Object[]}
|
||||
* @throws {TypeError}
|
||||
* @throws {Error}
|
||||
*/
|
||||
module.exports = function (style, options) {
|
||||
if (typeof style !== 'string') {
|
||||
throw new TypeError('First argument must be a string');
|
||||
}
|
||||
|
||||
if (!style) return [];
|
||||
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* Positional.
|
||||
*/
|
||||
var lineno = 1;
|
||||
var column = 1;
|
||||
|
||||
/**
|
||||
* Update lineno and column based on `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
*/
|
||||
function updatePosition(str) {
|
||||
var lines = str.match(NEWLINE_REGEX);
|
||||
if (lines) lineno += lines.length;
|
||||
var i = str.lastIndexOf(NEWLINE);
|
||||
column = ~i ? str.length - i : column + str.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark position and patch `node.position`.
|
||||
*
|
||||
* @return {Function}
|
||||
*/
|
||||
function position() {
|
||||
var start = { line: lineno, column: column };
|
||||
return function (node) {
|
||||
node.position = new Position(start);
|
||||
whitespace();
|
||||
return node;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Store position information for a node.
|
||||
*
|
||||
* @constructor
|
||||
* @property {Object} start
|
||||
* @property {Object} end
|
||||
* @property {undefined|String} source
|
||||
*/
|
||||
function Position(start) {
|
||||
this.start = start;
|
||||
this.end = { line: lineno, column: column };
|
||||
this.source = options.source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-enumerable source string.
|
||||
*/
|
||||
Position.prototype.content = style;
|
||||
|
||||
var errorsList = [];
|
||||
|
||||
/**
|
||||
* Error `msg`.
|
||||
*
|
||||
* @param {String} msg
|
||||
* @throws {Error}
|
||||
*/
|
||||
function error(msg) {
|
||||
var err = new Error(
|
||||
options.source + ':' + lineno + ':' + column + ': ' + msg
|
||||
);
|
||||
err.reason = msg;
|
||||
err.filename = options.source;
|
||||
err.line = lineno;
|
||||
err.column = column;
|
||||
err.source = style;
|
||||
|
||||
if (options.silent) {
|
||||
errorsList.push(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Match `re` and return captures.
|
||||
*
|
||||
* @param {RegExp} re
|
||||
* @return {undefined|Array}
|
||||
*/
|
||||
function match(re) {
|
||||
var m = re.exec(style);
|
||||
if (!m) return;
|
||||
var str = m[0];
|
||||
updatePosition(str);
|
||||
style = style.slice(str.length);
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse whitespace.
|
||||
*/
|
||||
function whitespace() {
|
||||
match(WHITESPACE_REGEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse comments.
|
||||
*
|
||||
* @param {Object[]} [rules]
|
||||
* @return {Object[]}
|
||||
*/
|
||||
function comments(rules) {
|
||||
var c;
|
||||
rules = rules || [];
|
||||
while ((c = comment())) {
|
||||
if (c !== false) {
|
||||
rules.push(c);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse comment.
|
||||
*
|
||||
* @return {Object}
|
||||
* @throws {Error}
|
||||
*/
|
||||
function comment() {
|
||||
var pos = position();
|
||||
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
||||
|
||||
var i = 2;
|
||||
while (
|
||||
EMPTY_STRING != style.charAt(i) &&
|
||||
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
||||
) {
|
||||
++i;
|
||||
}
|
||||
i += 2;
|
||||
|
||||
if (EMPTY_STRING === style.charAt(i - 1)) {
|
||||
return error('End of comment missing');
|
||||
}
|
||||
|
||||
var str = style.slice(2, i - 2);
|
||||
column += 2;
|
||||
updatePosition(str);
|
||||
style = style.slice(i);
|
||||
column += 2;
|
||||
|
||||
return pos({
|
||||
type: TYPE_COMMENT,
|
||||
comment: str
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse declaration.
|
||||
*
|
||||
* @return {Object}
|
||||
* @throws {Error}
|
||||
*/
|
||||
function declaration() {
|
||||
var pos = position();
|
||||
|
||||
// prop
|
||||
var prop = match(PROPERTY_REGEX);
|
||||
if (!prop) return;
|
||||
comment();
|
||||
|
||||
// :
|
||||
if (!match(COLON_REGEX)) return error("property missing ':'");
|
||||
|
||||
// val
|
||||
var val = match(VALUE_REGEX);
|
||||
|
||||
var ret = pos({
|
||||
type: TYPE_DECLARATION,
|
||||
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
||||
value: val
|
||||
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
|
||||
: EMPTY_STRING
|
||||
});
|
||||
|
||||
// ;
|
||||
match(SEMICOLON_REGEX);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse declarations.
|
||||
*
|
||||
* @return {Object[]}
|
||||
*/
|
||||
function declarations() {
|
||||
var decls = [];
|
||||
|
||||
comments(decls);
|
||||
|
||||
// declarations
|
||||
var decl;
|
||||
while ((decl = declaration())) {
|
||||
if (decl !== false) {
|
||||
decls.push(decl);
|
||||
comments(decls);
|
||||
}
|
||||
}
|
||||
|
||||
return decls;
|
||||
}
|
||||
|
||||
whitespace();
|
||||
return declarations();
|
||||
};
|
||||
|
||||
/**
|
||||
* Trim `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
*/
|
||||
function trim(str) {
|
||||
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
||||
}
|
||||
56
node_modules/inline-style-parser/package.json
generated
vendored
Normal file
56
node_modules/inline-style-parser/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"name": "inline-style-parser",
|
||||
"version": "0.2.4",
|
||||
"description": "An inline style parser.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "rollup --config --failAfterWarnings",
|
||||
"clean": "rm -rf dist",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"prepare": "husky",
|
||||
"prepublishOnly": "npm run lint && npm test && npm run build",
|
||||
"test": "jest",
|
||||
"test:ci": "CI=true jest --ci --colors --coverage --collectCoverageFrom=index.js",
|
||||
"test:esm": "node --test test/index.test.mjs",
|
||||
"test:watch": "jest --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkablemark/inline-style-parser"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/remarkablemark/inline-style-parser/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"inline-style-parser",
|
||||
"inline-style",
|
||||
"style",
|
||||
"parser",
|
||||
"css"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "19.4.1",
|
||||
"@commitlint/config-conventional": "19.4.1",
|
||||
"@eslint/compat": "1.1.1",
|
||||
"@eslint/eslintrc": "3.1.0",
|
||||
"@eslint/js": "9.9.1",
|
||||
"@rollup/plugin-commonjs": "26.0.1",
|
||||
"@rollup/plugin-terser": "0.4.4",
|
||||
"css": "3.0.0",
|
||||
"eslint": "9.9.1",
|
||||
"eslint-plugin-prettier": "5.2.1",
|
||||
"eslint-plugin-simple-import-sort": "12.1.1",
|
||||
"globals": "15.9.0",
|
||||
"husky": "9.1.5",
|
||||
"jest": "29.7.0",
|
||||
"lint-staged": "15.2.9",
|
||||
"prettier": "3.3.3",
|
||||
"rollup": "4.21.1"
|
||||
},
|
||||
"files": [
|
||||
"/dist",
|
||||
"/index.d.ts"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue