@loaders.gl/xml 3.4.0-alpha.2 → 3.4.0-alpha.3
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/dist.min.js +59 -18
- package/dist/es5/html-loader.js +6 -8
- package/dist/es5/html-loader.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parsers/parse-xml.js +0 -1
- package/dist/es5/lib/parsers/parse-xml.js.map +1 -1
- package/dist/es5/lib/parsers/streaming-xml-parser.js +2 -7
- package/dist/es5/lib/parsers/streaming-xml-parser.js.map +1 -1
- package/dist/es5/lib/xml-utils/uncapitalize.js +0 -2
- package/dist/es5/lib/xml-utils/uncapitalize.js.map +1 -1
- package/dist/es5/lib/xml-utils/xml-utils.js +1 -4
- package/dist/es5/lib/xml-utils/xml-utils.js.map +1 -1
- package/dist/es5/sax-ts/sax.js +1 -18
- package/dist/es5/sax-ts/sax.js.map +1 -1
- package/dist/es5/xml-loader.js +7 -11
- package/dist/es5/xml-loader.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/html-loader.js +0 -2
- package/dist/esm/html-loader.js.map +1 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/parsers/parse-xml.js +0 -3
- package/dist/esm/lib/parsers/parse-xml.js.map +1 -1
- package/dist/esm/lib/parsers/streaming-xml-parser.js +1 -6
- package/dist/esm/lib/parsers/streaming-xml-parser.js.map +1 -1
- package/dist/esm/lib/xml-utils/uncapitalize.js +0 -3
- package/dist/esm/lib/xml-utils/uncapitalize.js.map +1 -1
- package/dist/esm/lib/xml-utils/xml-utils.js +1 -5
- package/dist/esm/lib/xml-utils/xml-utils.js.map +1 -1
- package/dist/esm/sax-ts/sax.js +1 -19
- package/dist/esm/sax-ts/sax.js.map +1 -1
- package/dist/esm/xml-loader.js +1 -4
- package/dist/esm/xml-loader.js.map +1 -1
- package/dist/sax-ts/sax.js +1 -1
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export { XMLLoader } from './xml-loader';
|
|
4
|
-
|
|
5
2
|
export { HTMLLoader } from './html-loader';
|
|
6
|
-
|
|
7
3
|
export { SAXParser } from './sax-ts/sax';
|
|
8
|
-
|
|
9
4
|
export { convertXMLValueToArray, convertXMLFieldToArrayInPlace } from './lib/xml-utils/xml-utils';
|
|
10
|
-
|
|
11
5
|
export { uncapitalize as _uncapitalize, uncapitalizeKeys as _uncapitalizeKeys } from './lib/xml-utils/uncapitalize';
|
|
12
6
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["XMLLoader","HTMLLoader","SAXParser","convertXMLValueToArray","convertXMLFieldToArrayInPlace","uncapitalize","_uncapitalize","uncapitalizeKeys","_uncapitalizeKeys"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// XMLLoader\n\nexport type {XMLLoaderOptions} from './xml-loader';\nexport {XMLLoader} from './xml-loader';\n\n// HTMLLoader\n\nexport type {HTMLLoaderOptions} from './html-loader';\nexport {HTMLLoader} from './html-loader';\n\n// SAX\n\nexport type {SAXParserOptions as SAXParserOptions} from './sax-ts/sax';\nexport {SAXParser as SAXParser} from './sax-ts/sax';\n\n// Utilities\n\nexport {convertXMLValueToArray, convertXMLFieldToArrayInPlace} from './lib/xml-utils/xml-utils';\n\n// Experimental\n\nexport {\n uncapitalize as _uncapitalize,\n uncapitalizeKeys as _uncapitalizeKeys\n} from './lib/xml-utils/uncapitalize';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["XMLLoader","HTMLLoader","SAXParser","convertXMLValueToArray","convertXMLFieldToArrayInPlace","uncapitalize","_uncapitalize","uncapitalizeKeys","_uncapitalizeKeys"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// XMLLoader\n\nexport type {XMLLoaderOptions} from './xml-loader';\nexport {XMLLoader} from './xml-loader';\n\n// HTMLLoader\n\nexport type {HTMLLoaderOptions} from './html-loader';\nexport {HTMLLoader} from './html-loader';\n\n// SAX\n\nexport type {SAXParserOptions as SAXParserOptions} from './sax-ts/sax';\nexport {SAXParser as SAXParser} from './sax-ts/sax';\n\n// Utilities\n\nexport {convertXMLValueToArray, convertXMLFieldToArrayInPlace} from './lib/xml-utils/xml-utils';\n\n// Experimental\n\nexport {\n uncapitalize as _uncapitalize,\n uncapitalizeKeys as _uncapitalizeKeys\n} from './lib/xml-utils/uncapitalize';\n"],"mappings":"AAKA,SAAQA,SAAS,QAAO,cAAc;AAKtC,SAAQC,UAAU,QAAO,eAAe;AAKxC,SAAQC,SAAsB,QAAO,cAAc;AAInD,SAAQC,sBAAsB,EAAEC,6BAA6B,QAAO,2BAA2B;AAI/F,SACEC,YAAY,IAAIC,aAAa,EAC7BC,gBAAgB,IAAIC,iBAAiB,QAChC,8BAA8B"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import { StreamingXMLParser } from './streaming-xml-parser';
|
|
4
2
|
import { XMLParser as FastXMLParser } from 'fast-xml-parser';
|
|
5
3
|
export function fastParseXML(text, options) {
|
|
@@ -11,7 +9,6 @@ export function fastParseXML(text, options) {
|
|
|
11
9
|
const parsedXML = parser.parse(text);
|
|
12
10
|
return parsedXML;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
export function parseXMLInBatches(text) {
|
|
16
13
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17
14
|
const parser = new StreamingXMLParser({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-xml.js","names":["StreamingXMLParser","XMLParser","FastXMLParser","fastParseXML","text","options","parser","ignoreAttributes","attributeNamePrefix","parsedXML","parse","parseXMLInBatches","strict","write","close","result"],"sources":["../../../../src/lib/parsers/parse-xml.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {StreamingXMLParser} from './streaming-xml-parser';\nimport {XMLParser as FastXMLParser} from 'fast-xml-parser';\nimport type {X2jOptions} from 'fast-xml-parser';\n\n/** Type for passing through fast-xml-parser options */\nexport type FastXMLParserOptions = Partial<X2jOptions>;\n\nexport function fastParseXML(text: string, options: FastXMLParserOptions): any {\n const parser = new FastXMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: '',\n ...options\n });\n\n const parsedXML = parser.parse(text);\n\n return parsedXML;\n}\n\n/**\n * @todo Build a streaming XML parser based on sax-js\n * @param text\n * @param options\n * @returns\n */\nexport function parseXMLInBatches(text: string, options = {}): any {\n const parser = new StreamingXMLParser({\n ...options,\n strict: true\n });\n\n parser.write(text);\n parser.close();\n\n return parser.result;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-xml.js","names":["StreamingXMLParser","XMLParser","FastXMLParser","fastParseXML","text","options","parser","ignoreAttributes","attributeNamePrefix","parsedXML","parse","parseXMLInBatches","arguments","length","undefined","strict","write","close","result"],"sources":["../../../../src/lib/parsers/parse-xml.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {StreamingXMLParser} from './streaming-xml-parser';\nimport {XMLParser as FastXMLParser} from 'fast-xml-parser';\nimport type {X2jOptions} from 'fast-xml-parser';\n\n/** Type for passing through fast-xml-parser options */\nexport type FastXMLParserOptions = Partial<X2jOptions>;\n\nexport function fastParseXML(text: string, options: FastXMLParserOptions): any {\n const parser = new FastXMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: '',\n ...options\n });\n\n const parsedXML = parser.parse(text);\n\n return parsedXML;\n}\n\n/**\n * @todo Build a streaming XML parser based on sax-js\n * @param text\n * @param options\n * @returns\n */\nexport function parseXMLInBatches(text: string, options = {}): any {\n const parser = new StreamingXMLParser({\n ...options,\n strict: true\n });\n\n parser.write(text);\n parser.close();\n\n return parser.result;\n}\n"],"mappings":"AAEA,SAAQA,kBAAkB,QAAO,wBAAwB;AACzD,SAAQC,SAAS,IAAIC,aAAa,QAAO,iBAAiB;AAM1D,OAAO,SAASC,YAAYA,CAACC,IAAY,EAAEC,OAA6B,EAAO;EAC7E,MAAMC,MAAM,GAAG,IAAIJ,aAAa,CAAC;IAC/BK,gBAAgB,EAAE,KAAK;IACvBC,mBAAmB,EAAE,EAAE;IACvB,GAAGH;EACL,CAAC,CAAC;EAEF,MAAMI,SAAS,GAAGH,MAAM,CAACI,KAAK,CAACN,IAAI,CAAC;EAEpC,OAAOK,SAAS;AAClB;AAQA,OAAO,SAASE,iBAAiBA,CAACP,IAAY,EAAqB;EAAA,IAAnBC,OAAO,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC1D,MAAMN,MAAM,GAAG,IAAIN,kBAAkB,CAAC;IACpC,GAAGK,OAAO;IACVU,MAAM,EAAE;EACV,CAAC,CAAC;EAEFT,MAAM,CAACU,KAAK,CAACZ,IAAI,CAAC;EAClBE,MAAM,CAACW,KAAK,EAAE;EAEd,OAAOX,MAAM,CAACY,MAAM;AACtB"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
2
|
import { SAXParser } from '../../sax-ts/sax';
|
|
4
|
-
|
|
5
3
|
export class StreamingXMLParser {
|
|
6
|
-
|
|
7
4
|
constructor(options) {
|
|
8
5
|
_defineProperty(this, "parser", void 0);
|
|
9
6
|
_defineProperty(this, "result", undefined);
|
|
@@ -67,7 +64,6 @@ export class StreamingXMLParser {
|
|
|
67
64
|
close() {
|
|
68
65
|
this.parser.close();
|
|
69
66
|
}
|
|
70
|
-
|
|
71
67
|
_pushOrSet(value) {
|
|
72
68
|
const {
|
|
73
69
|
container,
|
|
@@ -78,8 +74,7 @@ export class StreamingXMLParser {
|
|
|
78
74
|
this.currentState.key = null;
|
|
79
75
|
} else if (Array.isArray(container)) {
|
|
80
76
|
container.push(value);
|
|
81
|
-
} else if (container) {
|
|
82
|
-
}
|
|
77
|
+
} else if (container) {}
|
|
83
78
|
}
|
|
84
79
|
_openArray() {
|
|
85
80
|
let newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming-xml-parser.js","names":["SAXParser","StreamingXMLParser","constructor","options","undefined","Object","freeze","container","key","reset","parser","onready","previousStates","length","currentState","onopentag","name","attributes","isSelfClosing","_openObject","emit","onkey","onclosetag","_closeObject","onopenarray","_openArray","onclosearray","_closeArray","ontext","value","_pushOrSet","onerror","error","onend","result","pop","write","chunk","close","Array","isArray","push","newContainer"],"sources":["../../../../src/lib/parsers/streaming-xml-parser.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable */\n\nimport {SAXParser, SAXParserOptions} from '../../sax-ts/sax';\n// import JSONPath from '../jsonpath/jsonpath';\n\nexport type StreamingXMLParserOptions = SAXParserOptions;\n\n/**\n * StreamingXMLParser builds a JSON object using the events emitted by the SAX parser\n */\nexport class StreamingXMLParser {\n readonly parser: SAXParser;\n result = undefined;\n previousStates = [];\n currentState = Object.freeze({container: [], key: null});\n // jsonpath: JSONPath = new JSONPath();\n\n constructor(options: SAXParserOptions) {\n this.reset();\n this.parser = new SAXParser({\n onready: () => {\n this.previousStates.length = 0;\n this.currentState.container.length = 0;\n },\n\n onopentag: ({name, attributes, isSelfClosing}) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n },\n\n onkey: (name) => {\n this.currentState.key = name;\n },\n\n onclosetag: () => {\n this._closeObject();\n },\n\n onopenarray: () => {\n this._openArray();\n },\n\n onclosearray: () => {\n this._closeArray();\n },\n\n ontext: (value) => {\n this._pushOrSet(value);\n },\n\n onerror: (error) => {\n throw error;\n },\n\n onend: () => {\n this.result = this.currentState.container.pop();\n },\n\n ...options\n });\n }\n\n reset(): void {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({container: [], key: null});\n }\n\n write(chunk): void {\n this.parser.write(chunk);\n }\n\n close(): void {\n this.parser.close();\n }\n\n // PRIVATE METHODS\n\n _pushOrSet(value): void {\n const {container, key} = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n } else if (Array.isArray(container)) {\n container.push(value);\n } else if (container) {\n // debugger\n }\n }\n\n _openArray(newContainer = []): void {\n // this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: true, key: null};\n }\n\n _closeArray(): void {\n // this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n\n _openObject(newContainer = {}): void {\n // this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: false, key: null};\n }\n\n _closeObject(): void {\n // this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"streaming-xml-parser.js","names":["SAXParser","StreamingXMLParser","constructor","options","_defineProperty","undefined","Object","freeze","container","key","reset","parser","onready","previousStates","length","currentState","onopentag","_ref","name","attributes","isSelfClosing","_openObject","emit","onkey","onclosetag","_closeObject","onopenarray","_openArray","onclosearray","_closeArray","ontext","value","_pushOrSet","onerror","error","onend","result","pop","write","chunk","close","Array","isArray","push","newContainer","arguments"],"sources":["../../../../src/lib/parsers/streaming-xml-parser.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable */\n\nimport {SAXParser, SAXParserOptions} from '../../sax-ts/sax';\n// import JSONPath from '../jsonpath/jsonpath';\n\nexport type StreamingXMLParserOptions = SAXParserOptions;\n\n/**\n * StreamingXMLParser builds a JSON object using the events emitted by the SAX parser\n */\nexport class StreamingXMLParser {\n readonly parser: SAXParser;\n result = undefined;\n previousStates = [];\n currentState = Object.freeze({container: [], key: null});\n // jsonpath: JSONPath = new JSONPath();\n\n constructor(options: SAXParserOptions) {\n this.reset();\n this.parser = new SAXParser({\n onready: () => {\n this.previousStates.length = 0;\n this.currentState.container.length = 0;\n },\n\n onopentag: ({name, attributes, isSelfClosing}) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n },\n\n onkey: (name) => {\n this.currentState.key = name;\n },\n\n onclosetag: () => {\n this._closeObject();\n },\n\n onopenarray: () => {\n this._openArray();\n },\n\n onclosearray: () => {\n this._closeArray();\n },\n\n ontext: (value) => {\n this._pushOrSet(value);\n },\n\n onerror: (error) => {\n throw error;\n },\n\n onend: () => {\n this.result = this.currentState.container.pop();\n },\n\n ...options\n });\n }\n\n reset(): void {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({container: [], key: null});\n }\n\n write(chunk): void {\n this.parser.write(chunk);\n }\n\n close(): void {\n this.parser.close();\n }\n\n // PRIVATE METHODS\n\n _pushOrSet(value): void {\n const {container, key} = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n } else if (Array.isArray(container)) {\n container.push(value);\n } else if (container) {\n // debugger\n }\n }\n\n _openArray(newContainer = []): void {\n // this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: true, key: null};\n }\n\n _closeArray(): void {\n // this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n\n _openObject(newContainer = {}): void {\n // this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: false, key: null};\n }\n\n _closeObject(): void {\n // this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n}\n"],"mappings":";AAGA,SAAQA,SAAS,QAAyB,kBAAkB;AAQ5D,OAAO,MAAMC,kBAAkB,CAAC;EAO9BC,WAAWA,CAACC,OAAyB,EAAE;IAAAC,eAAA;IAAAA,eAAA,iBAL9B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EACzE;EAEAoB,WAAWA,CAAA,EAAS;IAElB,IAAI,CAACd,YAAY,GAAG,IAAI,CAACF,cAAc,CAACwB,GAAG,EAAE;EAC/C;EAEAhB,WAAWA,CAAA,EAA0B;IAAA,IAAzBuB,YAAY,GAAAC,SAAA,CAAA/B,MAAA,QAAA+B,SAAA,QAAAxC,SAAA,GAAAwC,SAAA,MAAG,CAAC,CAAC;IAE3B,IAAI,CAACb,UAAU,CAACY,YAAY,CAAC;IAC7B,IAAI,CAAC/B,cAAc,CAAC8B,IAAI,CAAC,IAAI,CAAC5B,YAAY,CAAC;IAC3C,IAAI,CAACA,YAAY,GAAG;MAACP,SAAS,EAAEoC,YAAY;MAAEF,OAAO,EAAE,KAAK;MAAEjC,GAAG,EAAE;IAAI,CAAC;EAC1E;EAEAgB,YAAYA,CAAA,EAAS;IAEnB,IAAI,CAACV,YAAY,GAAG,IAAI,CAACF,cAAc,CAACwB,GAAG,EAAE;EAC/C;AACF"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export function uncapitalize(str) {
|
|
4
2
|
return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;
|
|
5
3
|
}
|
|
6
|
-
|
|
7
4
|
export function uncapitalizeKeys(object) {
|
|
8
5
|
if (Array.isArray(object)) {
|
|
9
6
|
return object.map(element => uncapitalizeKeys(element));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uncapitalize.js","names":["uncapitalize","str","charAt","toLowerCase","slice","uncapitalizeKeys","object","Array","isArray","map","element","newObject","key","value","Object","entries"],"sources":["../../../../src/lib/xml-utils/uncapitalize.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/**\n * Uncapitalize first letter of a string\n * @param str\n * @returns\n */\nexport function uncapitalize(str: string): string {\n return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;\n}\n\n/**\n * Recursively uncapitalize all keys in a nested object\n * @param object\n * @returns\n */\nexport function uncapitalizeKeys(object: any): any {\n if (Array.isArray(object)) {\n return object.map((element) => uncapitalizeKeys(element));\n }\n\n if (object && typeof object === 'object') {\n const newObject = {};\n for (const [key, value] of Object.entries(object)) {\n newObject[uncapitalize(key)] = uncapitalizeKeys(value);\n }\n return newObject;\n }\n\n return object;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"uncapitalize.js","names":["uncapitalize","str","charAt","toLowerCase","slice","uncapitalizeKeys","object","Array","isArray","map","element","newObject","key","value","Object","entries"],"sources":["../../../../src/lib/xml-utils/uncapitalize.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/**\n * Uncapitalize first letter of a string\n * @param str\n * @returns\n */\nexport function uncapitalize(str: string): string {\n return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;\n}\n\n/**\n * Recursively uncapitalize all keys in a nested object\n * @param object\n * @returns\n */\nexport function uncapitalizeKeys(object: any): any {\n if (Array.isArray(object)) {\n return object.map((element) => uncapitalizeKeys(element));\n }\n\n if (object && typeof object === 'object') {\n const newObject = {};\n for (const [key, value] of Object.entries(object)) {\n newObject[uncapitalize(key)] = uncapitalizeKeys(value);\n }\n return newObject;\n }\n\n return object;\n}\n"],"mappings":"AAOA,OAAO,SAASA,YAAYA,CAACC,GAAW,EAAU;EAChD,OAAO,OAAOA,GAAG,KAAK,QAAQ,GAAGA,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,GAAGF,GAAG,CAACG,KAAK,CAAC,CAAC,CAAC,GAAGH,GAAG;AACnF;AAOA,OAAO,SAASI,gBAAgBA,CAACC,MAAW,EAAO;EACjD,IAAIC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACzB,OAAOA,MAAM,CAACG,GAAG,CAAEC,OAAO,IAAKL,gBAAgB,CAACK,OAAO,CAAC,CAAC;EAC3D;EAEA,IAAIJ,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IACxC,MAAMK,SAAS,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACT,MAAM,CAAC,EAAE;MACjDK,SAAS,CAACX,YAAY,CAACY,GAAG,CAAC,CAAC,GAAGP,gBAAgB,CAACQ,KAAK,CAAC;IACxD;IACA,OAAOF,SAAS;EAClB;EAEA,OAAOL,MAAM;AACf"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export function convertXMLValueToArray(xmlValue) {
|
|
4
2
|
if (Array.isArray(xmlValue)) {
|
|
5
3
|
return xmlValue;
|
|
6
4
|
}
|
|
7
|
-
if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {
|
|
8
|
-
}
|
|
5
|
+
if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {}
|
|
9
6
|
if (xmlValue) {
|
|
10
7
|
return [xmlValue];
|
|
11
8
|
}
|
|
12
9
|
return [];
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
export function convertXMLFieldToArrayInPlace(xml, key) {
|
|
16
12
|
xml[key] = convertXMLValueToArray(xml[key]);
|
|
17
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml-utils.js","names":["convertXMLValueToArray","xmlValue","Array","isArray","convertXMLFieldToArrayInPlace","xml","key"],"sources":["../../../../src/lib/xml-utils/xml-utils.ts"],"sourcesContent":["// TODO - these utilities could be moved to the XML parser.\n// uncapitalizeKeys could be an XMLLoader option\n\n/**\n * Extracts a value or array and always return an array\n * Useful since XML parses to object instead of array when only a single value is provided\n */\nexport function convertXMLValueToArray(xmlValue: unknown): unknown[] {\n if (Array.isArray(xmlValue)) {\n return xmlValue;\n }\n if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {\n // Error this is an objectified array\n }\n if (xmlValue) {\n return [xmlValue];\n }\n return [];\n}\n\n/**\n * Mutates a field in place, converting it to array\n * Useful since XML parses to object instead of array when only a single value is provided\n */\nexport function convertXMLFieldToArrayInPlace(xml: any, key: string): void {\n xml[key] = convertXMLValueToArray(xml[key]);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"xml-utils.js","names":["convertXMLValueToArray","xmlValue","Array","isArray","convertXMLFieldToArrayInPlace","xml","key"],"sources":["../../../../src/lib/xml-utils/xml-utils.ts"],"sourcesContent":["// TODO - these utilities could be moved to the XML parser.\n// uncapitalizeKeys could be an XMLLoader option\n\n/**\n * Extracts a value or array and always return an array\n * Useful since XML parses to object instead of array when only a single value is provided\n */\nexport function convertXMLValueToArray(xmlValue: unknown): unknown[] {\n if (Array.isArray(xmlValue)) {\n return xmlValue;\n }\n if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {\n // Error this is an objectified array\n }\n if (xmlValue) {\n return [xmlValue];\n }\n return [];\n}\n\n/**\n * Mutates a field in place, converting it to array\n * Useful since XML parses to object instead of array when only a single value is provided\n */\nexport function convertXMLFieldToArrayInPlace(xml: any, key: string): void {\n xml[key] = convertXMLValueToArray(xml[key]);\n}\n"],"mappings":"AAOA,OAAO,SAASA,sBAAsBA,CAACC,QAAiB,EAAa;EACnE,IAAIC,KAAK,CAACC,OAAO,CAACF,QAAQ,CAAC,EAAE;IAC3B,OAAOA,QAAQ;EACjB;EACA,IAAIA,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAE/D;EACA,IAAIA,QAAQ,EAAE;IACZ,OAAO,CAACA,QAAQ,CAAC;EACnB;EACA,OAAO,EAAE;AACX;AAMA,OAAO,SAASG,6BAA6BA,CAACC,GAAQ,EAAEC,GAAW,EAAQ;EACzED,GAAG,CAACC,GAAG,CAAC,GAAGN,sBAAsB,CAACK,GAAG,CAACC,GAAG,CAAC,CAAC;AAC7C"}
|
package/dist/esm/sax-ts/sax.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
2
|
const DEFAULT_SAX_EVENTS = {
|
|
4
3
|
ontext: () => {},
|
|
5
4
|
onprocessinginstruction: () => {},
|
|
@@ -298,9 +297,7 @@ Object.keys(ENTITIES).forEach(key => {
|
|
|
298
297
|
const e = ENTITIES[key];
|
|
299
298
|
ENTITIES[key] = typeof e === 'number' ? String.fromCharCode(e) : e;
|
|
300
299
|
});
|
|
301
|
-
|
|
302
300
|
class SAX {
|
|
303
|
-
|
|
304
301
|
constructor() {
|
|
305
302
|
_defineProperty(this, "EVENTS", EVENTS);
|
|
306
303
|
_defineProperty(this, "ENTITIES", {
|
|
@@ -402,7 +399,6 @@ class SAX {
|
|
|
402
399
|
this.STATE[this.STATE[s]] = s;
|
|
403
400
|
}
|
|
404
401
|
}
|
|
405
|
-
|
|
406
402
|
this.S = this.STATE;
|
|
407
403
|
}
|
|
408
404
|
static charAt(chunk, i) {
|
|
@@ -432,7 +428,6 @@ class SAX {
|
|
|
432
428
|
const qualName = i < 0 ? ['', name] : name.split(':');
|
|
433
429
|
let prefix = qualName[0];
|
|
434
430
|
let local = qualName[1];
|
|
435
|
-
|
|
436
431
|
if (attribute && name === 'xmlns') {
|
|
437
432
|
prefix = 'xmlns';
|
|
438
433
|
local = '';
|
|
@@ -533,8 +528,7 @@ class SAX {
|
|
|
533
528
|
if (c === '!') {
|
|
534
529
|
this.state = this.S.SGML_DECL;
|
|
535
530
|
this.sgmlDecl = '';
|
|
536
|
-
} else if (SAX.isWhitespace(c)) {
|
|
537
|
-
} else if (SAX.isMatch(nameStart, c)) {
|
|
531
|
+
} else if (SAX.isWhitespace(c)) {} else if (SAX.isMatch(nameStart, c)) {
|
|
538
532
|
this.state = this.S.OPEN_TAG;
|
|
539
533
|
this.tagName = c;
|
|
540
534
|
} else if (c === '/') {
|
|
@@ -932,7 +926,6 @@ class SAX {
|
|
|
932
926
|
throw new Error("Unknown state: ".concat(this.state));
|
|
933
927
|
}
|
|
934
928
|
}
|
|
935
|
-
|
|
936
929
|
if (this.position >= this.bufferCheckPosition) {
|
|
937
930
|
this.checkBufferLength();
|
|
938
931
|
}
|
|
@@ -1007,7 +1000,6 @@ class SAX {
|
|
|
1007
1000
|
tag.ns[local] = this.attribValue;
|
|
1008
1001
|
}
|
|
1009
1002
|
}
|
|
1010
|
-
|
|
1011
1003
|
this.attribList.push([this.attribName, this.attribValue]);
|
|
1012
1004
|
} else {
|
|
1013
1005
|
this.tag.attributes[this.attribName] = this.attribValue;
|
|
@@ -1025,7 +1017,6 @@ class SAX {
|
|
|
1025
1017
|
name: this.tagName,
|
|
1026
1018
|
attributes: {}
|
|
1027
1019
|
};
|
|
1028
|
-
|
|
1029
1020
|
if (this.opt.xmlns) {
|
|
1030
1021
|
tag.ns = parent.ns;
|
|
1031
1022
|
}
|
|
@@ -1127,7 +1118,6 @@ class SAX {
|
|
|
1127
1118
|
openTag(selfClosing) {
|
|
1128
1119
|
if (this.opt.xmlns) {
|
|
1129
1120
|
const tag = this.tag;
|
|
1130
|
-
|
|
1131
1121
|
const qn = SAX.qname(this.tagName);
|
|
1132
1122
|
tag.prefix = qn.prefix;
|
|
1133
1123
|
tag.local = qn.local;
|
|
@@ -1146,7 +1136,6 @@ class SAX {
|
|
|
1146
1136
|
});
|
|
1147
1137
|
});
|
|
1148
1138
|
}
|
|
1149
|
-
|
|
1150
1139
|
for (let i = 0, l = this.attribList.length; i < l; i++) {
|
|
1151
1140
|
const nv = this.attribList[i];
|
|
1152
1141
|
const name = nv[0];
|
|
@@ -1162,7 +1151,6 @@ class SAX {
|
|
|
1162
1151
|
local,
|
|
1163
1152
|
uri
|
|
1164
1153
|
};
|
|
1165
|
-
|
|
1166
1154
|
if (prefix && prefix !== 'xmlns' && !uri) {
|
|
1167
1155
|
this.strictFail("Unbound namespace prefix: ".concat(JSON.stringify(prefix)));
|
|
1168
1156
|
a.uri = prefix;
|
|
@@ -1173,7 +1161,6 @@ class SAX {
|
|
|
1173
1161
|
this.attribList.length = 0;
|
|
1174
1162
|
}
|
|
1175
1163
|
this.tag.isSelfClosing = Boolean(selfClosing);
|
|
1176
|
-
|
|
1177
1164
|
this.sawRoot = true;
|
|
1178
1165
|
this.tags.push(this.tag);
|
|
1179
1166
|
this.emitNode('onopentag', this.tag);
|
|
@@ -1206,7 +1193,6 @@ class SAX {
|
|
|
1206
1193
|
this.emitNode('onscript', this.script);
|
|
1207
1194
|
this.script = '';
|
|
1208
1195
|
}
|
|
1209
|
-
|
|
1210
1196
|
let t = this.tags.length;
|
|
1211
1197
|
let tagName = this.tagName;
|
|
1212
1198
|
if (!this.strict) {
|
|
@@ -1220,7 +1206,6 @@ class SAX {
|
|
|
1220
1206
|
break;
|
|
1221
1207
|
}
|
|
1222
1208
|
}
|
|
1223
|
-
|
|
1224
1209
|
if (t < 0) {
|
|
1225
1210
|
this.strictFail("Unmatched closing tag: ".concat(this.tagName));
|
|
1226
1211
|
this.textNode += "</".concat(this.tagName, ">");
|
|
@@ -1257,7 +1242,6 @@ class SAX {
|
|
|
1257
1242
|
this.state = this.S.TEXT;
|
|
1258
1243
|
}
|
|
1259
1244
|
}
|
|
1260
|
-
|
|
1261
1245
|
export class SAXParser extends SAX {
|
|
1262
1246
|
constructor(opt) {
|
|
1263
1247
|
super();
|
|
@@ -1285,11 +1269,9 @@ export class SAXParser extends SAX {
|
|
|
1285
1269
|
this.strictEntities = this.opt.strictEntities;
|
|
1286
1270
|
this.ENTITIES = this.strictEntities ? Object.create(this.XML_ENTITIES) : Object.create(this.ENTITIES);
|
|
1287
1271
|
this.attribList = [];
|
|
1288
|
-
|
|
1289
1272
|
if (this.opt.xmlns) {
|
|
1290
1273
|
this.ns = Object.create(this.rootNS);
|
|
1291
1274
|
}
|
|
1292
|
-
|
|
1293
1275
|
this.trackPosition = this.opt.position !== false;
|
|
1294
1276
|
if (this.trackPosition) {
|
|
1295
1277
|
this.position = this.line = this.column = 0;
|