Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bbob/core

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbob/core - npm Package Compare versions

Comparing version 2.6.1 to 2.6.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [2.6.2](https://github.com/JiLiZART/bbob/compare/v2.5.8...v2.6.2) (2020-12-16)
### Features
* **parser:** rewrite lexer to make it faster ([#50](https://github.com/JiLiZART/bbob/issues/50)) ([772d422](https://github.com/JiLiZART/bbob/commit/772d422d770b0f7716a86ac82c10eb3baaf77828))
## [2.6.1](https://github.com/JiLiZART/bbob/compare/v2.5.8...v2.6.1) (2020-12-15)

@@ -8,0 +19,0 @@

90

dist/index.js

@@ -288,2 +288,23 @@ (function (global, factory) {

_proto.toTagStart = function toTagStart(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$openTag = _ref.openTag,
openTag = _ref$openTag === void 0 ? char_1.OPEN_BRAKET : _ref$openTag,
_ref$closeTag = _ref.closeTag,
closeTag = _ref$closeTag === void 0 ? char_1.CLOSE_BRAKET : _ref$closeTag;
var tagAttrs = getTagAttrs(this.tag, this.attrs);
return "" + openTag + tagAttrs + closeTag;
};
_proto.toTagEnd = function toTagEnd(_temp2) {
var _ref2 = _temp2 === void 0 ? {} : _temp2,
_ref2$openTag = _ref2.openTag,
openTag = _ref2$openTag === void 0 ? char_1.OPEN_BRAKET : _ref2$openTag,
_ref2$closeTag = _ref2.closeTag,
closeTag = _ref2$closeTag === void 0 ? char_1.CLOSE_BRAKET : _ref2$closeTag;
return "" + openTag + char_1.SLASH + this.tag + closeTag;
};
_proto.toTagNode = function toTagNode() {

@@ -293,16 +314,29 @@ return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);

_proto.toString = function toString() {
var OB = char_1.OPEN_BRAKET;
var CB = char_1.CLOSE_BRAKET;
_proto.toString = function toString(_temp3) {
var _ref3 = _temp3 === void 0 ? {} : _temp3,
_ref3$openTag = _ref3.openTag,
openTag = _ref3$openTag === void 0 ? char_1.OPEN_BRAKET : _ref3$openTag,
_ref3$closeTag = _ref3.closeTag,
closeTag = _ref3$closeTag === void 0 ? char_1.CLOSE_BRAKET : _ref3$closeTag;
var isEmpty = this.content.length === 0;
var content = this.content.reduce(function (r, node) {
return r + node.toString();
return r + node.toString({
openTag: openTag,
closeTag: closeTag
});
}, '');
var tagAttrs = getTagAttrs(this.tag, this.attrs);
var tagStart = this.toTagStart({
openTag: openTag,
closeTag: closeTag
});
if (isEmpty) {
return "" + OB + tagAttrs + CB;
return tagStart;
}
return "" + OB + tagAttrs + CB + content + OB + char_1.SLASH + this.tag + CB;
return "" + tagStart + content + this.toTagEnd({
openTag: openTag,
closeTag: closeTag
});
};

@@ -1202,2 +1236,4 @@

function _interopRequireDefault(obj) {

@@ -1227,2 +1263,4 @@ return obj && obj.__esModule ? obj : {

var options = opts;
var openTag = options.openTag || char_1.OPEN_BRAKET;
var closeTag = options.closeTag || char_1.CLOSE_BRAKET;
var tokenizer = null;

@@ -1259,13 +1297,20 @@ /**

* Cache for nested tags checks
* @type {{}}
*/
var nestedTagsMap = {};
var nestedTagsMap = new Set();
/**
*
* @param token
* @returns {boolean}
*/
var isTokenNested = function isTokenNested(token) {
if (typeof nestedTagsMap[token.getValue()] === 'undefined') {
nestedTagsMap[token.getValue()] = tokenizer.isTokenNested(token);
var value = token.getValue();
if (!nestedTagsMap.has(value) && tokenizer.isTokenNested && tokenizer.isTokenNested(token)) {
nestedTagsMap.add(value);
return true;
}
return nestedTagsMap[token.getValue()];
return nestedTagsMap.has(value);
};

@@ -1279,3 +1324,3 @@ /**

var isTagNested = function isTagNested(tagName) {
return !!nestedTagsMap[tagName];
return Boolean(nestedTagsMap.has(tagName));
};

@@ -1337,3 +1382,16 @@ /**

} else {
items.push(node.toString());
items.push(node.toTagStart({
openTag: openTag,
closeTag: closeTag
}));
if (node.content.length) {
node.content.forEach(function (item) {
items.push(item);
});
items.push(node.toTagEnd({
openTag: openTag,
closeTag: closeTag
}));
}
}

@@ -1467,4 +1525,4 @@ } else {

onlyAllowTags: options.onlyAllowTags,
openTag: options.openTag,
closeTag: options.closeTag,
openTag: openTag,
closeTag: closeTag,
enableEscapeTags: options.enableEscapeTags

@@ -1471,0 +1529,0 @@ }); // eslint-disable-next-line no-unused-vars

2

dist/index.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).BbobCore=e()}(this,(function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r=e((function(t,e){e.__esModule=!0,e.BACKSLASH=e.PLACEHOLDER_SPACE=e.PLACEHOLDER_SPACE_TAB=e.SLASH=e.CLOSE_BRAKET=e.OPEN_BRAKET=e.SPACE=e.QUOTEMARK=e.EQ=e.TAB=e.R=e.F=e.N=void 0;e.N="\n";e.TAB="\t";e.F="\f";e.R="\r";e.EQ="=";e.QUOTEMARK='"';e.SPACE=" ";e.OPEN_BRAKET="[";e.CLOSE_BRAKET="]";e.SLASH="/";e.BACKSLASH="\\";e.PLACEHOLDER_SPACE_TAB=" ";e.PLACEHOLDER_SPACE=" "}));t(r);var n=e((function(t,e){e.__esModule=!0,e.isEOL=e.isStringNode=e.isTagNode=e.getUniqAttr=e.getNodeLength=e.escapeHTML=e.appendToNode=e.attrValue=e.attrsToString=void 0;var n=function(t){return"object"==typeof t&&!!t.tag};e.isTagNode=n;var i=function(t){return"string"==typeof t};e.isStringNode=i;e.isEOL=function(t){return t===r.N};var u=function(t,e,r){return Object.keys(t).reduce(e,r)};e.getNodeLength=function t(e){return n(e)?e.content.reduce((function(e,r){return e+t(r)}),0):i(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var o=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript):/gi,"$1%3A")};e.escapeHTML=o;var a=function(t,e){var r=typeof e,n={boolean:function(){return e?""+t:""},number:function(){return t+'="'+e+'"'},string:function(){return t+'="'+o(e)+'"'},object:function(){return t+'="'+o(JSON.stringify(e))+'"'}};return n[r]?n[r]():""};e.attrValue=a;e.attrsToString=function(t){return null==t?"":u(t,(function(e,r){return[].concat(e,[a(r,t[r])])}),[""]).join(" ")};e.getUniqAttr=function(t){return u(t,(function(e,r){return t[r]===r?t[r]:null}),null)}}));t(n);var i=e((function(t,e){function i(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function u(){return(u=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}e.__esModule=!0,e.default=e.TagNode=void 0;var o=function(){function t(t,e,r){this.tag=t,this.attrs=e,this.content=Array.isArray(r)?r:[r]}var e,o,a,s=t.prototype;return s.attr=function(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]},s.append=function(t){return(0,n.appendToNode)(this,t)},s.toTagNode=function(){return new t(this.tag.toLowerCase(),this.attrs,this.content)},s.toString=function(){var t=r.OPEN_BRAKET,e=r.CLOSE_BRAKET,i=0===this.content.length,o=this.content.reduce((function(t,e){return t+""+e}),""),a=function(t,e){var r=(0,n.getUniqAttr)(e);if(r){var i=(0,n.attrValue)(t,r),o=u({},e);return delete o[r],""+i+(0,n.attrsToString)(o)}return""+t+(0,n.attrsToString)(e)}(this.tag,this.attrs);return i?""+t+a+e:""+t+a+e+o+t+r.SLASH+this.tag+e},e=t,(o=[{key:"length",get:function(){return(0,n.getNodeLength)(this)}}])&&i(e.prototype,o),a&&i(e,a),t}();e.TagNode=o,o.create=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=[]),new o(t,e,r)},o.isOf=function(t,e){return t.tag===e},e.default=o}));t(i);var u=e((function(t,e){e.__esModule=!0,e.default=e.Token=e.TYPE_NEW_LINE=e.TYPE_SPACE=e.TYPE_ATTR_VALUE=e.TYPE_ATTR_NAME=e.TYPE_TAG=e.TYPE_WORD=e.COLUMN_ID=e.LINE_ID=e.VALUE_ID=e.TYPE_ID=void 0;var n=function(t){return t&&void 0!==t.value?t.value:""},i=function(t){return n(t).charCodeAt(0)===r.SLASH.charCodeAt(0)},u=function(){function t(t,e,r,n){this.type=Number(t),this.value=e+"",this.line=Number(r),this.row=Number(n)}var e=t.prototype;return e.isEmpty=function(){return isNaN(this.type)},e.isText=function(){return!(!(t=this)||void 0===t.type||5!==t.type&&6!==t.type&&1!==t.type);var t},e.isTag=function(){return!(!(t=this)||void 0===t.type)&&2===t.type;var t},e.isAttrName=function(){return!(!(t=this)||void 0===t.type)&&3===t.type;var t},e.isAttrValue=function(){return!(!(t=this)||void 0===t.type)&&4===t.type;var t},e.isStart=function(){return!i(this)},e.isEnd=function(){return i(this)},e.getName=function(){return e=n(t=this),i(t)?e.slice(1):e;var t,e},e.getValue=function(){return n(this)},e.getLine=function(){return(t=this)&&t.line||0;var t},e.getColumn=function(){return(t=this)&&t.row||0;var t},e.toString=function(){return t=r.OPEN_BRAKET,t+=n(this),t+=r.CLOSE_BRAKET;var t},t}();e.Token=u;e.TYPE_ID="type";e.VALUE_ID="value";e.LINE_ID="line";e.COLUMN_ID="row";e.TYPE_WORD=1;e.TYPE_TAG=2;e.TYPE_ATTR_NAME=3;e.TYPE_ATTR_VALUE=4;e.TYPE_SPACE=5;e.TYPE_NEW_LINE=6,e.default=u}));t(u);var o=e((function(t,e){function n(t,e){var r={pos:0,len:t.length},n=function(){return r.len>r.pos},i=function(t,n){void 0===t&&(t=1),r.pos+=t,e&&e.onSkip&&!n&&e.onSkip()},u=function(){return t[r.pos]};this.skip=i,this.hasNext=n,this.getCurr=u,this.getRest=function(){return t.substr(r.pos)},this.getNext=function(){var e=r.pos+1;return e>t.length-1?null:t[e]},this.getPrev=function(){var e=r.pos-1;return void 0!==t[e]?t[e]:null},this.isLast=function(){return r.pos===r.len},this.includes=function(e){return t.indexOf(e,r.pos)>=0},this.grabWhile=function(e,o){var a=0;if(n())for(a=r.pos;n()&&e(u());)i(1,o);return t.substr(a,r.pos-a)},this.substrUntilChar=function(e){var n=r.pos,i=t.indexOf(e,n);return 0>i?"":t.substr(n,i-n)}}e.__esModule=!0,e.createList=e.unquote=e.trimChar=e.createCharGrabber=void 0;e.createCharGrabber=function(t,e){return new n(t,e)};e.trimChar=function(t,e){for(;t.charAt(0)===e;)t=t.substring(1);for(;t.charAt(t.length-1)===e;)t=t.substring(0,t.length-1);return t};function i(t){void 0===t&&(t=[]);var e=t;this.push=function(t){return e.push(t)},this.toArray=function(){return e},this.getLast=function(){return Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null},this.flushLast=function(){return!!e.length&&e.pop()}}e.unquote=function(t){return t.replace(r.BACKSLASH+r.QUOTEMARK,r.QUOTEMARK)};e.createList=function(t){return void 0===t&&(t=[]),new i(t)}}));t(o);var a=e((function(t,e){e.__esModule=!0,e.createLexer=function(t,e){void 0===e&&(e={});var i=0,a=0,s=-1,f=0,c=0,l=Array(Math.floor(t.length)),p=e.openTag||r.OPEN_BRAKET,g=e.closeTag||r.CLOSE_BRAKET,h=!!e.enableEscapeTags,T=e.onToken||function(){},d=[g,p,r.QUOTEMARK,r.BACKSLASH,r.SPACE,r.TAB,r.EQ,r.N,"!"],A=[p,r.SPACE,r.TAB,r.N],E=[r.SPACE,r.TAB],v=[r.EQ,r.SPACE,r.TAB],_=function(t){return E.indexOf(t)>=0},y=function(t){return-1===A.indexOf(t)},L=function(t){return t===r.BACKSLASH},N=function(){a++},O=function(t){return(0,o.unquote)((0,o.trimChar)(t,r.QUOTEMARK))},P=(0,o.createCharGrabber)(t,{onSkip:N});function b(t,e){var r=n(t,e,i,a);T(r),l[s+=1]=r}function S(t,e){if(1===c){var n=t.grabWhile((function(t){return!(t===r.EQ||_(t))})),i=t.isLast(),o=t.getCurr()!==r.EQ;return t.skip(),i||o?b(u.TYPE_ATTR_VALUE,O(n)):b(u.TYPE_ATTR_NAME,n),i?0:o?1:2}if(2===c){var a=!1,s=t.grabWhile((function(n){var i=n===r.QUOTEMARK,u=t.getPrev(),o=t.getNext(),s=u===r.BACKSLASH,f=o===r.EQ,c=_(n),l=_(o);return!(!a||!function(t){return v.indexOf(t)>=0}(n))||!!(!i||s||(a=!a)||f||l)&&(!!e||!1===c)}));return t.skip(),b(u.TYPE_ATTR_VALUE,O(s)),t.isLast()?0:1}var f=t.grabWhile((function(e){return!(e===r.EQ||_(e)||t.isLast())}));return b(u.TYPE_TAG,f),t.skip(),e?2:t.includes(r.EQ)?1:2}function C(){var t=P.getCurr();if(t===p){var e=P.getNext();P.skip();var n=P.substrUntilChar(g),i=0===n.length||n.indexOf(p)>=0;if(d.indexOf(e)>=0||i||P.isLast())return b(u.TYPE_WORD,t),0;if(-1===n.indexOf(r.EQ)||n[0]===r.SLASH){var o=P.grabWhile((function(t){return t!==g}));return P.skip(),b(u.TYPE_TAG,o),0}return 2}return 0}function k(){var t=P.grabWhile((function(t){return t!==g}),!0),e=(0,o.createCharGrabber)(t,{onSkip:N}),n=e.includes(r.SPACE);for(c=0;e.hasNext();)c=S(e,!n);return P.skip(),0}function R(){if(P.getCurr()===r.N)return b(u.TYPE_NEW_LINE,P.getCurr()),P.skip(),a=0,i++,0;if(_(P.getCurr()))return b(u.TYPE_SPACE,P.grabWhile(_)),0;if(P.getCurr()===p)return P.includes(g)?1:(b(u.TYPE_WORD,P.getCurr()),P.skip(),0);if(h){if(L(P.getCurr())){var t=P.getCurr(),e=P.getNext();return P.skip(),function(t){return t===p||t===g||t===r.BACKSLASH}(e)?(P.skip(),b(u.TYPE_WORD,e),0):(b(u.TYPE_WORD,t),0)}return b(u.TYPE_WORD,P.grabWhile((function(t){return y(t)&&!L(t)}))),0}return b(u.TYPE_WORD,P.grabWhile(y)),0}return{tokenize:function(){for(f=0;P.hasNext();)switch(f){case 1:f=C();break;case 2:f=k();break;case 0:f=R();break;default:f=0}return l.length=s+1,l},isTokenNested:function(e){var n=p+r.SLASH+e.getValue();return t.indexOf(n)>-1}}},e.createTokenOfType=void 0;var n=function(t,e,r,n){return void 0===r&&(r=0),void 0===n&&(n=0),new u.Token(t,e,r,n)};e.createTokenOfType=n}));t(a);var s=e((function(t,e){e.__esModule=!0,e.default=e.parse=void 0;var r,u=(r=i)&&r.__esModule?r:{default:r};var s=function(t,e){void 0===e&&(e={});var r=e,i=null,s=(0,o.createList)(),f=(0,o.createList)(),c=(0,o.createList)(),l=(0,o.createList)(),p={},g=function(){c.flushLast()&&l.flushLast()},h=function(t){var e,i,u=(e=f.getLast())&&Array.isArray(e.content)?e.content:s.toArray();Array.isArray(u)&&((0,n.isTagNode)(t)?(i=t.tag,r.onlyAllowTags&&r.onlyAllowTags.length&&0>r.onlyAllowTags.indexOf(i)?u.push(""+t):u.push(t.toTagNode())):u.push(t))},T=function(t){g();var e=u.default.create(t.getValue()),r=function(t){return void 0===p[t.getValue()]&&(p[t.getValue()]=i.isTokenNested(t)),p[t.getValue()]}(t);c.push(e),r?f.push(e):h(e)},d=function(t){t.isStart()&&T(t),t.isEnd()&&function(t){g();var e=f.flushLast();if(e)h(e);else if("function"==typeof r.onError){var n=t.getValue(),i=t.getLine(),u=t.getColumn();r.onError({message:"Inconsistent tag '"+n+"' on line "+i+" and column "+u,tagName:n,lineNumber:i,columnNumber:u})}}(t)},A=function(t){var e=c.getLast(),r=t.getValue(),n=!!p[t];if(e)if(t.isAttrName())l.push(r),e.attr(l.getLast(),"");else if(t.isAttrValue()){var i=l.getLast();i?(e.attr(i,r),l.flushLast()):e.attr(r,r)}else t.isText()?n?e.append(r):h(r):t.isTag()&&h(""+t);else t.isText()?h(r):t.isTag()&&h(""+t)};(i=(e.createTokenizer?e.createTokenizer:a.createLexer)(t,{onToken:function(t){t.isTag()?d(t):A(t)},onlyAllowTags:r.onlyAllowTags,openTag:r.openTag,closeTag:r.closeTag,enableEscapeTags:r.enableEscapeTags})).tokenize();return s.toArray()};e.parse=s,e.default=s}));t(s);var f=e((function(t,e){e.__esModule=!0,e.TagNode=e.parse=e.default=void 0;var r=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=n();if(e&&e.has(t))return e.get(t);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in t)if(Object.prototype.hasOwnProperty.call(t,u)){var o=i?Object.getOwnPropertyDescriptor(t,u):null;o&&(o.get||o.set)?Object.defineProperty(r,u,o):r[u]=t[u]}r.default=t,e&&e.set(t,r);return r}(s);function n(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return n=function(){return t},t}e.default=r.default,e.parse=r.parse,e.TagNode=i.TagNode}));t(f);var c=f.parse,l=function(t){return"object"==typeof t};function p(t,e){var r=t;if(Array.isArray(r))for(var n=0;r.length>n;n++)r[n]=p(e(r[n]),e);else r&&l(r)&&r.content&&p(r.content,e);return r}function g(t,e){return typeof t==typeof e&&(l(t)&&null!==t?Array.isArray(t)?t.every((function(t){return[].some.call(e,(function(e){return g(t,e)}))})):Object.keys(t).every((function(r){var n=e[r],i=t[r];return l(i)&&null!==i&&null!==n?g(i,n):"boolean"==typeof i?i!==(null===n):n===i})):t===e)}function h(t,e){return p(this,Array.isArray(t)?function(r){for(var n=0;t.length>n;n++)if(g(t[n],r))return e(r);return r}:function(r){return g(t,r)?e(r):r})}function T(t){return p(this,t)}return function(t){var e="function"==typeof t?[t]:t||[],r={skipParse:!1};return{process:function(t,n){var i=(r=n||{}).parser||c,u=r.render,o=r.data||null;if("function"!=typeof i)throw Error('"parser" is not a function, please pass to "process(input, { parser })" right function');var a=r.skipParse?t||[]:i(t,r),s=a;return a.messages=[],a.options=r,a.walk=T,a.match=h,e.forEach((function(t){a=t(a,{parse:i,render:u,iterate:p,match:h,data:o})||a})),{get html(){if("function"!=typeof u)throw Error('"render" function not defined, please pass to "process(input, { render })"');return u(a,a.options)},tree:a,raw:s,messages:a.messages}}}}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).BbobCore=e()}(this,(function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=e((function(t,e){e.__esModule=!0,e.BACKSLASH=e.PLACEHOLDER_SPACE=e.PLACEHOLDER_SPACE_TAB=e.SLASH=e.CLOSE_BRAKET=e.OPEN_BRAKET=e.SPACE=e.QUOTEMARK=e.EQ=e.TAB=e.R=e.F=e.N=void 0;e.N="\n";e.TAB="\t";e.F="\f";e.R="\r";e.EQ="=";e.QUOTEMARK='"';e.SPACE=" ";e.OPEN_BRAKET="[";e.CLOSE_BRAKET="]";e.SLASH="/";e.BACKSLASH="\\";e.PLACEHOLDER_SPACE_TAB=" ";e.PLACEHOLDER_SPACE=" "}));t(n);var r=e((function(t,e){e.__esModule=!0,e.isEOL=e.isStringNode=e.isTagNode=e.getUniqAttr=e.getNodeLength=e.escapeHTML=e.appendToNode=e.attrValue=e.attrsToString=void 0;var r=function(t){return"object"==typeof t&&!!t.tag};e.isTagNode=r;var o=function(t){return"string"==typeof t};e.isStringNode=o;e.isEOL=function(t){return t===n.N};var i=function(t,e,n){return Object.keys(t).reduce(e,n)};e.getNodeLength=function t(e){return r(e)?e.content.reduce((function(e,n){return e+t(n)}),0):o(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var u=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript):/gi,"$1%3A")};e.escapeHTML=u;var a=function(t,e){var n=typeof e,r={boolean:function(){return e?""+t:""},number:function(){return t+'="'+e+'"'},string:function(){return t+'="'+u(e)+'"'},object:function(){return t+'="'+u(JSON.stringify(e))+'"'}};return r[n]?r[n]():""};e.attrValue=a;e.attrsToString=function(t){return null==t?"":i(t,(function(e,n){return[].concat(e,[a(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return i(t,(function(e,n){return t[n]===n?t[n]:null}),null)}}));t(r);var o=e((function(t,e){function o(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(){return(i=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}e.__esModule=!0,e.default=e.TagNode=void 0;var u=function(){function t(t,e,n){this.tag=t,this.attrs=e,this.content=Array.isArray(n)?n:[n]}var e,u,a,s=t.prototype;return s.attr=function(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]},s.append=function(t){return(0,r.appendToNode)(this,t)},s.toTagStart=function(t){var e=void 0===t?{}:t,o=e.openTag,u=e.closeTag,a=void 0===u?n.CLOSE_BRAKET:u;return""+(void 0===o?n.OPEN_BRAKET:o)+function(t,e){var n=(0,r.getUniqAttr)(e);if(n){var o=(0,r.attrValue)(t,n),u=i({},e);return delete u[n],""+o+(0,r.attrsToString)(u)}return""+t+(0,r.attrsToString)(e)}(this.tag,this.attrs)+a},s.toTagEnd=function(t){var e=void 0===t?{}:t,r=e.openTag,o=e.closeTag;return""+(void 0===r?n.OPEN_BRAKET:r)+n.SLASH+this.tag+(void 0===o?n.CLOSE_BRAKET:o)},s.toTagNode=function(){return new t(this.tag.toLowerCase(),this.attrs,this.content)},s.toString=function(t){var e=void 0===t?{}:t,r=e.openTag,o=void 0===r?n.OPEN_BRAKET:r,i=e.closeTag,u=void 0===i?n.CLOSE_BRAKET:i,a=0===this.content.length,s=this.content.reduce((function(t,e){return t+e.toString({openTag:o,closeTag:u})}),""),c=this.toTagStart({openTag:o,closeTag:u});return a?c:""+c+s+this.toTagEnd({openTag:o,closeTag:u})},e=t,(u=[{key:"length",get:function(){return(0,r.getNodeLength)(this)}}])&&o(e.prototype,u),a&&o(e,a),t}();e.TagNode=u,u.create=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=[]),new u(t,e,n)},u.isOf=function(t,e){return t.tag===e},e.default=u}));t(o);var i=e((function(t,e){e.__esModule=!0,e.default=e.Token=e.TYPE_NEW_LINE=e.TYPE_SPACE=e.TYPE_ATTR_VALUE=e.TYPE_ATTR_NAME=e.TYPE_TAG=e.TYPE_WORD=e.COLUMN_ID=e.LINE_ID=e.VALUE_ID=e.TYPE_ID=void 0;var r=function(t){return t&&void 0!==t.value?t.value:""},o=function(t){return r(t).charCodeAt(0)===n.SLASH.charCodeAt(0)},i=function(){function t(t,e,n,r){this.type=Number(t),this.value=e+"",this.line=Number(n),this.row=Number(r)}var e=t.prototype;return e.isEmpty=function(){return isNaN(this.type)},e.isText=function(){return!(!(t=this)||void 0===t.type||5!==t.type&&6!==t.type&&1!==t.type);var t},e.isTag=function(){return!(!(t=this)||void 0===t.type)&&2===t.type;var t},e.isAttrName=function(){return!(!(t=this)||void 0===t.type)&&3===t.type;var t},e.isAttrValue=function(){return!(!(t=this)||void 0===t.type)&&4===t.type;var t},e.isStart=function(){return!o(this)},e.isEnd=function(){return o(this)},e.getName=function(){return e=r(t=this),o(t)?e.slice(1):e;var t,e},e.getValue=function(){return r(this)},e.getLine=function(){return(t=this)&&t.line||0;var t},e.getColumn=function(){return(t=this)&&t.row||0;var t},e.toString=function(){return t=n.OPEN_BRAKET,t+=r(this),t+=n.CLOSE_BRAKET;var t},t}();e.Token=i;e.TYPE_ID="type";e.VALUE_ID="value";e.LINE_ID="line";e.COLUMN_ID="row";e.TYPE_WORD=1;e.TYPE_TAG=2;e.TYPE_ATTR_NAME=3;e.TYPE_ATTR_VALUE=4;e.TYPE_SPACE=5;e.TYPE_NEW_LINE=6,e.default=i}));t(i);var u=e((function(t,e){function r(t,e){var n={pos:0,len:t.length},r=function(){return n.len>n.pos},o=function(t,r){void 0===t&&(t=1),n.pos+=t,e&&e.onSkip&&!r&&e.onSkip()},i=function(){return t[n.pos]};this.skip=o,this.hasNext=r,this.getCurr=i,this.getRest=function(){return t.substr(n.pos)},this.getNext=function(){var e=n.pos+1;return e>t.length-1?null:t[e]},this.getPrev=function(){var e=n.pos-1;return void 0!==t[e]?t[e]:null},this.isLast=function(){return n.pos===n.len},this.includes=function(e){return t.indexOf(e,n.pos)>=0},this.grabWhile=function(e,u){var a=0;if(r())for(a=n.pos;r()&&e(i());)o(1,u);return t.substr(a,n.pos-a)},this.substrUntilChar=function(e){var r=n.pos,o=t.indexOf(e,r);return 0>o?"":t.substr(r,o-r)}}e.__esModule=!0,e.createList=e.unquote=e.trimChar=e.createCharGrabber=void 0;e.createCharGrabber=function(t,e){return new r(t,e)};e.trimChar=function(t,e){for(;t.charAt(0)===e;)t=t.substring(1);for(;t.charAt(t.length-1)===e;)t=t.substring(0,t.length-1);return t};function o(t){void 0===t&&(t=[]);var e=t;this.push=function(t){return e.push(t)},this.toArray=function(){return e},this.getLast=function(){return Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null},this.flushLast=function(){return!!e.length&&e.pop()}}e.unquote=function(t){return t.replace(n.BACKSLASH+n.QUOTEMARK,n.QUOTEMARK)};e.createList=function(t){return void 0===t&&(t=[]),new o(t)}}));t(u);var a=e((function(t,e){e.__esModule=!0,e.createLexer=function(t,e){void 0===e&&(e={});var o=0,a=0,s=-1,c=0,f=0,l=Array(Math.floor(t.length)),g=e.openTag||n.OPEN_BRAKET,p=e.closeTag||n.CLOSE_BRAKET,T=!!e.enableEscapeTags,d=e.onToken||function(){},h=[p,g,n.QUOTEMARK,n.BACKSLASH,n.SPACE,n.TAB,n.EQ,n.N,"!"],E=[g,n.SPACE,n.TAB,n.N],v=[n.SPACE,n.TAB],A=[n.EQ,n.SPACE,n.TAB],_=function(t){return v.indexOf(t)>=0},y=function(t){return-1===E.indexOf(t)},L=function(t){return t===n.BACKSLASH},O=function(){a++},S=function(t){return(0,u.unquote)((0,u.trimChar)(t,n.QUOTEMARK))},N=(0,u.createCharGrabber)(t,{onSkip:O});function P(t,e){var n=r(t,e,o,a);d(n),l[s+=1]=n}function b(t,e){if(1===f){var r=t.grabWhile((function(t){return!(t===n.EQ||_(t))})),o=t.isLast(),u=t.getCurr()!==n.EQ;return t.skip(),o||u?P(i.TYPE_ATTR_VALUE,S(r)):P(i.TYPE_ATTR_NAME,r),o?0:u?1:2}if(2===f){var a=!1,s=t.grabWhile((function(r){var o=r===n.QUOTEMARK,i=t.getPrev(),u=t.getNext(),s=i===n.BACKSLASH,c=u===n.EQ,f=_(r),l=_(u);return!(!a||!function(t){return A.indexOf(t)>=0}(r))||!!(!o||s||(a=!a)||c||l)&&(!!e||!1===f)}));return t.skip(),P(i.TYPE_ATTR_VALUE,S(s)),t.isLast()?0:1}var c=t.grabWhile((function(e){return!(e===n.EQ||_(e)||t.isLast())}));return P(i.TYPE_TAG,c),t.skip(),e?2:t.includes(n.EQ)?1:2}function C(){var t=N.getCurr();if(t===g){var e=N.getNext();N.skip();var r=N.substrUntilChar(p),o=0===r.length||r.indexOf(g)>=0;if(h.indexOf(e)>=0||o||N.isLast())return P(i.TYPE_WORD,t),0;if(-1===r.indexOf(n.EQ)||r[0]===n.SLASH){var u=N.grabWhile((function(t){return t!==p}));return N.skip(),P(i.TYPE_TAG,u),0}return 2}return 0}function R(){var t=N.grabWhile((function(t){return t!==p}),!0),e=(0,u.createCharGrabber)(t,{onSkip:O}),r=e.includes(n.SPACE);for(f=0;e.hasNext();)f=b(e,!r);return N.skip(),0}function k(){if(N.getCurr()===n.N)return P(i.TYPE_NEW_LINE,N.getCurr()),N.skip(),a=0,o++,0;if(_(N.getCurr()))return P(i.TYPE_SPACE,N.grabWhile(_)),0;if(N.getCurr()===g)return N.includes(p)?1:(P(i.TYPE_WORD,N.getCurr()),N.skip(),0);if(T){if(L(N.getCurr())){var t=N.getCurr(),e=N.getNext();return N.skip(),function(t){return t===g||t===p||t===n.BACKSLASH}(e)?(N.skip(),P(i.TYPE_WORD,e),0):(P(i.TYPE_WORD,t),0)}return P(i.TYPE_WORD,N.grabWhile((function(t){return y(t)&&!L(t)}))),0}return P(i.TYPE_WORD,N.grabWhile(y)),0}return{tokenize:function(){for(c=0;N.hasNext();)switch(c){case 1:c=C();break;case 2:c=R();break;case 0:c=k();break;default:c=0}return l.length=s+1,l},isTokenNested:function(e){var r=g+n.SLASH+e.getValue();return t.indexOf(r)>-1}}},e.createTokenOfType=void 0;var r=function(t,e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),new i.Token(t,e,n,r)};e.createTokenOfType=r}));t(a);var s=e((function(t,e){e.__esModule=!0,e.default=e.parse=void 0;var i,s=(i=o)&&i.__esModule?i:{default:i};var c=function(t,e){void 0===e&&(e={});var o=e,i=o.openTag||n.OPEN_BRAKET,c=o.closeTag||n.CLOSE_BRAKET,f=null,l=(0,u.createList)(),g=(0,u.createList)(),p=(0,u.createList)(),T=(0,u.createList)(),d=new Set,h=function(){p.flushLast()&&T.flushLast()},E=function(t){var e,n,u=(e=g.getLast())&&Array.isArray(e.content)?e.content:l.toArray();Array.isArray(u)&&((0,r.isTagNode)(t)?(n=t.tag,o.onlyAllowTags&&o.onlyAllowTags.length&&0>o.onlyAllowTags.indexOf(n)?(u.push(t.toTagStart({openTag:i,closeTag:c})),t.content.length&&(t.content.forEach((function(t){u.push(t)})),u.push(t.toTagEnd({openTag:i,closeTag:c})))):u.push(t.toTagNode())):u.push(t))},v=function(t){h();var e=s.default.create(t.getValue()),n=function(t){var e=t.getValue();return!d.has(e)&&f.isTokenNested&&f.isTokenNested(t)?(d.add(e),!0):d.has(e)}(t);p.push(e),n?g.push(e):E(e)},A=function(t){t.isStart()&&v(t),t.isEnd()&&function(t){h();var e=g.flushLast();if(e)E(e);else if("function"==typeof o.onError){var n=t.getValue(),r=t.getLine(),i=t.getColumn();o.onError({message:"Inconsistent tag '"+n+"' on line "+r+" and column "+i,tagName:n,lineNumber:r,columnNumber:i})}}(t)},_=function(t){var e=p.getLast(),n=t.getValue(),r=!!d.has(t);if(e)if(t.isAttrName())T.push(n),e.attr(T.getLast(),"");else if(t.isAttrValue()){var o=T.getLast();o?(e.attr(o,n),T.flushLast()):e.attr(n,n)}else t.isText()?r?e.append(n):E(n):t.isTag()&&E(""+t);else t.isText()?E(n):t.isTag()&&E(""+t)};(f=(e.createTokenizer?e.createTokenizer:a.createLexer)(t,{onToken:function(t){t.isTag()?A(t):_(t)},onlyAllowTags:o.onlyAllowTags,openTag:i,closeTag:c,enableEscapeTags:o.enableEscapeTags})).tokenize();return l.toArray()};e.parse=c,e.default=c}));t(s);var c=e((function(t,e){e.__esModule=!0,e.TagNode=e.parse=e.default=void 0;var n=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=r();if(e&&e.has(t))return e.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var u=o?Object.getOwnPropertyDescriptor(t,i):null;u&&(u.get||u.set)?Object.defineProperty(n,i,u):n[i]=t[i]}n.default=t,e&&e.set(t,n);return n}(s);function r(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return r=function(){return t},t}e.default=n.default,e.parse=n.parse,e.TagNode=o.TagNode}));t(c);var f=c.parse,l=function(t){return"object"==typeof t};function g(t,e){var n=t;if(Array.isArray(n))for(var r=0;n.length>r;r++)n[r]=g(e(n[r]),e);else n&&l(n)&&n.content&&g(n.content,e);return n}function p(t,e){return typeof t==typeof e&&(l(t)&&null!==t?Array.isArray(t)?t.every((function(t){return[].some.call(e,(function(e){return p(t,e)}))})):Object.keys(t).every((function(n){var r=e[n],o=t[n];return l(o)&&null!==o&&null!==r?p(o,r):"boolean"==typeof o?o!==(null===r):r===o})):t===e)}function T(t,e){return g(this,Array.isArray(t)?function(n){for(var r=0;t.length>r;r++)if(p(t[r],n))return e(n);return n}:function(n){return p(t,n)?e(n):n})}function d(t){return g(this,t)}return function(t){var e="function"==typeof t?[t]:t||[],n={skipParse:!1};return{process:function(t,r){var o=(n=r||{}).parser||f,i=n.render,u=n.data||null;if("function"!=typeof o)throw Error('"parser" is not a function, please pass to "process(input, { parser })" right function');var a=n.skipParse?t||[]:o(t,n),s=a;return a.messages=[],a.options=n,a.walk=d,a.match=T,e.forEach((function(t){a=t(a,{parse:o,render:i,iterate:g,match:T,data:u})||a})),{get html(){if("function"!=typeof i)throw Error('"render" function not defined, please pass to "process(input, { render })"');return i(a,a.options)},tree:a,raw:s,messages:a.messages}}}}}));
{
"name": "@bbob/core",
"version": "2.6.1",
"version": "2.6.2",
"description": "⚡️Blazing fast BBCode transforming and parsing tool in pure javascript, no dependencies ",

@@ -23,3 +23,3 @@ "keywords": [

"dependencies": {
"@bbob/parser": "^2.6.1"
"@bbob/parser": "^2.6.2"
},

@@ -72,3 +72,3 @@ "main": "lib/index.js",

],
"gitHead": "58e6fba8ac5ac8fe368cade48d439671f86e727d"
"gitHead": "689d5a84cc6b88e96fe74481bb82997d924799fd"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc