xml-tokenizer 0.0.27 → 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
- "use strict";var k=require("../tokenizer/tokenize.js"),l=require("./TokenSelector.js");function s(e,t,n,o){const r=new l.TokenSelector(t);k.tokenize(e,c=>{r.pipeToken(c,i=>{n(i)})},o)}exports.select=s;
1
+ "use strict";var l=require("../tokenizer/tokenize.js"),s=require("./TokenSelector.js");function u(e,t,n,o){const r=new s.TokenSelector(t);l.tokenize(e,(c,i)=>{r.pipeToken(c,k=>{n(k,i)})},o)}exports.select=u;
@@ -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};
@@ -1 +1 @@
1
- import{tokenize as c}from"../tokenizer/tokenize.js";import{TokenSelector as m}from"./TokenSelector.js";function f(e,o,t,n){const r=new m(o);c(e,i=>{r.pipeToken(i,p=>{t(p)})},n)}export{f as select};
1
+ import{tokenize as m}from"../tokenizer/tokenize.js";import{TokenSelector as f}from"./TokenSelector.js";function k(e,o,t,n){const r=new f(o);m(e,(i,p)=>{r.pipeToken(i,c=>{t(c,p)})},n)}export{k as select};
@@ -1,4 +1,4 @@
1
- import { type TXmlToken } from '../tokenizer';
1
+ import { XmlStream, type TXmlToken } from '../tokenizer';
2
2
  export type TSelectedXmlToken = (TXmlToken | {
3
3
  type: 'SelectionStart';
4
4
  } | {
@@ -6,7 +6,7 @@ export type TSelectedXmlToken = (TXmlToken | {
6
6
  }) & {
7
7
  key?: string;
8
8
  };
9
- export type TSelectedTokenCallback = (token: TSelectedXmlToken) => void;
9
+ export type TSelectedTokenCallback = (token: TSelectedXmlToken, stream: XmlStream) => void;
10
10
  /**
11
11
  * A limited segment of an XPath expression in an object-oriented manner.
12
12
  *
@@ -1,5 +1,5 @@
1
1
  import { XmlStream } from './XmlStream';
2
- export type TTokenCallback = (token: TXmlToken, s: XmlStream) => void;
2
+ export type TTokenCallback = (token: TXmlToken, stream: XmlStream) => void;
3
3
  /**
4
4
  * A Processing Instruction token.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xml-tokenizer",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "private": false,
5
5
  "description": "Straightforward and typesafe XML tokenizer that streams tokens through a callback mechanism",
6
6
  "keywords": [],