xml-tokenizer 0.0.11 → 0.0.12
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/selector/TokenSelectState.js +1 -1
- package/dist/cjs/selector/TokenSelectStateMachine.js +1 -1
- package/dist/cjs/selector/match-string.js +1 -0
- package/dist/esm/selector/TokenSelectState.js +1 -1
- package/dist/esm/selector/TokenSelectStateMachine.js +1 -1
- package/dist/esm/selector/match-string.js +1 -0
- package/dist/types/selector/TokenSelectState.d.ts +2 -1
- package/dist/types/selector/TokenSelectState.d.ts.map +1 -1
- package/dist/types/selector/TokenSelectStateMachine.d.ts +11 -0
- package/dist/types/selector/TokenSelectStateMachine.d.ts.map +1 -1
- package/dist/types/selector/match-string.d.ts +3 -0
- package/dist/types/selector/match-string.d.ts.map +1 -0
- package/dist/types/selector/types.d.ts +19 -24
- package/dist/types/selector/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=require("./match-string.js"),m=Object.defineProperty,g=(t,e,r)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,a=(t,e,r)=>g(t,typeof e!="symbol"?e+"":e,r);class p{constructor(e){a(this,"_segment"),a(this,"_matchCriteria",0),a(this,"_toCacheNodeProps",0),a(this,"_enteredDepth",null),this._segment=e,this.applyLevels()}get matchCriteria(){return this._matchCriteria}get toCacheNodeProps(){return this._toCacheNodeProps}get enteredDepth(){return this._enteredDepth}applyLevels(){let e=0,r=0;(this._segment.local!=null||this._segment.prefix!=null)&&(e|=1),this._segment.attributes!=null&&(e|=2,r|=2),this._segment.text!=null&&(e|=4),this._matchCriteria=e,this._toCacheNodeProps=r}matchesName(e,r){return(this._segment.local==null||s.matchString(e,this._segment.local))&&(this._segment.prefix==null||s.matchString(r,this._segment.prefix))}matchesAttributes(e){if(this._segment.attributes==null)return!0;for(const r of this._segment.attributes){let n=!1;for(const i of e){const o=r.local==null||s.matchString(i.local,r.local),c=r.value==null||i.value!=null&&s.matchString(i.value,r.value),u=r.prefix==null||i.prefix!=null&&s.matchString(i.prefix,r.prefix);if(o&&c&&u){n=!0;break}}if(!n)return!1}return!0}matchesText(e){return this._segment.text==null||s.matchString(e,this._segment.text)}matchesDepth(e,r){switch(this._segment.axis){case"child":return e===r+1;case"self-or-descendant":return e>=r}}match(e){this._enteredDepth=e}unmatch(){this._enteredDepth=null}}var h=(t=>(t[t.None=0]="None",t[t.Name=1]="Name",t[t.Attributes=2]="Attributes",t[t.Text=4]="Text",t))(h||{}),l=(t=>(t[t.None=0]="None",t[t.Name=1]="Name",t[t.Attributes=2]="Attributes",t[t.Text=4]="Text",t[t.Node=8]="Node",t))(l||{});exports.EToCacheNodeProps=h,exports.ETokenMatchCriteria=l,exports.TokenSelectState=p;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("./TokenSelectState.js"),d=Object.defineProperty,_=(i,t,e)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,c=(i,t,e)=>_(i,typeof t!="symbol"?t+"":t,e);class S{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.push({local:t,prefix:e,value: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=S;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function a(t,e){if(typeof e=="string")return t===e;switch(e.matchStrategy){case"ANY":return!0;case"EXACT":return t===e.value;case"CONTAINS":return t.includes(e.value);case"STARTS_WITH":return t.startsWith(e.value);case"ENDS_WITH":return t.endsWith(e.value)}}exports.matchString=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{matchString as r}from"./match-string.js";var m=Object.defineProperty,p=(e,t,s)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,a=(e,t,s)=>p(e,typeof t!="symbol"?t+"":t,s);class _{constructor(t){a(this,"_segment"),a(this,"_matchCriteria",0),a(this,"_toCacheNodeProps",0),a(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.text!=null&&(t|=4),this._matchCriteria=t,this._toCacheNodeProps=s}matchesName(t,s){return(this._segment.local==null||r(t,this._segment.local))&&(this._segment.prefix==null||r(s,this._segment.prefix))}matchesAttributes(t){if(this._segment.attributes==null)return!0;for(const s of this._segment.attributes){let n=!1;for(const i of t){const o=s.local==null||r(i.local,s.local),u=s.value==null||i.value!=null&&r(i.value,s.value),c=s.prefix==null||i.prefix!=null&&r(i.prefix,s.prefix);if(o&&u&&c){n=!0;break}}if(!n)return!1}return!0}matchesText(t){return this._segment.text==null||r(t,this._segment.text)}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 h=(e=>(e[e.None=0]="None",e[e.Name=1]="Name",e[e.Attributes=2]="Attributes",e[e.Text=4]="Text",e))(h||{}),l=(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))(l||{});export{h as EToCacheNodeProps,l as ETokenMatchCriteria,_ as TokenSelectState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{TokenSelectState as _,EToCacheNodeProps as u,ETokenMatchCriteria as h}from"./TokenSelectState.js";var S=Object.defineProperty,p=(n,t,e)=>t in n?S(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t,e)=>p(n,typeof t!="symbol"?t+"":t,e);class N{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 _(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(),i=this.getCurrentState();return a==null?!1:(a.toCacheNodeProps&u.Name&&(this._cachedNodeProps.local=t,this._cachedNodeProps.prefix=e),a.matchesName(t,e)&&a.matchesDepth(r,(s=i==null?void 0:i.enteredDepth)!=null?s:0)&&!(a.matchCriteria&(h.Attributes|h.Text|h.Node))?(this.transitionForward(r),!0):!1)}transitionIfAttributesMatch(t,e,r,s){var a,i;const o=this.getNextState(),d=this.getCurrentState();if(o==null)return!1;const l=(a=this._cachedNodeProps.attributes)!=null?a:[];return l.push({local:t,prefix:e,value: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(),a=this.getCurrentState();return s==null?!1:(s.toCacheNodeProps&u.Text&&(this._cachedNodeProps.text=t),s.matchesText(t)&&s.matchesDepth(e,(r=a==null?void 0:a.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{N as TokenSelectStateMachine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function a(t,e){if(typeof e=="string")return t===e;switch(e.matchStrategy){case"ANY":return!0;case"EXACT":return t===e.value;case"CONTAINS":return t.includes(e.value);case"STARTS_WITH":return t.startsWith(e.value);case"ENDS_WITH":return t.endsWith(e.value)}}export{a as matchString};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TCachedAttribute } from './TokenSelectStateMachine';
|
|
1
2
|
import { type TTokenSelectPathSegment } from './types';
|
|
2
3
|
export declare class TokenSelectState {
|
|
3
4
|
private _segment;
|
|
@@ -10,7 +11,7 @@ export declare class TokenSelectState {
|
|
|
10
11
|
get enteredDepth(): number | null;
|
|
11
12
|
private applyLevels;
|
|
12
13
|
matchesName(local: string, prefix: string): boolean;
|
|
13
|
-
matchesAttributes(attributes:
|
|
14
|
+
matchesAttributes(attributes: TCachedAttribute[]): boolean;
|
|
14
15
|
matchesText(text: string): boolean;
|
|
15
16
|
matchesDepth(depth: number, parentDepth: number): boolean;
|
|
16
17
|
match(depth: number): void;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"TokenSelectState.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,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;IASnD,iBAAiB,CAAC,UAAU,EAAE,gBAAgB,EAAE,GAAG,OAAO;IAgC1D,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"}
|
|
@@ -21,4 +21,15 @@ export declare class TokenSelectStateMachine {
|
|
|
21
21
|
getOffsetToFinal(): number;
|
|
22
22
|
resetCurrentStateCache(): void;
|
|
23
23
|
}
|
|
24
|
+
export interface TCachedNodeProps {
|
|
25
|
+
prefix: string | null;
|
|
26
|
+
local: string | null;
|
|
27
|
+
attributes: TCachedAttribute[] | null;
|
|
28
|
+
text: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface TCachedAttribute {
|
|
31
|
+
local: string;
|
|
32
|
+
prefix?: string;
|
|
33
|
+
value?: string;
|
|
34
|
+
}
|
|
24
35
|
//# sourceMappingURL=TokenSelectStateMachine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenSelectStateMachine.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectStateMachine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TokenSelectStateMachine.d.ts","sourceRoot":"","sources":["../../../src/selector/TokenSelectStateMachine.ts"],"names":[],"mappings":"AAAA,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;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-string.d.ts","sourceRoot":"","sources":["../../../src/selector/match-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAkBxE"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type TXmlToken } from '../tokenizer';
|
|
2
|
-
export type TSelectedXmlToken = TXmlToken | {
|
|
2
|
+
export type TSelectedXmlToken = (TXmlToken | {
|
|
3
3
|
type: 'SelectionStart';
|
|
4
4
|
} | {
|
|
5
5
|
type: 'SelectionEnd';
|
|
6
|
+
}) & {
|
|
7
|
+
key?: string;
|
|
6
8
|
};
|
|
7
9
|
export type TSelectedTokenCallback = (token: TSelectedXmlToken) => void;
|
|
8
10
|
/**
|
|
@@ -21,6 +23,7 @@ export type TSelectedTokenCallback = (token: TSelectedXmlToken) => void;
|
|
|
21
23
|
* ];
|
|
22
24
|
*/
|
|
23
25
|
export interface TTokenSelectPathSegment {
|
|
26
|
+
key?: string;
|
|
24
27
|
/**
|
|
25
28
|
* Specifies the axis defining the relationship between nodes.
|
|
26
29
|
*
|
|
@@ -29,15 +32,13 @@ export interface TTokenSelectPathSegment {
|
|
|
29
32
|
*/
|
|
30
33
|
axis: 'child' | 'self-or-descendant';
|
|
31
34
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* Use '*' to match any node.
|
|
35
|
+
* Optional local name of the node to match.
|
|
35
36
|
*/
|
|
36
|
-
local?:
|
|
37
|
+
local?: TStringMatch;
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
+
* Optional namespace prefix to qualify the node name.
|
|
39
40
|
*/
|
|
40
|
-
prefix?:
|
|
41
|
+
prefix?: TStringMatch;
|
|
41
42
|
/**
|
|
42
43
|
* Optional filters based on node attributes.
|
|
43
44
|
*
|
|
@@ -46,9 +47,9 @@ export interface TTokenSelectPathSegment {
|
|
|
46
47
|
* attributes: [\{ local: 'category', value: 'fiction' \}]
|
|
47
48
|
*/
|
|
48
49
|
attributes?: {
|
|
49
|
-
local
|
|
50
|
-
prefix?:
|
|
51
|
-
value?:
|
|
50
|
+
local?: TStringMatch;
|
|
51
|
+
prefix?: TStringMatch;
|
|
52
|
+
value?: TStringMatch;
|
|
52
53
|
}[];
|
|
53
54
|
/**
|
|
54
55
|
* Optional filter to match nodes containing specific text content.
|
|
@@ -60,23 +61,17 @@ export interface TTokenSelectPathSegment {
|
|
|
60
61
|
* // Matches nodes containing the text 'bestseller'
|
|
61
62
|
* containsText: 'bestseller'
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Optional custom predicate function to further filter nodes.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // Custom predicate to match nodes with specific characteristics
|
|
69
|
-
* predicate: (node) =\> node.local === 'title'
|
|
70
|
-
*/
|
|
71
|
-
predicate?: (node: {
|
|
72
|
-
local: string;
|
|
73
|
-
prefix?: string;
|
|
74
|
-
attributes: Record<string, string>;
|
|
75
|
-
text?: string;
|
|
76
|
-
}) => boolean;
|
|
64
|
+
text?: TStringMatch;
|
|
77
65
|
}
|
|
78
66
|
/**
|
|
79
67
|
* A limited XPath expression composed of multiple segments in an object-oriented manner.
|
|
80
68
|
*/
|
|
81
69
|
export type TTokenSelectPath = TTokenSelectPathSegment[];
|
|
70
|
+
export type TStringMatchStrategy = 'EXACT' | 'CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'ANY';
|
|
71
|
+
export type TStringMatch = string | {
|
|
72
|
+
matchStrategy: 'ANY';
|
|
73
|
+
} | {
|
|
74
|
+
matchStrategy: Exclude<TStringMatchStrategy, 'ANY'>;
|
|
75
|
+
value: string;
|
|
76
|
+
};
|
|
82
77
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/selector/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/selector/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG,CAC7B,SAAS,GACT;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAC1B,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AAGH,MAAM,WAAW,uBAAuB;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAAC;IAErC;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,YAAY,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC;IAErF;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;CAepB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;AAEzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,WAAW,GAAG,KAAK,CAAC;AAE9F,MAAM,MAAM,YAAY,GACrB,MAAM,GACN;IAAE,aAAa,EAAE,KAAK,CAAA;CAAE,GACxB;IACA,aAAa,EAAE,OAAO,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;IACpD,KAAK,EAAE,MAAM,CAAC;CACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xml-tokenizer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Straightforward and typesafe XML tokenizer that streams tokens through a callback mechanism",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"saxen": "^10.0.0",
|
|
29
29
|
"txml": "^5.1.1",
|
|
30
30
|
"xml2js": "^0.6.2",
|
|
31
|
-
"@blgc/config": "0.0.
|
|
31
|
+
"@blgc/config": "0.0.22"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|