xml-tokenizer 0.0.28 → 0.0.29
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=require("./TokenSelectState.js"),o=require("./TokenSelectStateMachine.js"),u=Object.defineProperty,f=(r,e,t)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,s=(r,e,t)=>f(r,typeof e!="symbol"?e+"":e,t);class S{constructor(e){s(this,"_currentDepth",0),s(this,"_tspStateMachines"),s(this,"_isRecording",!1),this._tspStateMachines=e.map(t=>new o.TokenSelectStateMachine(t))}pipeToken(e,t){let n=!1,i=!1;switch(e.type){case"ElementStart":n=this.handleElementStart(e);break;case"Attribute":n=this.handleAttribute(e);break;case"Text":n=this.handleText(e);break;case"ElementEnd":{i=this.handleElementEnd(e);break}}n&&!this._isRecording&&(this._isRecording=!0,t({type:"SelectionStart"}));for(const c of this._tspStateMachines){c.record(e);const l=c.takeRecordedTokens();l!=null&&l.forEach(h=>{t(h)})}this._isRecording&&t(e),i&&(t({type:"SelectionEnd"}),this._isRecording=!1)}handleElementStart(e){this._currentDepth+=1;let t=!1;for(const n of this._tspStateMachines){if(n.resetCurrentStateCache(),n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.ETokenMatchCriteria.Name)||n.transitionIfNameMatch(e.local,e.prefix,this._currentDepth)&&n.isFinalState()&&(t=!0)}return t}handleAttribute(e){let t=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.ETokenMatchCriteria.Attributes)||n.transitionIfAttributesMatch(e.local,e.prefix,e.value,this._currentDepth)&&n.isFinalState()&&(t=!0)}return t}handleText(e){let t=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.ETokenMatchCriteria.Text)||n.transitionIfTextMatch(e.text,this._currentDepth)&&n.isFinalState()&&(t=!0)}return t}handleElementEnd(e){if(e.end.type==="Close"||e.end.type==="Empty"){this._currentDepth-=1;let t=!1;for(const n of this._tspStateMachines){const i=n.getCurrentState();i!=null&&(i.enteredDepth!=null&&this._currentDepth<i.enteredDepth&&n.transitionBack(this._currentDepth),t=t||n.isFinalState())}return!t}return!1}}exports.TokenSelector=S;
|
|
1
|
+
"use strict";var a=require("./TokenSelectState.js"),o=require("./TokenSelectStateMachine.js"),u=Object.defineProperty,f=(r,e,t)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,s=(r,e,t)=>f(r,typeof e!="symbol"?e+"":e,t);class S{constructor(e){s(this,"_currentDepth",0),s(this,"_tspStateMachines"),s(this,"_isRecording",!1),this._tspStateMachines=e.map(t=>new o.TokenSelectStateMachine(t))}pipeToken(e,t){let n=!1,i=!1;switch(e.type){case"ElementStart":n=this.handleElementStart(e);break;case"Attribute":n=this.handleAttribute(e);break;case"Text":n=this.handleText(e);break;case"ElementEnd":{i=this.handleElementEnd(e);break}}n&&!this._isRecording&&(this._isRecording=!0,t({type:"SelectionStart"}));for(const c of this._tspStateMachines){c.record(e);const l=c.takeRecordedTokens();l!=null&&l.forEach(h=>{t(h)})}this._isRecording&&t(e),i&&this._isRecording&&(t({type:"SelectionEnd"}),this._isRecording=!1)}handleElementStart(e){this._currentDepth+=1;let t=!1;for(const n of this._tspStateMachines){if(n.resetCurrentStateCache(),n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.ETokenMatchCriteria.Name)||n.transitionIfNameMatch(e.local,e.prefix,this._currentDepth)&&n.isFinalState()&&(t=!0)}return t}handleAttribute(e){let t=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.ETokenMatchCriteria.Attributes)||n.transitionIfAttributesMatch(e.local,e.prefix,e.value,this._currentDepth)&&n.isFinalState()&&(t=!0)}return t}handleText(e){let t=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.ETokenMatchCriteria.Text)||n.transitionIfTextMatch(e.text,this._currentDepth)&&n.isFinalState()&&(t=!0)}return t}handleElementEnd(e){if(e.end.type==="Close"||e.end.type==="Empty"){this._currentDepth-=1;let t=!1;for(const n of this._tspStateMachines){const i=n.getCurrentState();i!=null&&(i.enteredDepth!=null&&this._currentDepth<i.enteredDepth&&n.transitionBack(this._currentDepth),t=t||n.isFinalState())}return!t}return!1}}exports.TokenSelector=S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ETokenMatchCriteria as a}from"./TokenSelectState.js";import{TokenSelectStateMachine as o}from"./TokenSelectStateMachine.js";var u=Object.defineProperty,f=(r,t,e)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,s=(r,t,e)=>f(r,typeof t!="symbol"?t+"":t,e);class p{constructor(t){s(this,"_currentDepth",0),s(this,"_tspStateMachines"),s(this,"_isRecording",!1),this._tspStateMachines=t.map(e=>new o(e))}pipeToken(t,e){let n=!1,i=!1;switch(t.type){case"ElementStart":n=this.handleElementStart(t);break;case"Attribute":n=this.handleAttribute(t);break;case"Text":n=this.handleText(t);break;case"ElementEnd":{i=this.handleElementEnd(t);break}}n&&!this._isRecording&&(this._isRecording=!0,e({type:"SelectionStart"}));for(const c of this._tspStateMachines){c.record(t);const l=c.takeRecordedTokens();l!=null&&l.forEach(h=>{e(h)})}this._isRecording&&e(t),i&&(e({type:"SelectionEnd"}),this._isRecording=!1)}handleElementStart(t){this._currentDepth+=1;let e=!1;for(const n of this._tspStateMachines){if(n.resetCurrentStateCache(),n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.Name)||n.transitionIfNameMatch(t.local,t.prefix,this._currentDepth)&&n.isFinalState()&&(e=!0)}return e}handleAttribute(t){let e=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.Attributes)||n.transitionIfAttributesMatch(t.local,t.prefix,t.value,this._currentDepth)&&n.isFinalState()&&(e=!0)}return e}handleText(t){let e=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.Text)||n.transitionIfTextMatch(t.text,this._currentDepth)&&n.isFinalState()&&(e=!0)}return e}handleElementEnd(t){if(t.end.type==="Close"||t.end.type==="Empty"){this._currentDepth-=1;let e=!1;for(const n of this._tspStateMachines){const i=n.getCurrentState();i!=null&&(i.enteredDepth!=null&&this._currentDepth<i.enteredDepth&&n.transitionBack(this._currentDepth),e=e||n.isFinalState())}return!e}return!1}}export{p as TokenSelector};
|
|
1
|
+
import{ETokenMatchCriteria as a}from"./TokenSelectState.js";import{TokenSelectStateMachine as o}from"./TokenSelectStateMachine.js";var u=Object.defineProperty,f=(r,t,e)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,s=(r,t,e)=>f(r,typeof t!="symbol"?t+"":t,e);class p{constructor(t){s(this,"_currentDepth",0),s(this,"_tspStateMachines"),s(this,"_isRecording",!1),this._tspStateMachines=t.map(e=>new o(e))}pipeToken(t,e){let n=!1,i=!1;switch(t.type){case"ElementStart":n=this.handleElementStart(t);break;case"Attribute":n=this.handleAttribute(t);break;case"Text":n=this.handleText(t);break;case"ElementEnd":{i=this.handleElementEnd(t);break}}n&&!this._isRecording&&(this._isRecording=!0,e({type:"SelectionStart"}));for(const c of this._tspStateMachines){c.record(t);const l=c.takeRecordedTokens();l!=null&&l.forEach(h=>{e(h)})}this._isRecording&&e(t),i&&this._isRecording&&(e({type:"SelectionEnd"}),this._isRecording=!1)}handleElementStart(t){this._currentDepth+=1;let e=!1;for(const n of this._tspStateMachines){if(n.resetCurrentStateCache(),n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.Name)||n.transitionIfNameMatch(t.local,t.prefix,this._currentDepth)&&n.isFinalState()&&(e=!0)}return e}handleAttribute(t){let e=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.Attributes)||n.transitionIfAttributesMatch(t.local,t.prefix,t.value,this._currentDepth)&&n.isFinalState()&&(e=!0)}return e}handleText(t){let e=!1;for(const n of this._tspStateMachines){if(n.isFinalState())continue;const i=n.getNextState();i==null||!(i.matchCriteria&a.Text)||n.transitionIfTextMatch(t.text,this._currentDepth)&&n.isFinalState()&&(e=!0)}return e}handleElementEnd(t){if(t.end.type==="Close"||t.end.type==="Empty"){this._currentDepth-=1;let e=!1;for(const n of this._tspStateMachines){const i=n.getCurrentState();i!=null&&(i.enteredDepth!=null&&this._currentDepth<i.enteredDepth&&n.transitionBack(this._currentDepth),e=e||n.isFinalState())}return!e}return!1}}export{p as TokenSelector};
|