@gusto/baerly-storage 0.6.0 → 0.7.0

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 (218) hide show
  1. package/README.md +47 -124
  2. package/dist/API.md +161 -512
  3. package/dist/CHANGELOG.md +1137 -378
  4. package/dist/RECIPES.md +398 -80
  5. package/dist/THIRD-PARTY-LICENSES.txt +5 -26
  6. package/dist/{app-config-DyiFK3_k.d.ts → app-config-C6qW7m8S.d.ts} +119 -111
  7. package/dist/app-config.d.ts +31 -1
  8. package/dist/app-config.js +1 -2
  9. package/dist/app-config.js.map +1 -1
  10. package/dist/auth.d.ts +33 -28
  11. package/dist/auth.js +549 -985
  12. package/dist/auth.js.map +1 -1
  13. package/dist/baerly.js +130 -138
  14. package/dist/baerly.js.map +1 -1
  15. package/dist/baerly.spec.json +97 -22
  16. package/dist/capacity-warning-header-BlVopyiI.js +16 -0
  17. package/dist/capacity-warning-header-BlVopyiI.js.map +1 -0
  18. package/dist/{client-ypCm3zjt.d.ts → client-CHQTXpef.d.ts} +121 -36
  19. package/dist/client-react.d.ts +67 -20
  20. package/dist/client-react.js +240 -54
  21. package/dist/client-react.js.map +1 -1
  22. package/dist/client.d.ts +5 -4
  23. package/dist/client.js +51 -16
  24. package/dist/client.js.map +1 -1
  25. package/dist/{cloudflare-wrVYf4bb.js → cloudflare-CKHYXccw.js} +61 -82
  26. package/dist/cloudflare-CKHYXccw.js.map +1 -0
  27. package/dist/cloudflare.d.ts +106 -71
  28. package/dist/cloudflare.js +334 -271
  29. package/dist/cloudflare.js.map +1 -1
  30. package/dist/code-resolution-CL_7L0wS.js +22 -0
  31. package/dist/code-resolution-CL_7L0wS.js.map +1 -0
  32. package/dist/collection-api-DbyhLAY8.d.ts +1001 -0
  33. package/dist/config-DEzInG6M.js +4035 -0
  34. package/dist/config-DEzInG6M.js.map +1 -0
  35. package/dist/constants-D3GSH3tc.js +469 -0
  36. package/dist/constants-D3GSH3tc.js.map +1 -0
  37. package/dist/{context-DRZ3tZ5l.js → context-rlpSnHFA.js} +17 -17
  38. package/dist/context-rlpSnHFA.js.map +1 -0
  39. package/dist/cost-B52llVDx.js +330 -0
  40. package/dist/cost-B52llVDx.js.map +1 -0
  41. package/dist/{current-json-C6nhPOm1.js → current-json-CC6lE4Aj.js} +115 -32
  42. package/dist/current-json-CC6lE4Aj.js.map +1 -0
  43. package/dist/db-plFUNTSF.d.ts +130 -0
  44. package/dist/db-read-seams-BSs0m1z1.js +3261 -0
  45. package/dist/db-read-seams-BSs0m1z1.js.map +1 -0
  46. package/dist/{deploy-Di_Q01qx.js → deploy-Obj4nE-Z.js} +10 -14
  47. package/dist/deploy-Obj4nE-Z.js.map +1 -0
  48. package/dist/{dev-banner-CWHIk8tH.d.ts → dev-banner-B5AUHmu1.d.ts} +1 -4
  49. package/dist/dev-landing-BI5UdmOb.d.ts +32 -0
  50. package/dist/dev-landing-CD-si4dW.js +50 -0
  51. package/dist/dev-landing-CD-si4dW.js.map +1 -0
  52. package/dist/dev-vite.d.ts +9 -14
  53. package/dist/dev-vite.js +11 -10
  54. package/dist/dev-vite.js.map +1 -1
  55. package/dist/dev.d.ts +3 -2
  56. package/dist/dev.js +2 -1
  57. package/dist/doctor-BA0i-YAN.js +270 -0
  58. package/dist/doctor-BA0i-YAN.js.map +1 -0
  59. package/dist/dump-D1vX8ozg.js +133 -0
  60. package/dist/dump-D1vX8ozg.js.map +1 -0
  61. package/dist/errors-7Rk1HGCE.js +160 -0
  62. package/dist/errors-7Rk1HGCE.js.map +1 -0
  63. package/dist/{validate-DtljsCh1.js → export-BVL2EvYE.js} +409 -19
  64. package/dist/export-BVL2EvYE.js.map +1 -0
  65. package/dist/fsck-BWkPgov4.js +145 -0
  66. package/dist/fsck-BWkPgov4.js.map +1 -0
  67. package/dist/{gcs-admin-Bx6xSNJj.d.ts → gcs-admin-Dso1HWQj.d.ts} +18 -14
  68. package/dist/gcs.d.ts +19 -7
  69. package/dist/gcs.js +1 -2
  70. package/dist/{goog4-signer-Z7KnJ1su.js → goog4-signer-CeLIABoE.js} +102 -92
  71. package/dist/goog4-signer-CeLIABoE.js.map +1 -0
  72. package/dist/{http-7zT29K3P.js → http-Z5rZyYMX.js} +898 -271
  73. package/dist/http-Z5rZyYMX.js.map +1 -0
  74. package/dist/http-transport-DNUM8kU-.js +1299 -0
  75. package/dist/http-transport-DNUM8kU-.js.map +1 -0
  76. package/dist/http.d.ts +366 -294
  77. package/dist/http.js +2 -2
  78. package/dist/index-JJrIu1pO.d.ts +135 -0
  79. package/dist/index-LEgHN0qJ.d.ts +50 -0
  80. package/dist/{index-DP3ClvcA.d.ts → index-RiEYj8t0.d.ts} +291 -78
  81. package/dist/index.d.ts +27 -6
  82. package/dist/index.js +3 -5
  83. package/dist/inspect-BTsVYZKd.js +196 -0
  84. package/dist/inspect-BTsVYZKd.js.map +1 -0
  85. package/dist/{key-Di6yyxFu.js → key-C4FPZ9Io.js} +3 -4
  86. package/dist/{key-Di6yyxFu.js.map → key-C4FPZ9Io.js.map} +1 -1
  87. package/dist/ledger-Dj_bGgo0.js +192 -0
  88. package/dist/ledger-Dj_bGgo0.js.map +1 -0
  89. package/dist/legacy-names-DgZBtgOh.js +47 -0
  90. package/dist/legacy-names-DgZBtgOh.js.map +1 -0
  91. package/dist/log-C9W15Dfo.d.ts +94 -0
  92. package/dist/log-tail-DWJbneBF.js +142 -0
  93. package/dist/log-tail-DWJbneBF.js.map +1 -0
  94. package/dist/log-walk-C-vA-WGJ.js +111 -0
  95. package/dist/log-walk-C-vA-WGJ.js.map +1 -0
  96. package/dist/maintenance-Dd-Yakqj.js +1709 -0
  97. package/dist/maintenance-Dd-Yakqj.js.map +1 -0
  98. package/dist/maintenance-DevB6z4e.js +2237 -0
  99. package/dist/maintenance-DevB6z4e.js.map +1 -0
  100. package/dist/maintenance.d.ts +100 -3
  101. package/dist/maintenance.js +1 -3
  102. package/dist/node.d.ts +119 -92
  103. package/dist/node.js +3 -3
  104. package/dist/{observability-Ch-VQJyE.js → observability-C-ISCCLE.js} +1247 -326
  105. package/dist/observability-C-ISCCLE.js.map +1 -0
  106. package/dist/observability.d.ts +27 -3
  107. package/dist/observability.js +3 -3
  108. package/dist/path-segment-DBXG26PW.js +363 -0
  109. package/dist/path-segment-DBXG26PW.js.map +1 -0
  110. package/dist/{plan-C4qgiXSg.js → plan-BvQbaNMe.js} +19 -11
  111. package/dist/plan-BvQbaNMe.js.map +1 -0
  112. package/dist/request-CRWiTrza.js +272 -0
  113. package/dist/request-CRWiTrza.js.map +1 -0
  114. package/dist/restore-U6Im8V1V.js +1467 -0
  115. package/dist/restore-U6Im8V1V.js.map +1 -0
  116. package/dist/retry-OBtLB2GC.js +126 -0
  117. package/dist/retry-OBtLB2GC.js.map +1 -0
  118. package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
  119. package/dist/{runtime-spec--LykAdl1.js → runtime-spec-B5mg3pHF.js} +189 -28
  120. package/dist/runtime-spec-B5mg3pHF.js.map +1 -0
  121. package/dist/{s3-http-DD5gDc7t.d.ts → s3-http-DBC_wiCL.d.ts} +14 -8
  122. package/dist/s3.d.ts +20 -7
  123. package/dist/s3.js +4 -5
  124. package/dist/s3.js.map +1 -1
  125. package/dist/{sha256-CqcKTjw9.js → sha256-4FfGQNPw.js} +9 -9
  126. package/dist/sha256-4FfGQNPw.js.map +1 -0
  127. package/dist/{shared-secret-DgEicd3x.js → shared-secret-Vkur-8r0.js} +27 -15
  128. package/dist/shared-secret-Vkur-8r0.js.map +1 -0
  129. package/dist/{aws4fetch.esm-CXE5ZbAa.js → sigv4-sign-5IUflUD_.js} +143 -96
  130. package/dist/sigv4-sign-5IUflUD_.js.map +1 -0
  131. package/dist/snapshot-CknzkDM0.js +148 -0
  132. package/dist/snapshot-CknzkDM0.js.map +1 -0
  133. package/dist/{src-BMFfDUI2.js → src-Actga-bO.js} +949 -363
  134. package/dist/src-Actga-bO.js.map +1 -0
  135. package/dist/src-D0MQfvOp.js +812 -0
  136. package/dist/src-D0MQfvOp.js.map +1 -0
  137. package/dist/src-Dr9uo3dc.js +501 -0
  138. package/dist/src-Dr9uo3dc.js.map +1 -0
  139. package/dist/{subcommand-BV68pqwJ.js → subcommand-BLoF66dG.js} +89 -16
  140. package/dist/subcommand-BLoF66dG.js.map +1 -0
  141. package/dist/{time-DUqvFMHq.js → time-DRxTP9iv.js} +15 -34
  142. package/dist/time-DRxTP9iv.js.map +1 -0
  143. package/dist/types-suVbsEWS.d.ts +116 -0
  144. package/dist/{usage-BMZR8o6U.js → usage-CPzVhrQr.js} +40 -45
  145. package/dist/usage-CPzVhrQr.js.map +1 -0
  146. package/dist/uuid-BuT_c404.js +333 -0
  147. package/dist/uuid-BuT_c404.js.map +1 -0
  148. package/dist/verifier-Bmlmndzo.d.ts +95 -0
  149. package/dist/{wire-izfGZDvr.js → wire-DndvKU-K.js} +2 -3
  150. package/dist/wire-DndvKU-K.js.map +1 -0
  151. package/package.json +90 -69
  152. package/dist/aws4fetch.esm-CXE5ZbAa.js.map +0 -1
  153. package/dist/bytes-BXdamO3L.js +0 -11
  154. package/dist/bytes-BXdamO3L.js.map +0 -1
  155. package/dist/cloudflare-wrVYf4bb.js.map +0 -1
  156. package/dist/config-B6nTy8e2.js +0 -3095
  157. package/dist/config-B6nTy8e2.js.map +0 -1
  158. package/dist/constants-CfeMWQWk.js +0 -222
  159. package/dist/constants-CfeMWQWk.js.map +0 -1
  160. package/dist/context-DRZ3tZ5l.js.map +0 -1
  161. package/dist/cost-_SE_SVgZ.js +0 -203
  162. package/dist/cost-_SE_SVgZ.js.map +0 -1
  163. package/dist/current-json-C6nhPOm1.js.map +0 -1
  164. package/dist/db-DjjthkTi.d.ts +0 -254
  165. package/dist/deploy-Di_Q01qx.js.map +0 -1
  166. package/dist/doctor-RWVRpvat.js +0 -102
  167. package/dist/doctor-RWVRpvat.js.map +0 -1
  168. package/dist/dump-m2vEYDNY.js +0 -94
  169. package/dist/dump-m2vEYDNY.js.map +0 -1
  170. package/dist/errors-Dfa3p78c.js +0 -78
  171. package/dist/errors-Dfa3p78c.js.map +0 -1
  172. package/dist/export-DenKwEQu.js +0 -401
  173. package/dist/export-DenKwEQu.js.map +0 -1
  174. package/dist/fsck-2Vq-7-e2.js +0 -279
  175. package/dist/fsck-2Vq-7-e2.js.map +0 -1
  176. package/dist/goog4-signer-Z7KnJ1su.js.map +0 -1
  177. package/dist/http-7zT29K3P.js.map +0 -1
  178. package/dist/http-transport-BTgVCY5r.js +0 -1250
  179. package/dist/http-transport-BTgVCY5r.js.map +0 -1
  180. package/dist/index-BHz92Acj.d.ts +0 -162
  181. package/dist/index-CEZKQsKt.d.ts +0 -1113
  182. package/dist/index-uE-w2dgj.d.ts +0 -115
  183. package/dist/indexes-Dn9hbGQG.d.ts +0 -22
  184. package/dist/inspect-BpYbH1DM.js +0 -133
  185. package/dist/inspect-BpYbH1DM.js.map +0 -1
  186. package/dist/log-tail-QWU4wlu-.js +0 -514
  187. package/dist/log-tail-QWU4wlu-.js.map +0 -1
  188. package/dist/maintenance-BGHGt2Yg.d.ts +0 -537
  189. package/dist/maintenance-DULFcpd1.js +0 -2144
  190. package/dist/maintenance-DULFcpd1.js.map +0 -1
  191. package/dist/maintenance-fEi-UZ2o.js +0 -1412
  192. package/dist/maintenance-fEi-UZ2o.js.map +0 -1
  193. package/dist/normalize-rjnZLwS4.js +0 -133
  194. package/dist/normalize-rjnZLwS4.js.map +0 -1
  195. package/dist/observability-Ch-VQJyE.js.map +0 -1
  196. package/dist/plan-C4qgiXSg.js.map +0 -1
  197. package/dist/query-C43r-6ib.js +0 -1773
  198. package/dist/query-C43r-6ib.js.map +0 -1
  199. package/dist/rebuild-index-BH1dc1p6.js +0 -81
  200. package/dist/rebuild-index-BH1dc1p6.js.map +0 -1
  201. package/dist/request-u0M51mhJ.js +0 -72
  202. package/dist/request-u0M51mhJ.js.map +0 -1
  203. package/dist/restore-D0VYWzfP.js +0 -778
  204. package/dist/restore-D0VYWzfP.js.map +0 -1
  205. package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
  206. package/dist/runtime-spec--LykAdl1.js.map +0 -1
  207. package/dist/sha256-CqcKTjw9.js.map +0 -1
  208. package/dist/shared-secret-DgEicd3x.js.map +0 -1
  209. package/dist/src-BMFfDUI2.js.map +0 -1
  210. package/dist/src-DYZ4H1aF.js +0 -392
  211. package/dist/src-DYZ4H1aF.js.map +0 -1
  212. package/dist/src-DvbTEya2.js +0 -536
  213. package/dist/src-DvbTEya2.js.map +0 -1
  214. package/dist/subcommand-BV68pqwJ.js.map +0 -1
  215. package/dist/time-DUqvFMHq.js.map +0 -1
  216. package/dist/usage-BMZR8o6U.js.map +0 -1
  217. package/dist/validate-DtljsCh1.js.map +0 -1
  218. package/dist/wire-izfGZDvr.js.map +0 -1
