xml-tokenizer 0.0.32 → 0.0.33
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/config.js +1 -43
- package/dist/cjs/get-q-name.js +1 -8
- package/dist/cjs/index.js +1 -80
- package/dist/cjs/processor/process.js +1 -0
- package/dist/cjs/processor/processors/path-tracker.js +1 -0
- package/dist/cjs/processor/validate-processor-order.js +5 -0
- package/dist/cjs/selector/TokenSelectState.js +1 -107
- package/dist/cjs/selector/TokenSelectStateMachine.js +1 -151
- package/dist/cjs/selector/TokenSelector.js +1 -140
- package/dist/cjs/selector/match-string.js +1 -22
- package/dist/cjs/selector/select.js +1 -20
- package/dist/cjs/token-to-xml.js +1 -45
- package/dist/cjs/tokenizer/XmlError.js +1 -97
- package/dist/cjs/tokenizer/XmlStream.js +1 -479
- package/dist/cjs/tokenizer/ascii-constants.js +1 -70
- package/dist/cjs/tokenizer/tokenize.js +1 -420
- package/dist/cjs/tokenizer/utils.js +1 -48
- package/dist/cjs/tokens-to-xml.js +1 -14
- package/dist/cjs/xml-to-object.js +1 -70
- package/dist/cjs/xml-to-simplified-object.js +1 -87
- package/dist/esm/config.js +1 -39
- package/dist/esm/get-q-name.js +1 -6
- package/dist/esm/index.js +1 -16
- package/dist/esm/processor/process.js +1 -0
- package/dist/esm/processor/processors/path-tracker.js +1 -0
- package/dist/esm/processor/validate-processor-order.js +5 -0
- package/dist/esm/selector/TokenSelectState.js +1 -103
- package/dist/esm/selector/TokenSelectStateMachine.js +1 -149
- package/dist/esm/selector/TokenSelector.js +1 -138
- package/dist/esm/selector/match-string.js +1 -20
- package/dist/esm/selector/select.js +1 -18
- package/dist/esm/token-to-xml.js +1 -43
- package/dist/esm/tokenizer/XmlError.js +1 -95
- package/dist/esm/tokenizer/XmlStream.js +1 -477
- package/dist/esm/tokenizer/ascii-constants.js +1 -36
- package/dist/esm/tokenizer/tokenize.js +1 -417
- package/dist/esm/tokenizer/utils.js +1 -41
- package/dist/esm/tokens-to-xml.js +1 -12
- package/dist/esm/xml-to-object.js +1 -67
- package/dist/esm/xml-to-simplified-object.js +1 -84
- package/dist/types/config.d.ts +0 -1
- package/dist/types/get-q-name.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/processor/index.d.ts +4 -0
- package/dist/types/processor/process.d.ts +3 -0
- package/dist/types/processor/processors/index.d.ts +1 -0
- package/dist/types/processor/processors/path-tracker.d.ts +5 -0
- package/dist/types/processor/types.d.ts +10 -0
- package/dist/types/processor/validate-processor-order.d.ts +2 -0
- package/dist/types/selector/TokenSelectState.d.ts +0 -1
- package/dist/types/selector/TokenSelectStateMachine.d.ts +0 -1
- package/dist/types/selector/TokenSelector.d.ts +0 -1
- package/dist/types/selector/index.d.ts +0 -1
- package/dist/types/selector/match-string.d.ts +0 -1
- package/dist/types/selector/select.d.ts +0 -1
- package/dist/types/selector/types.d.ts +0 -1
- package/dist/types/token-to-xml.d.ts +0 -1
- package/dist/types/tokenizer/XmlError.d.ts +0 -1
- package/dist/types/tokenizer/XmlStream.d.ts +7 -1
- package/dist/types/tokenizer/ascii-constants.d.ts +0 -1
- package/dist/types/tokenizer/index.d.ts +0 -1
- package/dist/types/tokenizer/tokenize.d.ts +0 -1
- package/dist/types/tokenizer/types.d.ts +0 -1
- package/dist/types/tokenizer/utils.d.ts +0 -1
- package/dist/types/tokens-to-xml.d.ts +0 -1
- package/dist/types/xml-to-object.d.ts +0 -1
- package/dist/types/xml-to-simplified-object.d.ts +0 -1
- package/package.json +6 -6
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/get-q-name.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/selector/TokenSelectState.js.map +0 -1
- package/dist/cjs/selector/TokenSelectStateMachine.js.map +0 -1
- package/dist/cjs/selector/TokenSelector.js.map +0 -1
- package/dist/cjs/selector/match-string.js.map +0 -1
- package/dist/cjs/selector/select.js.map +0 -1
- package/dist/cjs/token-to-xml.js.map +0 -1
- package/dist/cjs/tokenizer/XmlError.js.map +0 -1
- package/dist/cjs/tokenizer/XmlStream.js.map +0 -1
- package/dist/cjs/tokenizer/ascii-constants.js.map +0 -1
- package/dist/cjs/tokenizer/tokenize.js.map +0 -1
- package/dist/cjs/tokenizer/utils.js.map +0 -1
- package/dist/cjs/tokens-to-xml.js.map +0 -1
- package/dist/cjs/xml-to-object.js.map +0 -1
- package/dist/cjs/xml-to-simplified-object.js.map +0 -1
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/get-q-name.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/selector/TokenSelectState.js.map +0 -1
- package/dist/esm/selector/TokenSelectStateMachine.js.map +0 -1
- package/dist/esm/selector/TokenSelector.js.map +0 -1
- package/dist/esm/selector/match-string.js.map +0 -1
- package/dist/esm/selector/select.js.map +0 -1
- package/dist/esm/token-to-xml.js.map +0 -1
- package/dist/esm/tokenizer/XmlError.js.map +0 -1
- package/dist/esm/tokenizer/XmlStream.js.map +0 -1
- package/dist/esm/tokenizer/ascii-constants.js.map +0 -1
- package/dist/esm/tokenizer/tokenize.js.map +0 -1
- package/dist/esm/tokenizer/utils.js.map +0 -1
- package/dist/esm/tokens-to-xml.js.map +0 -1
- package/dist/esm/xml-to-object.js.map +0 -1
- package/dist/esm/xml-to-simplified-object.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/get-q-name.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/selector/TokenSelectState.d.ts.map +0 -1
- package/dist/types/selector/TokenSelectStateMachine.d.ts.map +0 -1
- package/dist/types/selector/TokenSelector.d.ts.map +0 -1
- package/dist/types/selector/index.d.ts.map +0 -1
- package/dist/types/selector/match-string.d.ts.map +0 -1
- package/dist/types/selector/select.d.ts.map +0 -1
- package/dist/types/selector/types.d.ts.map +0 -1
- package/dist/types/token-to-xml.d.ts.map +0 -1
- package/dist/types/tokenizer/XmlError.d.ts.map +0 -1
- package/dist/types/tokenizer/XmlStream.d.ts.map +0 -1
- package/dist/types/tokenizer/ascii-constants.d.ts.map +0 -1
- package/dist/types/tokenizer/index.d.ts.map +0 -1
- package/dist/types/tokenizer/tokenize.d.ts.map +0 -1
- package/dist/types/tokenizer/types.d.ts.map +0 -1
- package/dist/types/tokenizer/utils.d.ts.map +0 -1
- package/dist/types/tokens-to-xml.d.ts.map +0 -1
- package/dist/types/xml-to-object.d.ts.map +0 -1
- package/dist/types/xml-to-simplified-object.d.ts.map +0 -1
package/dist/esm/config.js
CHANGED
|
@@ -1,39 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
strictDocument: true,
|
|
3
|
-
allowDtd: true,
|
|
4
|
-
rawTextElements: null,
|
|
5
|
-
implicitSelfClosingElements: null,
|
|
6
|
-
contextSliceSize: 30
|
|
7
|
-
};
|
|
8
|
-
const htmlConfig = {
|
|
9
|
-
strictDocument: false,
|
|
10
|
-
allowDtd: true,
|
|
11
|
-
rawTextElements: ["script", "style", "title", "textarea"],
|
|
12
|
-
implicitSelfClosingElements: [
|
|
13
|
-
"area",
|
|
14
|
-
"base",
|
|
15
|
-
"br",
|
|
16
|
-
"col",
|
|
17
|
-
"embed",
|
|
18
|
-
"hr",
|
|
19
|
-
"img",
|
|
20
|
-
"input",
|
|
21
|
-
"link",
|
|
22
|
-
"meta",
|
|
23
|
-
"param",
|
|
24
|
-
"source",
|
|
25
|
-
"track",
|
|
26
|
-
"wbr"
|
|
27
|
-
],
|
|
28
|
-
contextSliceSize: 30
|
|
29
|
-
};
|
|
30
|
-
const svgConfig = {
|
|
31
|
-
strictDocument: false,
|
|
32
|
-
allowDtd: true,
|
|
33
|
-
rawTextElements: ["style"],
|
|
34
|
-
implicitSelfClosingElements: [],
|
|
35
|
-
contextSliceSize: 30
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { htmlConfig, svgConfig, xmlConfig };
|
|
39
|
-
//# sourceMappingURL=config.js.map
|
|
1
|
+
const e={strictDocument:!0,allowDtd:!0,rawTextElements:null,implicitSelfClosingElements:null,contextSliceSize:30},t={strictDocument:!1,allowDtd:!0,rawTextElements:["script","style","title","textarea"],implicitSelfClosingElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],contextSliceSize:30},l={strictDocument:!1,allowDtd:!0,rawTextElements:["style"],implicitSelfClosingElements:[],contextSliceSize:30};export{t as htmlConfig,l as svgConfig,e as xmlConfig};
|
package/dist/esm/get-q-name.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
function
|
|
2
|
-
return prefix != null && prefix.length > 0 ? `${prefix}:${local}` : local;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export { getQName };
|
|
6
|
-
//# sourceMappingURL=get-q-name.js.map
|
|
1
|
+
function n(l,e=null){return e!=null&&e.length>0?`${e}:${l}`:l}export{n as getQName};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { getQName } from './get-q-name.js';
|
|
3
|
-
export { select } from './selector/select.js';
|
|
4
|
-
export { TokenSelector } from './selector/TokenSelector.js';
|
|
5
|
-
export { EToCacheNodeProps, ETokenMatchCriteria, TokenSelectState } from './selector/TokenSelectState.js';
|
|
6
|
-
export { TokenSelectStateMachine } from './selector/TokenSelectStateMachine.js';
|
|
7
|
-
export { tokenToXml } from './token-to-xml.js';
|
|
8
|
-
export { AMPERSAND, CARRIAGE_RETURN, CLOSE_SQUARE_BRACKET, COLON, DOUBLE_QUOTE, EQUALS, EXCLAMATION_MARK, GREATER_THAN, HASH, HORIZONTAL_TAB, HYPHEN, LESS_THAN, LINE_FEED, LOWERCASE_A, LOWERCASE_F, LOWERCASE_X, LOWERCASE_Z, NINE, OPEN_SQUARE_BRACKET, PERCENT, PERIOD, QUESTION_MARK, SEMICOLON, SINGLE_QUOTE, SLASH, SPACE, UNDERSCORE, UPPERCASE_A, UPPERCASE_F, UPPERCASE_P, UPPERCASE_S, UPPERCASE_Z, ZERO } from './tokenizer/ascii-constants.js';
|
|
9
|
-
export { tokenize, tokenizeXmlStream } from './tokenizer/tokenize.js';
|
|
10
|
-
export { isAsciiDigit, isXmlChar, isXmlName, isXmlNameByte, isXmlNameStart, isXmlSpaceByte } from './tokenizer/utils.js';
|
|
11
|
-
export { XmlError } from './tokenizer/XmlError.js';
|
|
12
|
-
export { XmlStream } from './tokenizer/XmlStream.js';
|
|
13
|
-
export { tokensToXml } from './tokens-to-xml.js';
|
|
14
|
-
export { processTokenForObject, xmlToObject } from './xml-to-object.js';
|
|
15
|
-
export { processTokenForSimplifiedObject, xmlToSimplifiedObject } from './xml-to-simplified-object.js';
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{htmlConfig as r,svgConfig as E,xmlConfig as t}from"./config.js";import{getQName as S}from"./get-q-name.js";import{process as R}from"./processor/process.js";import{pathTracker as i}from"./processor/processors/path-tracker.js";import{validateProcessorOrder as O}from"./processor/validate-processor-order.js";import{select as f}from"./selector/select.js";import{TokenSelector as _}from"./selector/TokenSelector.js";import{EToCacheNodeProps as x,ETokenMatchCriteria as a,TokenSelectState as s}from"./selector/TokenSelectState.js";import{TokenSelectStateMachine as c}from"./selector/TokenSelectStateMachine.js";import{tokenToXml as n}from"./token-to-xml.js";import{AMPERSAND as X,CARRIAGE_RETURN as k,CLOSE_SQUARE_BRACKET as I,COLON as H,DOUBLE_QUOTE as M,EQUALS as Q,EXCLAMATION_MARK as g,GREATER_THAN as h,HASH as B,HORIZONTAL_TAB as D,HYPHEN as d,LESS_THAN as F,LINE_FEED as b,LOWERCASE_A as j,LOWERCASE_F as K,LOWERCASE_X as W,LOWERCASE_Z as Z,NINE as G,OPEN_SQUARE_BRACKET as v,PERCENT as y,PERIOD as z,QUESTION_MARK as Y,SEMICOLON as q,SINGLE_QUOTE as u,SLASH as w,SPACE as J,UNDERSCORE as V,UPPERCASE_A as $,UPPERCASE_F as ee,UPPERCASE_P as oe,UPPERCASE_S as re,UPPERCASE_Z as Ee,ZERO as te}from"./tokenizer/ascii-constants.js";import{tokenize as Se,tokenizeXmlStream as Ae}from"./tokenizer/tokenize.js";import{isAsciiDigit as pe,isXmlChar as ie,isXmlName as Ce,isXmlNameByte as Oe,isXmlNameStart as Te,isXmlSpaceByte as fe}from"./tokenizer/utils.js";import{XmlError as _e}from"./tokenizer/XmlError.js";import{XmlStream as xe}from"./tokenizer/XmlStream.js";import{tokensToXml as se}from"./tokens-to-xml.js";import{processTokenForObject as ce,xmlToObject as Le}from"./xml-to-object.js";import{processTokenForSimplifiedObject as Ue,xmlToSimplifiedObject as Xe}from"./xml-to-simplified-object.js";export{X as AMPERSAND,k as CARRIAGE_RETURN,I as CLOSE_SQUARE_BRACKET,H as COLON,M as DOUBLE_QUOTE,Q as EQUALS,x as EToCacheNodeProps,a as ETokenMatchCriteria,g as EXCLAMATION_MARK,h as GREATER_THAN,B as HASH,D as HORIZONTAL_TAB,d as HYPHEN,F as LESS_THAN,b as LINE_FEED,j as LOWERCASE_A,K as LOWERCASE_F,W as LOWERCASE_X,Z as LOWERCASE_Z,G as NINE,v as OPEN_SQUARE_BRACKET,y as PERCENT,z as PERIOD,Y as QUESTION_MARK,q as SEMICOLON,u as SINGLE_QUOTE,w as SLASH,J as SPACE,s as TokenSelectState,c as TokenSelectStateMachine,_ as TokenSelector,V as UNDERSCORE,$ as UPPERCASE_A,ee as UPPERCASE_F,oe as UPPERCASE_P,re as UPPERCASE_S,Ee as UPPERCASE_Z,_e as XmlError,xe as XmlStream,te as ZERO,S as getQName,r as htmlConfig,pe as isAsciiDigit,ie as isXmlChar,Ce as isXmlName,Oe as isXmlNameByte,Te as isXmlNameStart,fe as isXmlSpaceByte,i as pathTracker,R as process,ce as processTokenForObject,Ue as processTokenForSimplifiedObject,f as select,E as svgConfig,n as tokenToXml,Se as tokenize,Ae as tokenizeXmlStream,se as tokensToXml,O as validateProcessorOrder,t as xmlConfig,Le as xmlToObject,Xe as xmlToSimplifiedObject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tokenize as f}from"../tokenizer/tokenize.js";import{validateProcessorOrder as i}from"./validate-processor-order.js";function a(c,o,n){i(o);const r={};for(const t of o)Object.assign(r,t.context);return f(c,t=>{var e;for(const s of o)(e=s.process)==null||e.call(s,t,r)},n),r}export{a as process};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a={name:"PathTracker",context:{currentPath:[]},process:(t,e)=>{if(t.type==="ElementStart"){const r=t.prefix?`${t.prefix}:${t.local}`:t.local;e.currentPath.push(r)}else t.type==="ElementEnd"&&t.end.type==="Close"&&e.currentPath.pop()}};export{a as pathTracker};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
function l(r){const t=new Set;for(let s=0;s<r.length;s++){const o=r[s];if(o.deps==null){t.add(o);continue}const d=[];for(const n of o.deps)t.has(n)||d.push(n);if(d.length>0){const n=o.name||`Processor[${s}]`,a=d.map((e,c)=>{const i=r.indexOf(e);return e.name||`Processor[${i>=0?i:c}]`}).join(", "),p=r.filter(e=>e!=null).map((e,c)=>e.name||`Processor[${c}]`).join(" \u2192 ");throw new Error(`Processor dependency order invalid:
|
|
2
|
+
${n} depends on: ${a}
|
|
3
|
+
But those dependencies haven't been processed yet.
|
|
4
|
+
Current order: ${p}
|
|
5
|
+
Solution: Move dependencies before ${n} in the processors array.`)}t.add(o)}}export{l as validateProcessorOrder};
|
|
@@ -1,103 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
class TokenSelectState {
|
|
7
|
-
constructor(segment) {
|
|
8
|
-
__publicField(this, "_segment");
|
|
9
|
-
__publicField(this, "_matchCriteria", 0 /* None */);
|
|
10
|
-
__publicField(this, "_toCacheNodeProps", 0 /* None */);
|
|
11
|
-
__publicField(this, "_enteredDepth", null);
|
|
12
|
-
this._segment = segment;
|
|
13
|
-
this.applyLevels();
|
|
14
|
-
}
|
|
15
|
-
get matchCriteria() {
|
|
16
|
-
return this._matchCriteria;
|
|
17
|
-
}
|
|
18
|
-
get toCacheNodeProps() {
|
|
19
|
-
return this._toCacheNodeProps;
|
|
20
|
-
}
|
|
21
|
-
get enteredDepth() {
|
|
22
|
-
return this._enteredDepth;
|
|
23
|
-
}
|
|
24
|
-
applyLevels() {
|
|
25
|
-
let matchCriteria = 0 /* None */;
|
|
26
|
-
let cacheProps = 0 /* None */;
|
|
27
|
-
if (this._segment.local != null || this._segment.prefix != null) {
|
|
28
|
-
matchCriteria |= 1 /* Name */;
|
|
29
|
-
}
|
|
30
|
-
if (this._segment.attributes != null) {
|
|
31
|
-
matchCriteria |= 2 /* Attributes */;
|
|
32
|
-
cacheProps |= 2 /* Attributes */;
|
|
33
|
-
}
|
|
34
|
-
if (this._segment.text != null) {
|
|
35
|
-
matchCriteria |= 4 /* Text */;
|
|
36
|
-
}
|
|
37
|
-
this._matchCriteria = matchCriteria;
|
|
38
|
-
this._toCacheNodeProps = cacheProps;
|
|
39
|
-
}
|
|
40
|
-
matchesName(local, prefix) {
|
|
41
|
-
return (
|
|
42
|
-
// Match local
|
|
43
|
-
(this._segment.local == null || matchString(local, this._segment.local)) && // Match prefix
|
|
44
|
-
(this._segment.prefix == null || matchString(prefix, this._segment.prefix))
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
matchesAttributes(attributes) {
|
|
48
|
-
if (this._segment.attributes == null) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
for (const attributeConfig of this._segment.attributes) {
|
|
52
|
-
let matchFound = false;
|
|
53
|
-
for (const attribute of attributes) {
|
|
54
|
-
const localMatch = attributeConfig.local == null || matchString(attribute.local, attributeConfig.local);
|
|
55
|
-
const valueMatch = attributeConfig.value == null || attribute.value != null && matchString(attribute.value, attributeConfig.value);
|
|
56
|
-
const prefixMatch = attributeConfig.prefix == null || attribute.prefix != null && matchString(attribute.prefix, attributeConfig.prefix);
|
|
57
|
-
if (localMatch && valueMatch && prefixMatch) {
|
|
58
|
-
matchFound = true;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (!matchFound) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
matchesText(text) {
|
|
69
|
-
return this._segment.text == null || matchString(text, this._segment.text);
|
|
70
|
-
}
|
|
71
|
-
matchesDepth(depth, parentDepth) {
|
|
72
|
-
switch (this._segment.axis) {
|
|
73
|
-
case "child":
|
|
74
|
-
return depth === parentDepth + 1;
|
|
75
|
-
case "self-or-descendant":
|
|
76
|
-
return depth >= parentDepth;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
match(depth) {
|
|
80
|
-
this._enteredDepth = depth;
|
|
81
|
-
}
|
|
82
|
-
unmatch() {
|
|
83
|
-
this._enteredDepth = null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
var EToCacheNodeProps = /* @__PURE__ */ ((EToCacheNodeProps2) => {
|
|
87
|
-
EToCacheNodeProps2[EToCacheNodeProps2["None"] = 0] = "None";
|
|
88
|
-
EToCacheNodeProps2[EToCacheNodeProps2["Name"] = 1] = "Name";
|
|
89
|
-
EToCacheNodeProps2[EToCacheNodeProps2["Attributes"] = 2] = "Attributes";
|
|
90
|
-
EToCacheNodeProps2[EToCacheNodeProps2["Text"] = 4] = "Text";
|
|
91
|
-
return EToCacheNodeProps2;
|
|
92
|
-
})(EToCacheNodeProps || {});
|
|
93
|
-
var ETokenMatchCriteria = /* @__PURE__ */ ((ETokenMatchCriteria2) => {
|
|
94
|
-
ETokenMatchCriteria2[ETokenMatchCriteria2["None"] = 0] = "None";
|
|
95
|
-
ETokenMatchCriteria2[ETokenMatchCriteria2["Name"] = 1] = "Name";
|
|
96
|
-
ETokenMatchCriteria2[ETokenMatchCriteria2["Attributes"] = 2] = "Attributes";
|
|
97
|
-
ETokenMatchCriteria2[ETokenMatchCriteria2["Text"] = 4] = "Text";
|
|
98
|
-
ETokenMatchCriteria2[ETokenMatchCriteria2["Node"] = 8] = "Node";
|
|
99
|
-
return ETokenMatchCriteria2;
|
|
100
|
-
})(ETokenMatchCriteria || {});
|
|
101
|
-
|
|
102
|
-
export { EToCacheNodeProps, ETokenMatchCriteria, TokenSelectState };
|
|
103
|
-
//# sourceMappingURL=TokenSelectState.js.map
|
|
1
|
+
import{matchString as s}from"./match-string.js";var m=Object.defineProperty,p=(e,t,r)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,a=(e,t,r)=>p(e,typeof t!="symbol"?t+"":t,r);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,r=0;(this._segment.local!=null||this._segment.prefix!=null)&&(t|=1),this._segment.attributes!=null&&(t|=2,r|=2),this._segment.text!=null&&(t|=4),this._matchCriteria=t,this._toCacheNodeProps=r}matchesName(t,r){return(this._segment.local==null||s(t,this._segment.local))&&(this._segment.prefix==null||s(r,this._segment.prefix))}matchesAttributes(t){if(this._segment.attributes==null)return!0;for(const r of this._segment.attributes){let n=!1;for(const i of t){const u=r.local==null||s(i.local,r.local),o=r.value==null||i.value!=null&&s(i.value,r.value),c=r.prefix==null||i.prefix!=null&&s(i.prefix,r.prefix);if(u&&o&&c){n=!0;break}}if(!n)return!1}return!0}matchesText(t){return this._segment.text==null||s(t,this._segment.text)}matchesDepth(t,r){switch(this._segment.axis){case"child":return t===r+1;case"self-or-descendant":return t>=r}}match(t){this._enteredDepth=t}unmatch(){this._enteredDepth=null}}var l=(e=>(e[e.None=0]="None",e[e.Name=1]="Name",e[e.Attributes=2]="Attributes",e[e.Text=4]="Text",e))(l||{}),h=(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))(h||{});export{l as EToCacheNodeProps,h as ETokenMatchCriteria,_ as TokenSelectState};
|
|
@@ -1,149 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
class TokenSelectStateMachine {
|
|
7
|
-
constructor(tokenSelectPath) {
|
|
8
|
-
__publicField(this, "_states");
|
|
9
|
-
// null (start state) -> index (x state)
|
|
10
|
-
__publicField(this, "_currentState", null);
|
|
11
|
-
// Current state cache
|
|
12
|
-
__publicField(this, "_cachedNodeProps", {
|
|
13
|
-
prefix: null,
|
|
14
|
-
local: null,
|
|
15
|
-
attributes: null,
|
|
16
|
-
text: null
|
|
17
|
-
});
|
|
18
|
-
__publicField(this, "_cachedTokens", []);
|
|
19
|
-
__publicField(this, "_toRecordTokens", []);
|
|
20
|
-
this._states = tokenSelectPath.map((part) => new TokenSelectState(part));
|
|
21
|
-
}
|
|
22
|
-
getNextState() {
|
|
23
|
-
var _a;
|
|
24
|
-
const nextIndex = this._currentState != null ? this._currentState + 1 : 0;
|
|
25
|
-
if (nextIndex < this._states.length) {
|
|
26
|
-
return (_a = this._states[nextIndex]) != null ? _a : null;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
getCurrentState() {
|
|
31
|
-
var _a;
|
|
32
|
-
if (this._currentState != null && this._currentState < this._states.length) {
|
|
33
|
-
return (_a = this._states[this._currentState]) != null ? _a : null;
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
record(token) {
|
|
38
|
-
if (this.getOffsetToFinal() <= 1) {
|
|
39
|
-
this._cachedTokens.push(token);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
takeRecordedTokens() {
|
|
43
|
-
if (this._toRecordTokens.length > 0) {
|
|
44
|
-
const recordedTokens = this._toRecordTokens;
|
|
45
|
-
this._toRecordTokens = [];
|
|
46
|
-
return recordedTokens;
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
transitionIfNameMatch(local, prefix, depth) {
|
|
51
|
-
var _a;
|
|
52
|
-
const nextState = this.getNextState();
|
|
53
|
-
const currentState = this.getCurrentState();
|
|
54
|
-
if (nextState == null) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (nextState.toCacheNodeProps & EToCacheNodeProps.Name) {
|
|
58
|
-
this._cachedNodeProps.local = local;
|
|
59
|
-
this._cachedNodeProps.prefix = prefix;
|
|
60
|
-
}
|
|
61
|
-
if (nextState.matchesName(local, prefix) && nextState.matchesDepth(depth, (_a = currentState == null ? void 0 : currentState.enteredDepth) != null ? _a : 0) && !(nextState.matchCriteria & (ETokenMatchCriteria.Attributes | ETokenMatchCriteria.Text | ETokenMatchCriteria.Node))) {
|
|
62
|
-
this.transitionForward(depth);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
// Transition forward if attributes and depth match, and no additional criteria are required
|
|
68
|
-
transitionIfAttributesMatch(local, prefix, value, depth) {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
const nextState = this.getNextState();
|
|
71
|
-
const currentState = this.getCurrentState();
|
|
72
|
-
if (nextState == null) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
const attributes = (_a = this._cachedNodeProps.attributes) != null ? _a : [];
|
|
76
|
-
attributes.push({ local, prefix, value });
|
|
77
|
-
if (nextState.toCacheNodeProps & EToCacheNodeProps.Attributes) {
|
|
78
|
-
this._cachedNodeProps.attributes = attributes;
|
|
79
|
-
}
|
|
80
|
-
if (nextState.matchesAttributes(attributes) && nextState.matchesDepth(depth, (_b = currentState == null ? void 0 : currentState.enteredDepth) != null ? _b : 0) && !(nextState.matchCriteria & (ETokenMatchCriteria.Text | ETokenMatchCriteria.Node))) {
|
|
81
|
-
this.transitionForward(depth);
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
// Transition forward if text content and depth match, and no additional criteria are required
|
|
87
|
-
transitionIfTextMatch(text, depth) {
|
|
88
|
-
var _a;
|
|
89
|
-
const nextState = this.getNextState();
|
|
90
|
-
const currentState = this.getCurrentState();
|
|
91
|
-
if (nextState == null) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
if (nextState.toCacheNodeProps & EToCacheNodeProps.Text) {
|
|
95
|
-
this._cachedNodeProps.text = text;
|
|
96
|
-
}
|
|
97
|
-
if (nextState.matchesText(text) && nextState.matchesDepth(depth, (_a = currentState == null ? void 0 : currentState.enteredDepth) != null ? _a : 0) && !(nextState.matchCriteria & ETokenMatchCriteria.Node)) {
|
|
98
|
-
this.transitionForward(depth);
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
transitionForward(depth) {
|
|
104
|
-
const previousState = this.getCurrentState();
|
|
105
|
-
if (previousState != null) {
|
|
106
|
-
previousState.unmatch();
|
|
107
|
-
}
|
|
108
|
-
this._currentState = this._currentState != null ? this._currentState + 1 : 0;
|
|
109
|
-
const currentState = this.getCurrentState();
|
|
110
|
-
if (currentState != null) {
|
|
111
|
-
currentState.match(depth);
|
|
112
|
-
}
|
|
113
|
-
if (this.isFinalState()) {
|
|
114
|
-
this._toRecordTokens = this._cachedTokens;
|
|
115
|
-
}
|
|
116
|
-
this.resetCurrentStateCache();
|
|
117
|
-
}
|
|
118
|
-
transitionBack(depth) {
|
|
119
|
-
const previousState = this.getCurrentState();
|
|
120
|
-
if (previousState != null) {
|
|
121
|
-
previousState.unmatch();
|
|
122
|
-
}
|
|
123
|
-
this._currentState = this._currentState != null ? this._currentState - 1 : 0;
|
|
124
|
-
const currentState = this.getCurrentState();
|
|
125
|
-
if (currentState != null) {
|
|
126
|
-
currentState.match(depth);
|
|
127
|
-
}
|
|
128
|
-
this.resetCurrentStateCache();
|
|
129
|
-
}
|
|
130
|
-
isFinalState() {
|
|
131
|
-
return this._currentState != null && this._currentState >= this._states.length - 1;
|
|
132
|
-
}
|
|
133
|
-
getOffsetToFinal() {
|
|
134
|
-
if (this._currentState == null) {
|
|
135
|
-
return this._states.length;
|
|
136
|
-
}
|
|
137
|
-
return this._states.length - 1 - this._currentState;
|
|
138
|
-
}
|
|
139
|
-
resetCurrentStateCache() {
|
|
140
|
-
this._cachedNodeProps.prefix = null;
|
|
141
|
-
this._cachedNodeProps.local = null;
|
|
142
|
-
this._cachedNodeProps.attributes = null;
|
|
143
|
-
this._cachedNodeProps.text = null;
|
|
144
|
-
this._cachedTokens = [];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export { TokenSelectStateMachine };
|
|
149
|
-
//# sourceMappingURL=TokenSelectStateMachine.js.map
|
|
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,o=(n,t,e)=>p(n,typeof t!="symbol"?t+"":t,e);class N{constructor(t){o(this,"_states"),o(this,"_currentState",null),o(this,"_cachedNodeProps",{prefix:null,local:null,attributes:null,text:null}),o(this,"_cachedTokens",[]),o(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 l=this.getNextState(),d=this.getCurrentState();if(l==null)return!1;const c=(a=this._cachedNodeProps.attributes)!=null?a:[];return c.push({local:t,prefix:e,value:r}),l.toCacheNodeProps&u.Attributes&&(this._cachedNodeProps.attributes=c),l.matchesAttributes(c)&&l.matchesDepth(s,(i=d==null?void 0:d.enteredDepth)!=null?i:0)&&!(l.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};
|
|
@@ -1,138 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TokenSelectStateMachine } from './TokenSelectStateMachine.js';
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
class TokenSelector {
|
|
8
|
-
constructor(tokenSelectPaths) {
|
|
9
|
-
__publicField(this, "_currentDepth", 0);
|
|
10
|
-
__publicField(this, "_tspStateMachines");
|
|
11
|
-
__publicField(this, "_isRecording", false);
|
|
12
|
-
this._tspStateMachines = tokenSelectPaths.map(
|
|
13
|
-
(tokenSelectPath) => new TokenSelectStateMachine(tokenSelectPath)
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
pipeToken(token, recorder) {
|
|
17
|
-
let startRecording = false;
|
|
18
|
-
let stopRecording = false;
|
|
19
|
-
switch (token.type) {
|
|
20
|
-
case "ElementStart":
|
|
21
|
-
startRecording = this.handleElementStart(token);
|
|
22
|
-
break;
|
|
23
|
-
case "Attribute":
|
|
24
|
-
startRecording = this.handleAttribute(token);
|
|
25
|
-
break;
|
|
26
|
-
case "Text":
|
|
27
|
-
startRecording = this.handleText(token);
|
|
28
|
-
break;
|
|
29
|
-
case "ElementEnd": {
|
|
30
|
-
stopRecording = this.handleElementEnd(token);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (startRecording && !this._isRecording) {
|
|
35
|
-
this._isRecording = true;
|
|
36
|
-
recorder({ type: "SelectionStart" });
|
|
37
|
-
}
|
|
38
|
-
for (const stateMachine of this._tspStateMachines) {
|
|
39
|
-
stateMachine.record(token);
|
|
40
|
-
const recordedTokens = stateMachine.takeRecordedTokens();
|
|
41
|
-
if (recordedTokens != null) {
|
|
42
|
-
recordedTokens.forEach((t) => {
|
|
43
|
-
recorder(t);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (this._isRecording) {
|
|
48
|
-
recorder(token);
|
|
49
|
-
}
|
|
50
|
-
if (stopRecording && this._isRecording) {
|
|
51
|
-
recorder({ type: "SelectionEnd" });
|
|
52
|
-
this._isRecording = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
handleElementStart(token) {
|
|
56
|
-
this._currentDepth += 1;
|
|
57
|
-
let startRecording = false;
|
|
58
|
-
for (const stateMachine of this._tspStateMachines) {
|
|
59
|
-
stateMachine.resetCurrentStateCache();
|
|
60
|
-
if (stateMachine.isFinalState()) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const nextState = stateMachine.getNextState();
|
|
64
|
-
if (nextState == null || !(nextState.matchCriteria & ETokenMatchCriteria.Name)) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
const transitioned = stateMachine.transitionIfNameMatch(
|
|
68
|
-
token.local,
|
|
69
|
-
token.prefix,
|
|
70
|
-
this._currentDepth
|
|
71
|
-
);
|
|
72
|
-
if (transitioned && stateMachine.isFinalState()) {
|
|
73
|
-
startRecording = true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return startRecording;
|
|
77
|
-
}
|
|
78
|
-
handleAttribute(token) {
|
|
79
|
-
let startRecording = false;
|
|
80
|
-
for (const stateMachine of this._tspStateMachines) {
|
|
81
|
-
if (stateMachine.isFinalState()) {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const nextState = stateMachine.getNextState();
|
|
85
|
-
if (nextState == null || !(nextState.matchCriteria & ETokenMatchCriteria.Attributes)) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const transitioned = stateMachine.transitionIfAttributesMatch(
|
|
89
|
-
token.local,
|
|
90
|
-
token.prefix,
|
|
91
|
-
token.value,
|
|
92
|
-
this._currentDepth
|
|
93
|
-
);
|
|
94
|
-
if (transitioned && stateMachine.isFinalState()) {
|
|
95
|
-
startRecording = true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return startRecording;
|
|
99
|
-
}
|
|
100
|
-
handleText(token) {
|
|
101
|
-
let startRecording = false;
|
|
102
|
-
for (const stateMachine of this._tspStateMachines) {
|
|
103
|
-
if (stateMachine.isFinalState()) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const nextState = stateMachine.getNextState();
|
|
107
|
-
if (nextState == null || !(nextState.matchCriteria & ETokenMatchCriteria.Text)) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
const transitioned = stateMachine.transitionIfTextMatch(token.text, this._currentDepth);
|
|
111
|
-
if (transitioned && stateMachine.isFinalState()) {
|
|
112
|
-
startRecording = true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return startRecording;
|
|
116
|
-
}
|
|
117
|
-
handleElementEnd(token) {
|
|
118
|
-
if (token.end.type === "Close" || token.end.type === "Empty") {
|
|
119
|
-
this._currentDepth -= 1;
|
|
120
|
-
let isFinalState = false;
|
|
121
|
-
for (const stateMachine of this._tspStateMachines) {
|
|
122
|
-
const currentState = stateMachine.getCurrentState();
|
|
123
|
-
if (currentState == null) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (currentState.enteredDepth != null && this._currentDepth < currentState.enteredDepth) {
|
|
127
|
-
stateMachine.transitionBack(this._currentDepth);
|
|
128
|
-
}
|
|
129
|
-
isFinalState = isFinalState || stateMachine.isFinalState();
|
|
130
|
-
}
|
|
131
|
-
return !isFinalState;
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export { TokenSelector };
|
|
138
|
-
//# sourceMappingURL=TokenSelector.js.map
|
|
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,20 +1 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (typeof config === "string") {
|
|
3
|
-
return value === config;
|
|
4
|
-
}
|
|
5
|
-
switch (config.matchStrategy) {
|
|
6
|
-
case "ANY":
|
|
7
|
-
return true;
|
|
8
|
-
case "EXACT":
|
|
9
|
-
return value === config.value;
|
|
10
|
-
case "CONTAINS":
|
|
11
|
-
return value.includes(config.value);
|
|
12
|
-
case "STARTS_WITH":
|
|
13
|
-
return value.startsWith(config.value);
|
|
14
|
-
case "ENDS_WITH":
|
|
15
|
-
return value.endsWith(config.value);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { matchString };
|
|
20
|
-
//# sourceMappingURL=match-string.js.map
|
|
1
|
+
function r(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{r as matchString};
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TokenSelector } from './TokenSelector.js';
|
|
3
|
-
|
|
4
|
-
function select(xml, tokenSelectPaths, callback, options) {
|
|
5
|
-
const selector = new TokenSelector(tokenSelectPaths);
|
|
6
|
-
tokenize(
|
|
7
|
-
xml,
|
|
8
|
-
(token, stream) => {
|
|
9
|
-
selector.pipeToken(token, (recordedToken) => {
|
|
10
|
-
callback(recordedToken, stream);
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
options
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { select };
|
|
18
|
-
//# sourceMappingURL=select.js.map
|
|
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};
|
package/dist/esm/token-to-xml.js
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
function
|
|
2
|
-
let xmlString = "";
|
|
3
|
-
switch (token.type) {
|
|
4
|
-
case "ProcessingInstruction":
|
|
5
|
-
xmlString += `<?${token.target}`;
|
|
6
|
-
if (token.content) {
|
|
7
|
-
xmlString += ` ${token.content}`;
|
|
8
|
-
}
|
|
9
|
-
xmlString += "?>";
|
|
10
|
-
break;
|
|
11
|
-
case "Comment":
|
|
12
|
-
xmlString += `<!--${token.text}-->`;
|
|
13
|
-
break;
|
|
14
|
-
case "EntityDeclaration":
|
|
15
|
-
xmlString += `<!ENTITY ${token.name} "${token.definition}">`;
|
|
16
|
-
break;
|
|
17
|
-
case "ElementStart":
|
|
18
|
-
xmlString += `<${token.prefix.length > 0 ? `${token.prefix}:` : ""}${token.local}`;
|
|
19
|
-
break;
|
|
20
|
-
case "Attribute":
|
|
21
|
-
xmlString += ` ${token.prefix.length > 0 ? `${token.prefix}:` : ""}${token.local}="${token.value}"`;
|
|
22
|
-
break;
|
|
23
|
-
case "ElementEnd":
|
|
24
|
-
if (token.end.type === "Open") {
|
|
25
|
-
xmlString += ">";
|
|
26
|
-
} else if (token.end.type === "Close") {
|
|
27
|
-
xmlString += `</${token.end.prefix.length > 0 ? `${token.end.prefix}:` : ""}${token.end.local}>`;
|
|
28
|
-
} else {
|
|
29
|
-
xmlString += "/>";
|
|
30
|
-
}
|
|
31
|
-
break;
|
|
32
|
-
case "Text":
|
|
33
|
-
xmlString += token.text;
|
|
34
|
-
break;
|
|
35
|
-
case "Cdata":
|
|
36
|
-
xmlString += `<![CDATA[${token.text}]]>`;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
return xmlString;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { tokenToXml };
|
|
43
|
-
//# sourceMappingURL=token-to-xml.js.map
|
|
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};
|