@cdklabs/cdk-ecs-codedeploy 0.0.445 → 0.0.446

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 (201) hide show
  1. package/.jsii +3 -3
  2. package/lib/api-canary/index.js +1 -1
  3. package/lib/ecs-appspec/index.js +1 -1
  4. package/lib/ecs-deployment/index.js +1 -1
  5. package/lib/ecs-patterns/application-load-balanced-codedeployed-fargate-service.js +1 -1
  6. package/node_modules/@aws-sdk/client-codedeploy/package.json +3 -3
  7. package/node_modules/@aws-sdk/core/package.json +2 -2
  8. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  9. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  10. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  11. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  12. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  13. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  14. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  15. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  19. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  20. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  21. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  22. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  23. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +1 -1
  24. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +233 -43
  25. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.browser.js +1 -1
  26. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +233 -43
  27. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-parser.d.ts +1 -1
  28. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-parser.d.ts +2 -1
  29. package/node_modules/@aws-sdk/xml-builder/package.json +4 -4
  30. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.browser.js +355 -145
  31. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.js +456 -142
  32. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.native.js +355 -145
  33. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +5 -2
  34. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +30 -36
  35. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +54 -110
  36. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +30 -36
  37. package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Js.js +27 -0
  38. package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js +21 -0
  39. package/node_modules/@smithy/core/dist-es/submodules/checksum/index.browser.js +7 -1
  40. package/node_modules/@smithy/core/dist-es/submodules/checksum/index.js +7 -1
  41. package/node_modules/@smithy/core/dist-es/submodules/checksum/index.native.js +7 -1
  42. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Js.js +92 -0
  43. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js +29 -0
  44. package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Js.js +179 -0
  45. package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js +59 -0
  46. package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256WebCrypto.js +71 -0
  47. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -1
  48. package/node_modules/@smithy/core/dist-es/submodules/serde/concatBytes.js +15 -0
  49. package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +2 -0
  50. package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +2 -0
  51. package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +2 -0
  52. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js +4 -0
  53. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/headStream.js +2 -1
  54. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.browser.js +12 -38
  55. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js +18 -33
  56. package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.browser.js +3 -0
  57. package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.js +3 -0
  58. package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Js.d.ts +13 -0
  59. package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Node.d.ts +13 -0
  60. package/node_modules/@smithy/core/dist-types/submodules/checksum/index.browser.d.ts +7 -1
  61. package/node_modules/@smithy/core/dist-types/submodules/checksum/index.d.ts +7 -1
  62. package/node_modules/@smithy/core/dist-types/submodules/checksum/index.native.d.ts +7 -1
  63. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Js.d.ts +19 -0
  64. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Node.d.ts +17 -0
  65. package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Js.d.ts +28 -0
  66. package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Node.d.ts +13 -0
  67. package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256WebCrypto.d.ts +22 -0
  68. package/node_modules/@smithy/core/dist-types/submodules/serde/concatBytes.d.ts +6 -0
  69. package/node_modules/@smithy/core/dist-types/submodules/serde/index.browser.d.ts +2 -0
  70. package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +2 -0
  71. package/node_modules/@smithy/core/dist-types/submodules/serde/index.native.d.ts +2 -0
  72. package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/checksum/ChecksumStream.d.ts +9 -0
  73. package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +8 -2
  74. package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.d.ts +4 -1
  75. package/node_modules/@smithy/core/package.json +4 -3
  76. package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
  77. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -55
  78. package/node_modules/@smithy/fetch-http-handler/dist-es/index.js +2 -2
  79. package/node_modules/@smithy/fetch-http-handler/dist-types/index.d.ts +2 -2
  80. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  81. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +3 -51
  82. package/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -3
  83. package/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -3
  84. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  85. package/node_modules/@smithy/signature-v4/package.json +2 -2
  86. package/package.json +2 -2
  87. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-external/nodable_entities.js +0 -333
  88. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-external/nodable_entities.js +0 -332
  89. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-external/nodable_entities.d.ts +0 -66
  90. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-external/nodable_entities.d.ts +0 -65
  91. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +0 -827
  92. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/LICENSE +0 -21
  93. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/README.md +0 -202
  94. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
  95. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
  96. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
  97. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +0 -770
  98. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
  99. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
  100. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
  101. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
  102. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js +0 -2
  103. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
  104. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +0 -93
  105. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/cli.js +0 -97
  106. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/man.js +0 -17
  107. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/read.js +0 -43
  108. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +0 -739
  109. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.js +0 -14
  110. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/ignoreAttributes.js +0 -18
  111. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/util.js +0 -61
  112. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +0 -16
  113. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +0 -106
  114. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +0 -61
  115. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -69
  116. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +0 -103
  117. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -100
  118. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +0 -154
  119. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -94
  120. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  121. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPath.js +0 -81
  122. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +0 -13
  123. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XMLParser.js +0 -83
  124. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +0 -235
  125. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +0 -210
  126. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +0 -111
  127. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +0 -116
  128. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +0 -121
  129. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +0 -105
  130. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +0 -22
  131. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +0 -19
  132. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +0 -38
  133. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +0 -13
  134. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +0 -14
  135. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +0 -6
  136. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/validator.js +0 -425
  137. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +0 -6
  138. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +0 -407
  139. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +0 -163
  140. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +0 -840
  141. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +0 -71
  142. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/node2json.js +0 -177
  143. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +0 -40
  144. package/node_modules/@nodable/entities/README.md +0 -41
  145. package/node_modules/@nodable/entities/package.json +0 -57
  146. package/node_modules/@nodable/entities/src/EntityDecoder.js +0 -644
  147. package/node_modules/@nodable/entities/src/EntityEncoder.js +0 -194
  148. package/node_modules/@nodable/entities/src/entities.js +0 -1159
  149. package/node_modules/@nodable/entities/src/entityTries.js +0 -49
  150. package/node_modules/@nodable/entities/src/index.d.ts +0 -341
  151. package/node_modules/@nodable/entities/src/index.js +0 -29
  152. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/constants.js +0 -3
  153. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/md5.js +0 -168
  154. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/constants.d.ts +0 -12
  155. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/md5.d.ts +0 -16
  156. package/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js +0 -53
  157. package/node_modules/@smithy/fetch-http-handler/dist-types/stream-collector.d.ts +0 -2
  158. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +0 -8
  159. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +0 -41
  160. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +0 -5
  161. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +0 -7
  162. package/node_modules/anynum/LICENSE +0 -21
  163. package/node_modules/anynum/README.md +0 -142
  164. package/node_modules/anynum/anynum.js +0 -135
  165. package/node_modules/anynum/digitTable.js +0 -116
  166. package/node_modules/anynum/package.json +0 -42
  167. package/node_modules/fast-xml-builder/CHANGELOG.md +0 -40
  168. package/node_modules/fast-xml-builder/LICENSE +0 -21
  169. package/node_modules/fast-xml-builder/README.md +0 -74
  170. package/node_modules/fast-xml-builder/lib/fxb.cjs +0 -1
  171. package/node_modules/fast-xml-builder/lib/fxb.d.cts +0 -270
  172. package/node_modules/fast-xml-builder/lib/fxb.min.js +0 -2
  173. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +0 -1
  174. package/node_modules/fast-xml-builder/package.json +0 -81
  175. package/node_modules/fast-xml-builder/src/fxb.d.ts +0 -270
  176. package/node_modules/fast-xml-builder/src/fxb.js +0 -599
  177. package/node_modules/fast-xml-builder/src/ignoreAttributes.js +0 -18
  178. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +0 -359
  179. package/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  180. package/node_modules/fast-xml-builder/src/util.js +0 -16
  181. package/node_modules/path-expression-matcher/LICENSE +0 -21
  182. package/node_modules/path-expression-matcher/README.md +0 -947
  183. package/node_modules/path-expression-matcher/lib/pem.cjs +0 -1
  184. package/node_modules/path-expression-matcher/lib/pem.d.cts +0 -715
  185. package/node_modules/path-expression-matcher/lib/pem.min.js +0 -2
  186. package/node_modules/path-expression-matcher/lib/pem.min.js.map +0 -1
  187. package/node_modules/path-expression-matcher/package.json +0 -79
  188. package/node_modules/path-expression-matcher/src/Expression.js +0 -232
  189. package/node_modules/path-expression-matcher/src/ExpressionSet.js +0 -225
  190. package/node_modules/path-expression-matcher/src/Matcher.js +0 -660
  191. package/node_modules/path-expression-matcher/src/index.d.ts +0 -589
  192. package/node_modules/path-expression-matcher/src/index.js +0 -29
  193. package/node_modules/strnum/CHANGELOG.md +0 -51
  194. package/node_modules/strnum/LICENSE +0 -21
  195. package/node_modules/strnum/README.md +0 -113
  196. package/node_modules/strnum/package.json +0 -36
  197. package/node_modules/strnum/strnum.js +0 -171
  198. package/node_modules/xml-naming/README.md +0 -189
  199. package/node_modules/xml-naming/package.json +0 -54
  200. package/node_modules/xml-naming/src/index.d.ts +0 -74
  201. package/node_modules/xml-naming/src/index.js +0 -270
