xml-tokenizer 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/selector/TokenSelectState.js +1 -1
- package/dist/cjs/selector/TokenSelectStateMachine.js +1 -1
- package/dist/cjs/token-to-xml.js +1 -0
- package/dist/cjs/tokenizer/XmlStream.js +1 -1
- package/dist/cjs/tokenizer/ascii-constants.js +1 -0
- package/dist/cjs/tokenizer/tokenize.js +1 -1
- package/dist/cjs/tokenizer/utils.js +1 -1
- package/dist/cjs/tokens-to-xml.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/selector/TokenSelectState.js +1 -1
- package/dist/esm/selector/TokenSelectStateMachine.js +1 -1
- package/dist/esm/token-to-xml.js +1 -0
- package/dist/esm/tokenizer/XmlStream.js +1 -1
- package/dist/esm/tokenizer/ascii-constants.js +1 -0
- package/dist/esm/tokenizer/tokenize.js +1 -1
- package/dist/esm/tokenizer/utils.js +1 -1
- package/dist/esm/tokens-to-xml.js +1 -1
- package/dist/types/get-q-name.d.ts +5 -0
- package/dist/types/get-q-name.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/selector/TokenSelectState.d.ts +3 -3
- package/dist/types/selector/TokenSelectState.d.ts.map +1 -1
- package/dist/types/selector/TokenSelectStateMachine.d.ts +1 -2
- package/dist/types/selector/TokenSelectStateMachine.d.ts.map +1 -1
- package/dist/types/selector/types.d.ts +40 -30
- package/dist/types/selector/types.d.ts.map +1 -1
- package/dist/types/token-to-xml.d.ts +3 -0
- package/dist/types/token-to-xml.d.ts.map +1 -0
- package/dist/types/tokenizer/XmlStream.d.ts +1 -1
- package/dist/types/tokenizer/XmlStream.d.ts.map +1 -1
- package/dist/types/tokenizer/ascii-constants.d.ts +33 -0
- package/dist/types/tokenizer/ascii-constants.d.ts.map +1 -0
- package/dist/types/tokenizer/index.d.ts +1 -0
- package/dist/types/tokenizer/index.d.ts.map +1 -1
- package/dist/types/tokenizer/tokenize.d.ts.map +1 -1
- package/dist/types/tokenizer/utils.d.ts +0 -32
- package/dist/types/tokenizer/utils.d.ts.map +1 -1
- package/dist/types/tokens-to-xml.d.ts +0 -1
- package/dist/types/tokens-to-xml.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("./selector/select.js"),
|
|
1
|
+
"use strict";var t=require("./selector/select.js"),A=require("./selector/TokenSelector.js"),S=require("./selector/TokenSelectState.js"),R=require("./selector/TokenSelectStateMachine.js"),i=require("./token-to-xml.js"),e=require("./tokenizer/ascii-constants.js"),r=require("./tokenizer/tokenize.js"),E=require("./tokenizer/utils.js"),a=require("./tokenizer/XmlError.js"),T=require("./tokenizer/XmlStream.js"),o=require("./tokens-to-xml.js"),N=require("./xml-to-object.js");exports.select=t.select,exports.TokenSelector=A.TokenSelector,exports.EToCacheNodeProps=S.EToCacheNodeProps,exports.ETokenMatchCriteria=S.ETokenMatchCriteria,exports.TokenSelectState=S.TokenSelectState,exports.TokenSelectStateMachine=R.TokenSelectStateMachine,exports.tokenToXml=i.tokenToXml,exports.AMPERSAND=e.AMPERSAND,exports.CARRIAGE_RETURN=e.CARRIAGE_RETURN,exports.COLON=e.COLON,exports.DOUBLE_QUOTE=e.DOUBLE_QUOTE,exports.EQUALS=e.EQUALS,exports.EXCLAMATION_MARK=e.EXCLAMATION_MARK,exports.GREATER_THAN=e.GREATER_THAN,exports.HASH=e.HASH,exports.HORIZONTAL_TAB=e.HORIZONTAL_TAB,exports.HYPHEN=e.HYPHEN,exports.LESS_THAN=e.LESS_THAN,exports.LINE_FEED=e.LINE_FEED,exports.LOWERCASE_A=e.LOWERCASE_A,exports.LOWERCASE_F=e.LOWERCASE_F,exports.LOWERCASE_X=e.LOWERCASE_X,exports.LOWERCASE_Z=e.LOWERCASE_Z,exports.NINE=e.NINE,exports.OPEN_BRACKET=e.OPEN_BRACKET,exports.PERCENT=e.PERCENT,exports.PERIOD=e.PERIOD,exports.QUESTION_MARK=e.QUESTION_MARK,exports.SEMICOLON=e.SEMICOLON,exports.SINGLE_QUOTE=e.SINGLE_QUOTE,exports.SLASH=e.SLASH,exports.SPACE=e.SPACE,exports.UNDERSCORE=e.UNDERSCORE,exports.UPPERCASE_A=e.UPPERCASE_A,exports.UPPERCASE_F=e.UPPERCASE_F,exports.UPPERCASE_P=e.UPPERCASE_P,exports.UPPERCASE_S=e.UPPERCASE_S,exports.UPPERCASE_Z=e.UPPERCASE_Z,exports.ZERO=e.ZERO,exports.tokenize=r.tokenize,exports.tokenizeXmlStream=r.tokenizeXmlStream,exports.isAsciiDigit=E.isAsciiDigit,exports.isXmlChar=E.isXmlChar,exports.isXmlName=E.isXmlName,exports.isXmlNameByte=E.isXmlNameByte,exports.isXmlNameStart=E.isXmlNameStart,exports.isXmlSpaceByte=E.isXmlSpaceByte,exports.XmlError=a.XmlError,exports.XmlStream=T.XmlStream,exports.tokensToXml=o.tokensToXml,exports.xmlToObject=N.xmlToObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=require("../get-q-name.js"),l=Object.defineProperty,o=(e,t,s)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,r=(e,t,s)=>o(e,typeof t!="symbol"?t+"":t,s);class c{constructor(t){r(this,"_segment"),r(this,"_matchCriteria",0),r(this,"_toCacheNodeProps",0),r(this,"_enteredDepth",null),this._segment=t,this.applyLevels()}get matchCriteria(){return this._matchCriteria}get toCacheNodeProps(){return this._toCacheNodeProps}get enteredDepth(){return this._enteredDepth}applyLevels(){let t=0,s=0;(this._segment.local!=null||this._segment.prefix!=null)&&(t|=1),this._segment.attributes!=null&&(t|=2,s|=2),this._segment.containsText!=null&&(t|=4),this._segment.predicate!=null&&(t|=8,s|=7),this._matchCriteria=t,this._toCacheNodeProps=s}matchesName(t,s){return(this._segment.local==null||this._segment.local==="*"||this._segment.local===t)&&(this._segment.prefix==null||this._segment.prefix===s)}matchesAttributes(t){if(this._segment.attributes!=null)for(const s of this._segment.attributes){const i=h.getQName(s.local,s.prefix);if(!(i in t)||s.value!=null&&t[i]!==s.value)return!1}return!0}matchesText(t){return this._segment.containsText==null||t.includes(this._segment.containsText)}matchesDepth(t,s){switch(this._segment.axis){case"child":return t===s+1;case"self-or-descendant":return t>=s}}match(t){this._enteredDepth=t}unmatch(){this._enteredDepth=null}}var a=(e=>(e[e.None=0]="None",e[e.Name=1]="Name",e[e.Attributes=2]="Attributes",e[e.Text=4]="Text",e))(a||{}),n=(e=>(e[e.None=0]="None",e[e.Name=1]="Name",e[e.Attributes=2]="Attributes",e[e.Text=4]="Text",e[e.Node=8]="Node",e))(n||{});exports.EToCacheNodeProps=a,exports.ETokenMatchCriteria=n,exports.TokenSelectState=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=require("../get-q-name.js"),
|
|
1
|
+
"use strict";var d=require("../get-q-name.js"),n=require("./TokenSelectState.js"),_=Object.defineProperty,S=(i,t,e)=>t in i?_(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,c=(i,t,e)=>S(i,typeof t!="symbol"?t+"":t,e);class p{constructor(t){c(this,"_states"),c(this,"_currentState",null),c(this,"_cachedNodeProps",{prefix:null,local:null,attributes:null,text:null}),c(this,"_cachedTokens",[]),c(this,"_toRecordTokens",[]),this._states=t.map(e=>new n.TokenSelectState(e))}getNextState(){var t;const e=this._currentState!=null?this._currentState+1:0;return e<this._states.length&&(t=this._states[e])!=null?t:null}getCurrentState(){var t;return this._currentState!=null&&this._currentState<this._states.length&&(t=this._states[this._currentState])!=null?t:null}record(t){this.getOffsetToFinal()<=1&&this._cachedTokens.push(t)}takeRecordedTokens(){if(this._toRecordTokens.length>0){const t=this._toRecordTokens;return this._toRecordTokens=[],t}return null}transitionIfNameMatch(t,e,r){var s;const a=this.getNextState(),h=this.getCurrentState();return a==null?!1:(a.toCacheNodeProps&n.EToCacheNodeProps.Name&&(this._cachedNodeProps.local=t,this._cachedNodeProps.prefix=e),a.matchesName(t,e)&&a.matchesDepth(r,(s=h==null?void 0:h.enteredDepth)!=null?s:0)&&!(a.matchCriteria&(n.ETokenMatchCriteria.Attributes|n.ETokenMatchCriteria.Text|n.ETokenMatchCriteria.Node))?(this.transitionForward(r),!0):!1)}transitionIfAttributesMatch(t,e,r,s){var a,h;const o=this.getNextState(),u=this.getCurrentState();if(o==null)return!1;const l=(a=this._cachedNodeProps.attributes)!=null?a:{};return l[d.getQName(t,e)]=r,o.toCacheNodeProps&n.EToCacheNodeProps.Attributes&&(this._cachedNodeProps.attributes=l),o.matchesAttributes(l)&&o.matchesDepth(s,(h=u==null?void 0:u.enteredDepth)!=null?h:0)&&!(o.matchCriteria&(n.ETokenMatchCriteria.Text|n.ETokenMatchCriteria.Node))?(this.transitionForward(s),!0):!1}transitionIfTextMatch(t,e){var r;const s=this.getNextState(),a=this.getCurrentState();return s==null?!1:(s.toCacheNodeProps&n.EToCacheNodeProps.Text&&(this._cachedNodeProps.text=t),s.matchesText(t)&&s.matchesDepth(e,(r=a==null?void 0:a.enteredDepth)!=null?r:0)&&!(s.matchCriteria&n.ETokenMatchCriteria.Node)?(this.transitionForward(e),!0):!1)}transitionForward(t){const e=this.getCurrentState();e!=null&&e.unmatch(),this._currentState=this._currentState!=null?this._currentState+1:0;const r=this.getCurrentState();r!=null&&r.match(t),this.isFinalState()&&(this._toRecordTokens=this._cachedTokens),this.resetCurrentStateCache()}transitionBack(t){const e=this.getCurrentState();e!=null&&e.unmatch(),this._currentState=this._currentState!=null?this._currentState-1:0;const r=this.getCurrentState();r!=null&&r.match(t),this.resetCurrentStateCache()}isFinalState(){return this._currentState!=null&&this._currentState>=this._states.length-1}getOffsetToFinal(){return this._currentState==null?this._states.length:this._states.length-1-this._currentState}resetCurrentStateCache(){this._cachedNodeProps.prefix=null,this._cachedNodeProps.local=null,this._cachedNodeProps.attributes=null,this._cachedNodeProps.text=null,this._cachedTokens=[]}}exports.TokenSelectStateMachine=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function n(t){let e="";switch(t.type){case"ProcessingInstruction":e+=`<?${t.target}`,t.content&&(e+=` ${t.content}`),e+="?>";break;case"Comment":e+=`<!--${t.text}-->`;break;case"EntityDeclaration":e+=`<!ENTITY ${t.name} "${t.definition}">`;break;case"ElementStart":e+=`<${t.prefix.length>0?`${t.prefix}:`:""}${t.local}`;break;case"Attribute":e+=` ${t.prefix.length>0?`${t.prefix}:`:""}${t.local}="${t.value}"`;break;case"ElementEnd":t.end.type==="Open"?e+=">":t.end.type==="Close"?e+=`</${t.end.prefix.length>0?`${t.end.prefix}:`:""}${t.end.local}>`:e+="/>";break;case"Text":e+=t.text;break;case"Cdata":e+=`<![CDATA[${t.text}]]>`;break}return e}exports.tokenToXml=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=require("./ascii-constants.js"),h=require("./utils.js"),o=require("./XmlError.js"),m=Object.defineProperty,d=(a,t,e)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,c=(a,t,e)=>d(a,typeof t!="symbol"?t+"":t,e);class p{constructor(t,e=0){c(this,"_text"),c(this,"_pos"),c(this,"_end"),this._text=t,this._pos=e,this._end=this._text.length}clone(){return new p(this._text,this._pos)}getPos(){return this._pos}atEnd(){return this._pos>=this._end}currCodeUnit(){if(this._pos>=this._end)throw new o.XmlError({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos)}currCodeUnitUnchecked(){return this._text.charCodeAt(this._pos)}nextCodeUnit(){if(this._pos+1>=this._end)throw new o.XmlError({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos+1)}advance(t){this._pos+=t}goTo(t){this._pos=t}startsWith(t){return this._text.startsWith(t,this._pos)}consumeCodeUnit(t){const e=this.currCodeUnit();if(e!==t)throw new o.XmlError({type:"InvalidChar",expected:t,actual:e},this.genTextPos());this._pos+=1}tryConsumeCodeUnit(t){return this.currCodeUnit()===t?(this._pos+=1,!0):!1}skipString(t){if(!this.startsWith(t))throw new o.XmlError({type:"InvalidString",expected:t},this.genTextPos());this._pos+=t.length}consumeCodeUnitsWhile(t){const e=this._pos;return this.skipCodeUnitsWhile(t),this.sliceBack(e)}skipCodeUnitsWhile(t){for(;this._pos<this._end&&t(this.currCodeUnitUnchecked());)this._pos+=1}consumeCharsWhile(t){const e=this._pos;return this.skipCharsWhile(t),this.sliceBack(e)}skipCharsWhile(t){for(;this._pos<this._end;){const e=this._text[this._pos];if(e==null||!h.isXmlChar(e.codePointAt(0)))throw new o.XmlError({type:"NonXmlChar",char:e!=null?e:"\uFFFD"},this.genTextPos());if(t(this,e))this._pos+=e.length;else break}}sliceBack(t){return this._text.slice(t,this._pos)}rangeFrom(t){return{start:t,end:this._pos}}skipSpaces(){for(;this.startsWithSpace();)this._pos+=1}startsWithSpace(){return this._pos<this._end&&h.isXmlSpaceByte(this.currCodeUnitUnchecked())}consumeSpaces(){if(this._pos>=this._end)throw new o.XmlError({type:"UnexpectedEndOfStream"},this.genTextPos());if(!this.startsWithSpace())throw new o.XmlError({type:"InvalidChar",expected:"a whitespace",actual:this.currCodeUnitUnchecked()},this.genTextPos());this.skipSpaces()}tryConsumeReference(){const t=this._pos,e=this.clone(),i=e.consumeReference();return i!=null?(this._pos+=e.getPos()-t,i):null}consumeReference(){if(!this.tryConsumeCodeUnit(r.AMPERSAND))return null;let t;if(this.tryConsumeCodeUnit(r.HASH)){let e,i;this.tryConsumeCodeUnit(r.LOWERCASE_X)?(e=this.consumeCodeUnitsWhile(s=>s>=r.ZERO&&s<=r.NINE||s>=r.UPPERCASE_A&&s<=r.UPPERCASE_F||s>=r.LOWERCASE_A&&s<=r.LOWERCASE_F),i=16):(e=this.consumeCodeUnitsWhile(s=>h.isAsciiDigit(s)),i=10);const n=parseInt(e,i);isNaN(n)||!h.isXmlChar(n)?t=null:t={type:"Char",value:String.fromCodePoint(n)}}else{const e=this.consumeName();switch(e){case"quot":t={type:"Char",value:'"'};break;case"amp":t={type:"Char",value:"&"};break;case"apos":t={type:"Char",value:"'"};break;case"lt":t={type:"Char",value:"<"};break;case"gt":t={type:"Char",value:">"};break;default:t={type:"Entity",value:e}}}return this.tryConsumeCodeUnit(r.SEMICOLON)?t:null}consumeName(){const t=this._pos;this.skipName();const e=this.sliceBack(t);if(e.length===0)throw new o.XmlError({type:"InvalidName"},this.genTextPosFrom(t));return e}skipName(){const t=this._pos;for(;this._pos<this._end;){const e=this.currCodeUnitUnchecked();if(this._pos===t){if(!h.isXmlNameStart(e))throw new o.XmlError({type:"InvalidName"},this.genTextPosFrom(t))}else if(!h.isXmlName(e))break;this._pos+=1}}consumeQName(){var t,e;const i=this._pos;let n=null;for(;this._pos<this._end;){const u=this.currCodeUnitUnchecked();if(u===r.COLON)if(n==null)n=this._pos,this._pos+=1;else throw new o.XmlError({type:"InvalidName"},this.genTextPosFrom(i));else if(h.isXmlName(u))this._pos+=1;else break}let s,l;if(n!=null?(s=this._text.slice(i,n),l=this.sliceBack(n+1)):(s="",l=this.sliceBack(i)),s.length>0&&!h.isXmlNameStart((t=s[0])==null?void 0:t.codePointAt(0)))throw new o.XmlError({type:"InvalidName"},this.genTextPosFrom(i));if(l.length>0){if(!h.isXmlNameStart((e=l[0])==null?void 0:e.codePointAt(0)))throw new o.XmlError({type:"InvalidName"},this.genTextPosFrom(i))}else throw new o.XmlError({type:"InvalidName"},this.genTextPosFrom(i));return[s,l]}consumeQuote(){const t=this.currCodeUnit();if(t===r.SINGLE_QUOTE||t===r.DOUBLE_QUOTE)return this._pos+=1,t;throw new o.XmlError({type:"InvalidChar",expected:"a quote",actual:t},this.genTextPos())}genTextPos(){return this.genTextPosFrom(this._pos)}genTextPosFrom(t){const e=Math.min(t,this._end);let i=1,n=1;for(let s=0;s<e;s++)this._text.charCodeAt(s)===r.LINE_FEED?(i++,n=1):n++;return{row:i,col:n}}}exports.XmlStream=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const E=9,A=10,R=13,S=32,O=33,_=34,C=35,N=37,P=38,L=39,T=45,U=46,I=47,H=48,D=57,M=58,Q=59,W=60,Z=61,B=62,F=63,G=65,K=70,X=80,s=83,t=90,Y=91,c=95,e=97,i=102,n=120,o=122;exports.AMPERSAND=38,exports.CARRIAGE_RETURN=13,exports.COLON=58,exports.DOUBLE_QUOTE=34,exports.EQUALS=61,exports.EXCLAMATION_MARK=33,exports.GREATER_THAN=62,exports.HASH=35,exports.HORIZONTAL_TAB=9,exports.HYPHEN=45,exports.LESS_THAN=60,exports.LINE_FEED=10,exports.LOWERCASE_A=97,exports.LOWERCASE_F=102,exports.LOWERCASE_X=120,exports.LOWERCASE_Z=122,exports.NINE=57,exports.OPEN_BRACKET=91,exports.PERCENT=37,exports.PERIOD=46,exports.QUESTION_MARK=63,exports.SEMICOLON=59,exports.SINGLE_QUOTE=39,exports.SLASH=47,exports.SPACE=32,exports.UNDERSCORE=95,exports.UPPERCASE_A=65,exports.UPPERCASE_F=70,exports.UPPERCASE_P=80,exports.UPPERCASE_S=83,exports.UPPERCASE_Z=90,exports.ZERO=48;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("./
|
|
1
|
+
"use strict";var r=require("./ascii-constants.js"),i=require("./XmlError.js"),P=require("./XmlStream.js");function w(t,n,s){T(new P.XmlStream(t),n,s)}function T(t,n,s){if(t.startsWith("\uFEFF")&&t.advance(1),t.startsWith("<?xml ")&&A(t),m(t,s),t.skipSpaces(),t.startsWith("<!DOCTYPE")){if(!n)throw new i.XmlError({type:"DtdDetected"});W(t,s),m(t,s)}if(t.skipSpaces(),!t.atEnd()&&t.currCodeUnit()===r.LESS_THAN&&S(t,s),m(t,s),!t.atEnd())throw new i.XmlError({type:"UnknownToken",message:"Not at end"},t.genTextPos())}function m(t,n){for(;!t.atEnd();)if(t.skipSpaces(),t.startsWith("<!--"))h(t,n);else if(t.startsWith("<?"))f(t,n);else break}function A(t){if(t.advance(5),E(t),!t.startsWith("version"))throw new i.XmlError({type:"InvalidString",expected:"version"},t.genTextPos());d(t),E(t),t.startsWith("encoding")&&(d(t),E(t)),t.startsWith("standalone")&&d(t),t.skipSpaces(),t.skipString("?>")}function E(t){if(t.startsWithSpace())t.skipSpaces();else if(!t.startsWith("?>")&&!t.atEnd())throw new i.XmlError({type:"InvalidChar",expected:"a whitespace",actual:t.currCodeUnitUnchecked()},t.genTextPos())}function h(t,n){const s=t.getPos();t.advance(4);const o=t.consumeCharsWhile((e,a)=>!(a==="-"&&e.startsWith("-->")));if(t.skipString("-->"),o.includes("--")||o.endsWith("-"))throw new i.XmlError({type:"InvalidComment"},t.genTextPosFrom(s));n({type:"Comment",text:o,range:t.rangeFrom(s)})}function f(t,n){if(t.startsWith("<?xml "))throw new i.XmlError({type:"UnexpectedDeclaration"},t.genTextPos());const s=t.getPos();t.advance(2);const o=t.consumeName();t.skipSpaces();const e=t.consumeCharsWhile((a,c)=>!(c==="?"&&a.startsWith("?>")));t.skipString("?>"),n({type:"ProcessingInstruction",target:o,content:e.length===0?void 0:e,range:t.rangeFrom(s)})}function W(t,n){const s=t.getPos();if(v(t),t.skipSpaces(),t.currCodeUnit()===r.GREATER_THAN){t.advance(1);return}for(t.advance(1);!t.atEnd();)if(t.skipSpaces(),t.startsWith("<!ENTITY"))y(t,n);else if(t.startsWith("<!--"))h(t,n);else if(t.startsWith("<?"))f(t,n);else if(t.startsWith("]"))if(t.advance(1),t.skipSpaces(),t.currCodeUnit()===r.GREATER_THAN){t.advance(1);break}else throw new i.XmlError({type:"InvalidChar",expected:"'>'",actual:t.currCodeUnitUnchecked()},t.genTextPos());else if(t.startsWith("<!ELEMENT")||t.startsWith("<!ATTLIST")||t.startsWith("<!NOTATION"))try{N(t)}catch(o){throw new i.XmlError({type:"UnknownToken",message:"Failed to consume declaration"},t.genTextPosFrom(s))}else throw new i.XmlError({type:"UnknownToken",message:"Failed to parse doctype"},t.genTextPos())}function v(t){t.advance(9),t.consumeSpaces(),t.skipName(),t.skipSpaces(),g(t),t.skipSpaces();const n=t.currCodeUnit();if(n!==r.OPEN_BRACKET&&n!==r.GREATER_THAN)throw new i.XmlError({type:"InvalidChar",expected:"'[' or '>'",actual:n},t.genTextPos())}function g(t){if(t.startsWith("SYSTEM")||t.startsWith("PUBLIC")){const n=t.getPos();t.advance(6);const s=t.sliceBack(n);t.consumeSpaces();const o=t.consumeQuote();if(t.consumeCodeUnitsWhile(e=>e!==o),t.consumeCodeUnit(o),s==="PUBLIC"){t.consumeSpaces();const e=t.consumeQuote();t.consumeCodeUnitsWhile(a=>a!==e),t.consumeCodeUnit(e)}return!0}return!1}function y(t,n){t.advance(8),t.consumeSpaces();const s=!t.tryConsumeCodeUnit(r.PERCENT);s||t.consumeSpaces();const o=t.consumeName();t.consumeSpaces();const e=x(t,s);e!==null&&n({type:"EntityDeclaration",name:o,definition:e}),t.skipSpaces(),t.consumeCodeUnit(r.GREATER_THAN)}function x(t,n){const s=t.currCodeUnit();if(s===r.DOUBLE_QUOTE||s===r.SINGLE_QUOTE){const o=t.consumeQuote(),e=t.getPos();t.skipCodeUnitsWhile(c=>c!==o);const a=t.sliceBack(e);return t.consumeCodeUnit(o),a}else if(s===r.UPPERCASE_S||s===r.UPPERCASE_P){if(g(t))return n&&(t.skipSpaces(),t.startsWith("NDATA")&&(t.advance(5),t.consumeSpaces(),t.skipName())),null;throw new i.XmlError({type:"InvalidExternalID"},t.genTextPos())}else throw new i.XmlError({type:"InvalidChar",expected:"a quote, SYSTEM or PUBLIC",actual:s},t.genTextPos())}function N(t){t.skipCodeUnitsWhile(n=>n!==r.GREATER_THAN),t.consumeCodeUnit(r.GREATER_THAN)}function S(t,n){const s=t.getPos();t.advance(1);const[o,e]=t.consumeQName();n({type:"ElementStart",prefix:o,local:e,start:s});let a=!1;for(;!t.atEnd();){const c=t.startsWithSpace();t.skipSpaces();const p=t.getPos(),u=t.currCodeUnit();if(u===r.SLASH){t.advance(1),t.consumeCodeUnit(r.GREATER_THAN);const l=t.rangeFrom(p);n({type:"ElementEnd",end:{type:"Empty"},range:l});break}else if(u===r.GREATER_THAN){t.advance(1);const l=t.rangeFrom(p);n({type:"ElementEnd",end:{type:"Open"},range:l}),a=!0;break}else{if(!c)throw new i.XmlError({type:"InvalidChar",expected:"a whitespace",actual:t.currCodeUnitUnchecked()},t.genTextPos());const[l,C,k]=d(t),U=t.getPos();n({type:"Attribute",range:{start:p,end:U},prefix:l,local:C,value:k})}}a&&R(t,n)}function d(t){const[n,s]=t.consumeQName();let o;const e=t.getPos();if(t.skipSpaces(),t.tryConsumeCodeUnit(r.EQUALS)){t.skipSpaces();const a=t.consumeQuote(),c=String.fromCharCode(a),p=t.getPos();t.skipCharsWhile((u,l)=>l!==c&&l!=="<"),o=t.sliceBack(p),t.consumeCodeUnit(a)}else t.goTo(e),o="true";return[n,s,o]}function R(t,n){for(;!t.atEnd();)if(t.currCodeUnit()===r.LESS_THAN){const s=t.nextCodeUnit();if(s===r.EXCLAMATION_MARK)if(t.startsWith("<!--"))h(t,n);else if(t.startsWith("<![CDATA["))X(t,n);else throw new i.XmlError({type:"UnknownToken",message:"Failed to parse content"},t.genTextPos());else if(s===r.QUESTION_MARK)f(t,n);else if(s===r.SLASH){I(t,n);break}else S(t,n)}else _(t,n)}function X(t,n){const s=t.getPos();t.advance(9);const o=t.consumeCharsWhile((a,c)=>!(c==="]"&&a.startsWith("]]>")));t.skipString("]]>");const e=t.rangeFrom(s);n({type:"Cdata",text:o,range:e})}function I(t,n){const s=t.getPos();t.advance(2);const[o,e]=t.consumeQName();t.skipSpaces(),t.consumeCodeUnit(r.GREATER_THAN);const a=t.rangeFrom(s);n({type:"ElementEnd",end:{type:"Close",prefix:o,local:e},range:a})}function _(t,n){const s=t.getPos(),o=t.consumeCharsWhile((e,a)=>a!=="<");if(o.includes(">")&&o.includes("]]>"))throw new i.XmlError({type:"InvalidCharacterData"},t.genTextPos());n({type:"Text",text:o,range:t.rangeFrom(s)})}exports.tokenize=w,exports.tokenizeXmlStream=T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var i=require("./ascii-constants.js");function e(E){return E>=i.ZERO&&E<=i.NINE}function r(E){return E==null?!1:E<=128?E>=i.UPPERCASE_A&&E<=i.UPPERCASE_Z||E>=i.LOWERCASE_A&&E<=i.LOWERCASE_Z||E===i.COLON||E===i.UNDERSCORE:E>=192&&E<=214||E>=216&&E<=246||E>=248&&E<=767||E>=880&&E<=893||E>=895&&E<=8191||E>=8204&&E<=8205||E>=8304&&E<=8591||E>=11264&&E<=12271||E>=12289&&E<=55295||E>=63744&&E<=64975||E>=65008&&E<=65533||E>=65536&&E<=983039}function R(E){return E==null?!1:E<=128?n(E):E===183||E>=192&&E<=214||E>=216&&E<=246||E>=248&&E<=767||E>=768&&E<=879||E>=880&&E<=893||E>=895&&E<=8191||E>=8204&&E<=8205||E>=8255&&E<=8256||E>=8304&&E<=8591||E>=11264&&E<=12271||E>=12289&&E<=55295||E>=63744&&E<=64975||E>=65008&&E<=65533||E>=65536&&E<=983039}function s(E){return E==null?!1:E<32?t(E):E!==65535&&E!==65534}function t(E){return E===i.SPACE||E===i.HORIZONTAL_TAB||E===i.LINE_FEED||E===i.CARRIAGE_RETURN}function n(E){return E>=i.ZERO&&E<=i.NINE||E>=i.UPPERCASE_A&&E<=i.UPPERCASE_Z||E>=i.LOWERCASE_A&&E<=i.LOWERCASE_Z||E===i.COLON||E===i.UNDERSCORE||E===i.HYPHEN||E===i.PERIOD}exports.isAsciiDigit=e,exports.isXmlChar=s,exports.isXmlName=R,exports.isXmlNameByte=n,exports.isXmlNameStart=r,exports.isXmlSpaceByte=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var n=require("./token-to-xml.js");function r(e){let o="";return e.forEach(t=>{o+=n.tokenToXml(t)}),o}exports.tokensToXml=r;
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{select as o}from"./selector/select.js";import{TokenSelector as
|
|
1
|
+
import{select as o}from"./selector/select.js";import{TokenSelector as t}from"./selector/TokenSelector.js";import{EToCacheNodeProps as A,ETokenMatchCriteria as m,TokenSelectState as R}from"./selector/TokenSelectState.js";import{TokenSelectStateMachine as C}from"./selector/TokenSelectStateMachine.js";import{tokenToXml as T}from"./token-to-xml.js";import{AMPERSAND as P,CARRIAGE_RETURN as i,COLON as l,DOUBLE_QUOTE as a,EQUALS as p,EXCLAMATION_MARK as L,GREATER_THAN as x,HASH as f,HORIZONTAL_TAB as U,HYPHEN as X,LESS_THAN as c,LINE_FEED as s,LOWERCASE_A as n,LOWERCASE_F as I,LOWERCASE_X as k,LOWERCASE_Z as H,NINE as M,OPEN_BRACKET as D,PERCENT as B,PERIOD as h,QUESTION_MARK as Q,SEMICOLON as W,SINGLE_QUOTE as Z,SLASH as F,SPACE as G,UNDERSCORE as K,UPPERCASE_A as y,UPPERCASE_F as z,UPPERCASE_P as b,UPPERCASE_S as d,UPPERCASE_Z as g,ZERO as j}from"./tokenizer/ascii-constants.js";import{tokenize as q,tokenizeXmlStream as u}from"./tokenizer/tokenize.js";import{isAsciiDigit as w,isXmlChar as J,isXmlName as V,isXmlNameByte as $,isXmlNameStart as EE,isXmlSpaceByte as eE}from"./tokenizer/utils.js";import{XmlError as rE}from"./tokenizer/XmlError.js";import{XmlStream as SE}from"./tokenizer/XmlStream.js";import{tokensToXml as mE}from"./tokens-to-xml.js";import{xmlToObject as NE}from"./xml-to-object.js";export{P as AMPERSAND,i as CARRIAGE_RETURN,l as COLON,a as DOUBLE_QUOTE,p as EQUALS,A as EToCacheNodeProps,m as ETokenMatchCriteria,L as EXCLAMATION_MARK,x as GREATER_THAN,f as HASH,U as HORIZONTAL_TAB,X as HYPHEN,c as LESS_THAN,s as LINE_FEED,n as LOWERCASE_A,I as LOWERCASE_F,k as LOWERCASE_X,H as LOWERCASE_Z,M as NINE,D as OPEN_BRACKET,B as PERCENT,h as PERIOD,Q as QUESTION_MARK,W as SEMICOLON,Z as SINGLE_QUOTE,F as SLASH,G as SPACE,R as TokenSelectState,C as TokenSelectStateMachine,t as TokenSelector,K as UNDERSCORE,y as UPPERCASE_A,z as UPPERCASE_F,b as UPPERCASE_P,d as UPPERCASE_S,g as UPPERCASE_Z,rE as XmlError,SE as XmlStream,j as ZERO,w as isAsciiDigit,J as isXmlChar,V as isXmlName,$ as isXmlNameByte,EE as isXmlNameStart,eE as isXmlSpaceByte,o as select,T as tokenToXml,q as tokenize,u as tokenizeXmlStream,mE as tokensToXml,NE as xmlToObject};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getQName as
|
|
1
|
+
import{getQName as h}from"../get-q-name.js";var l=Object.defineProperty,o=(e,t,s)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,r=(e,t,s)=>o(e,typeof t!="symbol"?t+"":t,s);class c{constructor(t){r(this,"_segment"),r(this,"_matchCriteria",0),r(this,"_toCacheNodeProps",0),r(this,"_enteredDepth",null),this._segment=t,this.applyLevels()}get matchCriteria(){return this._matchCriteria}get toCacheNodeProps(){return this._toCacheNodeProps}get enteredDepth(){return this._enteredDepth}applyLevels(){let t=0,s=0;(this._segment.local!=null||this._segment.prefix!=null)&&(t|=1),this._segment.attributes!=null&&(t|=2,s|=2),this._segment.containsText!=null&&(t|=4),this._segment.predicate!=null&&(t|=8,s|=7),this._matchCriteria=t,this._toCacheNodeProps=s}matchesName(t,s){return(this._segment.local==null||this._segment.local==="*"||this._segment.local===t)&&(this._segment.prefix==null||this._segment.prefix===s)}matchesAttributes(t){if(this._segment.attributes!=null)for(const s of this._segment.attributes){const i=h(s.local,s.prefix);if(!(i in t)||s.value!=null&&t[i]!==s.value)return!1}return!0}matchesText(t){return this._segment.containsText==null||t.includes(this._segment.containsText)}matchesDepth(t,s){switch(this._segment.axis){case"child":return t===s+1;case"self-or-descendant":return t>=s}}match(t){this._enteredDepth=t}unmatch(){this._enteredDepth=null}}var a=(e=>(e[e.None=0]="None",e[e.Name=1]="Name",e[e.Attributes=2]="Attributes",e[e.Text=4]="Text",e))(a||{}),n=(e=>(e[e.None=0]="None",e[e.Name=1]="Name",e[e.Attributes=2]="Attributes",e[e.Text=4]="Text",e[e.Node=8]="Node",e))(n||{});export{a as EToCacheNodeProps,n as ETokenMatchCriteria,c as TokenSelectState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getQName as _}from"../get-q-name.js";import{
|
|
1
|
+
import{getQName as _}from"../get-q-name.js";import{TokenSelectState as S,EToCacheNodeProps as u,ETokenMatchCriteria as h}from"./TokenSelectState.js";var p=Object.defineProperty,N=(a,t,e)=>t in a?p(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,c=(a,t,e)=>N(a,typeof t!="symbol"?t+"":t,e);class m{constructor(t){c(this,"_states"),c(this,"_currentState",null),c(this,"_cachedNodeProps",{prefix:null,local:null,attributes:null,text:null}),c(this,"_cachedTokens",[]),c(this,"_toRecordTokens",[]),this._states=t.map(e=>new S(e))}getNextState(){var t;const e=this._currentState!=null?this._currentState+1:0;return e<this._states.length&&(t=this._states[e])!=null?t:null}getCurrentState(){var t;return this._currentState!=null&&this._currentState<this._states.length&&(t=this._states[this._currentState])!=null?t:null}record(t){this.getOffsetToFinal()<=1&&this._cachedTokens.push(t)}takeRecordedTokens(){if(this._toRecordTokens.length>0){const t=this._toRecordTokens;return this._toRecordTokens=[],t}return null}transitionIfNameMatch(t,e,r){var s;const n=this.getNextState(),i=this.getCurrentState();return n==null?!1:(n.toCacheNodeProps&u.Name&&(this._cachedNodeProps.local=t,this._cachedNodeProps.prefix=e),n.matchesName(t,e)&&n.matchesDepth(r,(s=i==null?void 0:i.enteredDepth)!=null?s:0)&&!(n.matchCriteria&(h.Attributes|h.Text|h.Node))?(this.transitionForward(r),!0):!1)}transitionIfAttributesMatch(t,e,r,s){var n,i;const o=this.getNextState(),d=this.getCurrentState();if(o==null)return!1;const l=(n=this._cachedNodeProps.attributes)!=null?n:{};return l[_(t,e)]=r,o.toCacheNodeProps&u.Attributes&&(this._cachedNodeProps.attributes=l),o.matchesAttributes(l)&&o.matchesDepth(s,(i=d==null?void 0:d.enteredDepth)!=null?i:0)&&!(o.matchCriteria&(h.Text|h.Node))?(this.transitionForward(s),!0):!1}transitionIfTextMatch(t,e){var r;const s=this.getNextState(),n=this.getCurrentState();return s==null?!1:(s.toCacheNodeProps&u.Text&&(this._cachedNodeProps.text=t),s.matchesText(t)&&s.matchesDepth(e,(r=n==null?void 0:n.enteredDepth)!=null?r:0)&&!(s.matchCriteria&h.Node)?(this.transitionForward(e),!0):!1)}transitionForward(t){const e=this.getCurrentState();e!=null&&e.unmatch(),this._currentState=this._currentState!=null?this._currentState+1:0;const r=this.getCurrentState();r!=null&&r.match(t),this.isFinalState()&&(this._toRecordTokens=this._cachedTokens),this.resetCurrentStateCache()}transitionBack(t){const e=this.getCurrentState();e!=null&&e.unmatch(),this._currentState=this._currentState!=null?this._currentState-1:0;const r=this.getCurrentState();r!=null&&r.match(t),this.resetCurrentStateCache()}isFinalState(){return this._currentState!=null&&this._currentState>=this._states.length-1}getOffsetToFinal(){return this._currentState==null?this._states.length:this._states.length-1-this._currentState}resetCurrentStateCache(){this._cachedNodeProps.prefix=null,this._cachedNodeProps.local=null,this._cachedNodeProps.attributes=null,this._cachedNodeProps.text=null,this._cachedTokens=[]}}export{m as TokenSelectStateMachine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(t){let e="";switch(t.type){case"ProcessingInstruction":e+=`<?${t.target}`,t.content&&(e+=` ${t.content}`),e+="?>";break;case"Comment":e+=`<!--${t.text}-->`;break;case"EntityDeclaration":e+=`<!ENTITY ${t.name} "${t.definition}">`;break;case"ElementStart":e+=`<${t.prefix.length>0?`${t.prefix}:`:""}${t.local}`;break;case"Attribute":e+=` ${t.prefix.length>0?`${t.prefix}:`:""}${t.local}="${t.value}"`;break;case"ElementEnd":t.end.type==="Open"?e+=">":t.end.type==="Close"?e+=`</${t.end.prefix.length>0?`${t.end.prefix}:`:""}${t.end.local}>`:e+="/>";break;case"Text":e+=t.text;break;case"Cdata":e+=`<![CDATA[${t.text}]]>`;break}return e}export{n as tokenToXml};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{AMPERSAND as _,HASH as m,LOWERCASE_X as C,ZERO as f,NINE as x,UPPERCASE_A as U,UPPERCASE_F as w,LOWERCASE_A as y,LOWERCASE_F as g,SEMICOLON as k,COLON as E,SINGLE_QUOTE as P,DOUBLE_QUOTE as v,LINE_FEED as N}from"./ascii-constants.js";import{isXmlChar as u,isXmlSpaceByte as S,isAsciiDigit as A,isXmlNameStart as a,isXmlName as d}from"./utils.js";import{XmlError as n}from"./XmlError.js";var T=Object.defineProperty,W=(h,t,e)=>t in h?T(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,c=(h,t,e)=>W(h,typeof t!="symbol"?t+"":t,e);class l{constructor(t,e=0){c(this,"_text"),c(this,"_pos"),c(this,"_end"),this._text=t,this._pos=e,this._end=this._text.length}clone(){return new l(this._text,this._pos)}getPos(){return this._pos}atEnd(){return this._pos>=this._end}currCodeUnit(){if(this._pos>=this._end)throw new n({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos)}currCodeUnitUnchecked(){return this._text.charCodeAt(this._pos)}nextCodeUnit(){if(this._pos+1>=this._end)throw new n({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos+1)}advance(t){this._pos+=t}goTo(t){this._pos=t}startsWith(t){return this._text.startsWith(t,this._pos)}consumeCodeUnit(t){const e=this.currCodeUnit();if(e!==t)throw new n({type:"InvalidChar",expected:t,actual:e},this.genTextPos());this._pos+=1}tryConsumeCodeUnit(t){return this.currCodeUnit()===t?(this._pos+=1,!0):!1}skipString(t){if(!this.startsWith(t))throw new n({type:"InvalidString",expected:t},this.genTextPos());this._pos+=t.length}consumeCodeUnitsWhile(t){const e=this._pos;return this.skipCodeUnitsWhile(t),this.sliceBack(e)}skipCodeUnitsWhile(t){for(;this._pos<this._end&&t(this.currCodeUnitUnchecked());)this._pos+=1}consumeCharsWhile(t){const e=this._pos;return this.skipCharsWhile(t),this.sliceBack(e)}skipCharsWhile(t){for(;this._pos<this._end;){const e=this._text[this._pos];if(e==null||!u(e.codePointAt(0)))throw new n({type:"NonXmlChar",char:e!=null?e:"\uFFFD"},this.genTextPos());if(t(this,e))this._pos+=e.length;else break}}sliceBack(t){return this._text.slice(t,this._pos)}rangeFrom(t){return{start:t,end:this._pos}}skipSpaces(){for(;this.startsWithSpace();)this._pos+=1}startsWithSpace(){return this._pos<this._end&&S(this.currCodeUnitUnchecked())}consumeSpaces(){if(this._pos>=this._end)throw new n({type:"UnexpectedEndOfStream"},this.genTextPos());if(!this.startsWithSpace())throw new n({type:"InvalidChar",expected:"a whitespace",actual:this.currCodeUnitUnchecked()},this.genTextPos());this.skipSpaces()}tryConsumeReference(){const t=this._pos,e=this.clone(),i=e.consumeReference();return i!=null?(this._pos+=e.getPos()-t,i):null}consumeReference(){if(!this.tryConsumeCodeUnit(_))return null;let t;if(this.tryConsumeCodeUnit(m)){let e,i;this.tryConsumeCodeUnit(C)?(e=this.consumeCodeUnitsWhile(s=>s>=f&&s<=x||s>=U&&s<=w||s>=y&&s<=g),i=16):(e=this.consumeCodeUnitsWhile(s=>A(s)),i=10);const o=parseInt(e,i);isNaN(o)||!u(o)?t=null:t={type:"Char",value:String.fromCodePoint(o)}}else{const e=this.consumeName();switch(e){case"quot":t={type:"Char",value:'"'};break;case"amp":t={type:"Char",value:"&"};break;case"apos":t={type:"Char",value:"'"};break;case"lt":t={type:"Char",value:"<"};break;case"gt":t={type:"Char",value:">"};break;default:t={type:"Entity",value:e}}}return this.tryConsumeCodeUnit(k)?t:null}consumeName(){const t=this._pos;this.skipName();const e=this.sliceBack(t);if(e.length===0)throw new n({type:"InvalidName"},this.genTextPosFrom(t));return e}skipName(){const t=this._pos;for(;this._pos<this._end;){const e=this.currCodeUnitUnchecked();if(this._pos===t){if(!a(e))throw new n({type:"InvalidName"},this.genTextPosFrom(t))}else if(!d(e))break;this._pos+=1}}consumeQName(){var t,e;const i=this._pos;let o=null;for(;this._pos<this._end;){const p=this.currCodeUnitUnchecked();if(p===E)if(o==null)o=this._pos,this._pos+=1;else throw new n({type:"InvalidName"},this.genTextPosFrom(i));else if(d(p))this._pos+=1;else break}let s,r;if(o!=null?(s=this._text.slice(i,o),r=this.sliceBack(o+1)):(s="",r=this.sliceBack(i)),s.length>0&&!a((t=s[0])==null?void 0:t.codePointAt(0)))throw new n({type:"InvalidName"},this.genTextPosFrom(i));if(r.length>0){if(!a((e=r[0])==null?void 0:e.codePointAt(0)))throw new n({type:"InvalidName"},this.genTextPosFrom(i))}else throw new n({type:"InvalidName"},this.genTextPosFrom(i));return[s,r]}consumeQuote(){const t=this.currCodeUnit();if(t===P||t===v)return this._pos+=1,t;throw new n({type:"InvalidChar",expected:"a quote",actual:t},this.genTextPos())}genTextPos(){return this.genTextPosFrom(this._pos)}genTextPosFrom(t){const e=Math.min(t,this._end);let i=1,o=1;for(let s=0;s<e;s++)this._text.charCodeAt(s)===N?(i++,o=1):o++;return{row:i,col:o}}}export{l as XmlStream};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const E=9,A=10,R=13,S=32,O=33,_=34,C=35,N=37,P=38,L=39,T=45,U=46,I=47,H=48,D=57,M=58,Q=59,W=60,Z=61,B=62,F=63,G=65,K=70,o=80,t=83,X=90,c=91,e=95,n=97,p=102,r=120,s=122;export{P as AMPERSAND,R as CARRIAGE_RETURN,M as COLON,_ as DOUBLE_QUOTE,Z as EQUALS,O as EXCLAMATION_MARK,B as GREATER_THAN,C as HASH,E as HORIZONTAL_TAB,T as HYPHEN,W as LESS_THAN,A as LINE_FEED,n as LOWERCASE_A,p as LOWERCASE_F,r as LOWERCASE_X,s as LOWERCASE_Z,D as NINE,c as OPEN_BRACKET,N as PERCENT,U as PERIOD,F as QUESTION_MARK,Q as SEMICOLON,L as SINGLE_QUOTE,I as SLASH,S as SPACE,e as UNDERSCORE,G as UPPERCASE_A,K as UPPERCASE_F,o as UPPERCASE_P,t as UPPERCASE_S,X as UPPERCASE_Z,H as ZERO};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LESS_THAN as C,GREATER_THAN as r,OPEN_BRACKET as W,PERCENT as y,DOUBLE_QUOTE as x,SINGLE_QUOTE as v,UPPERCASE_S as I,UPPERCASE_P as N,SLASH as S,EQUALS as A,EXCLAMATION_MARK as F,QUESTION_MARK as L}from"./
|
|
1
|
+
import{LESS_THAN as C,GREATER_THAN as r,OPEN_BRACKET as W,PERCENT as y,DOUBLE_QUOTE as x,SINGLE_QUOTE as v,UPPERCASE_S as I,UPPERCASE_P as N,SLASH as S,EQUALS as A,EXCLAMATION_MARK as F,QUESTION_MARK as L}from"./ascii-constants.js";import{XmlError as i}from"./XmlError.js";import{XmlStream as Q}from"./XmlStream.js";function O(t,n,s){k(new Q(t),n,s)}function k(t,n,s){if(t.startsWith("\uFEFF")&&t.advance(1),t.startsWith("<?xml ")&&D(t),m(t,s),t.skipSpaces(),t.startsWith("<!DOCTYPE")){if(!n)throw new i({type:"DtdDetected"});_(t,s),m(t,s)}if(t.skipSpaces(),!t.atEnd()&&t.currCodeUnit()===C&&U(t,s),m(t,s),!t.atEnd())throw new i({type:"UnknownToken",message:"Not at end"},t.genTextPos())}function m(t,n){for(;!t.atEnd();)if(t.skipSpaces(),t.startsWith("<!--"))f(t,n);else if(t.startsWith("<?"))g(t,n);else break}function D(t){if(t.advance(5),h(t),!t.startsWith("version"))throw new i({type:"InvalidString",expected:"version"},t.genTextPos());u(t),h(t),t.startsWith("encoding")&&(u(t),h(t)),t.startsWith("standalone")&&u(t),t.skipSpaces(),t.skipString("?>")}function h(t){if(t.startsWithSpace())t.skipSpaces();else if(!t.startsWith("?>")&&!t.atEnd())throw new i({type:"InvalidChar",expected:"a whitespace",actual:t.currCodeUnitUnchecked()},t.genTextPos())}function f(t,n){const s=t.getPos();t.advance(4);const o=t.consumeCharsWhile((e,a)=>!(a==="-"&&e.startsWith("-->")));if(t.skipString("-->"),o.includes("--")||o.endsWith("-"))throw new i({type:"InvalidComment"},t.genTextPosFrom(s));n({type:"Comment",text:o,range:t.rangeFrom(s)})}function g(t,n){if(t.startsWith("<?xml "))throw new i({type:"UnexpectedDeclaration"},t.genTextPos());const s=t.getPos();t.advance(2);const o=t.consumeName();t.skipSpaces();const e=t.consumeCharsWhile((a,c)=>!(c==="?"&&a.startsWith("?>")));t.skipString("?>"),n({type:"ProcessingInstruction",target:o,content:e.length===0?void 0:e,range:t.rangeFrom(s)})}function _(t,n){const s=t.getPos();if(B(t),t.skipSpaces(),t.currCodeUnit()===r){t.advance(1);return}for(t.advance(1);!t.atEnd();)if(t.skipSpaces(),t.startsWith("<!ENTITY"))R(t,n);else if(t.startsWith("<!--"))f(t,n);else if(t.startsWith("<?"))g(t,n);else if(t.startsWith("]"))if(t.advance(1),t.skipSpaces(),t.currCodeUnit()===r){t.advance(1);break}else throw new i({type:"InvalidChar",expected:"'>'",actual:t.currCodeUnitUnchecked()},t.genTextPos());else if(t.startsWith("<!ELEMENT")||t.startsWith("<!ATTLIST")||t.startsWith("<!NOTATION"))try{M(t)}catch(o){throw new i({type:"UnknownToken",message:"Failed to consume declaration"},t.genTextPosFrom(s))}else throw new i({type:"UnknownToken",message:"Failed to parse doctype"},t.genTextPos())}function B(t){t.advance(9),t.consumeSpaces(),t.skipName(),t.skipSpaces(),E(t),t.skipSpaces();const n=t.currCodeUnit();if(n!==W&&n!==r)throw new i({type:"InvalidChar",expected:"'[' or '>'",actual:n},t.genTextPos())}function E(t){if(t.startsWith("SYSTEM")||t.startsWith("PUBLIC")){const n=t.getPos();t.advance(6);const s=t.sliceBack(n);t.consumeSpaces();const o=t.consumeQuote();if(t.consumeCodeUnitsWhile(e=>e!==o),t.consumeCodeUnit(o),s==="PUBLIC"){t.consumeSpaces();const e=t.consumeQuote();t.consumeCodeUnitsWhile(a=>a!==e),t.consumeCodeUnit(e)}return!0}return!1}function R(t,n){t.advance(8),t.consumeSpaces();const s=!t.tryConsumeCodeUnit(y);s||t.consumeSpaces();const o=t.consumeName();t.consumeSpaces();const e=b(t,s);e!==null&&n({type:"EntityDeclaration",name:o,definition:e}),t.skipSpaces(),t.consumeCodeUnit(r)}function b(t,n){const s=t.currCodeUnit();if(s===x||s===v){const o=t.consumeQuote(),e=t.getPos();t.skipCodeUnitsWhile(c=>c!==o);const a=t.sliceBack(e);return t.consumeCodeUnit(o),a}else if(s===I||s===N){if(E(t))return n&&(t.skipSpaces(),t.startsWith("NDATA")&&(t.advance(5),t.consumeSpaces(),t.skipName())),null;throw new i({type:"InvalidExternalID"},t.genTextPos())}else throw new i({type:"InvalidChar",expected:"a quote, SYSTEM or PUBLIC",actual:s},t.genTextPos())}function M(t){t.skipCodeUnitsWhile(n=>n!==r),t.consumeCodeUnit(r)}function U(t,n){const s=t.getPos();t.advance(1);const[o,e]=t.consumeQName();n({type:"ElementStart",prefix:o,local:e,start:s});let a=!1;for(;!t.atEnd();){const c=t.startsWithSpace();t.skipSpaces();const d=t.getPos(),l=t.currCodeUnit();if(l===S){t.advance(1),t.consumeCodeUnit(r);const p=t.rangeFrom(d);n({type:"ElementEnd",end:{type:"Empty"},range:p});break}else if(l===r){t.advance(1);const p=t.rangeFrom(d);n({type:"ElementEnd",end:{type:"Open"},range:p}),a=!0;break}else{if(!c)throw new i({type:"InvalidChar",expected:"a whitespace",actual:t.currCodeUnitUnchecked()},t.genTextPos());const[p,T,P]=u(t),w=t.getPos();n({type:"Attribute",range:{start:d,end:w},prefix:p,local:T,value:P})}}a&&X(t,n)}function u(t){const[n,s]=t.consumeQName();let o;const e=t.getPos();if(t.skipSpaces(),t.tryConsumeCodeUnit(A)){t.skipSpaces();const a=t.consumeQuote(),c=String.fromCharCode(a),d=t.getPos();t.skipCharsWhile((l,p)=>p!==c&&p!=="<"),o=t.sliceBack(d),t.consumeCodeUnit(a)}else t.goTo(e),o="true";return[n,s,o]}function X(t,n){for(;!t.atEnd();)if(t.currCodeUnit()===C){const s=t.nextCodeUnit();if(s===F)if(t.startsWith("<!--"))f(t,n);else if(t.startsWith("<![CDATA["))Y(t,n);else throw new i({type:"UnknownToken",message:"Failed to parse content"},t.genTextPos());else if(s===L)g(t,n);else if(s===S){H(t,n);break}else U(t,n)}else K(t,n)}function Y(t,n){const s=t.getPos();t.advance(9);const o=t.consumeCharsWhile((a,c)=>!(c==="]"&&a.startsWith("]]>")));t.skipString("]]>");const e=t.rangeFrom(s);n({type:"Cdata",text:o,range:e})}function H(t,n){const s=t.getPos();t.advance(2);const[o,e]=t.consumeQName();t.skipSpaces(),t.consumeCodeUnit(r);const a=t.rangeFrom(s);n({type:"ElementEnd",end:{type:"Close",prefix:o,local:e},range:a})}function K(t,n){const s=t.getPos(),o=t.consumeCharsWhile((e,a)=>a!=="<");if(o.includes(">")&&o.includes("]]>"))throw new i({type:"InvalidCharacterData"},t.genTextPos());n({type:"Text",text:o,range:t.rangeFrom(s)})}export{O as tokenize,k as tokenizeXmlStream};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ZERO as E,NINE as t,UPPERCASE_A as i,UPPERCASE_Z as r,LOWERCASE_A as u,LOWERCASE_Z as e,COLON as R,UNDERSCORE as A,SPACE as m,HORIZONTAL_TAB as o,LINE_FEED as C,CARRIAGE_RETURN as O,HYPHEN as c,PERIOD as S}from"./ascii-constants.js";function s(n){return n>=E&&n<=t}function P(n){return n==null?!1:n<=128?n>=i&&n<=r||n>=u&&n<=e||n===R||n===A:n>=192&&n<=214||n>=216&&n<=246||n>=248&&n<=767||n>=880&&n<=893||n>=895&&n<=8191||n>=8204&&n<=8205||n>=8304&&n<=8591||n>=11264&&n<=12271||n>=12289&&n<=55295||n>=63744&&n<=64975||n>=65008&&n<=65533||n>=65536&&n<=983039}function _(n){return n==null?!1:n<=128?N(n):n===183||n>=192&&n<=214||n>=216&&n<=246||n>=248&&n<=767||n>=768&&n<=879||n>=880&&n<=893||n>=895&&n<=8191||n>=8204&&n<=8205||n>=8255&&n<=8256||n>=8304&&n<=8591||n>=11264&&n<=12271||n>=12289&&n<=55295||n>=63744&&n<=64975||n>=65008&&n<=65533||n>=65536&&n<=983039}function a(n){return n==null?!1:n<32?l(n):n!==65535&&n!==65534}function l(n){return n===m||n===o||n===C||n===O}function N(n){return n>=E&&n<=t||n>=i&&n<=r||n>=u&&n<=e||n===R||n===A||n===c||n===S}export{s as isAsciiDigit,a as isXmlChar,_ as isXmlName,N as isXmlNameByte,P as isXmlNameStart,l as isXmlSpaceByte};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{tokenToXml as e}from"./token-to-xml.js";function n(t){let o="";return t.forEach(r=>{o+=e(r)}),o}export{n as tokensToXml};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs a qualified name (QName) from a local name and an optional namespace prefix.
|
|
3
|
+
*
|
|
4
|
+
* https://www.w3.org/2001/tag/doc/qnameids.html
|
|
5
|
+
*/
|
|
1
6
|
export declare function getQName(local: string, prefix?: string | null): string;
|
|
2
7
|
//# sourceMappingURL=get-q-name.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-q-name.d.ts","sourceRoot":"","sources":["../../src/get-q-name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-q-name.d.ts","sourceRoot":"","sources":["../../src/get-q-name.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CAE5E"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type TTokenSelectPathSegment } from './types';
|
|
2
2
|
export declare class TokenSelectState {
|
|
3
|
-
private
|
|
3
|
+
private _segment;
|
|
4
4
|
private _matchCriteria;
|
|
5
5
|
private _toCacheNodeProps;
|
|
6
6
|
private _enteredDepth;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(segment: TTokenSelectPathSegment);
|
|
8
8
|
get matchCriteria(): ETokenMatchCriteria;
|
|
9
9
|
get toCacheNodeProps(): EToCacheNodeProps;
|
|
10
10
|
get enteredDepth(): number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenSelectState.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"TokenSelectState.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,cAAc,CAAiD;IACvE,OAAO,CAAC,iBAAiB,CAA6C;IACtE,OAAO,CAAC,aAAa,CAAuB;gBAEhC,OAAO,EAAE,uBAAuB;IAK5C,IAAW,aAAa,IAAI,mBAAmB,CAE9C;IAED,IAAW,gBAAgB,IAAI,iBAAiB,CAE/C;IAED,IAAW,YAAY,IAAI,MAAM,GAAG,IAAI,CAEvC;IAED,OAAO,CAAC,WAAW;IAuBZ,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAWnD,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO;IAe9D,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IASzD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1B,OAAO,IAAI,IAAI;CAGtB;AAED,0BAAkB,iBAAiB;IAClC,IAAI,IAAI,CAAE,aAAa;IACvB,IAAI,IAAS,CAAE,uCAAuC;IACtD,UAAU,IAAS,CAAE,+CAA+C;IACpE,IAAI,IAAS;CACb;AAED,0BAAkB,mBAAmB;IACpC,IAAI,IAAI,CAAE,aAAa;IACvB,IAAI,IAAS,CAAE,uCAAuC;IACtD,UAAU,IAAS,CAAE,+CAA+C;IACpE,IAAI,IAAS,CAAE,sDAAsD;IACrE,IAAI,IAAS;CACb"}
|
|
@@ -4,8 +4,6 @@ import { type TTokenSelectPath } from './types';
|
|
|
4
4
|
export declare class TokenSelectStateMachine {
|
|
5
5
|
private _states;
|
|
6
6
|
private _currentState;
|
|
7
|
-
private _hasActiveCache;
|
|
8
|
-
private _toCacheNodeProps;
|
|
9
7
|
private _cachedNodeProps;
|
|
10
8
|
private _cachedTokens;
|
|
11
9
|
private _toRecordTokens;
|
|
@@ -20,6 +18,7 @@ export declare class TokenSelectStateMachine {
|
|
|
20
18
|
private transitionForward;
|
|
21
19
|
transitionBack(depth: number): void;
|
|
22
20
|
isFinalState(): boolean;
|
|
21
|
+
getOffsetToFinal(): number;
|
|
23
22
|
resetCurrentStateCache(): void;
|
|
24
23
|
}
|
|
25
24
|
//# sourceMappingURL=TokenSelectStateMachine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenSelectStateMachine.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectStateMachine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAA0C,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,qBAAa,uBAAuB;IACnC,OAAO,CAAC,OAAO,CAAqB;IAGpC,OAAO,CAAC,aAAa,CAAuB;IAG5C,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"TokenSelectStateMachine.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectStateMachine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAA0C,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,qBAAa,uBAAuB;IACnC,OAAO,CAAC,OAAO,CAAqB;IAGpC,OAAO,CAAC,aAAa,CAAuB;IAG5C,OAAO,CAAC,gBAAgB,CAKtB;IACF,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,eAAe,CAAmB;gBAE9B,eAAe,EAAE,gBAAgB;IAItC,YAAY,IAAI,gBAAgB,GAAG,IAAI;IAQvC,eAAe,IAAI,gBAAgB,GAAG,IAAI;IAO1C,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAM9B,kBAAkB,IAAI,SAAS,EAAE,GAAG,IAAI;IASxC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IA8B5E,2BAA2B,CACjC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,OAAO;IA4BH,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAwBlE,OAAO,CAAC,iBAAiB;IAmBlB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAgBnC,YAAY,IAAI,OAAO;IAIvB,gBAAgB,IAAI,MAAM;IAO1B,sBAAsB,IAAI,IAAI;CAOrC"}
|
|
@@ -1,45 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This interface allows for constructing XPath expressions in a object-oriented way,
|
|
5
|
-
* avoiding the complexities of parsing a full XPath string.
|
|
6
|
-
* If parsing a full XPath becomes necessary in the future, a tool like [Peggy](https://github.com/peggyjs/peggy)
|
|
7
|
-
* could be used to facilitate the process.
|
|
8
|
-
*
|
|
9
|
-
* https://www.w3.org/TR/xpath-31/
|
|
2
|
+
* A limited segment of an XPath expression in an object-oriented manner.
|
|
10
3
|
*
|
|
11
4
|
* @example
|
|
12
5
|
* // Represents the XPath expression `/bookstore/book[@category='fiction'][1]`
|
|
13
|
-
* const xpathExpr:
|
|
14
|
-
* \{ axis: '/',
|
|
6
|
+
* const xpathExpr: TTokenSelectPath = [
|
|
7
|
+
* \{ axis: '/', local: 'bookstore' \},
|
|
15
8
|
* \{
|
|
16
9
|
* axis: '/',
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* position: 1
|
|
20
|
-
* attributes: ['category', 'lang'] // Selects the 'category' and 'lang' attributes
|
|
10
|
+
* local: 'book',
|
|
11
|
+
* attributes: [\{ local: 'category', value: 'fiction' \}],
|
|
12
|
+
* position: 1
|
|
21
13
|
* \}
|
|
22
14
|
* ];
|
|
23
15
|
*/
|
|
24
|
-
export interface
|
|
16
|
+
export interface TTokenSelectPathSegment {
|
|
25
17
|
/**
|
|
26
|
-
*
|
|
18
|
+
* Specifies the axis defining the relationship between nodes.
|
|
19
|
+
*
|
|
20
|
+
* - 'child' ('/'): Selects all children of the current node
|
|
21
|
+
* - 'self-or-descendant' ('//'): Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself
|
|
27
22
|
*/
|
|
28
23
|
axis: 'child' | 'self-or-descendant';
|
|
29
24
|
/**
|
|
30
|
-
* The
|
|
25
|
+
* The local name of the node to match.
|
|
26
|
+
*
|
|
27
|
+
* Use '*' to match any node.
|
|
31
28
|
*/
|
|
32
29
|
local?: string | '*';
|
|
33
30
|
/**
|
|
34
|
-
* An optional prefix
|
|
31
|
+
* An optional namespace prefix to qualify the node name.
|
|
35
32
|
*/
|
|
36
33
|
prefix?: string;
|
|
37
34
|
/**
|
|
38
|
-
*
|
|
35
|
+
* Optional filters based on node attributes.
|
|
39
36
|
*
|
|
40
37
|
* @example
|
|
41
|
-
* // Matches a
|
|
42
|
-
*
|
|
38
|
+
* // Matches a node with an attribute 'category' equal to 'fiction'
|
|
39
|
+
* attributes: [\{ local: 'category', value: 'fiction' \}]
|
|
43
40
|
*/
|
|
44
41
|
attributes?: {
|
|
45
42
|
local: string;
|
|
@@ -47,19 +44,32 @@ export interface TTokenSelectPathPart {
|
|
|
47
44
|
value?: string;
|
|
48
45
|
}[];
|
|
49
46
|
/**
|
|
50
|
-
*
|
|
47
|
+
* Optional filter to match nodes containing specific text content.
|
|
48
|
+
*
|
|
49
|
+
* Currenlty only plain text can be matched.
|
|
50
|
+
* Text with sub nodes like <b/>, <strong/> can't be matched as of now.
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
|
-
* // Matches
|
|
54
|
-
*
|
|
53
|
+
* // Matches nodes containing the text 'bestseller'
|
|
54
|
+
* containsText: 'bestseller'
|
|
55
55
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
containsText?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Optional custom predicate function to further filter nodes.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Custom predicate to match nodes with specific characteristics
|
|
62
|
+
* predicate: (node) =\> node.local === 'title'
|
|
63
|
+
*/
|
|
64
|
+
predicate?: (node: {
|
|
65
|
+
local: string;
|
|
66
|
+
prefix?: string;
|
|
67
|
+
attributes: Record<string, string>;
|
|
68
|
+
text?: string;
|
|
69
|
+
}) => boolean;
|
|
58
70
|
}
|
|
59
71
|
/**
|
|
60
|
-
*
|
|
61
|
-
* The expression is an array of `TXPathPart` objects, each defining
|
|
62
|
-
* a segment of the XPath.
|
|
72
|
+
* A limited XPath expression composed of multiple segments in an object-oriented manner.
|
|
63
73
|
*/
|
|
64
|
-
export type TTokenSelectPath =
|
|
74
|
+
export type TTokenSelectPath = TTokenSelectPathSegment[];
|
|
65
75
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/selector/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/selector/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAAC;IAErC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAElE;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,KAAK,OAAO,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-to-xml.d.ts","sourceRoot":"","sources":["../../src/token-to-xml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAgDnD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TRange, type TReference, type TTextPos } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* A stream of characters for parsing XML-like content.
|
|
4
4
|
*
|
|
5
5
|
* This implementation uses UTF-16 code units, whereas the Rust implementation is based on bytes (UTF-8).
|
|
6
6
|
* This difference in encoding affects how characters are handled and parsed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XmlStream.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/XmlStream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XmlStream.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/XmlStream.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAItE;;;;;;GAMG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;gBAEF,IAAI,EAAE,MAAM,EAAE,GAAG,SAAI;IAMxC;;;;OAIG;IACI,KAAK,IAAI,SAAS;IAIzB;;;;OAIG;IACI,MAAM,IAAI,MAAM;IAIvB;;;;OAIG;IACI,KAAK,IAAI,OAAO;IAIvB;;;;;OAKG;IACI,YAAY,IAAI,MAAM;IAO7B;;;;OAIG;IACI,qBAAqB,IAAI,MAAM;IAItC;;;;;OAKG;IACI,YAAY,IAAI,MAAM;IAO7B;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;OAIG;IACI,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI9B;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIxC;;;;;OAKG;IACI,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAW9C;;;;;;OAMG;IACI,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQpD;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAOrC;;;;;OAKG;IACI,qBAAqB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM;IAM9E;;;;OAIG;IACI,kBAAkB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI;IAMzE;;;;;;OAMG;IACI,iBAAiB,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM;IAMzF;;;;;OAKG;IACI,cAAc,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI;IAapF;;;;;OAKG;IACI,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIrC;;;;;OAKG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIvC;;OAEG;IACI,UAAU,IAAI,IAAI;IAMzB;;;;OAIG;IACI,eAAe,IAAI,OAAO;IAIjC;;;;;OAKG;IACI,aAAa,IAAI,IAAI;IAe5B;;;;;OAKG;IACI,mBAAmB,IAAI,UAAU,GAAG,IAAI;IAiB/C;;;;OAIG;IACI,gBAAgB,IAAI,UAAU,GAAG,IAAI;IA4D5C;;;;;;OAMG;IACI,WAAW,IAAI,MAAM;IAY5B;;;;OAIG;IACI,QAAQ,IAAI,IAAI;IAgBvB;;;;;;OAMG;IACI,YAAY,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAiDvC;;;;;OAKG;IACI,YAAY,IAAI,MAAM;IAY7B;;;;;OAKG;IACI,UAAU,IAAI,QAAQ;IAI7B;;;;;;OAMG;IACI,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;CAc5C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const HORIZONTAL_TAB = 9;
|
|
2
|
+
export declare const LINE_FEED = 10;
|
|
3
|
+
export declare const CARRIAGE_RETURN = 13;
|
|
4
|
+
export declare const SPACE = 32;
|
|
5
|
+
export declare const EXCLAMATION_MARK = 33;
|
|
6
|
+
export declare const DOUBLE_QUOTE = 34;
|
|
7
|
+
export declare const HASH = 35;
|
|
8
|
+
export declare const PERCENT = 37;
|
|
9
|
+
export declare const AMPERSAND = 38;
|
|
10
|
+
export declare const SINGLE_QUOTE = 39;
|
|
11
|
+
export declare const HYPHEN = 45;
|
|
12
|
+
export declare const PERIOD = 46;
|
|
13
|
+
export declare const SLASH = 47;
|
|
14
|
+
export declare const ZERO = 48;
|
|
15
|
+
export declare const NINE = 57;
|
|
16
|
+
export declare const COLON = 58;
|
|
17
|
+
export declare const SEMICOLON = 59;
|
|
18
|
+
export declare const LESS_THAN = 60;
|
|
19
|
+
export declare const EQUALS = 61;
|
|
20
|
+
export declare const GREATER_THAN = 62;
|
|
21
|
+
export declare const QUESTION_MARK = 63;
|
|
22
|
+
export declare const UPPERCASE_A = 65;
|
|
23
|
+
export declare const UPPERCASE_F = 70;
|
|
24
|
+
export declare const UPPERCASE_P = 80;
|
|
25
|
+
export declare const UPPERCASE_S = 83;
|
|
26
|
+
export declare const UPPERCASE_Z = 90;
|
|
27
|
+
export declare const OPEN_BRACKET = 91;
|
|
28
|
+
export declare const UNDERSCORE = 95;
|
|
29
|
+
export declare const LOWERCASE_A = 97;
|
|
30
|
+
export declare const LOWERCASE_F = 102;
|
|
31
|
+
export declare const LOWERCASE_X = 120;
|
|
32
|
+
export declare const LOWERCASE_Z = 122;
|
|
33
|
+
//# sourceMappingURL=ascii-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ascii-constants.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/ascii-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,OAAO,KAAK,CAAC;AAC1B,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,MAAM,KAAK,CAAC;AACzB,eAAO,MAAM,MAAM,KAAK,CAAC;AACzB,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,MAAM,KAAK,CAAC;AACzB,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,WAAW,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenize.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/tokenize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokenize.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/tokenize.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,wBAAgB,QAAQ,CACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,cAAc,GAC3B,IAAI,CAEN;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,CAAC,EAAE,SAAS,EACZ,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,cAAc,GAC3B,IAAI,CAgCN"}
|
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
export declare const HORIZONTAL_TAB = 9;
|
|
2
|
-
export declare const LINE_FEED = 10;
|
|
3
|
-
export declare const CARRIAGE_RETURN = 13;
|
|
4
|
-
export declare const SPACE = 32;
|
|
5
|
-
export declare const EXCLAMATION_MARK = 33;
|
|
6
|
-
export declare const DOUBLE_QUOTE = 34;
|
|
7
|
-
export declare const HASH = 35;
|
|
8
|
-
export declare const PERCENT = 37;
|
|
9
|
-
export declare const AMPERSAND = 38;
|
|
10
|
-
export declare const SINGLE_QUOTE = 39;
|
|
11
|
-
export declare const HYPHEN = 45;
|
|
12
|
-
export declare const PERIOD = 46;
|
|
13
|
-
export declare const SLASH = 47;
|
|
14
|
-
export declare const ZERO = 48;
|
|
15
|
-
export declare const NINE = 57;
|
|
16
|
-
export declare const COLON = 58;
|
|
17
|
-
export declare const SEMICOLON = 59;
|
|
18
|
-
export declare const LESS_THAN = 60;
|
|
19
|
-
export declare const EQUALS = 61;
|
|
20
|
-
export declare const GREATER_THAN = 62;
|
|
21
|
-
export declare const QUESTION_MARK = 63;
|
|
22
|
-
export declare const UPPERCASE_A = 65;
|
|
23
|
-
export declare const UPPERCASE_F = 70;
|
|
24
|
-
export declare const UPPERCASE_P = 80;
|
|
25
|
-
export declare const UPPERCASE_S = 83;
|
|
26
|
-
export declare const UPPERCASE_Z = 90;
|
|
27
|
-
export declare const OPEN_BRACKET = 91;
|
|
28
|
-
export declare const UNDERSCORE = 95;
|
|
29
|
-
export declare const LOWERCASE_A = 97;
|
|
30
|
-
export declare const LOWERCASE_F = 102;
|
|
31
|
-
export declare const LOWERCASE_X = 120;
|
|
32
|
-
export declare const LOWERCASE_Z = 122;
|
|
33
1
|
export declare function isAsciiDigit(byte: number): boolean;
|
|
34
2
|
/**
|
|
35
3
|
* Checks if the unicode code point (character) is within the name start char range.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokenizer/utils.ts"],"names":[],"mappings":"AAiBA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CA6BrE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CA2BhE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAUhE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIpD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens-to-xml.d.ts","sourceRoot":"","sources":["../../src/tokens-to-xml.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokens-to-xml.d.ts","sourceRoot":"","sources":["../../src/tokens-to-xml.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAQvD"}
|