@@ -1,1250 +0,0 @@
1
- import { t as __commonJSMin } from "./rolldown-runtime-EAsCxrDo.js";
2
- import { t as BaerlyError } from "./errors-Dfa3p78c.js";
3
- import { t as delay } from "./time-DUqvFMHq.js";
4
- /*! @rgrove/parse-xml v4.2.1 | ISC License | Copyright Ryan Grove */
5
- //#endregion
6
- //#region packages/adapter-node/src/xml.ts
7
- var import_browser = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __export = (target, all) => {
13
- for (var name in all) __defProp(target, name, {
14
- get: all[name],
15
- enumerable: true
16
- });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
- get: () => from[key],
22
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
- });
24
- }
25
- return to;
26
- };
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var src_exports = {};
29
- __export(src_exports, {
30
- XmlCdata: () => XmlCdata,
31
- XmlComment: () => XmlComment,
32
- XmlDeclaration: () => XmlDeclaration,
33
- XmlDocument: () => XmlDocument,
34
- XmlDocumentType: () => XmlDocumentType,
35
- XmlElement: () => XmlElement,
36
- XmlError: () => XmlError,
37
- XmlNode: () => XmlNode,
38
- XmlProcessingInstruction: () => XmlProcessingInstruction,
39
- XmlText: () => XmlText,
40
- parseXml: () => parseXml
41
- });
42
- module.exports = __toCommonJS(src_exports);
43
- var emptyString = "";
44
- var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
45
- var StringScanner = class {
46
- constructor(string) {
47
- this.k = this.u(string, true);
48
- this.d = 0;
49
- this.length = string.length;
50
- this.l = this.k !== this.length;
51
- this.h = string;
52
- if (this.l) {
53
- let charsToBytes = [];
54
- for (let byteIndex = 0, charIndex = 0; charIndex < this.k; ++charIndex) {
55
- charsToBytes[charIndex] = byteIndex;
56
- byteIndex += string.codePointAt(byteIndex) > 65535 ? 2 : 1;
57
- }
58
- this.A = charsToBytes;
59
- }
60
- }
61
- /**
62
- * Whether the current character index is at the end of the input string.
63
- */
64
- get B() {
65
- return this.d >= this.k;
66
- }
67
- /**
68
- * Returns the number of characters in the given string, which may differ from
69
- * the byte length if the string contains multibyte characters.
70
- */
71
- u(string, multiByteSafe = this.l) {
72
- return multiByteSafe ? string.replace(surrogatePair, "_").length : string.length;
73
- }
74
- /**
75
- * Advances the scanner by the given number of characters, stopping if the end
76
- * of the string is reached.
77
- */
78
- p(count = 1) {
79
- this.d = Math.min(this.k, this.d + count);
80
- }
81
- /**
82
- * Returns the byte index of the given character index in the string. The two
83
- * may differ in strings that contain multibyte characters.
84
- */
85
- f(charIndex = this.d) {
86
- var _a;
87
- return this.l ? (_a = this.A[charIndex]) != null ? _a : Infinity : charIndex;
88
- }
89
- /**
90
- * Consumes and returns the given number of characters if possible, advancing
91
- * the scanner and stopping if the end of the string is reached.
92
- *
93
- * If no characters could be consumed, an empty string will be returned.
94
- */
95
- G(charCount = 1) {
96
- let chars = this.m(charCount);
97
- this.p(charCount);
98
- return chars;
99
- }
100
- /**
101
- * Consumes and returns the given number of bytes if possible, advancing the
102
- * scanner and stopping if the end of the string is reached.
103
- *
104
- * It's up to the caller to ensure that the given byte count doesn't split a
105
- * multibyte character.
106
- *
107
- * If no bytes could be consumed, an empty string will be returned.
108
- */
109
- v(byteCount) {
110
- let byteIndex = this.f();
111
- let result = this.h.slice(byteIndex, byteIndex + byteCount);
112
- this.p(this.u(result));
113
- return result;
114
- }
115
- /**
116
- * Consumes and returns all characters for which the given function returns
117
- * `true`, stopping when `false` is returned or the end of the input is
118
- * reached.
119
- */
120
- w(fn) {
121
- let { length, l: multiByteMode, h: string } = this;
122
- let startByteIndex = this.f();
123
- let endByteIndex = startByteIndex;
124
- if (multiByteMode) while (endByteIndex < length) {
125
- let char = string[endByteIndex];
126
- let isSurrogatePair = char >= "\ud800" && char <= "\udbff";
127
- if (isSurrogatePair) char += string[endByteIndex + 1];
128
- if (!fn(char)) break;
129
- endByteIndex += isSurrogatePair ? 2 : 1;
130
- }
131
- else while (endByteIndex < length && fn(string[endByteIndex])) ++endByteIndex;
132
- return this.v(endByteIndex - startByteIndex);
133
- }
134
- /**
135
- * Consumes the given string if it exists at the current character index, and
136
- * advances the scanner.
137
- *
138
- * If the given string doesn't exist at the current character index, an empty
139
- * string will be returned and the scanner will not be advanced.
140
- */
141
- b(stringToConsume) {
142
- let { length } = stringToConsume;
143
- let byteIndex = this.f();
144
- if (stringToConsume === this.h.slice(byteIndex, byteIndex + length)) {
145
- this.p(length === 1 ? 1 : this.u(stringToConsume));
146
- return stringToConsume;
147
- }
148
- return emptyString;
149
- }
150
- /**
151
- * Consumes characters until the given global regex is matched, advancing the
152
- * scanner up to (but not beyond) the beginning of the match. If the regex
153
- * doesn't match, nothing will be consumed.
154
- *
155
- * Returns the consumed string, or an empty string if nothing was consumed.
156
- */
157
- x(regex) {
158
- let matchByteIndex = this.h.slice(this.f()).search(regex);
159
- return matchByteIndex > 0 ? this.v(matchByteIndex) : emptyString;
160
- }
161
- /**
162
- * Consumes characters until the given string is found, advancing the scanner
163
- * up to (but not beyond) that point. If the string is never found, nothing
164
- * will be consumed.
165
- *
166
- * Returns the consumed string, or an empty string if nothing was consumed.
167
- */
168
- s(searchString) {
169
- let byteIndex = this.f();
170
- let matchByteIndex = this.h.indexOf(searchString, byteIndex);
171
- return matchByteIndex > 0 ? this.v(matchByteIndex - byteIndex) : emptyString;
172
- }
173
- /**
174
- * Returns the given number of characters starting at the current character
175
- * index, without advancing the scanner and without exceeding the end of the
176
- * input string.
177
- */
178
- m(count = 1) {
179
- let { d: charIndex, h: string } = this;
180
- return this.l ? string.slice(this.f(charIndex), this.f(charIndex + count)) : string.slice(charIndex, charIndex + count);
181
- }
182
- /**
183
- * Resets the scanner position to the given character _index_, or to the start
184
- * of the input string if no index is given.
185
- *
186
- * If _index_ is negative, the scanner position will be moved backward by that
187
- * many characters, stopping if the beginning of the string is reached.
188
- */
189
- n(index = 0) {
190
- this.d = index >= 0 ? Math.min(this.k, index) : Math.max(0, this.d + index);
191
- }
192
- };
193
- var attValueCharDoubleQuote = /["&<]/;
194
- var attValueCharSingleQuote = /['&<]/;
195
- var attValueNormalizedWhitespace = /\r\n|[\n\r\t]/g;
196
- var endCharData = /<|&|]]>/;
197
- var predefinedEntities = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
198
- amp: "&",
199
- apos: "'",
200
- gt: ">",
201
- lt: "<",
202
- quot: "\""
203
- }));
204
- function isNameChar(char) {
205
- let cp = char.codePointAt(0);
206
- return cp >= 97 && cp <= 122 || cp >= 65 && cp <= 90 || cp >= 48 && cp <= 57 || cp === 45 || cp === 46 || cp === 183 || cp >= 768 && cp <= 879 || cp === 8255 || cp === 8256 || isNameStartChar(char, cp);
207
- }
208
- function isNameStartChar(char, cp = char.codePointAt(0)) {
209
- return cp >= 97 && cp <= 122 || cp >= 65 && cp <= 90 || cp === 58 || cp === 95 || cp >= 192 && cp <= 214 || cp >= 216 && cp <= 246 || cp >= 248 && cp <= 767 || cp >= 880 && cp <= 893 || cp >= 895 && cp <= 8191 || cp === 8204 || cp === 8205 || cp >= 8304 && cp <= 8591 || cp >= 11264 && cp <= 12271 || cp >= 12289 && cp <= 55295 || cp >= 63744 && cp <= 64975 || cp >= 65008 && cp <= 65533 || cp >= 65536 && cp <= 983039;
210
- }
211
- function isReferenceChar(char) {
212
- return char === "#" || isNameChar(char);
213
- }
214
- function isWhitespace(char) {
215
- let cp = char.codePointAt(0);
216
- return cp === 32 || cp === 9 || cp === 10 || cp === 13;
217
- }
218
- function isXmlCodePoint(cp) {
219
- return cp >= 32 && cp <= 55295 || cp === 10 || cp === 9 || cp === 13 || cp >= 57344 && cp <= 65533 || cp >= 65536 && cp <= 1114111;
220
- }
221
- var _XmlNode = class _XmlNode {
222
- constructor() {
223
- /**
224
- * Parent node of this node, or `null` if this node has no parent.
225
- */
226
- this.parent = null;
227
- /**
228
- * Starting byte offset of this node in the original XML string, or `-1` if
229
- * the offset is unknown.
230
- */
231
- this.start = -1;
232
- /**
233
- * Ending byte offset of this node in the original XML string, or `-1` if the
234
- * offset is unknown.
235
- */
236
- this.end = -1;
237
- }
238
- /**
239
- * Document that contains this node, or `null` if this node is not associated
240
- * with a document.
241
- */
242
- get document() {
243
- var _a, _b;
244
- return (_b = (_a = this.parent) == null ? void 0 : _a.document) != null ? _b : null;
245
- }
246
- /**
247
- * Whether this node is the root node of the document (also known as the
248
- * document element).
249
- */
250
- get isRootNode() {
251
- return this.parent !== null && this.parent === this.document && this.type === _XmlNode.TYPE_ELEMENT;
252
- }
253
- /**
254
- * Whether whitespace should be preserved in the content of this element and
255
- * its children.
256
- *
257
- * This is influenced by the value of the special `xml:space` attribute, and
258
- * will be `true` for any node whose `xml:space` attribute is set to
259
- * "preserve". If a node has no such attribute, it will inherit the value of
260
- * the nearest ancestor that does (if any).
261
- *
262
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-white-space
263
- */
264
- get preserveWhitespace() {
265
- var _a;
266
- return !!((_a = this.parent) == null ? void 0 : _a.preserveWhitespace);
267
- }
268
- /**
269
- * Type of this node.
270
- *
271
- * The value of this property is a string that matches one of the static
272
- * `TYPE_*` properties on the `XmlNode` class (e.g. `TYPE_ELEMENT`,
273
- * `TYPE_TEXT`, etc.).
274
- *
275
- * The `XmlNode` class itself is a base class and doesn't have its own type
276
- * name.
277
- */
278
- get type() {
279
- return "";
280
- }
281
- /**
282
- * Returns a JSON-serializable object representing this node, minus properties
283
- * that could result in circular references.
284
- */
285
- toJSON() {
286
- let json = { type: this.type };
287
- if (this.isRootNode) json.isRootNode = true;
288
- if (this.preserveWhitespace) json.preserveWhitespace = true;
289
- if (this.start !== -1) {
290
- json.start = this.start;
291
- json.end = this.end;
292
- }
293
- return json;
294
- }
295
- };
296
- /**
297
- * Type value for an `XmlCdata` node.
298
- */
299
- _XmlNode.TYPE_CDATA = "cdata";
300
- /**
301
- * Type value for an `XmlComment` node.
302
- */
303
- _XmlNode.TYPE_COMMENT = "comment";
304
- /**
305
- * Type value for an `XmlDocument` node.
306
- */
307
- _XmlNode.TYPE_DOCUMENT = "document";
308
- /**
309
- * Type value for an `XmlDocumentType` node.
310
- */
311
- _XmlNode.TYPE_DOCUMENT_TYPE = "doctype";
312
- /**
313
- * Type value for an `XmlElement` node.
314
- */
315
- _XmlNode.TYPE_ELEMENT = "element";
316
- /**
317
- * Type value for an `XmlProcessingInstruction` node.
318
- */
319
- _XmlNode.TYPE_PROCESSING_INSTRUCTION = "pi";
320
- /**
321
- * Type value for an `XmlText` node.
322
- */
323
- _XmlNode.TYPE_TEXT = "text";
324
- /**
325
- * Type value for an `XmlDeclaration` node.
326
- */
327
- _XmlNode.TYPE_XML_DECLARATION = "xmldecl";
328
- var XmlNode = _XmlNode;
329
- var XmlText = class extends XmlNode {
330
- constructor(text = "") {
331
- super();
332
- this.text = text;
333
- }
334
- get type() {
335
- return XmlNode.TYPE_TEXT;
336
- }
337
- toJSON() {
338
- return Object.assign(XmlNode.prototype.toJSON.call(this), { text: this.text });
339
- }
340
- };
341
- var XmlCdata = class extends XmlText {
342
- get type() {
343
- return XmlNode.TYPE_CDATA;
344
- }
345
- };
346
- var XmlComment = class extends XmlNode {
347
- constructor(content = "") {
348
- super();
349
- this.content = content;
350
- }
351
- get type() {
352
- return XmlNode.TYPE_COMMENT;
353
- }
354
- toJSON() {
355
- return Object.assign(XmlNode.prototype.toJSON.call(this), { content: this.content });
356
- }
357
- };
358
- var XmlDeclaration = class extends XmlNode {
359
- constructor(version, encoding, standalone) {
360
- super();
361
- this.version = version;
362
- this.encoding = encoding != null ? encoding : null;
363
- this.standalone = standalone != null ? standalone : null;
364
- }
365
- get type() {
366
- return XmlNode.TYPE_XML_DECLARATION;
367
- }
368
- toJSON() {
369
- let json = XmlNode.prototype.toJSON.call(this);
370
- json.version = this.version;
371
- for (let key of ["encoding", "standalone"]) if (this[key] !== null) json[key] = this[key];
372
- return json;
373
- }
374
- };
375
- var XmlElement = class _XmlElement extends XmlNode {
376
- constructor(name, attributes = /* @__PURE__ */ Object.create(null), children = []) {
377
- super();
378
- this.name = name;
379
- this.attributes = attributes;
380
- this.children = children;
381
- }
382
- /**
383
- * Whether this element is empty (meaning it has no children).
384
- */
385
- get isEmpty() {
386
- return this.children.length === 0;
387
- }
388
- get preserveWhitespace() {
389
- let node = this;
390
- while (node instanceof _XmlElement) {
391
- if ("xml:space" in node.attributes) return node.attributes["xml:space"] === "preserve";
392
- node = node.parent;
393
- }
394
- return false;
395
- }
396
- /**
397
- * Text content of this element and all its descendants.
398
- */
399
- get text() {
400
- return this.children.map((child) => "text" in child ? child.text : "").join("");
401
- }
402
- get type() {
403
- return XmlNode.TYPE_ELEMENT;
404
- }
405
- toJSON() {
406
- return Object.assign(XmlNode.prototype.toJSON.call(this), {
407
- name: this.name,
408
- attributes: this.attributes,
409
- children: this.children.map((child) => child.toJSON())
410
- });
411
- }
412
- };
413
- var XmlDocument = class extends XmlNode {
414
- constructor(children = []) {
415
- super();
416
- this.children = children;
417
- }
418
- get document() {
419
- return this;
420
- }
421
- /**
422
- * Root element of this document, or `null` if this document is empty.
423
- */
424
- get root() {
425
- for (let child of this.children) if (child instanceof XmlElement) return child;
426
- return null;
427
- }
428
- /**
429
- * Text content of this document and all its descendants.
430
- */
431
- get text() {
432
- return this.children.map((child) => "text" in child ? child.text : "").join("");
433
- }
434
- get type() {
435
- return XmlNode.TYPE_DOCUMENT;
436
- }
437
- toJSON() {
438
- return Object.assign(XmlNode.prototype.toJSON.call(this), { children: this.children.map((child) => child.toJSON()) });
439
- }
440
- };
441
- var XmlDocumentType = class extends XmlNode {
442
- constructor(name, publicId, systemId, internalSubset) {
443
- super();
444
- this.name = name;
445
- this.publicId = publicId != null ? publicId : null;
446
- this.systemId = systemId != null ? systemId : null;
447
- this.internalSubset = internalSubset != null ? internalSubset : null;
448
- }
449
- get type() {
450
- return XmlNode.TYPE_DOCUMENT_TYPE;
451
- }
452
- toJSON() {
453
- let json = XmlNode.prototype.toJSON.call(this);
454
- json.name = this.name;
455
- for (let key of [
456
- "publicId",
457
- "systemId",
458
- "internalSubset"
459
- ]) if (this[key] !== null) json[key] = this[key];
460
- return json;
461
- }
462
- };
463
- var XmlError = class extends Error {
464
- constructor(message, charIndex, xml) {
465
- let column = 1;
466
- let excerpt = "";
467
- let line = 1;
468
- for (let i = 0; i < charIndex; ++i) {
469
- let char = xml[i];
470
- if (char === "\n") {
471
- column = 1;
472
- excerpt = "";
473
- line += 1;
474
- } else {
475
- column += 1;
476
- excerpt += char;
477
- }
478
- }
479
- let eol = xml.indexOf("\n", charIndex);
480
- excerpt += eol === -1 ? xml.slice(charIndex) : xml.slice(charIndex, eol);
481
- let excerptStart = 0;
482
- if (excerpt.length > 50) if (column < 40) excerpt = excerpt.slice(0, 50);
483
- else {
484
- excerptStart = column - 20;
485
- excerpt = excerpt.slice(excerptStart, column + 30);
486
- }
487
- super(`${message} (line ${line}, column ${column})
488
- ${excerpt}
489
- ` + " ".repeat(column - excerptStart + 1) + "^\n");
490
- this.column = column;
491
- this.excerpt = excerpt;
492
- this.line = line;
493
- this.name = "XmlError";
494
- this.pos = charIndex;
495
- }
496
- };
497
- var XmlProcessingInstruction = class extends XmlNode {
498
- constructor(name, content = "") {
499
- super();
500
- this.name = name;
501
- this.content = content;
502
- }
503
- get type() {
504
- return XmlNode.TYPE_PROCESSING_INSTRUCTION;
505
- }
506
- toJSON() {
507
- return Object.assign(XmlNode.prototype.toJSON.call(this), {
508
- name: this.name,
509
- content: this.content
510
- });
511
- }
512
- };
513
- var emptyString2 = "";
514
- var Parser = class {
515
- /**
516
- * @param xml XML string to parse.
517
- * @param options Parser options.
518
- */
519
- constructor(xml, options = {}) {
520
- let doc = this.document = new XmlDocument();
521
- this.j = doc;
522
- this.g = options;
523
- this.c = new StringScanner(xml);
524
- if (this.g.includeOffsets) {
525
- doc.start = 0;
526
- doc.end = xml.length;
527
- }
528
- this.parse();
529
- }
530
- /**
531
- * Adds the given `XmlNode` as a child of `this.currentNode`.
532
- */
533
- i(node, charIndex) {
534
- node.parent = this.j;
535
- if (this.g.includeOffsets) {
536
- node.start = this.c.f(charIndex);
537
- node.end = this.c.f();
538
- }
539
- this.j.children.push(node);
540
- return true;
541
- }
542
- /**
543
- * Adds the given _text_ to the document, either by appending it to a
544
- * preceding `XmlText` node (if possible) or by creating a new `XmlText` node.
545
- *
546
- * When _normalize_ is `true` (the default), line breaks in _text_ are
547
- * normalized per section 2.11 of the XML spec. This must be `false` for text
548
- * that comes from a character or entity reference, since references aren't
549
- * subject to line break normalization.
550
- */
551
- y(text, charIndex, normalize = true) {
552
- let { children } = this.j;
553
- let { length } = children;
554
- if (normalize) text = normalizeLineBreaks(text);
555
- if (length > 0) {
556
- let prevNode = children[length - 1];
557
- if ((prevNode == null ? void 0 : prevNode.type) === XmlNode.TYPE_TEXT) {
558
- let textNode = prevNode;
559
- textNode.text += text;
560
- if (this.g.includeOffsets) textNode.end = this.c.f();
561
- return true;
562
- }
563
- }
564
- return this.i(new XmlText(text), charIndex);
565
- }
566
- /**
567
- * Consumes element attributes.
568
- *
569
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-starttags
570
- */
571
- H() {
572
- let attributes = /* @__PURE__ */ Object.create(null);
573
- while (this.e()) {
574
- let attrName = this.q();
575
- if (!attrName) break;
576
- let attrValue = this.t() && this.I();
577
- if (attrValue === false) throw this.a("Attribute value expected");
578
- if (attrName in attributes) throw this.a(`Duplicate attribute: ${attrName}`);
579
- if (attrName === "xml:space" && attrValue !== "default" && attrValue !== "preserve") throw this.a("Value of the `xml:space` attribute must be \"default\" or \"preserve\"");
580
- attributes[attrName] = attrValue;
581
- }
582
- if (this.g.sortAttributes) {
583
- let attrNames = Object.keys(attributes).sort();
584
- let sortedAttributes = /* @__PURE__ */ Object.create(null);
585
- for (let i = 0; i < attrNames.length; ++i) {
586
- let attrName = attrNames[i];
587
- sortedAttributes[attrName] = attributes[attrName];
588
- }
589
- attributes = sortedAttributes;
590
- }
591
- return attributes;
592
- }
593
- /**
594
- * Consumes an `AttValue` (attribute value) if possible.
595
- *
596
- * @returns
597
- * Contents of the `AttValue` minus quotes, or `false` if nothing was
598
- * consumed. An empty string indicates that an `AttValue` was consumed but
599
- * was empty.
600
- *
601
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-AttValue
602
- */
603
- I() {
604
- let { c: scanner } = this;
605
- let quote = scanner.m();
606
- if (quote !== "\"" && quote !== "'") return false;
607
- scanner.p();
608
- let chars;
609
- let isClosed = false;
610
- let value = emptyString2;
611
- let regex = quote === "\"" ? attValueCharDoubleQuote : attValueCharSingleQuote;
612
- matchLoop: while (!scanner.B) {
613
- chars = scanner.x(regex);
614
- if (chars) {
615
- this.o(chars);
616
- value += chars.replace(attValueNormalizedWhitespace, " ");
617
- }
618
- switch (scanner.m()) {
619
- case quote:
620
- isClosed = true;
621
- break matchLoop;
622
- case "&":
623
- value += this.C();
624
- continue;
625
- case "<": throw this.a("Unescaped `<` is not allowed in an attribute value");
626
- default: break matchLoop;
627
- }
628
- }
629
- if (!isClosed) throw this.a("Unclosed attribute");
630
- scanner.p();
631
- return value;
632
- }
633
- /**
634
- * Consumes a CDATA section if possible.
635
- *
636
- * @returns Whether a CDATA section was consumed.
637
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-cdata-sect
638
- */
639
- J() {
640
- let { c: scanner } = this;
641
- let startIndex = scanner.d;
642
- if (!scanner.b("<![CDATA[")) return false;
643
- let text = scanner.s("]]>");
644
- this.o(text);
645
- if (!scanner.b("]]>")) throw this.a("Unclosed CDATA section");
646
- return this.g.preserveCdata ? this.i(new XmlCdata(normalizeLineBreaks(text)), startIndex) : this.y(text, startIndex);
647
- }
648
- /**
649
- * Consumes character data if possible.
650
- *
651
- * @returns Whether character data was consumed.
652
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#dt-chardata
653
- */
654
- K() {
655
- let { c: scanner } = this;
656
- let startIndex = scanner.d;
657
- let charData = scanner.x(endCharData);
658
- if (!charData) return false;
659
- this.o(charData);
660
- if (scanner.m(3) === "]]>") throw this.a("Element content may not contain the CDATA section close delimiter `]]>`");
661
- return this.y(charData, startIndex);
662
- }
663
- /**
664
- * Consumes a comment if possible.
665
- *
666
- * @returns Whether a comment was consumed.
667
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Comment
668
- */
669
- D() {
670
- let { c: scanner } = this;
671
- let startIndex = scanner.d;
672
- if (!scanner.b("<!--")) return false;
673
- let content = scanner.s("--");
674
- this.o(content);
675
- if (!scanner.b("-->")) {
676
- if (scanner.m(2) === "--") throw this.a("The string `--` isn't allowed inside a comment");
677
- throw this.a("Unclosed comment");
678
- }
679
- return this.g.preserveComments ? this.i(new XmlComment(normalizeLineBreaks(content)), startIndex) : true;
680
- }
681
- /**
682
- * Consumes a reference in a content context if possible.
683
- *
684
- * This differs from `consumeReference()` in that a consumed reference will be
685
- * added to the document as a text node instead of returned.
686
- *
687
- * @returns Whether a reference was consumed.
688
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#entproc
689
- */
690
- L() {
691
- let startIndex = this.c.d;
692
- let ref = this.C();
693
- return ref ? this.y(ref, startIndex, false) : false;
694
- }
695
- /**
696
- * Consumes a doctype declaration if possible.
697
- *
698
- * This is a loose implementation since doctype declarations are currently
699
- * discarded without further parsing.
700
- *
701
- * @returns Whether a doctype declaration was consumed.
702
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#dtd
703
- */
704
- M() {
705
- let { c: scanner } = this;
706
- let startIndex = scanner.d;
707
- if (!scanner.b("<!DOCTYPE")) return false;
708
- let name = this.e() && this.q();
709
- if (!name) throw this.a("Expected a name");
710
- let publicId;
711
- let systemId;
712
- if (this.e()) {
713
- if (scanner.b("PUBLIC")) {
714
- publicId = this.e() && this.N();
715
- if (publicId === false) throw this.a("Expected a public identifier");
716
- this.e();
717
- }
718
- if (publicId !== void 0 || scanner.b("SYSTEM")) {
719
- this.e();
720
- systemId = this.r();
721
- if (systemId === false) throw this.a("Expected a system identifier");
722
- this.e();
723
- }
724
- }
725
- let internalSubset;
726
- if (scanner.b("[")) {
727
- internalSubset = scanner.x(/\][\x20\t\r\n]*>/);
728
- if (!scanner.b("]")) throw this.a("Unclosed internal subset");
729
- this.e();
730
- }
731
- if (!scanner.b(">")) throw this.a("Unclosed doctype declaration");
732
- return this.g.preserveDocumentType ? this.i(new XmlDocumentType(name, publicId, systemId, internalSubset), startIndex) : true;
733
- }
734
- /**
735
- * Consumes an element if possible.
736
- *
737
- * @returns Whether an element was consumed.
738
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-element
739
- */
740
- E() {
741
- let { c: scanner } = this;
742
- let startIndex = scanner.d;
743
- if (!scanner.b("<")) return false;
744
- let name = this.q();
745
- if (!name) {
746
- scanner.n(startIndex);
747
- return false;
748
- }
749
- let attributes = this.H();
750
- let isEmpty = !!scanner.b("/>");
751
- let element = new XmlElement(name, attributes);
752
- element.parent = this.j;
753
- if (!isEmpty) {
754
- if (!scanner.b(">")) throw this.a(`Unclosed start tag for element \`${name}\``);
755
- this.j = element;
756
- do
757
- this.K();
758
- while (this.E() || this.L() || this.J() || this.F() || this.D());
759
- let endTagMark = scanner.d;
760
- let endTagName;
761
- if (!scanner.b("</") || !(endTagName = this.q()) || endTagName !== name) {
762
- scanner.n(endTagMark);
763
- throw this.a(`Missing end tag for element ${name}`);
764
- }
765
- this.e();
766
- if (!scanner.b(">")) throw this.a(`Unclosed end tag for element ${name}`);
767
- this.j = element.parent;
768
- }
769
- return this.i(element, startIndex);
770
- }
771
- /**
772
- * Consumes an `Eq` production if possible.
773
- *
774
- * @returns Whether an `Eq` production was consumed.
775
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Eq
776
- */
777
- t() {
778
- this.e();
779
- if (this.c.b("=")) {
780
- this.e();
781
- return true;
782
- }
783
- return false;
784
- }
785
- /**
786
- * Consumes `Misc` content if possible.
787
- *
788
- * @returns Whether anything was consumed.
789
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Misc
790
- */
791
- z() {
792
- return this.D() || this.F() || this.e();
793
- }
794
- /**
795
- * Consumes one or more `Name` characters if possible.
796
- *
797
- * @returns `Name` characters, or an empty string if none were consumed.
798
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name
799
- */
800
- q() {
801
- return isNameStartChar(this.c.m()) ? this.c.w(isNameChar) : emptyString2;
802
- }
803
- /**
804
- * Consumes a processing instruction if possible.
805
- *
806
- * @returns Whether a processing instruction was consumed.
807
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-pi
808
- */
809
- F() {
810
- let { c: scanner } = this;
811
- let startIndex = scanner.d;
812
- if (!scanner.b("<?")) return false;
813
- let name = this.q();
814
- if (name) {
815
- if (name.toLowerCase() === "xml") {
816
- scanner.n(startIndex);
817
- throw this.a("XML declaration isn't allowed here");
818
- }
819
- } else throw this.a("Invalid processing instruction");
820
- if (!this.e()) {
821
- if (scanner.b("?>")) return this.i(new XmlProcessingInstruction(name), startIndex);
822
- throw this.a("Whitespace is required after a processing instruction name");
823
- }
824
- let content = scanner.s("?>");
825
- this.o(content);
826
- if (!scanner.b("?>")) throw this.a("Unterminated processing instruction");
827
- return this.i(new XmlProcessingInstruction(name, normalizeLineBreaks(content)), startIndex);
828
- }
829
- /**
830
- * Consumes a prolog if possible.
831
- *
832
- * @returns Whether a prolog was consumed.
833
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-prolog-dtd
834
- */
835
- O() {
836
- let { c: scanner } = this;
837
- let startIndex = scanner.d;
838
- this.P();
839
- while (this.z());
840
- if (this.M()) while (this.z());
841
- return startIndex < scanner.d;
842
- }
843
- /**
844
- * Consumes a public identifier literal if possible.
845
- *
846
- * @returns
847
- * Value of the public identifier literal minus quotes, or `false` if
848
- * nothing was consumed. An empty string indicates that a public id literal
849
- * was consumed but was empty.
850
- *
851
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-PubidLiteral
852
- */
853
- N() {
854
- let startIndex = this.c.d;
855
- let value = this.r();
856
- if (value !== false && !/^[-\x20\r\na-zA-Z0-9'()+,./:=?;!*#@$_%]*$/.test(value)) {
857
- this.c.n(startIndex);
858
- throw this.a("Invalid character in public identifier");
859
- }
860
- return value;
861
- }
862
- /**
863
- * Consumes a reference if possible.
864
- *
865
- * This differs from `consumeContentReference()` in that a consumed reference
866
- * will be returned rather than added to the document.
867
- *
868
- * @returns
869
- * Parsed reference value, or `false` if nothing was consumed (to
870
- * distinguish from a reference that resolves to an empty string).
871
- *
872
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Reference
873
- */
874
- C() {
875
- let { c: scanner } = this;
876
- if (!scanner.b("&")) return false;
877
- let ref = scanner.w(isReferenceChar);
878
- if (scanner.G() !== ";") throw this.a("Unterminated reference (a reference must end with `;`)");
879
- let parsedValue;
880
- if (ref[0] === "#") {
881
- let codePoint = ref[1] === "x" ? parseInt(ref.slice(2), 16) : parseInt(ref.slice(1), 10);
882
- if (isNaN(codePoint)) throw this.a("Invalid character reference");
883
- if (!isXmlCodePoint(codePoint)) throw this.a("Character reference resolves to an invalid character");
884
- parsedValue = String.fromCodePoint(codePoint);
885
- } else {
886
- parsedValue = predefinedEntities[ref];
887
- if (parsedValue === void 0) {
888
- let { ignoreUndefinedEntities, resolveUndefinedEntity } = this.g;
889
- let wrappedRef = `&${ref};`;
890
- if (resolveUndefinedEntity) {
891
- let resolvedValue = resolveUndefinedEntity(wrappedRef);
892
- if (resolvedValue !== null && resolvedValue !== void 0) {
893
- let type = typeof resolvedValue;
894
- if (type !== "string") throw new TypeError(`\`resolveUndefinedEntity()\` must return a string, \`null\`, or \`undefined\`, but returned a value of type ${type}`);
895
- return resolvedValue;
896
- }
897
- }
898
- if (ignoreUndefinedEntities) return wrappedRef;
899
- scanner.n(-wrappedRef.length);
900
- throw this.a(`Named entity isn't defined: ${wrappedRef}`);
901
- }
902
- }
903
- return parsedValue;
904
- }
905
- /**
906
- * Consumes a `SystemLiteral` if possible.
907
- *
908
- * A `SystemLiteral` is similar to an attribute value, but allows the
909
- * characters `<` and `&` and doesn't replace references.
910
- *
911
- * @returns
912
- * Value of the `SystemLiteral` minus quotes, or `false` if nothing was
913
- * consumed. An empty string indicates that a `SystemLiteral` was consumed
914
- * but was empty.
915
- *
916
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-SystemLiteral
917
- */
918
- r() {
919
- let { c: scanner } = this;
920
- let quote = scanner.b("\"") || scanner.b("'");
921
- if (!quote) return false;
922
- let value = scanner.s(quote);
923
- this.o(value);
924
- if (!scanner.b(quote)) throw this.a("Missing end quote");
925
- return value;
926
- }
927
- /**
928
- * Consumes one or more whitespace characters if possible.
929
- *
930
- * @returns Whether any whitespace characters were consumed.
931
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#white
932
- */
933
- e() {
934
- return !!this.c.w(isWhitespace);
935
- }
936
- /**
937
- * Consumes an XML declaration if possible.
938
- *
939
- * @returns Whether an XML declaration was consumed.
940
- * @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-XMLDecl
941
- */
942
- P() {
943
- let { c: scanner } = this;
944
- let startIndex = scanner.d;
945
- if (!scanner.b("<?xml")) return false;
946
- if (!this.e()) throw this.a("Invalid XML declaration");
947
- let version = !!scanner.b("version") && this.t() && this.r();
948
- if (version === false) throw this.a("XML version is missing or invalid");
949
- else if (!/^1\.[0-9]+$/.test(version)) throw this.a("Invalid character in version number");
950
- let encoding;
951
- let standalone;
952
- if (this.e()) {
953
- encoding = !!scanner.b("encoding") && this.t() && this.r();
954
- if (encoding) {
955
- if (!/^[A-Za-z][\w.-]*$/.test(encoding)) throw this.a("Invalid character in encoding name");
956
- this.e();
957
- }
958
- standalone = !!scanner.b("standalone") && this.t() && this.r();
959
- if (standalone) {
960
- if (standalone !== "yes" && standalone !== "no") throw this.a("Only \"yes\" and \"no\" are permitted as values of `standalone`");
961
- this.e();
962
- }
963
- }
964
- if (!scanner.b("?>")) throw this.a("Invalid or unclosed XML declaration");
965
- return this.g.preserveXmlDeclaration ? this.i(new XmlDeclaration(version, encoding || void 0, standalone || void 0), startIndex) : true;
966
- }
967
- /**
968
- * Returns an `XmlError` for the current scanner position.
969
- */
970
- a(message) {
971
- let { c: scanner } = this;
972
- return new XmlError(message, scanner.d, scanner.h);
973
- }
974
- /**
975
- * Parses the XML input.
976
- */
977
- parse() {
978
- this.c.b("");
979
- this.O();
980
- if (!this.E()) throw this.a("Root element is missing or invalid");
981
- while (this.z());
982
- if (!this.c.B) throw this.a("Extra content at the end of the document");
983
- }
984
- /**
985
- * Throws an invalid character error if any character in the given _string_
986
- * isn't a valid XML character.
987
- */
988
- o(string) {
989
- let { length } = string;
990
- for (let i = 0; i < length; ++i) {
991
- let cp = string.codePointAt(i);
992
- if (!isXmlCodePoint(cp)) {
993
- this.c.n(-([...string].length - i));
994
- throw this.a("Invalid character");
995
- }
996
- if (cp > 65535) i += 1;
997
- }
998
- }
999
- };
1000
- function normalizeLineBreaks(text) {
1001
- let i = 0;
1002
- while ((i = text.indexOf("\r", i)) !== -1) text = text[i + 1] === "\n" ? text.slice(0, i) + text.slice(i + 1) : text.slice(0, i) + "\n" + text.slice(i + 1);
1003
- return text;
1004
- }
1005
- function parseXml(xml, options) {
1006
- return new Parser(xml, options).document;
1007
- }
1008
- })))();
1009
- const localName = (name) => name.includes(":") ? name.split(":")[1] : name;
1010
- const isElement = (node) => node.type === "element";
1011
- const isText = (node) => node.type === "text";
1012
- const child = (el, name) => {
1013
- for (const node of el.children) if (isElement(node) && localName(node.name) === name) return node;
1014
- };
1015
- const textOf = (el) => {
1016
- if (el === void 0) return;
1017
- let result = "";
1018
- for (const node of el.children) if (isText(node)) result += node.text;
1019
- return result === "" ? void 0 : result;
1020
- };
1021
- const docRoot = (doc) => doc.root ?? void 0;
1022
- const xmlVal = (el, name) => {
1023
- const v = el !== void 0 ? textOf(child(el, name)) : void 0;
1024
- if (v === void 0 || v === "") return;
1025
- try {
1026
- return decodeURIComponent(v.replace(/\+/g, " "));
1027
- } catch {
1028
- throw new BaerlyError("InvalidResponse", `Malformed percent-escape in S3 <${name}>: ${v}`);
1029
- }
1030
- };
1031
- const rawXmlVal = (el, name) => {
1032
- return el !== void 0 ? textOf(child(el, name)) : void 0;
1033
- };
1034
- /**
1035
- * Build a {@link ParsedS3Error} from the element that directly carries
1036
- * the `<Code>` / `<Message>` children — `<Error>` for S3, the inner
1037
- * `<Error>` for STS. Returns `undefined` when neither child is present
1038
- * so callers can fall back to the raw status. Shared by
1039
- * {@link parseS3Error} and {@link parseStsError}, which differ only in
1040
- * how they locate that element.
1041
- */
1042
- const codeMessageFrom = (el) => {
1043
- const code = rawXmlVal(el, "Code");
1044
- const message = rawXmlVal(el, "Message");
1045
- if (code === void 0 && message === void 0) return;
1046
- return {
1047
- ...code !== void 0 && { Code: code },
1048
- ...message !== void 0 && { Message: message }
1049
- };
1050
- };
1051
- /**
1052
- * Parse an S3 `<Error><Code>…</Code><Message>…</Message></Error>`
1053
- * body. Returns `undefined` when the body is not a recognizable S3
1054
- * error document (empty, HTML, a success payload, or a DTD), so
1055
- * callers can fall back to the raw response text. This never throws:
1056
- * it runs on a path that is already reporting an error.
1057
- */
1058
- const parseS3Error = (xml) => {
1059
- if (!/<Error\b/i.test(xml) || /<!DOCTYPE\b/i.test(xml)) return;
1060
- let root;
1061
- try {
1062
- root = docRoot((0, import_browser.parseXml)(xml));
1063
- } catch {
1064
- return;
1065
- }
1066
- if (root === void 0) return;
1067
- if (localName(root.name) !== "Error") return;
1068
- return codeMessageFrom(root);
1069
- };
1070
- /**
1071
- * Parse an STS `<ErrorResponse><Error><Code>…</Code><Message>…</Message>
1072
- * </Error></ErrorResponse>` body (the shape STS returns on a failed
1073
- * `AssumeRoleWithWebIdentity` — e.g. `InvalidIdentityToken`,
1074
- * `ExpiredTokenException`, `AccessDenied`). Returns `undefined` when the body
1075
- * is not a recognizable STS error document (empty, HTML, a success payload, or
1076
- * a DTD), so callers can fall back to the bare status. Like {@link parseS3Error}
1077
- * this never throws — it runs on a path that is already reporting an error.
1078
- *
1079
- * Note the nesting differs from S3: STS wraps `<Error>` inside `<ErrorResponse>`.
1080
- */
1081
- const parseStsError = (xml) => {
1082
- if (!/<Error\b/i.test(xml) || /<!DOCTYPE\b/i.test(xml)) return;
1083
- let root;
1084
- try {
1085
- root = docRoot((0, import_browser.parseXml)(xml));
1086
- } catch {
1087
- return;
1088
- }
1089
- if (root === void 0) return;
1090
- const errorEl = child(root, "Error");
1091
- if (errorEl === void 0) return;
1092
- return codeMessageFrom(errorEl);
1093
- };
1094
- /**
1095
- * Parse an STS `AssumeRoleWithWebIdentity` success body, returning the
1096
- * `<Credentials>` block. Reuses the hardened, DTD-guarded parser;
1097
- * throws `InvalidResponse` on a DTD or unparseable XML. Missing fields come
1098
- * back `undefined` so the caller can map them to its own `InvalidResponse`.
1099
- *
1100
- * Unlike {@link parseListObjectsV2CommandOutput}, the error on unparseable
1101
- * XML must NOT echo the body: a success-shaped STS body carries the plaintext
1102
- * `SecretAccessKey`/`SessionToken`, so folding it into a thrown-then-logged
1103
- * error would leak live credentials.
1104
- */
1105
- const parseAssumeRoleWithWebIdentity = (xml) => {
1106
- if (/<!DOCTYPE\b/i.test(xml)) throw new BaerlyError("InvalidResponse", "DTD not allowed in STS XML responses");
1107
- let root;
1108
- try {
1109
- root = docRoot((0, import_browser.parseXml)(xml));
1110
- } catch {
1111
- throw new BaerlyError("InvalidResponse", "unparseable STS credentials response");
1112
- }
1113
- const resultEl = root !== void 0 ? child(root, "AssumeRoleWithWebIdentityResult") : void 0;
1114
- const credsEl = resultEl !== void 0 ? child(resultEl, "Credentials") : void 0;
1115
- return {
1116
- AccessKeyId: rawXmlVal(credsEl, "AccessKeyId"),
1117
- SecretAccessKey: rawXmlVal(credsEl, "SecretAccessKey"),
1118
- SessionToken: rawXmlVal(credsEl, "SessionToken"),
1119
- Expiration: rawXmlVal(credsEl, "Expiration")
1120
- };
1121
- };
1122
- const parseLastModified = (lm) => {
1123
- if (lm === void 0) return;
1124
- const d = new Date(lm);
1125
- return Number.isNaN(d.getTime()) ? void 0 : d;
1126
- };
1127
- const parseListObjectsV2CommandOutput = (xml) => {
1128
- if (/<!DOCTYPE\b/i.test(xml)) throw new BaerlyError("InvalidResponse", "DTD not allowed in S3 XML responses");
1129
- let root;
1130
- try {
1131
- root = docRoot((0, import_browser.parseXml)(xml));
1132
- } catch {
1133
- throw new BaerlyError("InvalidResponse", `Invalid XML: ${xml}`);
1134
- }
1135
- if (root === void 0) return {};
1136
- if (localName(root.name) !== "ListBucketResult") return {};
1137
- return {
1138
- Contents: root.children.filter(isElement).filter((c) => localName(c.name) === "Contents").map((contentEl) => {
1139
- return {
1140
- ETag: rawXmlVal(contentEl, "ETag"),
1141
- Key: xmlVal(contentEl, "Key"),
1142
- LastModified: parseLastModified(rawXmlVal(contentEl, "LastModified")),
1143
- Generation: rawXmlVal(contentEl, "Generation")
1144
- };
1145
- }),
1146
- NextContinuationToken: rawXmlVal(root, "NextContinuationToken")
1147
- };
1148
- };
1149
- //#endregion
1150
- //#region packages/adapter-node/src/http-transport.ts
1151
- /**
1152
- * Permanent {@link BaerlyError} codes that must short-circuit `retry`.
1153
- * These represent caller- or environment-level faults where retrying
1154
- * cannot succeed: `AccessDenied` (403 — credentials/policy),
1155
- * `InvalidConfig` (bad bucket / unsupported credential type),
1156
- * `InvalidResponse` (server returned unparseable data), and
1157
- * `Conflict` (CAS guard lost — retrying would just re-lose against
1158
- * the same state). `NetworkError` is intentionally absent — it covers
1159
- * transient transport faults and stays retryable.
1160
- *
1161
- * Transport-layer set, distinct from `RETRIABLE_CODES` in `@baerly/protocol`'s
1162
- * `errors.ts` (the default wire `retriable` hint). `Conflict` is "permanent"
1163
- * here (a blind re-PUT re-loses the CAS race) yet retryable for logical CAS
1164
- * callers that can fresh-read + re-apply. Same code, two different questions.
1165
- */
1166
- const PERMANENT_ERROR_CODES = /* @__PURE__ */ new Set([
1167
- "AccessDenied",
1168
- "InvalidConfig",
1169
- "InvalidResponse",
1170
- "Conflict"
1171
- ]);
1172
- /**
1173
- * Parse an HTTP `Retry-After` header into a non-negative seconds value,
1174
- * clamped to {@link RETRY_AFTER_MAX_SECONDS}. Returns `undefined` if
1175
- * the header is absent, malformed, or whitespace.
1176
- *
1177
- * RFC 7231 §7.1.3 admits two forms: delta-seconds (non-negative
1178
- * integer) and HTTP-date. Both are accepted; dates in the past return
1179
- * `0`. Fractional seconds, negatives, and arbitrary strings reject.
1180
- *
1181
- * The `now` injection point exists for the unit test; production
1182
- * callers should pass nothing.
1183
- */
1184
- function parseRetryAfter(header, now = Date.now) {
1185
- if (header === null) return;
1186
- const trimmed = header.trim();
1187
- if (trimmed === "") return;
1188
- if (/^\d+$/.test(trimmed)) {
1189
- const n = Number.parseInt(trimmed, 10);
1190
- return Number.isFinite(n) ? Math.min(n, 60) : void 0;
1191
- }
1192
- if (!/[a-z]/i.test(trimmed)) return;
1193
- const t = Date.parse(trimmed);
1194
- if (Number.isNaN(t)) return;
1195
- const seconds = Math.max(0, Math.ceil((t - now()) / 1e3));
1196
- return Math.min(seconds, 60);
1197
- }
1198
- const retryAfterCause = (res) => {
1199
- const hint = parseRetryAfter(res.headers.get("Retry-After"));
1200
- return hint !== void 0 ? { retryAfterSeconds: hint } : {};
1201
- };
1202
- const xmlErrorDetail = (status, body) => {
1203
- const parsed = parseS3Error(body);
1204
- if (parsed !== void 0) {
1205
- const code = parsed.Code ?? "UnknownError";
1206
- return parsed.Message !== void 0 ? `${status} ${code}: ${parsed.Message}` : `${status} ${code}`;
1207
- }
1208
- return `${status} ${body}`;
1209
- };
1210
- /**
1211
- * Shared status→{@link BaerlyError} mapping for the S3/GCS XML adapters, so
1212
- * the retryable set (`429`/`≥500`) can't drift between them. Store-specific
1213
- * statuses (GCS `412`; S3 `409`/`404`-with-`If-Match`) are handled inline
1214
- * first; the rest route here: `403`→AccessDenied (permanent), `429`/`≥500`→
1215
- * retryable NetworkError carrying `{status, retryAfterSeconds?}`, else
1216
- * InvalidResponse. Callers `throw` the result; consumes `res.text()` on the
1217
- * non-`403` paths.
1218
- */
1219
- const mapStorageError = async (res, verb, key) => {
1220
- if (res.status === 403) return new BaerlyError("AccessDenied", `${verb} ${key}: 403`);
1221
- if (res.status === 429 || res.status >= 500) return new BaerlyError("NetworkError", `${verb} ${key}: ${res.status} ${await res.text()}`, {
1222
- status: res.status,
1223
- ...retryAfterCause(res)
1224
- });
1225
- return new BaerlyError("InvalidResponse", `${verb} ${key}: ${xmlErrorDetail(res.status, await res.text())}`);
1226
- };
1227
- const retry = async (fn, { retries = 8, backoffMs = 100, maxDelayMs = 1e4 } = {}) => {
1228
- let wait = backoffMs;
1229
- for (let attempt = 0; attempt <= retries; attempt++) try {
1230
- return await fn();
1231
- } catch (error) {
1232
- if (error instanceof BaerlyError && PERMANENT_ERROR_CODES.has(error.code)) throw error;
1233
- if (attempt === retries) throw error;
1234
- const hintMs = retryAfterHintMs(error, maxDelayMs);
1235
- await delay(hintMs ?? wait);
1236
- if (hintMs === void 0) wait = Math.min(wait * 1.5, maxDelayMs);
1237
- else wait = backoffMs;
1238
- }
1239
- throw new BaerlyError("Internal", "http-transport retry loop exited without returning or throwing");
1240
- };
1241
- const retryAfterHintMs = (e, maxDelayMs) => {
1242
- if (!(e instanceof BaerlyError)) return;
1243
- const cause = e.cause;
1244
- if (cause?.retryAfterSeconds === void 0) return;
1245
- return Math.min(cause.retryAfterSeconds * 1e3, maxDelayMs);
1246
- };
1247
- //#endregion
1248
- export { parseAssumeRoleWithWebIdentity as a, retryAfterCause as i, parseRetryAfter as n, parseListObjectsV2CommandOutput as o, retry as r, parseStsError as s, mapStorageError as t };
1249
-
1250
- //# sourceMappingURL=http-transport-BTgVCY5r.js.map