@@ -1,359 +0,0 @@
1
- import { Expression, Matcher } from 'path-expression-matcher';
2
- import { safeComment, safeCdata, escapeAttribute } from "./util.js";
3
- import { qName } from 'xml-naming';
4
-
5
- const EOL = "\n";
6
-
7
- /**
8
- * Detect XML version from the first element of the ordered array input.
9
- * The first element must be a ?xml processing instruction with a version attribute.
10
- * Returns '1.0' if not found.
11
- *
12
- * @param {array} jArray
13
- * @param {object} options
14
- */
15
- function detectXmlVersionFromArray(jArray, options) {
16
- if (!Array.isArray(jArray) || jArray.length === 0) return '1.0';
17
- const first = jArray[0];
18
- const firstKey = propName(first);
19
- if (firstKey === '?xml') {
20
- const attrs = first[':@'];
21
- if (attrs) {
22
- const versionKey = options.attributeNamePrefix + 'version';
23
- if (attrs[versionKey]) return attrs[versionKey];
24
- }
25
- }
26
- return '1.0';
27
- }
28
-
29
- /**
30
- * Resolve a tag or attribute name through sanitizeName if configured.
31
- * Validation via xml-naming's qName is performed first; the sanitizeName
32
- * callback is invoked only when the name is invalid. If sanitizeName is
33
- * false (default), no validation occurs and the name is used as-is.
34
- *
35
- * @param {string} name - raw name from the JS object
36
- * @param {boolean} isAttribute - true when resolving an attribute name
37
- * @param {object} options
38
- * @param {Matcher} matcher - current matcher state (readonly from callback perspective)
39
- * @param {string} xmlVersion - '1.0' or '1.1', forwarded to xml-naming
40
- */
41
- function resolveTagName(name, isAttribute, options, matcher, xmlVersion) {
42
- if (!options.sanitizeName) return name;
43
- if (qName(name, { xmlVersion })) return name;
44
- return options.sanitizeName(name, { isAttribute, matcher: matcher.readOnly() });
45
- }
46
-
47
- /**
48
- * @param {array} jArray
49
- * @param {any} options
50
- * @returns
51
- */
52
- export default function toXml(jArray, options) {
53
- let indentation = "";
54
- if (options.format) {
55
- indentation = EOL;
56
- }
57
-
58
- // Pre-compile stopNode expressions for pattern matching
59
- const stopNodeExpressions = [];
60
- if (options.stopNodes && Array.isArray(options.stopNodes)) {
61
- for (let i = 0; i < options.stopNodes.length; i++) {
62
- const node = options.stopNodes[i];
63
- if (typeof node === 'string') {
64
- stopNodeExpressions.push(new Expression(node));
65
- } else if (node instanceof Expression) {
66
- stopNodeExpressions.push(node);
67
- }
68
- }
69
- }
70
-
71
- // Detect XML version for use in name validation
72
- const xmlVersion = detectXmlVersionFromArray(jArray, options);
73
-
74
- // Initialize matcher for path tracking
75
- const matcher = new Matcher();
76
-
77
- return arrToStr(jArray, options, indentation, matcher, stopNodeExpressions, xmlVersion);
78
- }
79
-
80
- function arrToStr(arr, options, indentation, matcher, stopNodeExpressions, xmlVersion) {
81
- let xmlStr = "";
82
- let isPreviousElementTag = false;
83
-
84
- if (options.maxNestedTags && matcher.getDepth() > options.maxNestedTags) {
85
- throw new Error("Maximum nested tags exceeded");
86
- }
87
-
88
- if (!Array.isArray(arr)) {
89
- // Non-array values (e.g. string tag values) should be treated as text content
90
- if (arr !== undefined && arr !== null) {
91
- let text = arr.toString();
92
- text = replaceEntitiesValue(text, options);
93
- return text;
94
- }
95
- return "";
96
- }
97
-
98
- for (let i = 0; i < arr.length; i++) {
99
- const tagObj = arr[i];
100
- const rawTagName = propName(tagObj);
101
- if (rawTagName === undefined) continue;
102
-
103
- // Special names are exempt from sanitizeName: internal conventions and PI tags
104
- // are not user-supplied XML element names.
105
- const isSpecialName = rawTagName === options.textNodeName
106
- || rawTagName === options.cdataPropName
107
- || rawTagName === options.commentPropName
108
- || rawTagName[0] === '?';
109
-
110
- // Resolve tag name (may transform it; may throw for invalid names)
111
- const tagName = isSpecialName
112
- ? rawTagName
113
- : resolveTagName(rawTagName, false, options, matcher, xmlVersion);
114
-
115
- // Extract attributes from ":@" property
116
- const attrValues = extractAttributeValues(tagObj[":@"], options);
117
-
118
- // Push resolved tag to matcher WITH attributes
119
- matcher.push(tagName, attrValues);
120
-
121
- // Check if this is a stop node using Expression matching
122
- const isStopNode = checkStopNode(matcher, stopNodeExpressions);
123
-
124
- if (tagName === options.textNodeName) {
125
- let tagText = tagObj[rawTagName];
126
- if (!isStopNode) {
127
- tagText = options.tagValueProcessor(tagName, tagText);
128
- tagText = replaceEntitiesValue(tagText, options);
129
- }
130
- if (isPreviousElementTag) {
131
- xmlStr += indentation;
132
- }
133
- xmlStr += tagText;
134
- isPreviousElementTag = false;
135
- matcher.pop();
136
- continue;
137
- } else if (tagName === options.cdataPropName) {
138
- if (isPreviousElementTag) {
139
- xmlStr += indentation;
140
- }
141
- const val = tagObj[rawTagName][0][options.textNodeName];
142
- const safeVal = safeCdata(val);
143
- xmlStr += `<![CDATA[${safeVal}]]>`;
144
- isPreviousElementTag = false;
145
- matcher.pop();
146
- continue;
147
- } else if (tagName === options.commentPropName) {
148
- const val = tagObj[rawTagName][0][options.textNodeName];
149
- const safeVal = safeComment(val);
150
- xmlStr += indentation + `<!--${safeVal}-->`;
151
- isPreviousElementTag = true;
152
- matcher.pop();
153
- continue;
154
- } else if (tagName[0] === "?") {
155
- const attStr = attr_to_str(tagObj[":@"], options, isStopNode, matcher, xmlVersion);
156
- const tempInd = tagName === "?xml" ? "" : indentation;
157
- // Text node content on PI/XML declaration tags is intentionally ignored.
158
- // Only attributes are valid on these tags per the XML spec.
159
- xmlStr += tempInd + `<${tagName}${attStr}?>`;
160
- isPreviousElementTag = true;
161
- matcher.pop();
162
- continue;
163
- }
164
-
165
- let newIdentation = indentation;
166
- if (newIdentation !== "") {
167
- newIdentation += options.indentBy;
168
- }
169
-
170
- // Pass isStopNode to attr_to_str so attributes are also not processed for stopNodes
171
- const attStr = attr_to_str(tagObj[":@"], options, isStopNode, matcher, xmlVersion);
172
- const tagStart = indentation + `<${tagName}${attStr}`;
173
-
174
- // If this is a stopNode, get raw content without processing
175
- let tagValue;
176
- if (isStopNode) {
177
- tagValue = getRawContent(tagObj[rawTagName], options);
178
- } else {
179
- tagValue = arrToStr(tagObj[rawTagName], options, newIdentation, matcher, stopNodeExpressions, xmlVersion);
180
- }
181
-
182
- if (options.unpairedTags.indexOf(tagName) !== -1) {
183
- if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
184
- else xmlStr += tagStart + "/>";
185
- } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
186
- xmlStr += tagStart + "/>";
187
- } else if (tagValue && tagValue.endsWith(">")) {
188
- xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
189
- } else {
190
- xmlStr += tagStart + ">";
191
- if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
192
- xmlStr += indentation + options.indentBy + tagValue + indentation;
193
- } else {
194
- xmlStr += tagValue;
195
- }
196
- xmlStr += `</${tagName}>`;
197
- }
198
- isPreviousElementTag = true;
199
-
200
- // Pop tag from matcher
201
- matcher.pop();
202
- }
203
-
204
- return xmlStr;
205
- }
206
-
207
- /**
208
- * Extract attribute values from the ":@" object and return as plain object
209
- * for passing to matcher.push()
210
- */
211
- function extractAttributeValues(attrMap, options) {
212
- if (!attrMap || options.ignoreAttributes) return null;
213
-
214
- const attrValues = {};
215
- let hasAttrs = false;
216
-
217
- for (let attr in attrMap) {
218
- if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
219
- // Remove the attribute prefix to get clean attribute name
220
- const cleanAttrName = attr.startsWith(options.attributeNamePrefix)
221
- ? attr.substr(options.attributeNamePrefix.length)
222
- : attr;
223
- attrValues[cleanAttrName] = escapeAttribute(attrMap[attr]);
224
- hasAttrs = true;
225
- }
226
-
227
- return hasAttrs ? attrValues : null;
228
- }
229
-
230
- /**
231
- * Extract raw content from a stopNode without any processing
232
- * This preserves the content exactly as-is, including special characters
233
- */
234
- function getRawContent(arr, options) {
235
- if (!Array.isArray(arr)) {
236
- // Non-array values return as-is
237
- if (arr !== undefined && arr !== null) {
238
- return arr.toString();
239
- }
240
- return "";
241
- }
242
-
243
- let content = "";
244
- for (let i = 0; i < arr.length; i++) {
245
- const item = arr[i];
246
- const tagName = propName(item);
247
-
248
- if (tagName === options.textNodeName) {
249
- // Raw text content - NO processing, NO entity replacement
250
- content += item[tagName];
251
- } else if (tagName === options.cdataPropName) {
252
- // CDATA content
253
- content += item[tagName][0][options.textNodeName];
254
- } else if (tagName === options.commentPropName) {
255
- // Comment content
256
- content += item[tagName][0][options.textNodeName];
257
- } else if (tagName && tagName[0] === "?") {
258
- // Processing instruction - skip for stopNodes
259
- continue;
260
- } else if (tagName) {
261
- // Nested tags within stopNode — no sanitizeName, content is raw
262
- const attStr = attr_to_str_raw(item[":@"], options);
263
- const nestedContent = getRawContent(item[tagName], options);
264
-
265
- if (!nestedContent || nestedContent.length === 0) {
266
- content += `<${tagName}${attStr}/>`;
267
- } else {
268
- content += `<${tagName}${attStr}>${nestedContent}</${tagName}>`;
269
- }
270
- }
271
- }
272
- return content;
273
- }
274
-
275
- /**
276
- * Build attribute string for stopNodes - NO entity replacement
277
- */
278
- function attr_to_str_raw(attrMap, options) {
279
- let attrStr = "";
280
- if (attrMap && !options.ignoreAttributes) {
281
- for (let attr in attrMap) {
282
- if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
283
- // For stopNodes, use raw value without processing
284
- let attrVal = attrMap[attr];
285
- if (attrVal === true && options.suppressBooleanAttributes) {
286
- attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
287
- } else {
288
- attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${escapeAttribute(attrVal)}"`;
289
- }
290
- }
291
- }
292
- return attrStr;
293
- }
294
-
295
- function propName(obj) {
296
- const keys = Object.keys(obj);
297
- for (let i = 0; i < keys.length; i++) {
298
- const key = keys[i];
299
- if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
300
- if (key !== ":@") return key;
301
- }
302
- }
303
-
304
- /**
305
- * Build attribute string, resolving attribute names through sanitizeName when configured.
306
- * Accepts matcher so the callback has path context.
307
- */
308
- function attr_to_str(attrMap, options, isStopNode, matcher, xmlVersion) {
309
- let attrStr = "";
310
- if (attrMap && !options.ignoreAttributes) {
311
- for (let attr in attrMap) {
312
- if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
313
-
314
- // Strip prefix to get the clean XML attribute name, then optionally sanitize it
315
- const cleanAttrName = attr.substr(options.attributeNamePrefix.length);
316
- const resolvedAttrName = isStopNode
317
- ? cleanAttrName // stopNodes are raw — skip sanitizeName for attr names too
318
- : resolveTagName(cleanAttrName, true, options, matcher, xmlVersion);
319
-
320
- let attrVal;
321
- if (isStopNode) {
322
- // For stopNodes, use raw value without any processing
323
- attrVal = attrMap[attr];
324
- } else {
325
- // Normal processing: apply attributeValueProcessor and entity replacement
326
- attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
327
- attrVal = replaceEntitiesValue(attrVal, options);
328
- }
329
-
330
- if (attrVal === true && options.suppressBooleanAttributes) {
331
- attrStr += ` ${resolvedAttrName}`;
332
- } else {
333
- attrStr += ` ${resolvedAttrName}="${escapeAttribute(attrVal)}"`;
334
- }
335
- }
336
- }
337
- return attrStr;
338
- }
339
-
340
- function checkStopNode(matcher, stopNodeExpressions) {
341
- if (!stopNodeExpressions || stopNodeExpressions.length === 0) return false;
342
-
343
- for (let i = 0; i < stopNodeExpressions.length; i++) {
344
- if (matcher.matches(stopNodeExpressions[i])) {
345
- return true;
346
- }
347
- }
348
- return false;
349
- }
350
-
351
- function replaceEntitiesValue(textValue, options) {
352
- if (textValue && textValue.length > 0 && options.processEntities) {
353
- for (let i = 0; i < options.entities.length; i++) {
354
- const entity = options.entities[i];
355
- textValue = textValue.replace(entity.regex, entity.val);
356
- }
357
- }
358
- return textValue;
359
- }
@@ -1,16 +0,0 @@
1
-
2
-
3
- export function safeComment(val) {
4
- return String(val)
5
- .replace(/--/g, '- -') // -- is illegal anywhere in comment content
6
- .replace(/--/g, '- -') // handle the scenario when 2 consiucative dashes appears
7
- .replace(/-$/, '- '); // trailing - would form -- with the closing -->
8
- }
9
-
10
- export function safeCdata(val) {
11
- return String(val).replace(/\]\]>/g, ']]]]><![CDATA[>')
12
- }
13
-
14
- export function escapeAttribute(val) {
15
- return String(val).replace(/"/g, '&quot;').replace(/'/g, '&apos;')
16
- }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.