@cdk8s/awscdk-resolver 0.0.318 → 0.0.319

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.
Files changed (134) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +14 -14
  4. package/node_modules/@aws-sdk/client-sso/package.json +13 -13
  5. package/node_modules/@aws-sdk/core/package.json +4 -4
  6. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  7. package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -6
  8. package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  11. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  12. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  13. package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
  14. package/node_modules/@aws-sdk/nested-clients/package.json +13 -13
  15. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  16. package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +30 -0
  17. package/node_modules/@aws-sdk/util-endpoints/dist-es/index.js +1 -0
  18. package/node_modules/@aws-sdk/util-endpoints/dist-es/resolveDefaultAwsRegionalEndpointsConfig.js +21 -0
  19. package/node_modules/@aws-sdk/util-endpoints/dist-types/index.d.ts +1 -0
  20. package/node_modules/@aws-sdk/util-endpoints/dist-types/resolveDefaultAwsRegionalEndpointsConfig.d.ts +56 -0
  21. package/node_modules/@aws-sdk/util-endpoints/dist-types/ts3.4/index.d.ts +1 -0
  22. package/node_modules/@aws-sdk/util-endpoints/dist-types/ts3.4/resolveDefaultAwsRegionalEndpointsConfig.d.ts +35 -0
  23. package/node_modules/@aws-sdk/util-endpoints/package.json +2 -1
  24. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  25. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +20 -20
  26. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +80 -6
  27. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +20 -20
  28. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js +10 -0
  29. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +10 -0
  30. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +10 -0
  31. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +10 -0
  32. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +10 -0
  33. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +10 -0
  34. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
  35. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
  36. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ListSchema.d.ts +3 -0
  37. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/MapSchema.d.ts +3 -0
  38. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
  39. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
  40. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/StructureSchema.d.ts +3 -0
  41. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
  42. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
  43. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +3 -0
  44. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +3 -0
  45. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
  46. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
  47. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +3 -0
  48. package/node_modules/@smithy/core/package.json +2 -2
  49. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -2
  50. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +4 -4
  51. package/node_modules/@smithy/fetch-http-handler/dist-types/fetch-http-handler.d.ts +1 -1
  52. package/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/fetch-http-handler.d.ts +1 -1
  53. package/node_modules/@smithy/fetch-http-handler/package.json +1 -1
  54. package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +5 -2
  55. package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js +3 -0
  56. package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointFromInstructions.js +1 -1
  57. package/node_modules/@smithy/middleware-endpoint/dist-es/endpointMiddleware.js +1 -1
  58. package/node_modules/@smithy/middleware-endpoint/dist-types/resolveEndpointConfig.d.ts +5 -2
  59. package/node_modules/@smithy/middleware-endpoint/dist-types/ts3.4/resolveEndpointConfig.d.ts +5 -2
  60. package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
  61. package/node_modules/@smithy/middleware-retry/package.json +2 -2
  62. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -9
  63. package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +4 -3
  64. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +7 -6
  65. package/node_modules/@smithy/node-http-handler/dist-types/node-http-handler.d.ts +1 -1
  66. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
  67. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +1 -1
  68. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
  69. package/node_modules/@smithy/node-http-handler/package.json +1 -1
  70. package/node_modules/@smithy/smithy-client/package.json +4 -4
  71. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  72. package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
  73. package/node_modules/@smithy/util-stream/package.json +3 -3
  74. package/node_modules/fast-xml-parser/CHANGELOG.md +77 -0
  75. package/node_modules/fast-xml-parser/README.md +39 -52
  76. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
  77. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
  78. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
  79. package/node_modules/fast-xml-parser/lib/fxp.d.cts +458 -0
  80. package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
  81. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
  82. package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
  83. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
  84. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
  85. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
  86. package/node_modules/fast-xml-parser/package.json +36 -20
  87. package/node_modules/fast-xml-parser/src/cli/cli.js +16 -12
  88. package/node_modules/fast-xml-parser/src/cli/man.js +6 -1
  89. package/node_modules/fast-xml-parser/src/cli/read.js +30 -79
  90. package/node_modules/fast-xml-parser/src/fxp.d.ts +52 -9
  91. package/node_modules/fast-xml-parser/src/fxp.js +11 -8
  92. package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
  93. package/node_modules/fast-xml-parser/src/util.js +14 -18
  94. package/node_modules/fast-xml-parser/src/{v5 → v6}/CharsSymbol.js +1 -1
  95. package/node_modules/fast-xml-parser/src/{v5/valueParsers → v6}/EntitiesParser.js +3 -6
  96. package/node_modules/fast-xml-parser/src/{v5 → v6}/OptionsBuilder.js +3 -6
  97. package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/BaseOutputBuilder.js +1 -3
  98. package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsArrBuilder.js +3 -3
  99. package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsMinArrBuilder.js +3 -5
  100. package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsObjBuilder.js +3 -5
  101. package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/ParserOptionsBuilder.js +6 -11
  102. package/node_modules/fast-xml-parser/src/{v5 → v6}/TagPath.js +1 -1
  103. package/node_modules/fast-xml-parser/src/{v5 → v6}/TagPathMatcher.js +3 -5
  104. package/node_modules/fast-xml-parser/src/{v5 → v6}/XMLParser.js +3 -5
  105. package/node_modules/fast-xml-parser/src/{v5 → v6}/Xml2JsParser.js +8 -10
  106. package/node_modules/fast-xml-parser/src/{v5 → v6}/XmlPartReader.js +24 -26
  107. package/node_modules/fast-xml-parser/src/{v5 → v6}/XmlSpecialTagsReader.js +5 -12
  108. package/node_modules/fast-xml-parser/src/{v5 → v6}/inputSource/BufferSource.js +1 -3
  109. package/node_modules/fast-xml-parser/src/{v5 → v6}/inputSource/StringSource.js +1 -3
  110. package/node_modules/fast-xml-parser/src/{v5 → v6/valueParsers}/EntitiesParser.js +3 -5
  111. package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/booleanParser.js +1 -2
  112. package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/booleanParserExt.js +1 -2
  113. package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/currency.js +1 -3
  114. package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/join.js +1 -2
  115. package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/number.js +2 -4
  116. package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/trim.js +1 -3
  117. package/node_modules/fast-xml-parser/src/validator.js +5 -5
  118. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +17 -13
  119. package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +1 -2
  120. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +288 -71
  121. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +3 -5
  122. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +28 -23
  123. package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +21 -8
  124. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +8 -2
  125. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +22 -7
  126. package/node_modules/strnum/.github/SECURITY.md +5 -0
  127. package/node_modules/strnum/CHANGELOG.md +11 -0
  128. package/node_modules/strnum/algo.stflow +84 -0
  129. package/node_modules/strnum/package.json +2 -1
  130. package/node_modules/strnum/strnum.js +53 -35
  131. package/node_modules/strnum/strnum.test.js +9 -1
  132. package/node_modules/strnum/test.js +9 -0
  133. package/package.json +4 -4
  134. /package/node_modules/fast-xml-parser/src/{v5 → v6}/Report.js +0 -0
