@visactor/vrender-core 1.1.0-alpha.25 → 1.1.0-alpha.27
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/cjs/allocator/bounds-allocate.js +2 -1
- package/cjs/allocator/graphic-allocate.js +1 -2
- package/cjs/common/bezier-utils.js +2 -1
- package/cjs/common/event-listener-manager.js +1 -2
- package/cjs/common/performance-raf.js +2 -1
- package/cjs/common/polygon.js +2 -2
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +1 -1
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/common/xml/is-xml.d.ts +2 -0
- package/cjs/common/xml/is-xml.js +14 -0
- package/cjs/common/xml/is-xml.js.map +1 -0
- package/cjs/common/xml/parser.d.ts +2 -2
- package/cjs/common/xml/parser.js +14 -11
- package/cjs/common/xml/parser.js.map +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -2
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +1 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.js +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/graphic/graphic-service/graphic-service.d.ts +0 -1
- package/cjs/graphic/graphic-service/graphic-service.js +1 -8
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.js +3 -3
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/tools.js +3 -3
- package/cjs/graphic/tools.js.map +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +389 -393
- package/es/allocator/bounds-allocate.js +2 -1
- package/es/allocator/graphic-allocate.js +1 -2
- package/es/common/bezier-utils.js +2 -1
- package/es/common/event-listener-manager.js +1 -2
- package/es/common/performance-raf.js +2 -1
- package/es/common/polygon.js +1 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +1 -1
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -1
- package/es/common/xml/is-xml.d.ts +2 -0
- package/es/common/xml/is-xml.js +8 -0
- package/es/common/xml/is-xml.js.map +1 -0
- package/es/common/xml/parser.d.ts +2 -2
- package/es/common/xml/parser.js +3 -7
- package/es/common/xml/parser.js.map +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -2
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +1 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.js +1 -1
- package/es/core/window.js +1 -1
- package/es/graphic/graphic-service/graphic-service.d.ts +0 -1
- package/es/graphic/graphic-service/graphic-service.js +0 -10
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.js +3 -3
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/tools.js +3 -3
- package/es/graphic/tools.js.map +1 -1
- package/es/index.js.map +1 -1
- package/package.json +3 -3
- package/cjs/allocator/constants.d.ts +0 -9
- package/cjs/allocator/constants.js +0 -11
- package/cjs/allocator/constants.js.map +0 -1
- package/cjs/common/Reflect-metadata.d.ts +0 -2
- package/cjs/common/Reflect-metadata.js +0 -182
- package/cjs/common/Reflect-metadata.js.map +0 -1
- package/cjs/common/segment/curve/arc.d.ts +0 -17
- package/cjs/common/segment/curve/arc.js +0 -38
- package/cjs/common/segment/curve/arc.js.map +0 -1
- package/cjs/common/segment/curve/ellipse.d.ts +0 -21
- package/cjs/common/segment/curve/ellipse.js +0 -39
- package/cjs/common/segment/curve/ellipse.js.map +0 -1
- package/cjs/common/segment/curve/move.d.ts +0 -16
- package/cjs/common/segment/curve/move.js +0 -37
- package/cjs/common/segment/curve/move.js.map +0 -1
- package/cjs/common/store.d.ts +0 -2
- package/cjs/common/store.js +0 -2
- package/cjs/common/store.js.map +0 -1
- package/cjs/core/application.d.ts +0 -1
- package/cjs/core/application.js +0 -6
- package/cjs/core/application.js.map +0 -1
- package/cjs/core/global-module.d.ts +0 -1
- package/cjs/core/global-module.js +0 -3
- package/cjs/core/global-module.js.map +0 -1
- package/cjs/export.d.ts +0 -1
- package/cjs/export.js +0 -1
- package/cjs/export.js.map +0 -1
- package/cjs/interface/creator.d.ts +0 -4
- package/cjs/interface/creator.js +0 -6
- package/cjs/interface/creator.js.map +0 -1
- package/cjs/interface/graphic/dynamic-path.d.ts +0 -1
- package/cjs/interface/graphic/dynamic-path.js +0 -3
- package/cjs/interface/graphic/dynamic-path.js.map +0 -1
- package/cjs/interface/graphic-utils.d.ts +0 -1
- package/cjs/interface/graphic-utils.js +0 -3
- package/cjs/interface/graphic-utils.js.map +0 -1
- package/cjs/interface/theme-service.d.ts +0 -1
- package/cjs/interface/theme-service.js +0 -3
- package/cjs/interface/theme-service.js.map +0 -1
- package/cjs/plugins/builtin-plugin/poptip-plugin.d.ts +0 -1
- package/cjs/plugins/builtin-plugin/poptip-plugin.js +0 -3
- package/cjs/plugins/builtin-plugin/poptip-plugin.js.map +0 -1
- package/cjs/render/contributions/render/clear-screen.d.ts +0 -1
- package/cjs/render/contributions/render/clear-screen.js +0 -3
- package/cjs/render/contributions/render/clear-screen.js.map +0 -1
- package/cjs/render/contributions/render/render-slector.d.ts +0 -1
- package/cjs/render/contributions/render/render-slector.js +0 -3
- package/cjs/render/contributions/render/render-slector.js.map +0 -1
- package/es/allocator/constants.d.ts +0 -9
- package/es/allocator/constants.js +0 -18
- package/es/allocator/constants.js.map +0 -1
- package/es/common/Reflect-metadata.d.ts +0 -2
- package/es/common/Reflect-metadata.js +0 -178
- package/es/common/Reflect-metadata.js.map +0 -1
- package/es/common/segment/curve/arc.d.ts +0 -17
- package/es/common/segment/curve/arc.js +0 -31
- package/es/common/segment/curve/arc.js.map +0 -1
- package/es/common/segment/curve/ellipse.d.ts +0 -21
- package/es/common/segment/curve/ellipse.js +0 -33
- package/es/common/segment/curve/ellipse.js.map +0 -1
- package/es/common/segment/curve/move.d.ts +0 -16
- package/es/common/segment/curve/move.js +0 -31
- package/es/common/segment/curve/move.js.map +0 -1
- package/es/common/store.d.ts +0 -2
- package/es/common/store.js +0 -2
- package/es/common/store.js.map +0 -1
- package/es/core/application.d.ts +0 -1
- package/es/core/application.js +0 -2
- package/es/core/application.js.map +0 -1
- package/es/core/global-module.d.ts +0 -1
- package/es/core/global-module.js +0 -3
- package/es/core/global-module.js.map +0 -1
- package/es/export.d.ts +0 -1
- package/es/export.js +0 -1
- package/es/export.js.map +0 -1
- package/es/interface/creator.d.ts +0 -4
- package/es/interface/creator.js +0 -2
- package/es/interface/creator.js.map +0 -1
- package/es/interface/graphic/dynamic-path.d.ts +0 -1
- package/es/interface/graphic/dynamic-path.js +0 -3
- package/es/interface/graphic/dynamic-path.js.map +0 -1
- package/es/interface/graphic-utils.d.ts +0 -1
- package/es/interface/graphic-utils.js +0 -3
- package/es/interface/graphic-utils.js.map +0 -1
- package/es/interface/theme-service.d.ts +0 -1
- package/es/interface/theme-service.js +0 -3
- package/es/interface/theme-service.js.map +0 -1
- package/es/plugins/builtin-plugin/poptip-plugin.d.ts +0 -1
- package/es/plugins/builtin-plugin/poptip-plugin.js +0 -3
- package/es/plugins/builtin-plugin/poptip-plugin.js.map +0 -1
- package/es/render/contributions/render/clear-screen.d.ts +0 -1
- package/es/render/contributions/render/clear-screen.js +0 -3
- package/es/render/contributions/render/clear-screen.js.map +0 -1
- package/es/render/contributions/render/render-slector.d.ts +0 -1
- package/es/render/contributions/render/render-slector.js +0 -3
- package/es/render/contributions/render/render-slector.js.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -5984,309 +5984,6 @@ const builtInSymbolStrMap = {
|
|
|
5984
5984
|
roundLine: 'M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z'
|
|
5985
5985
|
};
|
|
5986
5986
|
|
|
5987
|
-
function getAllMatches(string, regex) {
|
|
5988
|
-
const matches = [];
|
|
5989
|
-
let match = regex.exec(string);
|
|
5990
|
-
while (match) {
|
|
5991
|
-
const allmatches = [];
|
|
5992
|
-
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
5993
|
-
const len = match.length;
|
|
5994
|
-
for (let index = 0; index < len; index++) {
|
|
5995
|
-
allmatches.push(match[index]);
|
|
5996
|
-
}
|
|
5997
|
-
matches.push(allmatches);
|
|
5998
|
-
match = regex.exec(string);
|
|
5999
|
-
}
|
|
6000
|
-
return matches;
|
|
6001
|
-
}
|
|
6002
|
-
|
|
6003
|
-
class XmlNode {
|
|
6004
|
-
constructor(tagname) {
|
|
6005
|
-
this.tagname = tagname;
|
|
6006
|
-
this.child = [];
|
|
6007
|
-
this[':@'] = {};
|
|
6008
|
-
}
|
|
6009
|
-
add(key, val) {
|
|
6010
|
-
if (key === '__proto__') {
|
|
6011
|
-
key = '#__proto__';
|
|
6012
|
-
}
|
|
6013
|
-
this.child.push({ [key]: val });
|
|
6014
|
-
}
|
|
6015
|
-
addChild(node) {
|
|
6016
|
-
if (node.tagname === '__proto__') {
|
|
6017
|
-
node.tagname = '#__proto__';
|
|
6018
|
-
}
|
|
6019
|
-
if (node[':@'] && Object.keys(node[':@']).length > 0) {
|
|
6020
|
-
this.child.push({ [node.tagname]: node.child, [':@']: node[':@'] });
|
|
6021
|
-
}
|
|
6022
|
-
else {
|
|
6023
|
-
this.child.push({ [node.tagname]: node.child });
|
|
6024
|
-
}
|
|
6025
|
-
}
|
|
6026
|
-
}
|
|
6027
|
-
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
6028
|
-
const closingIndex = xmlData.indexOf(str, i);
|
|
6029
|
-
if (closingIndex === -1) {
|
|
6030
|
-
throw new Error(errMsg);
|
|
6031
|
-
}
|
|
6032
|
-
else {
|
|
6033
|
-
return closingIndex + str.length - 1;
|
|
6034
|
-
}
|
|
6035
|
-
}
|
|
6036
|
-
function tagExpWithClosingIndex(xmlData, i, closingChar = '>') {
|
|
6037
|
-
let attrBoundary;
|
|
6038
|
-
let tagExp = '';
|
|
6039
|
-
for (let index = i; index < xmlData.length; index++) {
|
|
6040
|
-
let ch = xmlData[index];
|
|
6041
|
-
if (attrBoundary) {
|
|
6042
|
-
if (ch === attrBoundary) {
|
|
6043
|
-
attrBoundary = '';
|
|
6044
|
-
}
|
|
6045
|
-
}
|
|
6046
|
-
else if (ch === '"' || ch === "'") {
|
|
6047
|
-
attrBoundary = ch;
|
|
6048
|
-
}
|
|
6049
|
-
else if (ch === closingChar[0]) {
|
|
6050
|
-
if (closingChar[1]) {
|
|
6051
|
-
if (xmlData[index + 1] === closingChar[1]) {
|
|
6052
|
-
return {
|
|
6053
|
-
data: tagExp,
|
|
6054
|
-
index: index
|
|
6055
|
-
};
|
|
6056
|
-
}
|
|
6057
|
-
}
|
|
6058
|
-
else {
|
|
6059
|
-
return {
|
|
6060
|
-
data: tagExp,
|
|
6061
|
-
index: index
|
|
6062
|
-
};
|
|
6063
|
-
}
|
|
6064
|
-
}
|
|
6065
|
-
else if (ch === '\t') {
|
|
6066
|
-
ch = ' ';
|
|
6067
|
-
}
|
|
6068
|
-
tagExp += ch;
|
|
6069
|
-
}
|
|
6070
|
-
}
|
|
6071
|
-
function readTagExp(xmlData, i, removeNSPrefix, closingChar = '>') {
|
|
6072
|
-
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
6073
|
-
if (!result) {
|
|
6074
|
-
return;
|
|
6075
|
-
}
|
|
6076
|
-
let tagExp = result.data;
|
|
6077
|
-
const closeIndex = result.index;
|
|
6078
|
-
const separatorIndex = tagExp.search(/\s/);
|
|
6079
|
-
let tagName = tagExp;
|
|
6080
|
-
let attrExpPresent = true;
|
|
6081
|
-
if (separatorIndex !== -1) {
|
|
6082
|
-
tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, '');
|
|
6083
|
-
tagExp = tagExp.substr(separatorIndex + 1);
|
|
6084
|
-
}
|
|
6085
|
-
const rawTagName = tagName;
|
|
6086
|
-
if (removeNSPrefix) {
|
|
6087
|
-
const colonIndex = tagName.indexOf(':');
|
|
6088
|
-
if (colonIndex !== -1) {
|
|
6089
|
-
tagName = tagName.substr(colonIndex + 1);
|
|
6090
|
-
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
6091
|
-
}
|
|
6092
|
-
}
|
|
6093
|
-
return {
|
|
6094
|
-
tagName: tagName,
|
|
6095
|
-
tagExp: tagExp,
|
|
6096
|
-
closeIndex: closeIndex,
|
|
6097
|
-
attrExpPresent: attrExpPresent,
|
|
6098
|
-
rawTagName: rawTagName
|
|
6099
|
-
};
|
|
6100
|
-
}
|
|
6101
|
-
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
|
|
6102
|
-
class OrderedObjParser {
|
|
6103
|
-
constructor(options) {
|
|
6104
|
-
this.currentNode = null;
|
|
6105
|
-
this.options = options;
|
|
6106
|
-
this.tagsNodeStack = [];
|
|
6107
|
-
this.docTypeEntities = {};
|
|
6108
|
-
}
|
|
6109
|
-
addChild(currentNode, childNode, jPath) {
|
|
6110
|
-
const result = childNode.tagname;
|
|
6111
|
-
if (typeof result === 'string') {
|
|
6112
|
-
childNode.tagname = result;
|
|
6113
|
-
currentNode.addChild(childNode);
|
|
6114
|
-
}
|
|
6115
|
-
else {
|
|
6116
|
-
currentNode.addChild(childNode);
|
|
6117
|
-
}
|
|
6118
|
-
}
|
|
6119
|
-
buildAttributesMap(attrStr, jPath, tagName) {
|
|
6120
|
-
const attrs = {};
|
|
6121
|
-
if (!attrStr) {
|
|
6122
|
-
return;
|
|
6123
|
-
}
|
|
6124
|
-
const matches = getAllMatches(attrStr, attrsRegx);
|
|
6125
|
-
const len = matches.length;
|
|
6126
|
-
for (let i = 0; i < len; i++) {
|
|
6127
|
-
const attrName = matches[i][1];
|
|
6128
|
-
const oldVal = matches[i][4];
|
|
6129
|
-
const aName = attrName;
|
|
6130
|
-
if (attrName) {
|
|
6131
|
-
if (oldVal !== undefined) {
|
|
6132
|
-
attrs[aName] = isNaN(oldVal) ? oldVal : Number(oldVal);
|
|
6133
|
-
}
|
|
6134
|
-
else {
|
|
6135
|
-
attrs[aName] = true;
|
|
6136
|
-
}
|
|
6137
|
-
}
|
|
6138
|
-
}
|
|
6139
|
-
return attrs;
|
|
6140
|
-
}
|
|
6141
|
-
parseXml(xmlData) {
|
|
6142
|
-
xmlData = xmlData.replace(/\r\n?/g, '\n');
|
|
6143
|
-
const xmlObj = new XmlNode('!xml');
|
|
6144
|
-
let currentNode = xmlObj;
|
|
6145
|
-
let textData = '';
|
|
6146
|
-
let jPath = '';
|
|
6147
|
-
for (let i = 0; i < xmlData.length; i++) {
|
|
6148
|
-
const ch = xmlData[i];
|
|
6149
|
-
if (ch === '<') {
|
|
6150
|
-
if (xmlData[i + 1] === '/') {
|
|
6151
|
-
const closeIndex = findClosingIndex(xmlData, '>', i, 'Closing Tag is not closed.');
|
|
6152
|
-
const propIndex = jPath.lastIndexOf('.');
|
|
6153
|
-
jPath = jPath.substring(0, propIndex);
|
|
6154
|
-
currentNode = this.tagsNodeStack.pop();
|
|
6155
|
-
if (currentNode && currentNode.child && textData) {
|
|
6156
|
-
currentNode.child[currentNode.child.length - 1][':@'] &&
|
|
6157
|
-
(currentNode.child[currentNode.child.length - 1][':@'].text = textData);
|
|
6158
|
-
}
|
|
6159
|
-
textData = '';
|
|
6160
|
-
i = closeIndex;
|
|
6161
|
-
}
|
|
6162
|
-
else if (xmlData[i + 1] === '?') {
|
|
6163
|
-
const tagData = readTagExp(xmlData, i, false, '?>');
|
|
6164
|
-
i = tagData.closeIndex + 1;
|
|
6165
|
-
}
|
|
6166
|
-
else if (xmlData.substr(i + 1, 3) === '!--') {
|
|
6167
|
-
const endIndex = findClosingIndex(xmlData, '-->', i + 4, 'Comment is not closed.');
|
|
6168
|
-
i = endIndex;
|
|
6169
|
-
}
|
|
6170
|
-
else {
|
|
6171
|
-
const result = readTagExp(xmlData, i, false);
|
|
6172
|
-
let tagName = result.tagName;
|
|
6173
|
-
let tagExp = result.tagExp;
|
|
6174
|
-
const attrExpPresent = result.attrExpPresent;
|
|
6175
|
-
const closeIndex = result.closeIndex;
|
|
6176
|
-
if (tagName !== xmlObj.tagname) {
|
|
6177
|
-
jPath += jPath ? '.' + tagName : tagName;
|
|
6178
|
-
}
|
|
6179
|
-
if (tagExp.length > 0 && tagExp.lastIndexOf('/') === tagExp.length - 1) {
|
|
6180
|
-
if (tagName[tagName.length - 1] === '/') {
|
|
6181
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
6182
|
-
jPath = jPath.substr(0, jPath.length - 1);
|
|
6183
|
-
tagExp = tagName;
|
|
6184
|
-
}
|
|
6185
|
-
else {
|
|
6186
|
-
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
6187
|
-
}
|
|
6188
|
-
const childNode = new XmlNode(tagName);
|
|
6189
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
6190
|
-
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
6191
|
-
}
|
|
6192
|
-
this.addChild(currentNode, childNode, jPath);
|
|
6193
|
-
jPath = jPath.substr(0, jPath.lastIndexOf('.'));
|
|
6194
|
-
}
|
|
6195
|
-
else {
|
|
6196
|
-
const childNode = new XmlNode(tagName);
|
|
6197
|
-
this.tagsNodeStack.push(currentNode);
|
|
6198
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
6199
|
-
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
6200
|
-
}
|
|
6201
|
-
this.addChild(currentNode, childNode, jPath);
|
|
6202
|
-
currentNode = childNode;
|
|
6203
|
-
}
|
|
6204
|
-
textData = '';
|
|
6205
|
-
i = closeIndex;
|
|
6206
|
-
}
|
|
6207
|
-
}
|
|
6208
|
-
else {
|
|
6209
|
-
textData += xmlData[i];
|
|
6210
|
-
}
|
|
6211
|
-
}
|
|
6212
|
-
return xmlObj.child;
|
|
6213
|
-
}
|
|
6214
|
-
}
|
|
6215
|
-
|
|
6216
|
-
function prettify(node, options) {
|
|
6217
|
-
return compress(node);
|
|
6218
|
-
}
|
|
6219
|
-
function compress(arr, jPath) {
|
|
6220
|
-
const compressedObj = {};
|
|
6221
|
-
for (let i = 0; i < arr.length; i++) {
|
|
6222
|
-
const tagObj = arr[i];
|
|
6223
|
-
const property = propName(tagObj);
|
|
6224
|
-
if (property === undefined) {
|
|
6225
|
-
continue;
|
|
6226
|
-
}
|
|
6227
|
-
else if (tagObj[property]) {
|
|
6228
|
-
const val = compress(tagObj[property]);
|
|
6229
|
-
isLeafTag(val);
|
|
6230
|
-
if (tagObj[':@']) {
|
|
6231
|
-
assignAttributes(val, tagObj[':@']);
|
|
6232
|
-
}
|
|
6233
|
-
if (compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {
|
|
6234
|
-
if (!Array.isArray(compressedObj[property])) {
|
|
6235
|
-
compressedObj[property] = [compressedObj[property]];
|
|
6236
|
-
}
|
|
6237
|
-
compressedObj[property].push(val);
|
|
6238
|
-
}
|
|
6239
|
-
else {
|
|
6240
|
-
compressedObj[property] = val;
|
|
6241
|
-
}
|
|
6242
|
-
}
|
|
6243
|
-
}
|
|
6244
|
-
return compressedObj;
|
|
6245
|
-
}
|
|
6246
|
-
function propName(obj) {
|
|
6247
|
-
const keys = Object.keys(obj);
|
|
6248
|
-
for (let i = 0; i < keys.length; i++) {
|
|
6249
|
-
const key = keys[i];
|
|
6250
|
-
if (key !== ':@') {
|
|
6251
|
-
return key;
|
|
6252
|
-
}
|
|
6253
|
-
}
|
|
6254
|
-
}
|
|
6255
|
-
function assignAttributes(obj, attrMap, jpath) {
|
|
6256
|
-
if (attrMap) {
|
|
6257
|
-
const keys = Object.keys(attrMap);
|
|
6258
|
-
const len = keys.length;
|
|
6259
|
-
for (let i = 0; i < len; i++) {
|
|
6260
|
-
const atrrName = keys[i];
|
|
6261
|
-
obj[atrrName] = attrMap[atrrName];
|
|
6262
|
-
}
|
|
6263
|
-
}
|
|
6264
|
-
}
|
|
6265
|
-
function isLeafTag(obj) {
|
|
6266
|
-
const propCount = Object.keys(obj).length;
|
|
6267
|
-
if (propCount === 0) {
|
|
6268
|
-
return true;
|
|
6269
|
-
}
|
|
6270
|
-
return false;
|
|
6271
|
-
}
|
|
6272
|
-
|
|
6273
|
-
class XMLParser {
|
|
6274
|
-
constructor(options) {
|
|
6275
|
-
this.options = Object.assign({}, XMLParser.defaultOptions, options);
|
|
6276
|
-
}
|
|
6277
|
-
valid(xml) {
|
|
6278
|
-
return xml.startsWith('<');
|
|
6279
|
-
}
|
|
6280
|
-
parse(xmlData) {
|
|
6281
|
-
if (!this.valid) {
|
|
6282
|
-
return false;
|
|
6283
|
-
}
|
|
6284
|
-
const orderedObjParser = new OrderedObjParser(this.options);
|
|
6285
|
-
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
6286
|
-
return prettify(orderedResult, this.options);
|
|
6287
|
-
}
|
|
6288
|
-
}
|
|
6289
|
-
XMLParser.defaultOptions = {};
|
|
6290
5987
|
function isSvg(str) {
|
|
6291
5988
|
return str.startsWith('<svg') || str.startsWith('<?xml');
|
|
6292
5989
|
}
|
|
@@ -6294,6 +5991,7 @@ function isXML(str) {
|
|
|
6294
5991
|
return str.startsWith('<');
|
|
6295
5992
|
}
|
|
6296
5993
|
|
|
5994
|
+
const loadXMLParser$1 = () => require('../common/xml/parser');
|
|
6297
5995
|
function incrementalAddTo(group, graphic) {
|
|
6298
5996
|
group.incrementalAppendChild(graphic);
|
|
6299
5997
|
}
|
|
@@ -6406,6 +6104,7 @@ function xul(str) {
|
|
|
6406
6104
|
}
|
|
6407
6105
|
const valid = isXML(xmlStr);
|
|
6408
6106
|
if (valid === true) {
|
|
6107
|
+
const { XMLParser } = loadXMLParser$1();
|
|
6409
6108
|
const parser = new XMLParser();
|
|
6410
6109
|
const data = parser.parse(xmlStr);
|
|
6411
6110
|
data.tc &&
|
|
@@ -9736,6 +9435,7 @@ function flushStageSharedStateRefresh(stage) {
|
|
|
9736
9435
|
|
|
9737
9436
|
const _tempBounds$1 = new AABBBounds();
|
|
9738
9437
|
const loadShadowRootFactory = () => require('./shadow-root');
|
|
9438
|
+
const loadXMLParser = () => require('../common/xml/parser');
|
|
9739
9439
|
const tempMatrix = new Matrix();
|
|
9740
9440
|
const PURE_STYLE_KEY = [
|
|
9741
9441
|
'stroke',
|
|
@@ -10599,6 +10299,7 @@ class Graphic extends Node {
|
|
|
10599
10299
|
symbolType = _symbolType || symbolType;
|
|
10600
10300
|
const valid = isSvg(symbolType);
|
|
10601
10301
|
if (valid === true) {
|
|
10302
|
+
const { XMLParser } = loadXMLParser();
|
|
10602
10303
|
const parser = new XMLParser();
|
|
10603
10304
|
const { svg } = parser.parse(symbolType);
|
|
10604
10305
|
if (!svg) {
|
|
@@ -17087,15 +16788,6 @@ class DefaultGraphicService {
|
|
|
17087
16788
|
this.hooks.clearAABBBounds.call(graphic, stage, b);
|
|
17088
16789
|
}
|
|
17089
16790
|
}
|
|
17090
|
-
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
17091
|
-
const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
17092
|
-
if (!path) {
|
|
17093
|
-
return false;
|
|
17094
|
-
}
|
|
17095
|
-
const boundsContext = new BoundsContext(aabbBounds);
|
|
17096
|
-
renderCommandList(path.commandList, boundsContext, 0, 0);
|
|
17097
|
-
return true;
|
|
17098
|
-
}
|
|
17099
16791
|
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
17100
16792
|
const { textAlign, textBaseline } = attribute;
|
|
17101
16793
|
if (attribute.forceBoundsHeight != null) {
|
|
@@ -28726,111 +28418,415 @@ class DefaultCircleAllocate extends DefaultGraphicAllocate {
|
|
|
28726
28418
|
if (!this.pools.length) {
|
|
28727
28419
|
return application.graphicService.creator.circle(area.attribute);
|
|
28728
28420
|
}
|
|
28729
|
-
const g = this.pools.pop();
|
|
28730
|
-
g.initAttributes(area.attribute);
|
|
28731
|
-
return g;
|
|
28421
|
+
const g = this.pools.pop();
|
|
28422
|
+
g.initAttributes(area.attribute);
|
|
28423
|
+
return g;
|
|
28424
|
+
}
|
|
28425
|
+
}
|
|
28426
|
+
const defaultCircleAllocate = new DefaultCircleAllocate();
|
|
28427
|
+
class DefaultLineAllocate extends DefaultGraphicAllocate {
|
|
28428
|
+
allocate(attribute) {
|
|
28429
|
+
if (!this.pools.length) {
|
|
28430
|
+
return application.graphicService.creator.line(attribute);
|
|
28431
|
+
}
|
|
28432
|
+
const g = this.pools.pop();
|
|
28433
|
+
g.initAttributes(attribute);
|
|
28434
|
+
return g;
|
|
28435
|
+
}
|
|
28436
|
+
allocateByObj(line) {
|
|
28437
|
+
if (!this.pools.length) {
|
|
28438
|
+
return application.graphicService.creator.line(line.attribute);
|
|
28439
|
+
}
|
|
28440
|
+
const g = this.pools.pop();
|
|
28441
|
+
g.initAttributes(line.attribute);
|
|
28442
|
+
return g;
|
|
28443
|
+
}
|
|
28444
|
+
}
|
|
28445
|
+
const defaultLineAllocate = new DefaultLineAllocate();
|
|
28446
|
+
class DefaultPathAllocate extends DefaultGraphicAllocate {
|
|
28447
|
+
allocate(attribute) {
|
|
28448
|
+
if (!this.pools.length) {
|
|
28449
|
+
return application.graphicService.creator.path(attribute);
|
|
28450
|
+
}
|
|
28451
|
+
const g = this.pools.pop();
|
|
28452
|
+
g.initAttributes(attribute);
|
|
28453
|
+
return g;
|
|
28454
|
+
}
|
|
28455
|
+
allocateByObj(path) {
|
|
28456
|
+
if (!this.pools.length) {
|
|
28457
|
+
return application.graphicService.creator.path(path.attribute);
|
|
28458
|
+
}
|
|
28459
|
+
const g = this.pools.pop();
|
|
28460
|
+
g.initAttributes(path.attribute);
|
|
28461
|
+
return g;
|
|
28462
|
+
}
|
|
28463
|
+
}
|
|
28464
|
+
const defaultPathAllocate = new DefaultPathAllocate();
|
|
28465
|
+
class DefaultSymbolAllocate extends DefaultGraphicAllocate {
|
|
28466
|
+
allocate(attribute) {
|
|
28467
|
+
if (!this.pools.length) {
|
|
28468
|
+
return application.graphicService.creator.symbol(attribute);
|
|
28469
|
+
}
|
|
28470
|
+
const g = this.pools.pop();
|
|
28471
|
+
g.initAttributes(attribute);
|
|
28472
|
+
return g;
|
|
28473
|
+
}
|
|
28474
|
+
allocateByObj(symbol) {
|
|
28475
|
+
if (!this.pools.length) {
|
|
28476
|
+
return application.graphicService.creator.symbol(symbol.attribute);
|
|
28477
|
+
}
|
|
28478
|
+
const g = this.pools.pop();
|
|
28479
|
+
g.initAttributes(symbol.attribute);
|
|
28480
|
+
return g;
|
|
28481
|
+
}
|
|
28482
|
+
}
|
|
28483
|
+
const defaultSymbolAllocate = new DefaultSymbolAllocate();
|
|
28484
|
+
class DefaultTextAllocate extends DefaultGraphicAllocate {
|
|
28485
|
+
allocate(attribute) {
|
|
28486
|
+
if (!this.pools.length) {
|
|
28487
|
+
return application.graphicService.creator.text(attribute);
|
|
28488
|
+
}
|
|
28489
|
+
const g = this.pools.pop();
|
|
28490
|
+
g.initAttributes(attribute);
|
|
28491
|
+
return g;
|
|
28492
|
+
}
|
|
28493
|
+
allocateByObj(text) {
|
|
28494
|
+
if (!this.pools.length) {
|
|
28495
|
+
return application.graphicService.creator.text(text.attribute);
|
|
28496
|
+
}
|
|
28497
|
+
const g = this.pools.pop();
|
|
28498
|
+
g.initAttributes(text.attribute);
|
|
28499
|
+
return g;
|
|
28500
|
+
}
|
|
28501
|
+
}
|
|
28502
|
+
const defaultTextAllocate = new DefaultTextAllocate();
|
|
28503
|
+
class DefaultGraphicMemoryManager {
|
|
28504
|
+
constructor() {
|
|
28505
|
+
this.map = {
|
|
28506
|
+
text: defaultTextAllocate,
|
|
28507
|
+
symbol: defaultSymbolAllocate
|
|
28508
|
+
};
|
|
28509
|
+
}
|
|
28510
|
+
gc(g) {
|
|
28511
|
+
if (g.isContainer) {
|
|
28512
|
+
g.forEachChildren(i => this.gc(i));
|
|
28513
|
+
}
|
|
28514
|
+
else {
|
|
28515
|
+
this.gcItem(g);
|
|
28516
|
+
}
|
|
28517
|
+
}
|
|
28518
|
+
gcItem(g) {
|
|
28519
|
+
const allocate = this.map[g.type];
|
|
28520
|
+
if (allocate) {
|
|
28521
|
+
allocate.free(g);
|
|
28522
|
+
}
|
|
28523
|
+
}
|
|
28524
|
+
}
|
|
28525
|
+
const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager();
|
|
28526
|
+
|
|
28527
|
+
function getAllMatches(string, regex) {
|
|
28528
|
+
const matches = [];
|
|
28529
|
+
let match = regex.exec(string);
|
|
28530
|
+
while (match) {
|
|
28531
|
+
const allmatches = [];
|
|
28532
|
+
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
28533
|
+
const len = match.length;
|
|
28534
|
+
for (let index = 0; index < len; index++) {
|
|
28535
|
+
allmatches.push(match[index]);
|
|
28536
|
+
}
|
|
28537
|
+
matches.push(allmatches);
|
|
28538
|
+
match = regex.exec(string);
|
|
28539
|
+
}
|
|
28540
|
+
return matches;
|
|
28541
|
+
}
|
|
28542
|
+
|
|
28543
|
+
class XmlNode {
|
|
28544
|
+
constructor(tagname) {
|
|
28545
|
+
this.tagname = tagname;
|
|
28546
|
+
this.child = [];
|
|
28547
|
+
this[':@'] = {};
|
|
28548
|
+
}
|
|
28549
|
+
add(key, val) {
|
|
28550
|
+
if (key === '__proto__') {
|
|
28551
|
+
key = '#__proto__';
|
|
28552
|
+
}
|
|
28553
|
+
this.child.push({ [key]: val });
|
|
28554
|
+
}
|
|
28555
|
+
addChild(node) {
|
|
28556
|
+
if (node.tagname === '__proto__') {
|
|
28557
|
+
node.tagname = '#__proto__';
|
|
28558
|
+
}
|
|
28559
|
+
if (node[':@'] && Object.keys(node[':@']).length > 0) {
|
|
28560
|
+
this.child.push({ [node.tagname]: node.child, [':@']: node[':@'] });
|
|
28561
|
+
}
|
|
28562
|
+
else {
|
|
28563
|
+
this.child.push({ [node.tagname]: node.child });
|
|
28564
|
+
}
|
|
28565
|
+
}
|
|
28566
|
+
}
|
|
28567
|
+
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
28568
|
+
const closingIndex = xmlData.indexOf(str, i);
|
|
28569
|
+
if (closingIndex === -1) {
|
|
28570
|
+
throw new Error(errMsg);
|
|
28571
|
+
}
|
|
28572
|
+
else {
|
|
28573
|
+
return closingIndex + str.length - 1;
|
|
28574
|
+
}
|
|
28575
|
+
}
|
|
28576
|
+
function tagExpWithClosingIndex(xmlData, i, closingChar = '>') {
|
|
28577
|
+
let attrBoundary;
|
|
28578
|
+
let tagExp = '';
|
|
28579
|
+
for (let index = i; index < xmlData.length; index++) {
|
|
28580
|
+
let ch = xmlData[index];
|
|
28581
|
+
if (attrBoundary) {
|
|
28582
|
+
if (ch === attrBoundary) {
|
|
28583
|
+
attrBoundary = '';
|
|
28584
|
+
}
|
|
28585
|
+
}
|
|
28586
|
+
else if (ch === '"' || ch === "'") {
|
|
28587
|
+
attrBoundary = ch;
|
|
28588
|
+
}
|
|
28589
|
+
else if (ch === closingChar[0]) {
|
|
28590
|
+
if (closingChar[1]) {
|
|
28591
|
+
if (xmlData[index + 1] === closingChar[1]) {
|
|
28592
|
+
return {
|
|
28593
|
+
data: tagExp,
|
|
28594
|
+
index: index
|
|
28595
|
+
};
|
|
28596
|
+
}
|
|
28597
|
+
}
|
|
28598
|
+
else {
|
|
28599
|
+
return {
|
|
28600
|
+
data: tagExp,
|
|
28601
|
+
index: index
|
|
28602
|
+
};
|
|
28603
|
+
}
|
|
28604
|
+
}
|
|
28605
|
+
else if (ch === '\t') {
|
|
28606
|
+
ch = ' ';
|
|
28607
|
+
}
|
|
28608
|
+
tagExp += ch;
|
|
28609
|
+
}
|
|
28610
|
+
}
|
|
28611
|
+
function readTagExp(xmlData, i, removeNSPrefix, closingChar = '>') {
|
|
28612
|
+
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
28613
|
+
if (!result) {
|
|
28614
|
+
return;
|
|
28615
|
+
}
|
|
28616
|
+
let tagExp = result.data;
|
|
28617
|
+
const closeIndex = result.index;
|
|
28618
|
+
const separatorIndex = tagExp.search(/\s/);
|
|
28619
|
+
let tagName = tagExp;
|
|
28620
|
+
let attrExpPresent = true;
|
|
28621
|
+
if (separatorIndex !== -1) {
|
|
28622
|
+
tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, '');
|
|
28623
|
+
tagExp = tagExp.substr(separatorIndex + 1);
|
|
28624
|
+
}
|
|
28625
|
+
const rawTagName = tagName;
|
|
28626
|
+
if (removeNSPrefix) {
|
|
28627
|
+
const colonIndex = tagName.indexOf(':');
|
|
28628
|
+
if (colonIndex !== -1) {
|
|
28629
|
+
tagName = tagName.substr(colonIndex + 1);
|
|
28630
|
+
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
28631
|
+
}
|
|
28732
28632
|
}
|
|
28633
|
+
return {
|
|
28634
|
+
tagName: tagName,
|
|
28635
|
+
tagExp: tagExp,
|
|
28636
|
+
closeIndex: closeIndex,
|
|
28637
|
+
attrExpPresent: attrExpPresent,
|
|
28638
|
+
rawTagName: rawTagName
|
|
28639
|
+
};
|
|
28733
28640
|
}
|
|
28734
|
-
const
|
|
28735
|
-
class
|
|
28736
|
-
|
|
28737
|
-
|
|
28738
|
-
|
|
28739
|
-
|
|
28740
|
-
|
|
28741
|
-
g.initAttributes(attribute);
|
|
28742
|
-
return g;
|
|
28641
|
+
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
|
|
28642
|
+
class OrderedObjParser {
|
|
28643
|
+
constructor(options) {
|
|
28644
|
+
this.currentNode = null;
|
|
28645
|
+
this.options = options;
|
|
28646
|
+
this.tagsNodeStack = [];
|
|
28647
|
+
this.docTypeEntities = {};
|
|
28743
28648
|
}
|
|
28744
|
-
|
|
28745
|
-
|
|
28746
|
-
|
|
28649
|
+
addChild(currentNode, childNode, jPath) {
|
|
28650
|
+
const result = childNode.tagname;
|
|
28651
|
+
if (typeof result === 'string') {
|
|
28652
|
+
childNode.tagname = result;
|
|
28653
|
+
currentNode.addChild(childNode);
|
|
28654
|
+
}
|
|
28655
|
+
else {
|
|
28656
|
+
currentNode.addChild(childNode);
|
|
28747
28657
|
}
|
|
28748
|
-
const g = this.pools.pop();
|
|
28749
|
-
g.initAttributes(line.attribute);
|
|
28750
|
-
return g;
|
|
28751
28658
|
}
|
|
28752
|
-
|
|
28753
|
-
const
|
|
28754
|
-
|
|
28755
|
-
|
|
28756
|
-
if (!this.pools.length) {
|
|
28757
|
-
return application.graphicService.creator.path(attribute);
|
|
28659
|
+
buildAttributesMap(attrStr, jPath, tagName) {
|
|
28660
|
+
const attrs = {};
|
|
28661
|
+
if (!attrStr) {
|
|
28662
|
+
return;
|
|
28758
28663
|
}
|
|
28759
|
-
const
|
|
28760
|
-
|
|
28761
|
-
|
|
28664
|
+
const matches = getAllMatches(attrStr, attrsRegx);
|
|
28665
|
+
const len = matches.length;
|
|
28666
|
+
for (let i = 0; i < len; i++) {
|
|
28667
|
+
const attrName = matches[i][1];
|
|
28668
|
+
const oldVal = matches[i][4];
|
|
28669
|
+
const aName = attrName;
|
|
28670
|
+
if (attrName) {
|
|
28671
|
+
if (oldVal !== undefined) {
|
|
28672
|
+
attrs[aName] = isNaN(oldVal) ? oldVal : Number(oldVal);
|
|
28673
|
+
}
|
|
28674
|
+
else {
|
|
28675
|
+
attrs[aName] = true;
|
|
28676
|
+
}
|
|
28677
|
+
}
|
|
28678
|
+
}
|
|
28679
|
+
return attrs;
|
|
28762
28680
|
}
|
|
28763
|
-
|
|
28764
|
-
|
|
28765
|
-
|
|
28681
|
+
parseXml(xmlData) {
|
|
28682
|
+
xmlData = xmlData.replace(/\r\n?/g, '\n');
|
|
28683
|
+
const xmlObj = new XmlNode('!xml');
|
|
28684
|
+
let currentNode = xmlObj;
|
|
28685
|
+
let textData = '';
|
|
28686
|
+
let jPath = '';
|
|
28687
|
+
for (let i = 0; i < xmlData.length; i++) {
|
|
28688
|
+
const ch = xmlData[i];
|
|
28689
|
+
if (ch === '<') {
|
|
28690
|
+
if (xmlData[i + 1] === '/') {
|
|
28691
|
+
const closeIndex = findClosingIndex(xmlData, '>', i, 'Closing Tag is not closed.');
|
|
28692
|
+
const propIndex = jPath.lastIndexOf('.');
|
|
28693
|
+
jPath = jPath.substring(0, propIndex);
|
|
28694
|
+
currentNode = this.tagsNodeStack.pop();
|
|
28695
|
+
if (currentNode && currentNode.child && textData) {
|
|
28696
|
+
currentNode.child[currentNode.child.length - 1][':@'] &&
|
|
28697
|
+
(currentNode.child[currentNode.child.length - 1][':@'].text = textData);
|
|
28698
|
+
}
|
|
28699
|
+
textData = '';
|
|
28700
|
+
i = closeIndex;
|
|
28701
|
+
}
|
|
28702
|
+
else if (xmlData[i + 1] === '?') {
|
|
28703
|
+
const tagData = readTagExp(xmlData, i, false, '?>');
|
|
28704
|
+
i = tagData.closeIndex + 1;
|
|
28705
|
+
}
|
|
28706
|
+
else if (xmlData.substr(i + 1, 3) === '!--') {
|
|
28707
|
+
const endIndex = findClosingIndex(xmlData, '-->', i + 4, 'Comment is not closed.');
|
|
28708
|
+
i = endIndex;
|
|
28709
|
+
}
|
|
28710
|
+
else {
|
|
28711
|
+
const result = readTagExp(xmlData, i, false);
|
|
28712
|
+
let tagName = result.tagName;
|
|
28713
|
+
let tagExp = result.tagExp;
|
|
28714
|
+
const attrExpPresent = result.attrExpPresent;
|
|
28715
|
+
const closeIndex = result.closeIndex;
|
|
28716
|
+
if (tagName !== xmlObj.tagname) {
|
|
28717
|
+
jPath += jPath ? '.' + tagName : tagName;
|
|
28718
|
+
}
|
|
28719
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf('/') === tagExp.length - 1) {
|
|
28720
|
+
if (tagName[tagName.length - 1] === '/') {
|
|
28721
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
28722
|
+
jPath = jPath.substr(0, jPath.length - 1);
|
|
28723
|
+
tagExp = tagName;
|
|
28724
|
+
}
|
|
28725
|
+
else {
|
|
28726
|
+
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
28727
|
+
}
|
|
28728
|
+
const childNode = new XmlNode(tagName);
|
|
28729
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
28730
|
+
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
28731
|
+
}
|
|
28732
|
+
this.addChild(currentNode, childNode, jPath);
|
|
28733
|
+
jPath = jPath.substr(0, jPath.lastIndexOf('.'));
|
|
28734
|
+
}
|
|
28735
|
+
else {
|
|
28736
|
+
const childNode = new XmlNode(tagName);
|
|
28737
|
+
this.tagsNodeStack.push(currentNode);
|
|
28738
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
28739
|
+
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
28740
|
+
}
|
|
28741
|
+
this.addChild(currentNode, childNode, jPath);
|
|
28742
|
+
currentNode = childNode;
|
|
28743
|
+
}
|
|
28744
|
+
textData = '';
|
|
28745
|
+
i = closeIndex;
|
|
28746
|
+
}
|
|
28747
|
+
}
|
|
28748
|
+
else {
|
|
28749
|
+
textData += xmlData[i];
|
|
28750
|
+
}
|
|
28766
28751
|
}
|
|
28767
|
-
|
|
28768
|
-
g.initAttributes(path.attribute);
|
|
28769
|
-
return g;
|
|
28752
|
+
return xmlObj.child;
|
|
28770
28753
|
}
|
|
28771
28754
|
}
|
|
28772
|
-
|
|
28773
|
-
|
|
28774
|
-
|
|
28775
|
-
|
|
28776
|
-
|
|
28755
|
+
|
|
28756
|
+
function prettify(node, options) {
|
|
28757
|
+
return compress(node);
|
|
28758
|
+
}
|
|
28759
|
+
function compress(arr, jPath) {
|
|
28760
|
+
const compressedObj = {};
|
|
28761
|
+
for (let i = 0; i < arr.length; i++) {
|
|
28762
|
+
const tagObj = arr[i];
|
|
28763
|
+
const property = propName(tagObj);
|
|
28764
|
+
if (property === undefined) {
|
|
28765
|
+
continue;
|
|
28777
28766
|
}
|
|
28778
|
-
|
|
28779
|
-
|
|
28780
|
-
|
|
28781
|
-
|
|
28782
|
-
|
|
28783
|
-
|
|
28784
|
-
|
|
28767
|
+
else if (tagObj[property]) {
|
|
28768
|
+
const val = compress(tagObj[property]);
|
|
28769
|
+
isLeafTag(val);
|
|
28770
|
+
if (tagObj[':@']) {
|
|
28771
|
+
assignAttributes(val, tagObj[':@']);
|
|
28772
|
+
}
|
|
28773
|
+
if (compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {
|
|
28774
|
+
if (!Array.isArray(compressedObj[property])) {
|
|
28775
|
+
compressedObj[property] = [compressedObj[property]];
|
|
28776
|
+
}
|
|
28777
|
+
compressedObj[property].push(val);
|
|
28778
|
+
}
|
|
28779
|
+
else {
|
|
28780
|
+
compressedObj[property] = val;
|
|
28781
|
+
}
|
|
28785
28782
|
}
|
|
28786
|
-
const g = this.pools.pop();
|
|
28787
|
-
g.initAttributes(symbol.attribute);
|
|
28788
|
-
return g;
|
|
28789
28783
|
}
|
|
28784
|
+
return compressedObj;
|
|
28790
28785
|
}
|
|
28791
|
-
|
|
28792
|
-
|
|
28793
|
-
|
|
28794
|
-
|
|
28795
|
-
|
|
28786
|
+
function propName(obj) {
|
|
28787
|
+
const keys = Object.keys(obj);
|
|
28788
|
+
for (let i = 0; i < keys.length; i++) {
|
|
28789
|
+
const key = keys[i];
|
|
28790
|
+
if (key !== ':@') {
|
|
28791
|
+
return key;
|
|
28796
28792
|
}
|
|
28797
|
-
const g = this.pools.pop();
|
|
28798
|
-
g.initAttributes(attribute);
|
|
28799
|
-
return g;
|
|
28800
28793
|
}
|
|
28801
|
-
|
|
28802
|
-
|
|
28803
|
-
|
|
28794
|
+
}
|
|
28795
|
+
function assignAttributes(obj, attrMap, jpath) {
|
|
28796
|
+
if (attrMap) {
|
|
28797
|
+
const keys = Object.keys(attrMap);
|
|
28798
|
+
const len = keys.length;
|
|
28799
|
+
for (let i = 0; i < len; i++) {
|
|
28800
|
+
const atrrName = keys[i];
|
|
28801
|
+
obj[atrrName] = attrMap[atrrName];
|
|
28804
28802
|
}
|
|
28805
|
-
const g = this.pools.pop();
|
|
28806
|
-
g.initAttributes(text.attribute);
|
|
28807
|
-
return g;
|
|
28808
28803
|
}
|
|
28809
28804
|
}
|
|
28810
|
-
|
|
28811
|
-
|
|
28812
|
-
|
|
28813
|
-
|
|
28814
|
-
text: defaultTextAllocate,
|
|
28815
|
-
symbol: defaultSymbolAllocate
|
|
28816
|
-
};
|
|
28805
|
+
function isLeafTag(obj) {
|
|
28806
|
+
const propCount = Object.keys(obj).length;
|
|
28807
|
+
if (propCount === 0) {
|
|
28808
|
+
return true;
|
|
28817
28809
|
}
|
|
28818
|
-
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28823
|
-
|
|
28824
|
-
}
|
|
28810
|
+
return false;
|
|
28811
|
+
}
|
|
28812
|
+
|
|
28813
|
+
class XMLParser {
|
|
28814
|
+
constructor(options) {
|
|
28815
|
+
this.options = Object.assign({}, XMLParser.defaultOptions, options);
|
|
28825
28816
|
}
|
|
28826
|
-
|
|
28827
|
-
|
|
28828
|
-
|
|
28829
|
-
|
|
28817
|
+
valid(xml) {
|
|
28818
|
+
return xml.startsWith('<');
|
|
28819
|
+
}
|
|
28820
|
+
parse(xmlData) {
|
|
28821
|
+
if (!this.valid) {
|
|
28822
|
+
return false;
|
|
28830
28823
|
}
|
|
28824
|
+
const orderedObjParser = new OrderedObjParser(this.options);
|
|
28825
|
+
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
28826
|
+
return prettify(orderedResult, this.options);
|
|
28831
28827
|
}
|
|
28832
28828
|
}
|
|
28833
|
-
|
|
28829
|
+
XMLParser.defaultOptions = {};
|
|
28834
28830
|
|
|
28835
28831
|
function describeServiceIdentifier(serviceIdentifier) {
|
|
28836
28832
|
if (typeof serviceIdentifier === 'string') {
|