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

@bbob/core

Package Overview
Dependencies
Maintainers
0
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 0.0.0-alpha.a733494 to 0.0.0-alpha.cad4675

types/errors.d.ts

89

dist/index.js

@@ -137,2 +137,8 @@ (function (global, factory) {

}
setStart(value) {
this.start = value;
}
setEnd(value) {
this.end = value;
}
get length() {

@@ -142,3 +148,3 @@ return getNodeLength(this);

toTagStart({ openTag = OPEN_BRAKET, closeTag = CLOSE_BRAKET } = {}) {
const tagAttrs = getTagAttrs(this.tag, this.attrs);
const tagAttrs = getTagAttrs(String(this.tag), this.attrs);
return `${openTag}${tagAttrs}${closeTag}`;

@@ -150,3 +156,10 @@ }

toTagNode() {
return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);
const newNode = new TagNode(String(this.tag).toLowerCase(), this.attrs, this.content);
if (this.start) {
newNode.setStart(this.start);
}
if (this.end) {
newNode.setEnd(this.end);
}
return newNode;
}

@@ -167,4 +180,8 @@ toString({ openTag = OPEN_BRAKET, closeTag = CLOSE_BRAKET } = {}) {

}
static create(tag, attrs = {}, content = null) {
return new TagNode(tag, attrs, content);
static create(tag, attrs = {}, content = null, start) {
const node = new TagNode(tag, attrs, content);
if (start) {
node.setStart(start);
}
return node;
}

@@ -181,3 +198,3 @@ static isOf(node, type) {

// type, value, line, row,
// type, value, line, row, start pos, end pos
const TOKEN_TYPE_ID = 't'; // 0;

@@ -187,2 +204,4 @@ const TOKEN_VALUE_ID = 'v'; // 1;

const TOKEN_LINE_ID = 'l'; // 3;
const TOKEN_START_POS_ID = 's'; // 4;
const TOKEN_END_POS_ID = 'e'; // 5;
const TOKEN_TYPE_WORD = 1; // 'word';

@@ -202,2 +221,4 @@ const TOKEN_TYPE_TAG = 2; // 'tag';

const getTokenColumn = (token)=>token && token[TOKEN_COLUMN_ID] || 0;
const getStartPosition = (token)=>token && token[TOKEN_START_POS_ID] || 0;
const getEndPosition = (token)=>token && token[TOKEN_END_POS_ID] || 0;
const isTextToken = (token)=>{

@@ -279,6 +300,12 @@ if (token && typeof token[TOKEN_TYPE_ID] !== 'undefined') {

}
getStart() {
return getStartPosition(this);
}
getEnd() {
return getEndPosition(this);
}
toString() {
return tokenToText(this);
}
constructor(type, value, row = 0, col = 0){
constructor(type, value, row = 0, col = 0, start = 0, end = 0){
this[TOKEN_LINE_ID] = row;

@@ -288,2 +315,4 @@ this[TOKEN_COLUMN_ID] = col;

this[TOKEN_VALUE_ID] = String(value);
this[TOKEN_START_POS_ID] = start;
this[TOKEN_END_POS_ID] = end;
}

@@ -314,2 +343,8 @@ }

}
getPos() {
return this.c.pos;
}
getLength() {
return this.c.len;
}
getRest() {

@@ -388,4 +423,4 @@ return this.s.substring(this.c.pos);

const EM = '!';
function createTokenOfType(type, value, r = 0, cl = 0) {
return new Token(type, value, r, cl);
function createTokenOfType(type, value, r = 0, cl = 0, p = 0, e = 0) {
return new Token(type, value, r, cl, p, e);
}

@@ -407,2 +442,3 @@ const STATE_WORD = 0;

];
const END_POS_OFFSET = 2; // length + start position offset
const isWhiteSpace = (char)=>WHITESPACES.indexOf(char) >= 0;

@@ -415,2 +451,3 @@ const isEscapeChar = (char)=>char === BACKSLASH;

let row = 0;
let prevCol = 0;
let col = 0;

@@ -466,9 +503,10 @@ let tokenIndex = -1;

* @param {String} value
*/ function emitToken(type, value) {
const token = createTokenOfType(type, value, row, col);
*/ function emitToken(type, value, startPos, endPos) {
const token = createTokenOfType(type, value, row, prevCol, startPos, endPos);
onToken(token);
prevCol = col;
tokenIndex += 1;
tokens[tokenIndex] = token;
}
function nextTagState(tagChars, isSingleValueTag) {
function nextTagState(tagChars, isSingleValueTag, masterStartPos) {
if (tagMode === TAG_STATE_ATTR) {

@@ -523,2 +561,5 @@ const validAttrName = (char)=>!(char === EQ || isWhiteSpace(char));

emitToken(TYPE_ATTR_VALUE, unq(name));
if (tagChars.getPrev() === QUOTEMARK) {
prevCol++;
}
if (tagChars.isLast()) {

@@ -529,7 +570,9 @@ return TAG_STATE_NAME;

}
const start = masterStartPos + tagChars.getPos() - 1;
const validName = (char)=>!(char === EQ || isWhiteSpace(char) || tagChars.isLast());
const name = tagChars.grabWhile(validName);
emitToken(TYPE_TAG, name);
emitToken(TYPE_TAG, name, start, masterStartPos + tagChars.getLength() + 1);
checkContextFreeMode(name);
tagChars.skip();
prevCol++;
// in cases when we has [url=someval]GET[/url] and we dont need to parse all

@@ -558,5 +601,7 @@ if (isSingleValueTag) {

if (isNoAttrsInTag || isClosingTag) {
const startPos = chars.getPos() - 1;
const name = chars.grabWhile((char)=>char !== closeTag);
const endPos = startPos + name.length + END_POS_OFFSET;
chars.skip(); // skip closeTag
emitToken(TYPE_TAG, name);
emitToken(TYPE_TAG, name, startPos, endPos);
checkContextFreeMode(name, isClosingTag);

@@ -568,2 +613,3 @@ return STATE_WORD;

function stateAttrs() {
const startPos = chars.getPos();
const silent = true;

@@ -577,3 +623,3 @@ const tagStr = chars.grabWhile((char)=>char !== closeTag, silent);

while(tagGrabber.hasNext()){
tagMode = nextTagState(tagGrabber, !hasSpace);
tagMode = nextTagState(tagGrabber, !hasSpace, startPos);
}

@@ -588,2 +634,3 @@ chars.skip(); // skip closeTag

col = 0;
prevCol = 0;
row++;

@@ -611,2 +658,3 @@ return STATE_WORD;

chars.skip();
prevCol++;
return STATE_WORD;

@@ -697,2 +745,3 @@ }

const onlyAllowTags = (options.onlyAllowTags || []).filter(Boolean).map((tag)=>tag.toLowerCase());
options.caseFreeTags || false;
let tokenizer = null;

@@ -801,3 +850,6 @@ /**

flushTagNodes();
const tagNode = TagNode.create(token.getValue(), {}, []);
const tagNode = TagNode.create(token.getValue(), {}, [], {
from: token.getStart(),
to: token.getEnd()
});
const isNested = isTokenNested(token);

@@ -816,2 +868,9 @@ tagNodes.push(tagNode);

*/ function handleTagEnd(token) {
const lastTagNode = nestedNodes.last();
if (isTagNode(lastTagNode)) {
lastTagNode.setEnd({
from: token.getStart(),
to: token.getEnd()
});
}
flushTagNodes();

@@ -818,0 +877,0 @@ const lastNestedNode = nestedNodes.flush();

2

dist/index.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BbobCore={})}(this,function(t){"use strict";function e(t){return"object"==typeof t&&null!==t&&"tag"in t}function r(t,e,r){return Object.keys(t).reduce((r,n)=>e(r,n,t),r)}function n(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript|data|vbscript):/gi,"$1%3A")}function s(t,e){switch(typeof e){case"boolean":return e?""+t:"";case"number":return`${t}="${e}"`;case"string":return`${t}="${n(e)}"`;case"object":return`${t}="${n(JSON.stringify(e))}"`;default:return""}}function i(t){return null==t?"":r(t,(t,e,r)=>[...t,s(e,r[e])],[""]).join(" ")}let o=(t,e)=>{let n=r(e||{},(t,e,r)=>r[e]===e?r[e]:null,null);if(n){let r=s(t,n),o={...e};delete o[n+""];let u=i(o);return`${r}${u}`}return`${t}${i(e)}`},u=(t,r,n)=>{let s=t=>e(t)?t.toString({openTag:r,closeTag:n}):t+"";return Array.isArray(t)?t.reduce((t,e)=>null!==e?t+s(e):t,""):t?s(t):null};class l{attr(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]}append(t){Array.isArray(this.content)&&this.content.push(t)}get length(){return function t(r){return e(r)&&Array.isArray(r.content)?r.content.reduce((e,r)=>e+t(r),0):"string"==typeof r?(r+"").length:0}(this)}toTagStart({openTag:t="[",closeTag:e="]"}={}){let r=o(this.tag,this.attrs);return`${t}${r}${e}`}toTagEnd({openTag:t="[",closeTag:e="]"}={}){return`${t}/${this.tag}${e}`}toTagNode(){return new l(this.tag.toLowerCase(),this.attrs,this.content)}toString({openTag:t="[",closeTag:e="]"}={}){let r=this.content?u(this.content,t,e):"",n=this.toTagStart({openTag:t,closeTag:e});return null===this.content||Array.isArray(this.content)&&0===this.content.length?n:`${n}${r}${this.toTagEnd({openTag:t,closeTag:e})}`}static create(t,e={},r=null){return new l(t,e,r)}static isOf(t,e){return t.tag===e}constructor(t,e,r){this.tag=t,this.attrs=e,this.content=r}}let a=t=>t&&void 0!==t.v?t.v:"",h=t=>t&&t.l||0,c=t=>t&&t.r||0,g=t=>!!t&&void 0!==t.t&&(5===t.t||6===t.t||1===t.t),f=t=>!!t&&void 0!==t.t&&2===t.t,p=t=>47===a(t).charCodeAt(0),d=t=>!p(t),y=t=>!!t&&void 0!==t.t&&3===t.t,b=t=>!!t&&void 0!==t.t&&4===t.t,A=t=>{let e=a(t);return p(t)?e.slice(1):e},T=t=>"["+a(t)+"]";class k{get type(){return this.t}isEmpty(){return 0===this.t||isNaN(this.t)}isText(){return g(this)}isTag(){return f(this)}isAttrName(){return y(this)}isAttrValue(){return b(this)}isStart(){return d(this)}isEnd(){return p(this)}getName(){return A(this)}getValue(){return a(this)}getLine(){return h(this)}getColumn(){return c(this)}toString(){return T(this)}constructor(t,e,r=0,n=0){this.l=r,this.r=n,this.t=t||0,this.v=e+""}}class x{skip(t=1,e){this.c.pos+=t,this.o&&this.o.onSkip&&!e&&this.o.onSkip()}hasNext(){return this.c.len>this.c.pos}getCurr(){return void 0===this.s[this.c.pos]?"":this.s[this.c.pos]}getRest(){return this.s.substring(this.c.pos)}getNext(){let t=this.c.pos+1;return t<=this.s.length-1?this.s[t]:null}getPrev(){let t=this.c.pos-1;return void 0===this.s[t]?null:this.s[t]}isLast(){return this.c.pos===this.c.len}includes(t){return this.s.indexOf(t,this.c.pos)>=0}grabWhile(t,e){let r=0;if(this.hasNext())for(r=this.c.pos;this.hasNext()&&t(this.getCurr());)this.skip(1,e);return this.s.substring(r,this.c.pos)}grabN(t=0){return this.s.substring(this.c.pos,this.c.pos+t)}substrUntilChar(t){let{pos:e}=this.c,r=this.s.indexOf(t,e);return r>=0?this.s.substring(e,r):""}constructor(t,e={}){this.s=t,this.c={pos:0,len:t.length},this.o=e}}let v=(t,e)=>new x(t,e),C=(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},m=t=>t.replace('\\"','"'),N=[" "," "],$=["="," "," "],w=t=>N.indexOf(t)>=0,O=t=>"\\"===t,S=t=>$.indexOf(t)>=0,E=t=>"\n"===t,L=t=>m(C(t,'"'));class j{last(){return Array.isArray(this.n)&&this.n.length>0&&void 0!==this.n[this.n.length-1]?this.n[this.n.length-1]:null}flush(){return!!this.n.length&&this.n.pop()}push(t){this.n.push(t)}toArray(){return this.n}constructor(){this.n=[]}}let W=()=>new j;function V(t,r={}){var n;let s=r.openTag||"[",i=r.closeTag||"]",o=(r.onlyAllowTags||[]).filter(Boolean).map(t=>t.toLowerCase()),u=null,a=W(),h=W(),c=W(),g=W(),f=new Set;function p(){c.flush()&&g.flush()}function d(){let t=h.last();return t&&e(t)?t.content:a.toArray()}function y(t,e,r=!0){Array.isArray(t)&&void 0!==e&&(t.push(e.toTagStart({openTag:s,closeTag:i})),Array.isArray(e.content)&&e.content.length&&(e.content.forEach(e=>{t.push(e)}),r&&t.push(e.toTagEnd({openTag:s,closeTag:i}))))}function b(t,r){if(Array.isArray(t)&&void 0!==r){if(e(r)){var n;(n=r.tag,!o.length||o.indexOf(n.toLowerCase())>=0)?t.push(r.toTagNode()):y(t,r)}else t.push(r)}}(u=(r.createTokenizer?r.createTokenizer:function(t,e={}){let r=0,n=0,s=-1,i=0,o=0,u="",l=Array(Math.floor(t.length)),a=e.openTag||"[",h=e.closeTag||"]",c=!!e.enableEscapeTags,g=(e.contextFreeTags||[]).filter(Boolean).map(t=>t.toLowerCase()),f=new Map,p=e.onToken||(()=>{}),d=[h,a,'"',"\\"," "," ","=","\n","!"],y=[a," "," ","\n"],b=t=>d.indexOf(t)>=0,A=t=>-1===y.indexOf(t),T=t=>t===a||t===h||"\\"===t,x=()=>{n++},C=(t,e)=>{""!==u&&e&&(u=""),""===u&&g.includes(t.toLowerCase())&&(u=t)},m=v(t,{onSkip:x});function N(t,e){let i=function(t,e,r=0,n=0){return new k(t,e,r,n)}(t,e,r,n);p(i),l[s+=1]=i}return{tokenize:function(){for(i=0;m.hasNext();)switch(i){case 1:i=function(){let t=m.getCurr(),e=m.getNext();m.skip();let r=m.substrUntilChar(h),n=0===r.length||r.indexOf(a)>=0;if(e&&b(e)||n||m.isLast())return N(1,t),0;let s=-1===r.indexOf("="),i="/"===r[0];if(s||i){let t=m.grabWhile(t=>t!==h);return m.skip(),N(2,t),C(t,i),0}return 2}();break;case 2:i=function(){let t=v(m.grabWhile(t=>t!==h,!0),{onSkip:x}),e=t.includes(" ");for(o=0;t.hasNext();)o=function(t,e){if(1===o){let e=t.grabWhile(t=>!("="===t||w(t))),r=t.isLast(),n="="!==t.getCurr();return(t.skip(),r||n?N(4,L(e)):N(3,e),r)?0:n?1:2}if(2===o){let r=!1,n=t.grabWhile(n=>{let s='"'===n,i=t.getPrev(),o=t.getNext(),u="="===o,l=w(n),a=o&&w(o);return!!(r&&S(n))||(!s||"\\"===i||!!(r=!r)||!!u||!!a)&&(!!e||!l)});return(t.skip(),N(4,L(n)),t.isLast())?0:1}let r=t.grabWhile(e=>!("="===e||w(e)||t.isLast()));return(N(2,r),C(r),t.skip(),e)?2:t.includes("=")?1:2}(t,!e);return m.skip(),0}();break;default:i=function(){if(E(m.getCurr()))return N(6,m.getCurr()),m.skip(),n=0,r++,0;if(w(m.getCurr()))return N(5,m.grabWhile(w)),0;if(m.getCurr()===a){if(u){let t=a.length+1+u.length,e=`${a}/${u}`;if(m.grabN(t)===e)return 1}else if(m.includes(h))return 1;return N(1,m.getCurr()),m.skip(),0}if(c){if(O(m.getCurr())){let t=m.getCurr(),e=m.getNext();return(m.skip(),e&&T(e))?(m.skip(),N(1,e)):N(1,t),0}return N(1,m.grabWhile(t=>A(t)&&!O(t))),0}return N(1,m.grabWhile(A)),0}()}return l.length=s+1,l},isTokenNested:function(e){let r=a+"/"+e.getValue();if(f.has(r))return!!f.get(r);{let e=t.indexOf(r)>-1;return f.set(r,e),e}}}})(t,{onToken:function(t){t.isTag()?(t.isStart()&&function(t){p();let e=l.create(t.getValue(),{},[]),r=function(t){let e=t.getValue(),{isTokenNested:r}=u||{};return!f.has(e)&&r&&r(t)?(f.add(e),!0):f.has(e)}(t);c.push(e),r?h.push(e):b(d(),e)}(t),t.isEnd()&&function(t){p();let e=h.flush();if(e)b(d(),e);else if("function"==typeof r.onError){let e=t.getValue(),n=t.getLine(),s=t.getColumn();r.onError({tagName:e,lineNumber:n,columnNumber:s})}}(t)):!function(t){var e;let r=c.last(),n=t.getValue(),s=(e=t.toString(),!!f.has(e)),i=d();if(null!==r){if(t.isAttrName()){g.push(n);let t=g.last();t&&r.attr(t,"")}else if(t.isAttrValue()){let t=g.last();t?(r.attr(t,n),g.flush()):r.attr(n,n)}else t.isText()?s?r.append(n):b(i,n):t.isTag()&&b(i,t.toString())}else t.isText()?b(i,n):t.isTag()&&b(i,t.toString())}(t)},openTag:s,closeTag:i,onlyAllowTags:r.onlyAllowTags,contextFreeTags:r.contextFreeTags,enableEscapeTags:r.enableEscapeTags})).tokenize();let A=h.flush();return null!==A&&A&&e(A)&&(n=A.tag,f.has(n))&&y(d(),A,!1),a.toArray()}let P=t=>"object"==typeof t&&null!==t,z=t=>"boolean"==typeof t;function B(t,e){if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=B(e(t[r]),e);else P(t)&&"content"in t&&B(t.content,e);return t}function F(t,e){return typeof t==typeof e&&(P(t)&&null!==t?Array.isArray(t)?t.every(t=>[].some.call(e,e=>F(t,e))):!!(P(t)&&P(e))&&Object.keys(t).every(r=>{let n=e[r],s=t[r];return P(s)&&P(n)?F(s,n):z(s)?s!==(null===n):n===s}):t===e)}function M(t,e){return t.messages=[...t.messages||[]],t.options={...e,...t.options},t.walk=function(t){return B(this,t)},t.match=function(t,e){return Array.isArray(t)?B(this,r=>{for(let n=0;n<t.length;n++)if(F(t[n],r))return e(r);return r}):B(this,r=>F(t,r)?e(r):r)},t}t.createTree=M,t.default=function(t){let e="function"==typeof t?[t]:t||[],r=()=>"";return{process(t,n){let s=n||{skipParse:!1,parser:V,render:r,data:null},i=s.parser||V,o=s.render,u=s.data||null;if("function"!=typeof i)throw Error("C1");let l=s.skipParse&&Array.isArray(t)?t:i(t,s),a=s.skipParse&&Array.isArray(t)?M(t||[],s):M(l,s);for(let t=0;t<e.length;t++){let r=e[t];"function"==typeof r&&o&&(a=M(r(a,{parse:i,render:o,iterate:B,data:u})||a,s))}return{get html(){if("function"!=typeof o)throw Error("C2");return o(a,a.options)},tree:a,raw:l,messages:a.messages}}}},Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BbobCore={})}(this,function(t){"use strict";function e(t){return"object"==typeof t&&null!==t&&"tag"in t}function r(t,e,r){return Object.keys(t).reduce((r,n)=>e(r,n,t),r)}function n(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript|data|vbscript):/gi,"$1%3A")}function s(t,e){switch(typeof e){case"boolean":return e?""+t:"";case"number":return`${t}="${e}"`;case"string":return`${t}="${n(e)}"`;case"object":return`${t}="${n(JSON.stringify(e))}"`;default:return""}}function i(t){return null==t?"":r(t,(t,e,r)=>[...t,s(e,r[e])],[""]).join(" ")}let o=(t,e)=>{let n=r(e||{},(t,e,r)=>r[e]===e?r[e]:null,null);if(n){let r=s(t,n),o={...e};delete o[n+""];let a=i(o);return`${r}${a}`}return`${t}${i(e)}`},a=(t,r,n)=>{let s=t=>e(t)?t.toString({openTag:r,closeTag:n}):t+"";return Array.isArray(t)?t.reduce((t,e)=>null!==e?t+s(e):t,""):t?s(t):null};class u{attr(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]}append(t){Array.isArray(this.content)&&this.content.push(t)}setStart(t){this.start=t}setEnd(t){this.end=t}get length(){return function t(r){return e(r)&&Array.isArray(r.content)?r.content.reduce((e,r)=>e+t(r),0):"string"==typeof r?(r+"").length:0}(this)}toTagStart({openTag:t="[",closeTag:e="]"}={}){let r=o(this.tag+"",this.attrs);return`${t}${r}${e}`}toTagEnd({openTag:t="[",closeTag:e="]"}={}){return`${t}/${this.tag}${e}`}toTagNode(){let t=new u((this.tag+"").toLowerCase(),this.attrs,this.content);return this.start&&t.setStart(this.start),this.end&&t.setEnd(this.end),t}toString({openTag:t="[",closeTag:e="]"}={}){let r=this.content?a(this.content,t,e):"",n=this.toTagStart({openTag:t,closeTag:e});return null===this.content||Array.isArray(this.content)&&0===this.content.length?n:`${n}${r}${this.toTagEnd({openTag:t,closeTag:e})}`}static create(t,e={},r=null,n){let s=new u(t,e,r);return n&&s.setStart(n),s}static isOf(t,e){return t.tag===e}constructor(t,e,r){this.tag=t,this.attrs=e,this.content=r}}let l=t=>t&&void 0!==t.v?t.v:"",h=t=>t&&t.l||0,c=t=>t&&t.r||0,g=t=>t&&t.s||0,f=t=>t&&t.e||0,p=t=>!!t&&void 0!==t.t&&(5===t.t||6===t.t||1===t.t),d=t=>!!t&&void 0!==t.t&&2===t.t,y=t=>47===l(t).charCodeAt(0),b=t=>!y(t),A=t=>!!t&&void 0!==t.t&&3===t.t,T=t=>!!t&&void 0!==t.t&&4===t.t,k=t=>{let e=l(t);return y(t)?e.slice(1):e},x=t=>"["+l(t)+"]";class m{get type(){return this.t}isEmpty(){return 0===this.t||isNaN(this.t)}isText(){return p(this)}isTag(){return d(this)}isAttrName(){return A(this)}isAttrValue(){return T(this)}isStart(){return b(this)}isEnd(){return y(this)}getName(){return k(this)}getValue(){return l(this)}getLine(){return h(this)}getColumn(){return c(this)}getStart(){return g(this)}getEnd(){return f(this)}toString(){return x(this)}constructor(t,e,r=0,n=0,s=0,i=0){this.l=r,this.r=n,this.t=t||0,this.v=e+"",this.s=s,this.e=i}}class v{skip(t=1,e){this.c.pos+=t,this.o&&this.o.onSkip&&!e&&this.o.onSkip()}hasNext(){return this.c.len>this.c.pos}getCurr(){return void 0===this.s[this.c.pos]?"":this.s[this.c.pos]}getPos(){return this.c.pos}getLength(){return this.c.len}getRest(){return this.s.substring(this.c.pos)}getNext(){let t=this.c.pos+1;return t<=this.s.length-1?this.s[t]:null}getPrev(){let t=this.c.pos-1;return void 0===this.s[t]?null:this.s[t]}isLast(){return this.c.pos===this.c.len}includes(t){return this.s.indexOf(t,this.c.pos)>=0}grabWhile(t,e){let r=0;if(this.hasNext())for(r=this.c.pos;this.hasNext()&&t(this.getCurr());)this.skip(1,e);return this.s.substring(r,this.c.pos)}grabN(t=0){return this.s.substring(this.c.pos,this.c.pos+t)}substrUntilChar(t){let{pos:e}=this.c,r=this.s.indexOf(t,e);return r>=0?this.s.substring(e,r):""}constructor(t,e={}){this.s=t,this.c={pos:0,len:t.length},this.o=e}}let C=(t,e)=>new v(t,e),N=(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},$=t=>t.replace('\\"','"'),S=[" "," "],w=["="," "," "],E=t=>S.indexOf(t)>=0,O=t=>"\\"===t,L=t=>w.indexOf(t)>=0,P=t=>"\n"===t,j=t=>$(N(t,'"'));class W{last(){return Array.isArray(this.n)&&this.n.length>0&&void 0!==this.n[this.n.length-1]?this.n[this.n.length-1]:null}flush(){return!!this.n.length&&this.n.pop()}push(t){this.n.push(t)}toArray(){return this.n}constructor(){this.n=[]}}let V=()=>new W;function z(t,r={}){var n;let s=r.openTag||"[",i=r.closeTag||"]",o=(r.onlyAllowTags||[]).filter(Boolean).map(t=>t.toLowerCase());r.caseFreeTags;let a=null,l=V(),h=V(),c=V(),g=V(),f=new Set;function p(){c.flush()&&g.flush()}function d(){let t=h.last();return t&&e(t)?t.content:l.toArray()}function y(t,e,r=!0){Array.isArray(t)&&void 0!==e&&(t.push(e.toTagStart({openTag:s,closeTag:i})),Array.isArray(e.content)&&e.content.length&&(e.content.forEach(e=>{t.push(e)}),r&&t.push(e.toTagEnd({openTag:s,closeTag:i}))))}function b(t,r){if(Array.isArray(t)&&void 0!==r){if(e(r)){var n;(n=r.tag,!o.length||o.indexOf(n.toLowerCase())>=0)?t.push(r.toTagNode()):y(t,r)}else t.push(r)}}(a=(r.createTokenizer?r.createTokenizer:function(t,e={}){let r=0,n=0,s=0,i=-1,o=0,a=0,u="",l=Array(Math.floor(t.length)),h=e.openTag||"[",c=e.closeTag||"]",g=!!e.enableEscapeTags,f=(e.contextFreeTags||[]).filter(Boolean).map(t=>t.toLowerCase()),p=new Map,d=e.onToken||(()=>{}),y=[c,h,'"',"\\"," "," ","=","\n","!"],b=[h," "," ","\n"],A=t=>y.indexOf(t)>=0,T=t=>-1===b.indexOf(t),k=t=>t===h||t===c||"\\"===t,x=()=>{s++},v=(t,e)=>{""!==u&&e&&(u=""),""===u&&f.includes(t.toLowerCase())&&(u=t)},N=C(t,{onSkip:x});function $(t,e,o,a){let u=function(t,e,r=0,n=0,s=0,i=0){return new m(t,e,r,n,s,i)}(t,e,r,n,o,a);d(u),n=s,l[i+=1]=u}return{tokenize:function(){for(o=0;N.hasNext();)switch(o){case 1:o=function(){let t=N.getCurr(),e=N.getNext();N.skip();let r=N.substrUntilChar(c),n=0===r.length||r.indexOf(h)>=0;if(e&&A(e)||n||N.isLast())return $(1,t),0;let s=-1===r.indexOf("="),i="/"===r[0];if(s||i){let t=N.getPos()-1,e=N.grabWhile(t=>t!==c),r=t+e.length+2;return N.skip(),$(2,e,t,r),v(e,i),0}return 2}();break;case 2:o=function(){let t=N.getPos(),e=C(N.grabWhile(t=>t!==c,!0),{onSkip:x}),r=e.includes(" ");for(a=0;e.hasNext();)a=function(t,e,r){if(1===a){let e=t.grabWhile(t=>!("="===t||E(t))),r=t.isLast(),n="="!==t.getCurr();return(t.skip(),r||n?$(4,j(e)):$(3,e),r)?0:n?1:2}if(2===a){let r=!1,s=t.grabWhile(n=>{let s='"'===n,i=t.getPrev(),o=t.getNext(),a="="===o,u=E(n),l=o&&E(o);return!!(r&&L(n))||(!s||"\\"===i||!!(r=!r)||!!a||!!l)&&(!!e||!u)});return(t.skip(),$(4,j(s)),'"'===t.getPrev()&&n++,t.isLast())?0:1}let s=r+t.getPos()-1,i=t.grabWhile(e=>!("="===e||E(e)||t.isLast()));return($(2,i,s,r+t.getLength()+1),v(i),t.skip(),n++,e)?2:t.includes("=")?1:2}(e,!r,t);return N.skip(),0}();break;default:o=function(){if(P(N.getCurr()))return $(6,N.getCurr()),N.skip(),s=0,n=0,r++,0;if(E(N.getCurr()))return $(5,N.grabWhile(E)),0;if(N.getCurr()===h){if(u){let t=h.length+1+u.length,e=`${h}/${u}`;if(N.grabN(t)===e)return 1}else if(N.includes(c))return 1;return $(1,N.getCurr()),N.skip(),n++,0}if(g){if(O(N.getCurr())){let t=N.getCurr(),e=N.getNext();return(N.skip(),e&&k(e))?(N.skip(),$(1,e)):$(1,t),0}return $(1,N.grabWhile(t=>T(t)&&!O(t))),0}return $(1,N.grabWhile(T)),0}()}return l.length=i+1,l},isTokenNested:function(e){let r=h+"/"+e.getValue();if(p.has(r))return!!p.get(r);{let e=t.indexOf(r)>-1;return p.set(r,e),e}}}})(t,{onToken:function(t){t.isTag()?(t.isStart()&&function(t){p();let e=u.create(t.getValue(),{},[],{from:t.getStart(),to:t.getEnd()}),r=function(t){let e=t.getValue(),{isTokenNested:r}=a||{};return!f.has(e)&&r&&r(t)?(f.add(e),!0):f.has(e)}(t);c.push(e),r?h.push(e):b(d(),e)}(t),t.isEnd()&&function(t){let n=h.last();e(n)&&n.setEnd({from:t.getStart(),to:t.getEnd()}),p();let s=h.flush();if(s)b(d(),s);else if("function"==typeof r.onError){let e=t.getValue(),n=t.getLine(),s=t.getColumn();r.onError({tagName:e,lineNumber:n,columnNumber:s})}}(t)):!function(t){var e;let r=c.last(),n=t.getValue(),s=(e=t.toString(),!!f.has(e)),i=d();if(null!==r){if(t.isAttrName()){g.push(n);let t=g.last();t&&r.attr(t,"")}else if(t.isAttrValue()){let t=g.last();t?(r.attr(t,n),g.flush()):r.attr(n,n)}else t.isText()?s?r.append(n):b(i,n):t.isTag()&&b(i,t.toString())}else t.isText()?b(i,n):t.isTag()&&b(i,t.toString())}(t)},openTag:s,closeTag:i,onlyAllowTags:r.onlyAllowTags,contextFreeTags:r.contextFreeTags,enableEscapeTags:r.enableEscapeTags})).tokenize();let A=h.flush();return null!==A&&A&&e(A)&&(n=A.tag,f.has(n))&&y(d(),A,!1),l.toArray()}let F=t=>"object"==typeof t&&null!==t,B=t=>"boolean"==typeof t;function M(t,e){if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=M(e(t[r]),e);else F(t)&&"content"in t&&M(t.content,e);return t}function U(t,e){return typeof t==typeof e&&(F(t)&&null!==t?Array.isArray(t)?t.every(t=>[].some.call(e,e=>U(t,e))):!!(F(t)&&F(e))&&Object.keys(t).every(r=>{let n=e[r],s=t[r];return F(s)&&F(n)?U(s,n):B(s)?s!==(null===n):n===s}):t===e)}function _(t,e){return t.messages=[...t.messages||[]],t.options={...e,...t.options},t.walk=function(t){return M(this,t)},t.match=function(t,e){return Array.isArray(t)?M(this,r=>{for(let n=0;n<t.length;n++)if(U(t[n],r))return e(r);return r}):M(this,r=>U(t,r)?e(r):r)},t}t.createTree=_,t.default=function(t){let e="function"==typeof t?[t]:t||[],r=()=>"";return{process(t,n){let s=n||{skipParse:!1,parser:z,render:r,data:null},i=s.parser||z,o=s.render,a=s.data||null;if("function"!=typeof i)throw Error("C1");let u=s.skipParse&&Array.isArray(t)?t:i(t,s),l=s.skipParse&&Array.isArray(t)?_(t||[],s):_(u,s);for(let t=0;t<e.length;t++){let r=e[t];"function"==typeof r&&o&&(l=_(r(l,{parse:i,render:o,iterate:M,data:a})||l,s))}return{get html(){if("function"!=typeof o)throw Error("C2");return o(l,l.options)},tree:l,raw:u,messages:l.messages}}}},Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "@bbob/core",
"version": "0.0.0-alpha.a733494",
"version": "0.0.0-alpha.cad4675",
"description": "⚡️Blazing-fast js-bbcode-parser, bbcode js, that transforms and parses to AST with plugin support in pure javascript, no dependencies",

@@ -52,2 +52,15 @@ "keywords": [

},
"scripts": {
"build:commonjs": "pkg-task",
"build:es": "pkg-task",
"build:umd": "pkg-task",
"build": "pkg-task",
"test": "pkg-task",
"cover": "pkg-task",
"lint": "pkg-task",
"size": "pkg-task",
"bundlesize": "pkg-task",
"types": "pkg-task",
"prepublishOnly": "npm run build"
},
"size-limit": [

@@ -72,16 +85,5 @@ {

"src",
"es"
],
"scripts": {
"build:commonjs": "pkg-task",
"build:es": "pkg-task",
"build:umd": "pkg-task",
"build": "pkg-task",
"test": "pkg-task",
"cover": "pkg-task",
"lint": "pkg-task",
"size": "pkg-task",
"bundlesize": "pkg-task",
"types": "pkg-task"
}
}
"es",
"types"
]
}
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