@@ -1,7 +1,7 @@
1
- const util = require('../util');
1
+ import {isName} from '../util.js';
2
2
 
3
3
  //TODO: handle comments
4
- function readDocType(xmlData, i){
4
+ export default function readDocType(xmlData, i){
5
5
 
6
6
  const entities = {};
7
7
  if( xmlData[i + 3] === 'O' &&
@@ -17,20 +17,30 @@ function readDocType(xmlData, i){
17
17
  let exp = "";
18
18
  for(;i<xmlData.length;i++){
19
19
  if (xmlData[i] === '<' && !comment) { //Determine the tag type
20
- if( hasBody && isEntity(xmlData, i)){
20
+ if( hasBody && hasSeq(xmlData, "!ENTITY",i)){
21
21
  i += 7;
22
+ let entityName, val;
22
23
  [entityName, val,i] = readEntityExp(xmlData,i+1);
23
24
  if(val.indexOf("&") === -1) //Parameter entities are not supported
24
- entities[ validateEntityName(entityName) ] = {
25
+ entities[ entityName ] = {
25
26
  regx : RegExp( `&${entityName};`,"g"),
26
27
  val: val
27
28
  };
28
29
  }
29
- else if( hasBody && isElement(xmlData, i)) i += 8;//Not supported
30
- else if( hasBody && isAttlist(xmlData, i)) i += 8;//Not supported
31
- else if( hasBody && isNotation(xmlData, i)) i += 9;//Not supported
32
- else if( isComment) comment = true;
33
- else throw new Error("Invalid DOCTYPE");
30
+ else if( hasBody && hasSeq(xmlData, "!ELEMENT",i)) {
31
+ i += 8;//Not supported
32
+ const {index} = readElementExp(xmlData,i+1);
33
+ i = index;
34
+ }else if( hasBody && hasSeq(xmlData, "!ATTLIST",i)){
35
+ i += 8;//Not supported
36
+ // const {index} = readAttlistExp(xmlData,i+1);
37
+ // i = index;
38
+ }else if( hasBody && hasSeq(xmlData, "!NOTATION",i)) {
39
+ i += 9;//Not supported
40
+ const {index} = readNotationExp(xmlData,i+1);
41
+ i = index;
42
+ }else if( hasSeq(xmlData, "!--",i) ) comment = true;
43
+ else throw new Error(`Invalid DOCTYPE`);
34
44
 
35
45
  angleBracketsCount++;
36
46
  exp = "";
@@ -61,7 +71,14 @@ function readDocType(xmlData, i){
61
71
  return {entities, i};
62
72
  }
63
73
 
64
- function readEntityExp(xmlData,i){
74
+ const skipWhitespace = (data, index) => {
75
+ while (index < data.length && /\s/.test(data[index])) {
76
+ index++;
77
+ }
78
+ return index;
79
+ };
80
+
81
+ function readEntityExp(xmlData, i) {
65
82
  //External entities are not supported
66
83
  // <!ENTITY ext SYSTEM "http://normal-website.com" >
67
84
 
@@ -70,83 +87,283 @@ function readEntityExp(xmlData,i){
70
87
 
71
88
  //Internal entities are supported
72
89
  // <!ENTITY entityname "replacement text">
73
-
74
- //read EntityName
90
+
91
+ // Skip leading whitespace after <!ENTITY
92
+ i = skipWhitespace(xmlData, i);
93
+
94
+ // Read entity name
75
95
  let entityName = "";
76
- for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"' ); i++) {
77
- // if(xmlData[i] === " ") continue;
78
- // else
96
+ while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
79
97
  entityName += xmlData[i];
98
+ i++;
80
99
  }
81
- entityName = entityName.trim();
82
- if(entityName.indexOf(" ") !== -1) throw new Error("External entites are not supported");
100
+ validateEntityName(entityName);
83
101
 
84
- //read Entity Value
85
- const startChar = xmlData[i++];
86
- let val = ""
87
- for (; i < xmlData.length && xmlData[i] !== startChar ; i++) {
88
- val += xmlData[i];
102
+ // Skip whitespace after entity name
103
+ i = skipWhitespace(xmlData, i);
104
+
105
+ // Check for unsupported constructs (external entities or parameter entities)
106
+ if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
107
+ throw new Error("External entities are not supported");
108
+ }else if (xmlData[i] === "%") {
109
+ throw new Error("Parameter entities are not supported");
89
110
  }
90
- return [entityName, val, i];
111
+
112
+ // Read entity value (internal entity)
113
+ let entityValue = "";
114
+ [i, entityValue] = readIdentifierVal(xmlData, i, "entity");
115
+ i--;
116
+ return [entityName, entityValue, i ];
91
117
  }
92
118
 
93
- function isComment(xmlData, i){
94
- if(xmlData[i+1] === '!' &&
95
- xmlData[i+2] === '-' &&
96
- xmlData[i+3] === '-') return true
97
- return false
119
+ function readNotationExp(xmlData, i) {
120
+ // Skip leading whitespace after <!NOTATION
121
+ i = skipWhitespace(xmlData, i);
122
+
123
+ // Read notation name
124
+ let notationName = "";
125
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
126
+ notationName += xmlData[i];
127
+ i++;
128
+ }
129
+ validateEntityName(notationName);
130
+
131
+ // Skip whitespace after notation name
132
+ i = skipWhitespace(xmlData, i);
133
+
134
+ // Check identifier type (SYSTEM or PUBLIC)
135
+ const identifierType = xmlData.substring(i, i + 6).toUpperCase();
136
+ if (identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
137
+ throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
138
+ }
139
+ i += identifierType.length;
140
+
141
+ // Skip whitespace after identifier type
142
+ i = skipWhitespace(xmlData, i);
143
+
144
+ // Read public identifier (if PUBLIC)
145
+ let publicIdentifier = null;
146
+ let systemIdentifier = null;
147
+
148
+ if (identifierType === "PUBLIC") {
149
+ [i, publicIdentifier ] = readIdentifierVal(xmlData, i, "publicIdentifier");
150
+
151
+ // Skip whitespace after public identifier
152
+ i = skipWhitespace(xmlData, i);
153
+
154
+ // Optionally read system identifier
155
+ if (xmlData[i] === '"' || xmlData[i] === "'") {
156
+ [i, systemIdentifier ] = readIdentifierVal(xmlData, i,"systemIdentifier");
157
+ }
158
+ } else if (identifierType === "SYSTEM") {
159
+ // Read system identifier (mandatory for SYSTEM)
160
+ [i, systemIdentifier ] = readIdentifierVal(xmlData, i, "systemIdentifier");
161
+
162
+ if (!systemIdentifier) {
163
+ throw new Error("Missing mandatory system identifier for SYSTEM notation");
164
+ }
165
+ }
166
+
167
+ return {notationName, publicIdentifier, systemIdentifier, index: --i};
98
168
  }
99
- function isEntity(xmlData, i){
100
- if(xmlData[i+1] === '!' &&
101
- xmlData[i+2] === 'E' &&
102
- xmlData[i+3] === 'N' &&
103
- xmlData[i+4] === 'T' &&
104
- xmlData[i+5] === 'I' &&
105
- xmlData[i+6] === 'T' &&
106
- xmlData[i+7] === 'Y') return true
107
- return false
169
+
170
+ function readIdentifierVal(xmlData, i, type) {
171
+ let identifierVal = "";
172
+ const startChar = xmlData[i];
173
+ if (startChar !== '"' && startChar !== "'") {
174
+ throw new Error(`Expected quoted string, found "${startChar}"`);
175
+ }
176
+ i++;
177
+
178
+ while (i < xmlData.length && xmlData[i] !== startChar) {
179
+ identifierVal += xmlData[i];
180
+ i++;
181
+ }
182
+
183
+ if (xmlData[i] !== startChar) {
184
+ throw new Error(`Unterminated ${type} value`);
185
+ }
186
+ i++;
187
+ return [i, identifierVal];
108
188
  }
109
- function isElement(xmlData, i){
110
- if(xmlData[i+1] === '!' &&
111
- xmlData[i+2] === 'E' &&
112
- xmlData[i+3] === 'L' &&
113
- xmlData[i+4] === 'E' &&
114
- xmlData[i+5] === 'M' &&
115
- xmlData[i+6] === 'E' &&
116
- xmlData[i+7] === 'N' &&
117
- xmlData[i+8] === 'T') return true
118
- return false
189
+
190
+ function readElementExp(xmlData, i) {
191
+ // <!ELEMENT br EMPTY>
192
+ // <!ELEMENT div ANY>
193
+ // <!ELEMENT title (#PCDATA)>
194
+ // <!ELEMENT book (title, author+)>
195
+ // <!ELEMENT name (content-model)>
196
+
197
+ // Skip leading whitespace after <!ELEMENT
198
+ i = skipWhitespace(xmlData, i);
199
+
200
+ // Read element name
201
+ let elementName = "";
202
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
203
+ elementName += xmlData[i];
204
+ i++;
205
+ }
206
+
207
+ // Validate element name
208
+ if (!validateEntityName(elementName)) {
209
+ throw new Error(`Invalid element name: "${elementName}"`);
210
+ }
211
+
212
+ // Skip whitespace after element name
213
+ i = skipWhitespace(xmlData, i);
214
+ let contentModel = "";
215
+ // Expect '(' to start content model
216
+ if(xmlData[i] === "E" && hasSeq(xmlData, "MPTY",i)) i+=4;
217
+ else if(xmlData[i] === "A" && hasSeq(xmlData, "NY",i)) i+=2;
218
+ else if (xmlData[i] === "(") {
219
+ i++; // Move past '('
220
+
221
+ // Read content model
222
+ while (i < xmlData.length && xmlData[i] !== ")") {
223
+ contentModel += xmlData[i];
224
+ i++;
225
+ }
226
+ if (xmlData[i] !== ")") {
227
+ throw new Error("Unterminated content model");
228
+ }
229
+
230
+ }else{
231
+ throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
232
+ }
233
+
234
+ return {
235
+ elementName,
236
+ contentModel: contentModel.trim(),
237
+ index: i
238
+ };
119
239
  }
120
240
 
121
- function isAttlist(xmlData, i){
122
- if(xmlData[i+1] === '!' &&
123
- xmlData[i+2] === 'A' &&
124
- xmlData[i+3] === 'T' &&
125
- xmlData[i+4] === 'T' &&
126
- xmlData[i+5] === 'L' &&
127
- xmlData[i+6] === 'I' &&
128
- xmlData[i+7] === 'S' &&
129
- xmlData[i+8] === 'T') return true
130
- return false
241
+ function readAttlistExp(xmlData, i) {
242
+ // Skip leading whitespace after <!ATTLIST
243
+ i = skipWhitespace(xmlData, i);
244
+
245
+ // Read element name
246
+ let elementName = "";
247
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
248
+ elementName += xmlData[i];
249
+ i++;
250
+ }
251
+
252
+ // Validate element name
253
+ validateEntityName(elementName)
254
+
255
+ // Skip whitespace after element name
256
+ i = skipWhitespace(xmlData, i);
257
+
258
+ // Read attribute name
259
+ let attributeName = "";
260
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
261
+ attributeName += xmlData[i];
262
+ i++;
263
+ }
264
+
265
+ // Validate attribute name
266
+ if (!validateEntityName(attributeName)) {
267
+ throw new Error(`Invalid attribute name: "${attributeName}"`);
268
+ }
269
+
270
+ // Skip whitespace after attribute name
271
+ i = skipWhitespace(xmlData, i);
272
+
273
+ // Read attribute type
274
+ let attributeType = "";
275
+ if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
276
+ attributeType = "NOTATION";
277
+ i += 8; // Move past "NOTATION"
278
+
279
+ // Skip whitespace after "NOTATION"
280
+ i = skipWhitespace(xmlData, i);
281
+
282
+ // Expect '(' to start the list of notations
283
+ if (xmlData[i] !== "(") {
284
+ throw new Error(`Expected '(', found "${xmlData[i]}"`);
285
+ }
286
+ i++; // Move past '('
287
+
288
+ // Read the list of allowed notations
289
+ let allowedNotations = [];
290
+ while (i < xmlData.length && xmlData[i] !== ")") {
291
+ let notation = "";
292
+ while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
293
+ notation += xmlData[i];
294
+ i++;
295
+ }
296
+
297
+ // Validate notation name
298
+ notation = notation.trim();
299
+ if (!validateEntityName(notation)) {
300
+ throw new Error(`Invalid notation name: "${notation}"`);
301
+ }
302
+
303
+ allowedNotations.push(notation);
304
+
305
+ // Skip '|' separator or exit loop
306
+ if (xmlData[i] === "|") {
307
+ i++; // Move past '|'
308
+ i = skipWhitespace(xmlData, i); // Skip optional whitespace after '|'
309
+ }
310
+ }
311
+
312
+ if (xmlData[i] !== ")") {
313
+ throw new Error("Unterminated list of notations");
314
+ }
315
+ i++; // Move past ')'
316
+
317
+ // Store the allowed notations as part of the attribute type
318
+ attributeType += " (" + allowedNotations.join("|") + ")";
319
+ } else {
320
+ // Handle simple types (e.g., CDATA, ID, IDREF, etc.)
321
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
322
+ attributeType += xmlData[i];
323
+ i++;
324
+ }
325
+
326
+ // Validate simple attribute type
327
+ const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
328
+ if (!validTypes.includes(attributeType.toUpperCase())) {
329
+ throw new Error(`Invalid attribute type: "${attributeType}"`);
330
+ }
331
+ }
332
+
333
+ // Skip whitespace after attribute type
334
+ i = skipWhitespace(xmlData, i);
335
+
336
+ // Read default value
337
+ let defaultValue = "";
338
+ if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
339
+ defaultValue = "#REQUIRED";
340
+ i += 8;
341
+ } else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
342
+ defaultValue = "#IMPLIED";
343
+ i += 7;
344
+ } else {
345
+ [i, defaultValue] = readIdentifierVal(xmlData, i, "ATTLIST");
346
+ }
347
+
348
+ return {
349
+ elementName,
350
+ attributeName,
351
+ attributeType,
352
+ defaultValue,
353
+ index: i
354
+ }
131
355
  }
132
- function isNotation(xmlData, i){
133
- if(xmlData[i+1] === '!' &&
134
- xmlData[i+2] === 'N' &&
135
- xmlData[i+3] === 'O' &&
136
- xmlData[i+4] === 'T' &&
137
- xmlData[i+5] === 'A' &&
138
- xmlData[i+6] === 'T' &&
139
- xmlData[i+7] === 'I' &&
140
- xmlData[i+8] === 'O' &&
141
- xmlData[i+9] === 'N') return true
142
- return false
356
+
357
+ function hasSeq(data, seq,i){
358
+ for(let j=0;j<seq.length;j++){
359
+ if(seq[j]!==data[i+j+1]) return false;
360
+ }
361
+ return true;
143
362
  }
144
363
 
145
364
  function validateEntityName(name){
146
- if (util.isName(name))
365
+ if (isName(name))
147
366
  return name;
148
367
  else
149
368
  throw new Error(`Invalid entity name ${name}`);
150
369
  }
151
-
152
- module.exports = readDocType;
@@ -1,5 +1,5 @@
1
1
 
2
- const defaultOptions = {
2
+ export const defaultOptions = {
3
3
  preserveOrder: false,
4
4
  attributeNamePrefix: '@_',
5
5
  attributesGroupName: false,
@@ -38,11 +38,9 @@ const defaultOptions = {
38
38
  return tagName
39
39
  },
40
40
  // skipEmptyListItem: false
41
+ captureMetaData: false,
41
42
  };
42
43
 
43
- const buildOptions = function(options) {
44
+ export const buildOptions = function(options) {
44
45
  return Object.assign({}, defaultOptions, options);
45
46
  };
46
-
47
- exports.buildOptions = buildOptions;
48
- exports.defaultOptions = defaultOptions;
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
  ///@ts-check
3
3
 
4
- const util = require('../util');
5
- const xmlNode = require('./xmlNode');
6
- const readDocType = require("./DocTypeReader");
7
- const toNumber = require("strnum");
4
+ import {getAllMatches, isExist} from '../util.js';
5
+ import xmlNode from './xmlNode.js';
6
+ import readDocType from './DocTypeReader.js';
7
+ import toNumber from "strnum";
8
+ import getIgnoreAttributesFn from "../ignoreAttributes.js";
8
9
 
9
10
  // const regx =
10
11
  // '<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)'
@@ -13,7 +14,7 @@ const toNumber = require("strnum");
13
14
  //const tagsRegx = new RegExp("<(\\/?[\\w:\\-\._]+)([^>]*)>(\\s*"+cdataRegx+")*([^<]+)?","g");
14
15
  //const tagsRegx = new RegExp("<(\\/?)((\\w*:)?([\\w:\\-\._]+))([^>]*)>([^<]*)("+cdataRegx+"([^<]*))*([^<]+)?","g");
15
16
 
16
- class OrderedObjParser{
17
+ export default class OrderedObjParser{
17
18
  constructor(options){
18
19
  this.options = options;
19
20
  this.currentNode = null;
@@ -40,8 +41,8 @@ class OrderedObjParser{
40
41
  "copyright" : { regex: /&(copy|#169);/g, val: "©" },
41
42
  "reg" : { regex: /&(reg|#174);/g, val: "®" },
42
43
  "inr" : { regex: /&(inr|#8377);/g, val: "₹" },
43
- "num_dec": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
44
- "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 16)) },
44
+ "num_dec": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 10)) },
45
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
45
46
  };
46
47
  this.addExternalEntities = addExternalEntities;
47
48
  this.parseXml = parseXml;
@@ -53,6 +54,7 @@ class OrderedObjParser{
53
54
  this.readStopNodeData = readStopNodeData;
54
55
  this.saveTextToParentTag = saveTextToParentTag;
55
56
  this.addChild = addChild;
57
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes)
56
58
  }
57
59
 
58
60
  }
@@ -125,15 +127,18 @@ function resolveNameSpace(tagname) {
125
127
  const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
126
128
 
127
129
  function buildAttributesMap(attrStr, jPath, tagName) {
128
- if (!this.options.ignoreAttributes && typeof attrStr === 'string') {
130
+ if (this.options.ignoreAttributes !== true && typeof attrStr === 'string') {
129
131
  // attrStr = attrStr.replace(/\r?\n/g, ' ');
130
132
  //attrStr = attrStr || attrStr.trim();
131
133
 
132
- const matches = util.getAllMatches(attrStr, attrsRegx);
134
+ const matches = getAllMatches(attrStr, attrsRegx);
133
135
  const len = matches.length; //don't make it inline
134
136
  const attrs = {};
135
137
  for (let i = 0; i < len; i++) {
136
138
  const attrName = this.resolveNameSpace(matches[i][1]);
139
+ if (this.ignoreAttributesFn(attrName, jPath)) {
140
+ continue
141
+ }
137
142
  let oldVal = matches[i][4];
138
143
  let aName = this.options.attributeNamePrefix + attrName;
139
144
  if (attrName.length) {
@@ -241,8 +246,7 @@ const parseXml = function(xmlData) {
241
246
  if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){
242
247
  childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
243
248
  }
244
- this.addChild(currentNode, childNode, jPath)
245
-
249
+ this.addChild(currentNode, childNode, jPath, i);
246
250
  }
247
251
 
248
252
 
@@ -307,6 +311,7 @@ const parseXml = function(xmlData) {
307
311
  if(tagName !== xmlObj.tagname){
308
312
  jPath += jPath ? "." + tagName : tagName;
309
313
  }
314
+ const startIndex = i;
310
315
  if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
311
316
  let tagContent = "";
312
317
  //self-closing tag
@@ -335,6 +340,7 @@ const parseXml = function(xmlData) {
335
340
  }
336
341
 
337
342
  const childNode = new xmlNode(tagName);
343
+
338
344
  if(tagName !== tagExp && attrExpPresent){
339
345
  childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
340
346
  }
@@ -345,7 +351,7 @@ const parseXml = function(xmlData) {
345
351
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
346
352
  childNode.add(this.options.textNodeName, tagContent);
347
353
 
348
- this.addChild(currentNode, childNode, jPath)
354
+ this.addChild(currentNode, childNode, jPath, startIndex);
349
355
  }else{
350
356
  //selfClosing tag
351
357
  if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
@@ -365,7 +371,7 @@ const parseXml = function(xmlData) {
365
371
  if(tagName !== tagExp && attrExpPresent){
366
372
  childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
367
373
  }
368
- this.addChild(currentNode, childNode, jPath)
374
+ this.addChild(currentNode, childNode, jPath, startIndex);
369
375
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
370
376
  }
371
377
  //opening tag
@@ -376,7 +382,7 @@ const parseXml = function(xmlData) {
376
382
  if(tagName !== tagExp && attrExpPresent){
377
383
  childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
378
384
  }
379
- this.addChild(currentNode, childNode, jPath)
385
+ this.addChild(currentNode, childNode, jPath, startIndex);
380
386
  currentNode = childNode;
381
387
  }
382
388
  textData = "";
@@ -390,14 +396,16 @@ const parseXml = function(xmlData) {
390
396
  return xmlObj.child;
391
397
  }
392
398
 
393
- function addChild(currentNode, childNode, jPath){
399
+ function addChild(currentNode, childNode, jPath, startIndex){
400
+ // unset startIndex if not requested
401
+ if (!this.options.captureMetaData) startIndex = undefined;
394
402
  const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"])
395
403
  if(result === false){
396
- }else if(typeof result === "string"){
404
+ } else if(typeof result === "string"){
397
405
  childNode.tagname = result
398
- currentNode.addChild(childNode);
406
+ currentNode.addChild(childNode, startIndex);
399
407
  }else{
400
- currentNode.addChild(childNode);
408
+ currentNode.addChild(childNode, startIndex);
401
409
  }
402
410
  }
403
411
 
@@ -424,7 +432,7 @@ const replaceEntitiesValue = function(val){
424
432
  }
425
433
  function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
426
434
  if (textData) { //store previously collected data as textNode
427
- if(isLeafNode === undefined) isLeafNode = Object.keys(currentNode.child).length === 0
435
+ if(isLeafNode === undefined) isLeafNode = currentNode.child.length === 0
428
436
 
429
437
  textData = this.parseTextData(textData,
430
438
  currentNode.tagname,
@@ -589,13 +597,10 @@ function parseValue(val, shouldParse, options) {
589
597
  else if(newval === 'false' ) return false;
590
598
  else return toNumber(val, options);
591
599
  } else {
592
- if (util.isExist(val)) {
600
+ if (isExist(val)) {
593
601
  return val;
594
602
  } else {
595
603
  return '';
596
604
  }
597
605
  }
598
606
  }
599
-
600
-
601
- module.exports = OrderedObjParser;
@@ -1,9 +1,10 @@
1
- const { buildOptions} = require("./OptionsBuilder");
2
- const OrderedObjParser = require("./OrderedObjParser");
3
- const { prettify} = require("./node2json");
4
- const validator = require('../validator');
1
+ import { buildOptions} from './OptionsBuilder.js';
2
+ import OrderedObjParser from './OrderedObjParser.js';
3
+ import prettify from './node2json.js';
4
+ import {validate} from "../validator.js";
5
+ import XmlNode from './xmlNode.js';
5
6
 
6
- class XMLParser{
7
+ export default class XMLParser{
7
8
 
8
9
  constructor(options){
9
10
  this.externalEntities = {};
@@ -25,7 +26,7 @@ class XMLParser{
25
26
  if( validationOption){
26
27
  if(validationOption === true) validationOption = {}; //validate with default options
27
28
 
28
- const result = validator.validate(xmlData, validationOption);
29
+ const result = validate(xmlData, validationOption);
29
30
  if (result !== true) {
30
31
  throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` )
31
32
  }
@@ -53,6 +54,18 @@ class XMLParser{
53
54
  this.externalEntities[key] = value;
54
55
  }
55
56
  }
56
- }
57
57
 
58
- module.exports = XMLParser;
58
+ /**
59
+ * Returns a Symbol that can be used to access the metadata
60
+ * property on a node.
61
+ *
62
+ * If Symbol is not available in the environment, an ordinary property is used
63
+ * and the name of the property is here returned.
64
+ *
65
+ * The XMLMetaData property is only present when `captureMetaData`
66
+ * is true in the options.
67
+ */
68
+ static getMetaDataSymbol() {
69
+ return XmlNode.getMetaDataSymbol();
70
+ }
71
+ }
@@ -1,12 +1,16 @@
1
1
  'use strict';
2
2
 
3
+ import XmlNode from './xmlNode.js';
4
+
5
+ const METADATA_SYMBOL = XmlNode.getMetaDataSymbol();
6
+
3
7
  /**
4
8
  *
5
9
  * @param {array} node
6
10
  * @param {any} options
7
11
  * @returns
8
12
  */
9
- function prettify(node, options){
13
+ export default function prettify(node, options){
10
14
  return compress( node, options);
11
15
  }
12
16
 
@@ -36,6 +40,9 @@ function compress(arr, options, jPath){
36
40
 
37
41
  let val = compress(tagObj[property], options, newJpath);
38
42
  const isLeaf = isLeafTag(val, options);
43
+ if (tagObj[METADATA_SYMBOL] !== undefined) {
44
+ val[METADATA_SYMBOL] = tagObj[METADATA_SYMBOL]; // copy over metadata
45
+ }
39
46
 
40
47
  if(tagObj[":@"]){
41
48
  assignAttributes( val, tagObj[":@"], newJpath, options);
@@ -110,4 +117,3 @@ function isLeafTag(obj, options){
110
117
 
111
118
  return false;
112
119
  }
113
- exports.prettify = prettify;