@d1g1tal/transportr 3.1.5 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -22
- package/dist/iife/content-type.js +4 -180
- package/dist/iife/content-type.js.map +7 -0
- package/dist/iife/request-header.js +4 -270
- package/dist/iife/request-header.js.map +7 -0
- package/dist/iife/request-method.js +4 -295
- package/dist/iife/request-method.js.map +7 -0
- package/dist/iife/response-header.js +4 -368
- package/dist/iife/response-header.js.map +7 -0
- package/dist/iife/transportr.js +1262 -3048
- package/dist/iife/transportr.js.map +7 -0
- package/package.json +8 -10
package/dist/iife/transportr.js
CHANGED
|
@@ -1,3098 +1,1312 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __esm = (fn, res) => function __init() {
|
|
15
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
-
};
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
|
|
39
|
-
// node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/dist/purify.es.mjs
|
|
40
|
-
var purify_es_exports = {};
|
|
41
|
-
__export(purify_es_exports, {
|
|
42
|
-
default: () => purify
|
|
43
|
-
});
|
|
44
|
-
function unapply(func) {
|
|
45
|
-
return function(thisArg) {
|
|
46
|
-
if (thisArg instanceof RegExp) {
|
|
47
|
-
thisArg.lastIndex = 0;
|
|
48
|
-
}
|
|
49
|
-
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
50
|
-
args[_key3 - 1] = arguments[_key3];
|
|
51
|
-
}
|
|
52
|
-
return apply(func, thisArg, args);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function unconstruct(Func) {
|
|
56
|
-
return function() {
|
|
57
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
58
|
-
args[_key4] = arguments[_key4];
|
|
59
|
-
}
|
|
60
|
-
return construct(Func, args);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function addToSet(set, array) {
|
|
64
|
-
let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
|
|
65
|
-
if (setPrototypeOf) {
|
|
66
|
-
setPrototypeOf(set, null);
|
|
67
|
-
}
|
|
68
|
-
let l2 = array.length;
|
|
69
|
-
while (l2--) {
|
|
70
|
-
let element = array[l2];
|
|
71
|
-
if (typeof element === "string") {
|
|
72
|
-
const lcElement = transformCaseFunc(element);
|
|
73
|
-
if (lcElement !== element) {
|
|
74
|
-
if (!isFrozen(array)) {
|
|
75
|
-
array[l2] = lcElement;
|
|
76
|
-
}
|
|
77
|
-
element = lcElement;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
set[element] = true;
|
|
81
|
-
}
|
|
82
|
-
return set;
|
|
83
|
-
}
|
|
84
|
-
function cleanArray(array) {
|
|
85
|
-
for (let index = 0; index < array.length; index++) {
|
|
86
|
-
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
87
|
-
if (!isPropertyExist) {
|
|
88
|
-
array[index] = null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return array;
|
|
92
|
-
}
|
|
93
|
-
function clone(object) {
|
|
94
|
-
const newObject = create(null);
|
|
95
|
-
for (const [property, value] of entries(object)) {
|
|
96
|
-
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
97
|
-
if (isPropertyExist) {
|
|
98
|
-
if (Array.isArray(value)) {
|
|
99
|
-
newObject[property] = cleanArray(value);
|
|
100
|
-
} else if (value && typeof value === "object" && value.constructor === Object) {
|
|
101
|
-
newObject[property] = clone(value);
|
|
102
|
-
} else {
|
|
103
|
-
newObject[property] = value;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return newObject;
|
|
108
|
-
}
|
|
109
|
-
function lookupGetter(object, prop) {
|
|
110
|
-
while (object !== null) {
|
|
111
|
-
const desc = getOwnPropertyDescriptor(object, prop);
|
|
112
|
-
if (desc) {
|
|
113
|
-
if (desc.get) {
|
|
114
|
-
return unapply(desc.get);
|
|
115
|
-
}
|
|
116
|
-
if (typeof desc.value === "function") {
|
|
117
|
-
return unapply(desc.value);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
object = getPrototypeOf(object);
|
|
121
|
-
}
|
|
122
|
-
function fallbackValue() {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
return fallbackValue;
|
|
126
|
-
}
|
|
127
|
-
function createDOMPurify() {
|
|
128
|
-
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
129
|
-
const DOMPurify = (root) => createDOMPurify(root);
|
|
130
|
-
DOMPurify.version = "3.3.3";
|
|
131
|
-
DOMPurify.removed = [];
|
|
132
|
-
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
133
|
-
DOMPurify.isSupported = false;
|
|
134
|
-
return DOMPurify;
|
|
135
|
-
}
|
|
136
|
-
let {
|
|
137
|
-
document: document2
|
|
138
|
-
} = window2;
|
|
139
|
-
const originalDocument = document2;
|
|
140
|
-
const currentScript = originalDocument.currentScript;
|
|
141
|
-
const {
|
|
142
|
-
DocumentFragment: DocumentFragment2,
|
|
143
|
-
HTMLTemplateElement,
|
|
144
|
-
Node,
|
|
145
|
-
Element,
|
|
146
|
-
NodeFilter,
|
|
147
|
-
NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
|
|
148
|
-
HTMLFormElement,
|
|
149
|
-
DOMParser: DOMParser2,
|
|
150
|
-
trustedTypes
|
|
151
|
-
} = window2;
|
|
152
|
-
const ElementPrototype = Element.prototype;
|
|
153
|
-
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
154
|
-
const remove = lookupGetter(ElementPrototype, "remove");
|
|
155
|
-
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
156
|
-
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
157
|
-
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
158
|
-
if (typeof HTMLTemplateElement === "function") {
|
|
159
|
-
const template = document2.createElement("template");
|
|
160
|
-
if (template.content && template.content.ownerDocument) {
|
|
161
|
-
document2 = template.content.ownerDocument;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
let trustedTypesPolicy;
|
|
165
|
-
let emptyHTML = "";
|
|
166
|
-
const {
|
|
167
|
-
implementation,
|
|
168
|
-
createNodeIterator,
|
|
169
|
-
createDocumentFragment,
|
|
170
|
-
getElementsByTagName
|
|
171
|
-
} = document2;
|
|
172
|
-
const {
|
|
173
|
-
importNode
|
|
174
|
-
} = originalDocument;
|
|
175
|
-
let hooks = _createHooksMap();
|
|
176
|
-
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
|
|
177
|
-
const {
|
|
178
|
-
MUSTACHE_EXPR: MUSTACHE_EXPR2,
|
|
179
|
-
ERB_EXPR: ERB_EXPR2,
|
|
180
|
-
TMPLIT_EXPR: TMPLIT_EXPR2,
|
|
181
|
-
DATA_ATTR: DATA_ATTR2,
|
|
182
|
-
ARIA_ATTR: ARIA_ATTR2,
|
|
183
|
-
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
|
|
184
|
-
ATTR_WHITESPACE: ATTR_WHITESPACE2,
|
|
185
|
-
CUSTOM_ELEMENT: CUSTOM_ELEMENT2
|
|
186
|
-
} = EXPRESSIONS;
|
|
187
|
-
let {
|
|
188
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
189
|
-
} = EXPRESSIONS;
|
|
190
|
-
let ALLOWED_TAGS = null;
|
|
191
|
-
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
192
|
-
let ALLOWED_ATTR = null;
|
|
193
|
-
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
194
|
-
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
195
|
-
tagNameCheck: {
|
|
196
|
-
writable: true,
|
|
197
|
-
configurable: false,
|
|
198
|
-
enumerable: true,
|
|
199
|
-
value: null
|
|
200
|
-
},
|
|
201
|
-
attributeNameCheck: {
|
|
202
|
-
writable: true,
|
|
203
|
-
configurable: false,
|
|
204
|
-
enumerable: true,
|
|
205
|
-
value: null
|
|
206
|
-
},
|
|
207
|
-
allowCustomizedBuiltInElements: {
|
|
208
|
-
writable: true,
|
|
209
|
-
configurable: false,
|
|
210
|
-
enumerable: true,
|
|
211
|
-
value: false
|
|
212
|
-
}
|
|
213
|
-
}));
|
|
214
|
-
let FORBID_TAGS = null;
|
|
215
|
-
let FORBID_ATTR = null;
|
|
216
|
-
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
217
|
-
tagCheck: {
|
|
218
|
-
writable: true,
|
|
219
|
-
configurable: false,
|
|
220
|
-
enumerable: true,
|
|
221
|
-
value: null
|
|
222
|
-
},
|
|
223
|
-
attributeCheck: {
|
|
224
|
-
writable: true,
|
|
225
|
-
configurable: false,
|
|
226
|
-
enumerable: true,
|
|
227
|
-
value: null
|
|
228
|
-
}
|
|
229
|
-
}));
|
|
230
|
-
let ALLOW_ARIA_ATTR = true;
|
|
231
|
-
let ALLOW_DATA_ATTR = true;
|
|
232
|
-
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
233
|
-
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
234
|
-
let SAFE_FOR_TEMPLATES = false;
|
|
235
|
-
let SAFE_FOR_XML = true;
|
|
236
|
-
let WHOLE_DOCUMENT = false;
|
|
237
|
-
let SET_CONFIG = false;
|
|
238
|
-
let FORCE_BODY = false;
|
|
239
|
-
let RETURN_DOM = false;
|
|
240
|
-
let RETURN_DOM_FRAGMENT = false;
|
|
241
|
-
let RETURN_TRUSTED_TYPE = false;
|
|
242
|
-
let SANITIZE_DOM = true;
|
|
243
|
-
let SANITIZE_NAMED_PROPS = false;
|
|
244
|
-
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
245
|
-
let KEEP_CONTENT = true;
|
|
246
|
-
let IN_PLACE = false;
|
|
247
|
-
let USE_PROFILES = {};
|
|
248
|
-
let FORBID_CONTENTS = null;
|
|
249
|
-
const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
250
|
-
let DATA_URI_TAGS = null;
|
|
251
|
-
const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
252
|
-
let URI_SAFE_ATTRIBUTES = null;
|
|
253
|
-
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
|
|
254
|
-
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
255
|
-
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
256
|
-
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
257
|
-
let NAMESPACE = HTML_NAMESPACE;
|
|
258
|
-
let IS_EMPTY_INPUT = false;
|
|
259
|
-
let ALLOWED_NAMESPACES = null;
|
|
260
|
-
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
261
|
-
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
|
|
262
|
-
let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
|
|
263
|
-
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
264
|
-
let PARSER_MEDIA_TYPE = null;
|
|
265
|
-
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
266
|
-
const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
|
267
|
-
let transformCaseFunc = null;
|
|
268
|
-
let CONFIG = null;
|
|
269
|
-
const formElement = document2.createElement("form");
|
|
270
|
-
const isRegexOrFunction = function isRegexOrFunction2(testValue) {
|
|
271
|
-
return testValue instanceof RegExp || testValue instanceof Function;
|
|
272
|
-
};
|
|
273
|
-
const _parseConfig = function _parseConfig2() {
|
|
274
|
-
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
275
|
-
if (CONFIG && CONFIG === cfg) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
if (!cfg || typeof cfg !== "object") {
|
|
279
|
-
cfg = {};
|
|
280
|
-
}
|
|
281
|
-
cfg = clone(cfg);
|
|
282
|
-
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
283
|
-
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
284
|
-
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
285
|
-
ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
286
|
-
ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
287
|
-
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
288
|
-
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
289
|
-
DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
290
|
-
FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
291
|
-
FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
|
|
292
|
-
FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
|
|
293
|
-
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
|
|
294
|
-
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
295
|
-
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
296
|
-
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
297
|
-
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
|
298
|
-
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
|
299
|
-
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
|
300
|
-
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
|
301
|
-
RETURN_DOM = cfg.RETURN_DOM || false;
|
|
302
|
-
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
|
303
|
-
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
|
304
|
-
FORCE_BODY = cfg.FORCE_BODY || false;
|
|
305
|
-
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
|
306
|
-
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
307
|
-
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
308
|
-
IN_PLACE = cfg.IN_PLACE || false;
|
|
309
|
-
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
310
|
-
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
311
|
-
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
|
312
|
-
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
|
313
|
-
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
314
|
-
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
315
|
-
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
316
|
-
}
|
|
317
|
-
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
318
|
-
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
319
|
-
}
|
|
320
|
-
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
|
|
321
|
-
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
322
|
-
}
|
|
323
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
324
|
-
ALLOW_DATA_ATTR = false;
|
|
325
|
-
}
|
|
326
|
-
if (RETURN_DOM_FRAGMENT) {
|
|
327
|
-
RETURN_DOM = true;
|
|
328
|
-
}
|
|
329
|
-
if (USE_PROFILES) {
|
|
330
|
-
ALLOWED_TAGS = addToSet({}, text);
|
|
331
|
-
ALLOWED_ATTR = create(null);
|
|
332
|
-
if (USE_PROFILES.html === true) {
|
|
333
|
-
addToSet(ALLOWED_TAGS, html$1);
|
|
334
|
-
addToSet(ALLOWED_ATTR, html);
|
|
335
|
-
}
|
|
336
|
-
if (USE_PROFILES.svg === true) {
|
|
337
|
-
addToSet(ALLOWED_TAGS, svg$1);
|
|
338
|
-
addToSet(ALLOWED_ATTR, svg);
|
|
339
|
-
addToSet(ALLOWED_ATTR, xml);
|
|
340
|
-
}
|
|
341
|
-
if (USE_PROFILES.svgFilters === true) {
|
|
342
|
-
addToSet(ALLOWED_TAGS, svgFilters);
|
|
343
|
-
addToSet(ALLOWED_ATTR, svg);
|
|
344
|
-
addToSet(ALLOWED_ATTR, xml);
|
|
345
|
-
}
|
|
346
|
-
if (USE_PROFILES.mathMl === true) {
|
|
347
|
-
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
348
|
-
addToSet(ALLOWED_ATTR, mathMl);
|
|
349
|
-
addToSet(ALLOWED_ATTR, xml);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (!objectHasOwnProperty(cfg, "ADD_TAGS")) {
|
|
353
|
-
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
354
|
-
}
|
|
355
|
-
if (!objectHasOwnProperty(cfg, "ADD_ATTR")) {
|
|
356
|
-
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
357
|
-
}
|
|
358
|
-
if (cfg.ADD_TAGS) {
|
|
359
|
-
if (typeof cfg.ADD_TAGS === "function") {
|
|
360
|
-
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
361
|
-
} else {
|
|
362
|
-
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
363
|
-
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
364
|
-
}
|
|
365
|
-
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
if (cfg.ADD_ATTR) {
|
|
369
|
-
if (typeof cfg.ADD_ATTR === "function") {
|
|
370
|
-
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
371
|
-
} else {
|
|
372
|
-
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
373
|
-
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
374
|
-
}
|
|
375
|
-
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
379
|
-
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
380
|
-
}
|
|
381
|
-
if (cfg.FORBID_CONTENTS) {
|
|
382
|
-
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
383
|
-
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
384
|
-
}
|
|
385
|
-
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
386
|
-
}
|
|
387
|
-
if (cfg.ADD_FORBID_CONTENTS) {
|
|
388
|
-
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
389
|
-
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
390
|
-
}
|
|
391
|
-
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
392
|
-
}
|
|
393
|
-
if (KEEP_CONTENT) {
|
|
394
|
-
ALLOWED_TAGS["#text"] = true;
|
|
395
|
-
}
|
|
396
|
-
if (WHOLE_DOCUMENT) {
|
|
397
|
-
addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
|
|
398
|
-
}
|
|
399
|
-
if (ALLOWED_TAGS.table) {
|
|
400
|
-
addToSet(ALLOWED_TAGS, ["tbody"]);
|
|
401
|
-
delete FORBID_TAGS.tbody;
|
|
402
|
-
}
|
|
403
|
-
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
404
|
-
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
|
|
405
|
-
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
406
|
-
}
|
|
407
|
-
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
|
|
408
|
-
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
409
|
-
}
|
|
410
|
-
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
411
|
-
emptyHTML = trustedTypesPolicy.createHTML("");
|
|
412
|
-
} else {
|
|
413
|
-
if (trustedTypesPolicy === void 0) {
|
|
414
|
-
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
415
|
-
}
|
|
416
|
-
if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
|
|
417
|
-
emptyHTML = trustedTypesPolicy.createHTML("");
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
if (freeze) {
|
|
421
|
-
freeze(cfg);
|
|
422
|
-
}
|
|
423
|
-
CONFIG = cfg;
|
|
424
|
-
};
|
|
425
|
-
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
426
|
-
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
427
|
-
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
428
|
-
let parent = getParentNode(element);
|
|
429
|
-
if (!parent || !parent.tagName) {
|
|
430
|
-
parent = {
|
|
431
|
-
namespaceURI: NAMESPACE,
|
|
432
|
-
tagName: "template"
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
const tagName = stringToLowerCase(element.tagName);
|
|
436
|
-
const parentTagName = stringToLowerCase(parent.tagName);
|
|
437
|
-
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
441
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
442
|
-
return tagName === "svg";
|
|
443
|
-
}
|
|
444
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
445
|
-
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
446
|
-
}
|
|
447
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
448
|
-
}
|
|
449
|
-
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
450
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
451
|
-
return tagName === "math";
|
|
452
|
-
}
|
|
453
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
454
|
-
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
455
|
-
}
|
|
456
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
457
|
-
}
|
|
458
|
-
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
459
|
-
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
462
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
466
|
-
}
|
|
467
|
-
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
468
|
-
return true;
|
|
469
|
-
}
|
|
470
|
-
return false;
|
|
471
|
-
};
|
|
472
|
-
const _forceRemove = function _forceRemove2(node) {
|
|
473
|
-
arrayPush(DOMPurify.removed, {
|
|
474
|
-
element: node
|
|
475
|
-
});
|
|
476
|
-
try {
|
|
477
|
-
getParentNode(node).removeChild(node);
|
|
478
|
-
} catch (_) {
|
|
479
|
-
remove(node);
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
const _removeAttribute = function _removeAttribute2(name, element) {
|
|
483
|
-
try {
|
|
484
|
-
arrayPush(DOMPurify.removed, {
|
|
485
|
-
attribute: element.getAttributeNode(name),
|
|
486
|
-
from: element
|
|
487
|
-
});
|
|
488
|
-
} catch (_) {
|
|
489
|
-
arrayPush(DOMPurify.removed, {
|
|
490
|
-
attribute: null,
|
|
491
|
-
from: element
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
element.removeAttribute(name);
|
|
495
|
-
if (name === "is") {
|
|
496
|
-
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
497
|
-
try {
|
|
498
|
-
_forceRemove(element);
|
|
499
|
-
} catch (_) {
|
|
500
|
-
}
|
|
501
|
-
} else {
|
|
502
|
-
try {
|
|
503
|
-
element.setAttribute(name, "");
|
|
504
|
-
} catch (_) {
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
const _initDocument = function _initDocument2(dirty) {
|
|
510
|
-
let doc = null;
|
|
511
|
-
let leadingWhitespace = null;
|
|
512
|
-
if (FORCE_BODY) {
|
|
513
|
-
dirty = "<remove></remove>" + dirty;
|
|
514
|
-
} else {
|
|
515
|
-
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
516
|
-
leadingWhitespace = matches && matches[0];
|
|
517
|
-
}
|
|
518
|
-
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
|
|
519
|
-
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
|
520
|
-
}
|
|
521
|
-
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
522
|
-
if (NAMESPACE === HTML_NAMESPACE) {
|
|
523
|
-
try {
|
|
524
|
-
doc = new DOMParser2().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
525
|
-
} catch (_) {
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
if (!doc || !doc.documentElement) {
|
|
529
|
-
doc = implementation.createDocument(NAMESPACE, "template", null);
|
|
530
|
-
try {
|
|
531
|
-
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
532
|
-
} catch (_) {
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
const body = doc.body || doc.documentElement;
|
|
536
|
-
if (dirty && leadingWhitespace) {
|
|
537
|
-
body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
538
|
-
}
|
|
539
|
-
if (NAMESPACE === HTML_NAMESPACE) {
|
|
540
|
-
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
|
541
|
-
}
|
|
542
|
-
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
543
|
-
};
|
|
544
|
-
const _createNodeIterator = function _createNodeIterator2(root) {
|
|
545
|
-
return createNodeIterator.call(
|
|
546
|
-
root.ownerDocument || root,
|
|
547
|
-
root,
|
|
548
|
-
// eslint-disable-next-line no-bitwise
|
|
549
|
-
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
|
|
550
|
-
null
|
|
551
|
-
);
|
|
552
|
-
};
|
|
553
|
-
const _isClobbered = function _isClobbered2(element) {
|
|
554
|
-
return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
|
|
555
|
-
};
|
|
556
|
-
const _isNode = function _isNode2(value) {
|
|
557
|
-
return typeof Node === "function" && value instanceof Node;
|
|
558
|
-
};
|
|
559
|
-
function _executeHooks(hooks2, currentNode, data) {
|
|
560
|
-
arrayForEach(hooks2, (hook) => {
|
|
561
|
-
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
const _sanitizeElements = function _sanitizeElements2(currentNode) {
|
|
565
|
-
let content = null;
|
|
566
|
-
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
567
|
-
if (_isClobbered(currentNode)) {
|
|
568
|
-
_forceRemove(currentNode);
|
|
569
|
-
return true;
|
|
570
|
-
}
|
|
571
|
-
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
572
|
-
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
573
|
-
tagName,
|
|
574
|
-
allowedTags: ALLOWED_TAGS
|
|
575
|
-
});
|
|
576
|
-
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
|
|
577
|
-
_forceRemove(currentNode);
|
|
578
|
-
return true;
|
|
579
|
-
}
|
|
580
|
-
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
581
|
-
_forceRemove(currentNode);
|
|
582
|
-
return true;
|
|
583
|
-
}
|
|
584
|
-
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
585
|
-
_forceRemove(currentNode);
|
|
586
|
-
return true;
|
|
587
|
-
}
|
|
588
|
-
if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {
|
|
589
|
-
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
590
|
-
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
591
|
-
return false;
|
|
592
|
-
}
|
|
593
|
-
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
594
|
-
return false;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
598
|
-
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
599
|
-
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
600
|
-
if (childNodes && parentNode) {
|
|
601
|
-
const childCount = childNodes.length;
|
|
602
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
603
|
-
const childClone = cloneNode(childNodes[i], true);
|
|
604
|
-
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
605
|
-
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
_forceRemove(currentNode);
|
|
610
|
-
return true;
|
|
611
|
-
}
|
|
612
|
-
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
613
|
-
_forceRemove(currentNode);
|
|
614
|
-
return true;
|
|
615
|
-
}
|
|
616
|
-
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
617
|
-
_forceRemove(currentNode);
|
|
618
|
-
return true;
|
|
619
|
-
}
|
|
620
|
-
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
621
|
-
content = currentNode.textContent;
|
|
622
|
-
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
623
|
-
content = stringReplace(content, expr, " ");
|
|
624
|
-
});
|
|
625
|
-
if (currentNode.textContent !== content) {
|
|
626
|
-
arrayPush(DOMPurify.removed, {
|
|
627
|
-
element: currentNode.cloneNode()
|
|
628
|
-
});
|
|
629
|
-
currentNode.textContent = content;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
633
|
-
return false;
|
|
634
|
-
};
|
|
635
|
-
const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
|
636
|
-
if (FORBID_ATTR[lcName]) {
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
|
|
640
|
-
return false;
|
|
641
|
-
}
|
|
642
|
-
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ;
|
|
643
|
-
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ;
|
|
644
|
-
else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ;
|
|
645
|
-
else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
646
|
-
if (
|
|
647
|
-
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
648
|
-
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
649
|
-
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
650
|
-
_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
651
|
-
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
652
|
-
lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
|
|
653
|
-
) ;
|
|
654
|
-
else {
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
} else if (URI_SAFE_ATTRIBUTES[lcName]) ;
|
|
658
|
-
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
|
|
659
|
-
else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
|
|
660
|
-
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
|
|
661
|
-
else if (value) {
|
|
662
|
-
return false;
|
|
663
|
-
} else ;
|
|
664
|
-
return true;
|
|
665
|
-
};
|
|
666
|
-
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
667
|
-
return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
|
|
668
|
-
};
|
|
669
|
-
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
670
|
-
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
671
|
-
const {
|
|
672
|
-
attributes
|
|
673
|
-
} = currentNode;
|
|
674
|
-
if (!attributes || _isClobbered(currentNode)) {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
const hookEvent = {
|
|
678
|
-
attrName: "",
|
|
679
|
-
attrValue: "",
|
|
680
|
-
keepAttr: true,
|
|
681
|
-
allowedAttributes: ALLOWED_ATTR,
|
|
682
|
-
forceKeepAttr: void 0
|
|
683
|
-
};
|
|
684
|
-
let l2 = attributes.length;
|
|
685
|
-
while (l2--) {
|
|
686
|
-
const attr = attributes[l2];
|
|
687
|
-
const {
|
|
688
|
-
name,
|
|
689
|
-
namespaceURI,
|
|
690
|
-
value: attrValue
|
|
691
|
-
} = attr;
|
|
692
|
-
const lcName = transformCaseFunc(name);
|
|
693
|
-
const initValue = attrValue;
|
|
694
|
-
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
695
|
-
hookEvent.attrName = lcName;
|
|
696
|
-
hookEvent.attrValue = value;
|
|
697
|
-
hookEvent.keepAttr = true;
|
|
698
|
-
hookEvent.forceKeepAttr = void 0;
|
|
699
|
-
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
700
|
-
value = hookEvent.attrValue;
|
|
701
|
-
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
|
|
702
|
-
_removeAttribute(name, currentNode);
|
|
703
|
-
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
704
|
-
}
|
|
705
|
-
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
706
|
-
_removeAttribute(name, currentNode);
|
|
707
|
-
continue;
|
|
708
|
-
}
|
|
709
|
-
if (lcName === "attributename" && stringMatch(value, "href")) {
|
|
710
|
-
_removeAttribute(name, currentNode);
|
|
711
|
-
continue;
|
|
712
|
-
}
|
|
713
|
-
if (hookEvent.forceKeepAttr) {
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
716
|
-
if (!hookEvent.keepAttr) {
|
|
717
|
-
_removeAttribute(name, currentNode);
|
|
718
|
-
continue;
|
|
719
|
-
}
|
|
720
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
721
|
-
_removeAttribute(name, currentNode);
|
|
722
|
-
continue;
|
|
723
|
-
}
|
|
724
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
725
|
-
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
726
|
-
value = stringReplace(value, expr, " ");
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
730
|
-
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
731
|
-
_removeAttribute(name, currentNode);
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
|
|
735
|
-
if (namespaceURI) ;
|
|
736
|
-
else {
|
|
737
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
738
|
-
case "TrustedHTML": {
|
|
739
|
-
value = trustedTypesPolicy.createHTML(value);
|
|
740
|
-
break;
|
|
741
|
-
}
|
|
742
|
-
case "TrustedScriptURL": {
|
|
743
|
-
value = trustedTypesPolicy.createScriptURL(value);
|
|
744
|
-
break;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
if (value !== initValue) {
|
|
750
|
-
try {
|
|
751
|
-
if (namespaceURI) {
|
|
752
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
753
|
-
} else {
|
|
754
|
-
currentNode.setAttribute(name, value);
|
|
755
|
-
}
|
|
756
|
-
if (_isClobbered(currentNode)) {
|
|
757
|
-
_forceRemove(currentNode);
|
|
758
|
-
} else {
|
|
759
|
-
arrayPop(DOMPurify.removed);
|
|
760
|
-
}
|
|
761
|
-
} catch (_) {
|
|
762
|
-
_removeAttribute(name, currentNode);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
767
|
-
};
|
|
768
|
-
const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
|
|
769
|
-
let shadowNode = null;
|
|
770
|
-
const shadowIterator = _createNodeIterator(fragment);
|
|
771
|
-
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
772
|
-
while (shadowNode = shadowIterator.nextNode()) {
|
|
773
|
-
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
774
|
-
_sanitizeElements(shadowNode);
|
|
775
|
-
_sanitizeAttributes(shadowNode);
|
|
776
|
-
if (shadowNode.content instanceof DocumentFragment2) {
|
|
777
|
-
_sanitizeShadowDOM2(shadowNode.content);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
781
|
-
};
|
|
782
|
-
DOMPurify.sanitize = function(dirty) {
|
|
783
|
-
let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
784
|
-
let body = null;
|
|
785
|
-
let importedNode = null;
|
|
786
|
-
let currentNode = null;
|
|
787
|
-
let returnNode = null;
|
|
788
|
-
IS_EMPTY_INPUT = !dirty;
|
|
789
|
-
if (IS_EMPTY_INPUT) {
|
|
790
|
-
dirty = "<!-->";
|
|
791
|
-
}
|
|
792
|
-
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
793
|
-
if (typeof dirty.toString === "function") {
|
|
794
|
-
dirty = dirty.toString();
|
|
795
|
-
if (typeof dirty !== "string") {
|
|
796
|
-
throw typeErrorCreate("dirty is not a string, aborting");
|
|
797
|
-
}
|
|
798
|
-
} else {
|
|
799
|
-
throw typeErrorCreate("toString is not a function");
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
if (!DOMPurify.isSupported) {
|
|
803
|
-
return dirty;
|
|
804
|
-
}
|
|
805
|
-
if (!SET_CONFIG) {
|
|
806
|
-
_parseConfig(cfg);
|
|
807
|
-
}
|
|
808
|
-
DOMPurify.removed = [];
|
|
809
|
-
if (typeof dirty === "string") {
|
|
810
|
-
IN_PLACE = false;
|
|
811
|
-
}
|
|
812
|
-
if (IN_PLACE) {
|
|
813
|
-
if (dirty.nodeName) {
|
|
814
|
-
const tagName = transformCaseFunc(dirty.nodeName);
|
|
815
|
-
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
816
|
-
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
} else if (dirty instanceof Node) {
|
|
820
|
-
body = _initDocument("<!---->");
|
|
821
|
-
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
822
|
-
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
|
|
823
|
-
body = importedNode;
|
|
824
|
-
} else if (importedNode.nodeName === "HTML") {
|
|
825
|
-
body = importedNode;
|
|
826
|
-
} else {
|
|
827
|
-
body.appendChild(importedNode);
|
|
828
|
-
}
|
|
829
|
-
} else {
|
|
830
|
-
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
|
831
|
-
dirty.indexOf("<") === -1) {
|
|
832
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
833
|
-
}
|
|
834
|
-
body = _initDocument(dirty);
|
|
835
|
-
if (!body) {
|
|
836
|
-
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
if (body && FORCE_BODY) {
|
|
840
|
-
_forceRemove(body.firstChild);
|
|
841
|
-
}
|
|
842
|
-
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
843
|
-
while (currentNode = nodeIterator.nextNode()) {
|
|
844
|
-
_sanitizeElements(currentNode);
|
|
845
|
-
_sanitizeAttributes(currentNode);
|
|
846
|
-
if (currentNode.content instanceof DocumentFragment2) {
|
|
847
|
-
_sanitizeShadowDOM(currentNode.content);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
if (IN_PLACE) {
|
|
851
|
-
return dirty;
|
|
852
|
-
}
|
|
853
|
-
if (RETURN_DOM) {
|
|
854
|
-
if (RETURN_DOM_FRAGMENT) {
|
|
855
|
-
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
856
|
-
while (body.firstChild) {
|
|
857
|
-
returnNode.appendChild(body.firstChild);
|
|
858
|
-
}
|
|
859
|
-
} else {
|
|
860
|
-
returnNode = body;
|
|
861
|
-
}
|
|
862
|
-
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
863
|
-
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
864
|
-
}
|
|
865
|
-
return returnNode;
|
|
866
|
-
}
|
|
867
|
-
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
868
|
-
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
869
|
-
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
870
|
-
}
|
|
871
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
872
|
-
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
873
|
-
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
877
|
-
};
|
|
878
|
-
DOMPurify.setConfig = function() {
|
|
879
|
-
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
880
|
-
_parseConfig(cfg);
|
|
881
|
-
SET_CONFIG = true;
|
|
882
|
-
};
|
|
883
|
-
DOMPurify.clearConfig = function() {
|
|
884
|
-
CONFIG = null;
|
|
885
|
-
SET_CONFIG = false;
|
|
886
|
-
};
|
|
887
|
-
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
888
|
-
if (!CONFIG) {
|
|
889
|
-
_parseConfig({});
|
|
890
|
-
}
|
|
891
|
-
const lcTag = transformCaseFunc(tag);
|
|
892
|
-
const lcName = transformCaseFunc(attr);
|
|
893
|
-
return _isValidAttribute(lcTag, lcName, value);
|
|
894
|
-
};
|
|
895
|
-
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
896
|
-
if (typeof hookFunction !== "function") {
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
arrayPush(hooks[entryPoint], hookFunction);
|
|
900
|
-
};
|
|
901
|
-
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
902
|
-
if (hookFunction !== void 0) {
|
|
903
|
-
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
904
|
-
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
905
|
-
}
|
|
906
|
-
return arrayPop(hooks[entryPoint]);
|
|
907
|
-
};
|
|
908
|
-
DOMPurify.removeHooks = function(entryPoint) {
|
|
909
|
-
hooks[entryPoint] = [];
|
|
910
|
-
};
|
|
911
|
-
DOMPurify.removeAllHooks = function() {
|
|
912
|
-
hooks = _createHooksMap();
|
|
913
|
-
};
|
|
914
|
-
return DOMPurify;
|
|
915
|
-
}
|
|
916
|
-
var entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor, freeze, seal, create, apply, construct, arrayForEach, arrayLastIndexOf, arrayPop, arrayPush, arraySplice, stringToLowerCase, stringToString, stringMatch, stringReplace, stringIndexOf, stringTrim, objectHasOwnProperty, regExpTest, typeErrorCreate, html$1, svg$1, svgFilters, svgDisallowed, mathMl$1, mathMlDisallowed, text, html, svg, mathMl, xml, MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_ALLOWED_URI, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, DOCTYPE_NAME, CUSTOM_ELEMENT, EXPRESSIONS, NODE_TYPE, getGlobal, _createTrustedTypesPolicy, _createHooksMap, purify;
|
|
917
|
-
var init_purify_es = __esm({
|
|
918
|
-
"node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/dist/purify.es.mjs"() {
|
|
919
|
-
({
|
|
920
|
-
entries,
|
|
921
|
-
setPrototypeOf,
|
|
922
|
-
isFrozen,
|
|
923
|
-
getPrototypeOf,
|
|
924
|
-
getOwnPropertyDescriptor
|
|
925
|
-
} = Object);
|
|
926
|
-
({
|
|
927
|
-
freeze,
|
|
928
|
-
seal,
|
|
929
|
-
create
|
|
930
|
-
} = Object);
|
|
931
|
-
({
|
|
932
|
-
apply,
|
|
933
|
-
construct
|
|
934
|
-
} = typeof Reflect !== "undefined" && Reflect);
|
|
935
|
-
if (!freeze) {
|
|
936
|
-
freeze = function freeze2(x) {
|
|
937
|
-
return x;
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
if (!seal) {
|
|
941
|
-
seal = function seal2(x) {
|
|
942
|
-
return x;
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
if (!apply) {
|
|
946
|
-
apply = function apply2(func, thisArg) {
|
|
947
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
948
|
-
args[_key - 2] = arguments[_key];
|
|
949
|
-
}
|
|
950
|
-
return func.apply(thisArg, args);
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
if (!construct) {
|
|
954
|
-
construct = function construct2(Func) {
|
|
955
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
956
|
-
args[_key2 - 1] = arguments[_key2];
|
|
957
|
-
}
|
|
958
|
-
return new Func(...args);
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
arrayForEach = unapply(Array.prototype.forEach);
|
|
962
|
-
arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
963
|
-
arrayPop = unapply(Array.prototype.pop);
|
|
964
|
-
arrayPush = unapply(Array.prototype.push);
|
|
965
|
-
arraySplice = unapply(Array.prototype.splice);
|
|
966
|
-
stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
967
|
-
stringToString = unapply(String.prototype.toString);
|
|
968
|
-
stringMatch = unapply(String.prototype.match);
|
|
969
|
-
stringReplace = unapply(String.prototype.replace);
|
|
970
|
-
stringIndexOf = unapply(String.prototype.indexOf);
|
|
971
|
-
stringTrim = unapply(String.prototype.trim);
|
|
972
|
-
objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
973
|
-
regExpTest = unapply(RegExp.prototype.test);
|
|
974
|
-
typeErrorCreate = unconstruct(TypeError);
|
|
975
|
-
html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
|
|
976
|
-
svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
|
|
977
|
-
svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
|
|
978
|
-
svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
|
|
979
|
-
mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
|
|
980
|
-
mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
981
|
-
text = freeze(["#text"]);
|
|
982
|
-
html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
|
|
983
|
-
svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
|
|
984
|
-
mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
|
|
985
|
-
xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
986
|
-
MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
|
|
987
|
-
ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
988
|
-
TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
|
|
989
|
-
DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
990
|
-
ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
991
|
-
IS_ALLOWED_URI = seal(
|
|
992
|
-
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
993
|
-
// eslint-disable-line no-useless-escape
|
|
994
|
-
);
|
|
995
|
-
IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
996
|
-
ATTR_WHITESPACE = seal(
|
|
997
|
-
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
998
|
-
// eslint-disable-line no-control-regex
|
|
999
|
-
);
|
|
1000
|
-
DOCTYPE_NAME = seal(/^html$/i);
|
|
1001
|
-
CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
1002
|
-
EXPRESSIONS = /* @__PURE__ */ Object.freeze({
|
|
1003
|
-
__proto__: null,
|
|
1004
|
-
ARIA_ATTR,
|
|
1005
|
-
ATTR_WHITESPACE,
|
|
1006
|
-
CUSTOM_ELEMENT,
|
|
1007
|
-
DATA_ATTR,
|
|
1008
|
-
DOCTYPE_NAME,
|
|
1009
|
-
ERB_EXPR,
|
|
1010
|
-
IS_ALLOWED_URI,
|
|
1011
|
-
IS_SCRIPT_OR_DATA,
|
|
1012
|
-
MUSTACHE_EXPR,
|
|
1013
|
-
TMPLIT_EXPR
|
|
1014
|
-
});
|
|
1015
|
-
NODE_TYPE = {
|
|
1016
|
-
element: 1,
|
|
1017
|
-
attribute: 2,
|
|
1018
|
-
text: 3,
|
|
1019
|
-
cdataSection: 4,
|
|
1020
|
-
entityReference: 5,
|
|
1021
|
-
// Deprecated
|
|
1022
|
-
entityNode: 6,
|
|
1023
|
-
// Deprecated
|
|
1024
|
-
progressingInstruction: 7,
|
|
1025
|
-
comment: 8,
|
|
1026
|
-
document: 9,
|
|
1027
|
-
documentType: 10,
|
|
1028
|
-
documentFragment: 11,
|
|
1029
|
-
notation: 12
|
|
1030
|
-
// Deprecated
|
|
1031
|
-
};
|
|
1032
|
-
getGlobal = function getGlobal2() {
|
|
1033
|
-
return typeof window === "undefined" ? null : window;
|
|
1034
|
-
};
|
|
1035
|
-
_createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
|
|
1036
|
-
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
|
|
1037
|
-
return null;
|
|
1038
|
-
}
|
|
1039
|
-
let suffix = null;
|
|
1040
|
-
const ATTR_NAME = "data-tt-policy-suffix";
|
|
1041
|
-
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
|
1042
|
-
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
1043
|
-
}
|
|
1044
|
-
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
1045
|
-
try {
|
|
1046
|
-
return trustedTypes.createPolicy(policyName, {
|
|
1047
|
-
createHTML(html2) {
|
|
1048
|
-
return html2;
|
|
1049
|
-
},
|
|
1050
|
-
createScriptURL(scriptUrl) {
|
|
1051
|
-
return scriptUrl;
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
} catch (_) {
|
|
1055
|
-
console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
|
1056
|
-
return null;
|
|
1057
|
-
}
|
|
1058
|
-
};
|
|
1059
|
-
_createHooksMap = function _createHooksMap2() {
|
|
1060
|
-
return {
|
|
1061
|
-
afterSanitizeAttributes: [],
|
|
1062
|
-
afterSanitizeElements: [],
|
|
1063
|
-
afterSanitizeShadowDOM: [],
|
|
1064
|
-
beforeSanitizeAttributes: [],
|
|
1065
|
-
beforeSanitizeElements: [],
|
|
1066
|
-
beforeSanitizeShadowDOM: [],
|
|
1067
|
-
uponSanitizeAttribute: [],
|
|
1068
|
-
uponSanitizeElement: [],
|
|
1069
|
-
uponSanitizeShadowNode: []
|
|
1070
|
-
};
|
|
1071
|
-
};
|
|
1072
|
-
purify = createDOMPurify();
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1
|
+
(() => {
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn2, res) => function __init() {
|
|
5
|
+
return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res;
|
|
6
|
+
};
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
1075
11
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
var c = class r extends Map {
|
|
1087
|
-
constructor(t = []) {
|
|
1088
|
-
super(t);
|
|
1089
|
-
}
|
|
1090
|
-
static isValid(t, e) {
|
|
1091
|
-
return o.test(t) && d.test(e);
|
|
1092
|
-
}
|
|
1093
|
-
get(t) {
|
|
1094
|
-
return super.get(t.toLowerCase());
|
|
1095
|
-
}
|
|
1096
|
-
has(t) {
|
|
1097
|
-
return super.has(t.toLowerCase());
|
|
1098
|
-
}
|
|
1099
|
-
set(t, e) {
|
|
1100
|
-
if (!r.isValid(t, e)) throw new Error(`Invalid media type parameter name/value: ${t}/${e}`);
|
|
1101
|
-
return super.set(t.toLowerCase(), e), this;
|
|
1102
|
-
}
|
|
1103
|
-
delete(t) {
|
|
1104
|
-
return super.delete(t.toLowerCase());
|
|
1105
|
-
}
|
|
1106
|
-
toString() {
|
|
1107
|
-
return Array.from(this).map(([t, e]) => `;${t}=${!e || !o.test(e) ? `"${e.replace(y, "\\$1")}"` : e}`).join("");
|
|
1108
|
-
}
|
|
1109
|
-
get [Symbol.toStringTag]() {
|
|
1110
|
-
return "MediaTypeParameters";
|
|
1111
|
-
}
|
|
12
|
+
// iife:/home/runner/work/transportr/transportr/dist/OP3JQ447.js
|
|
13
|
+
var OP3JQ447_exports = {};
|
|
14
|
+
__export(OP3JQ447_exports, {
|
|
15
|
+
default: () => mn
|
|
16
|
+
});
|
|
17
|
+
function R(s2) {
|
|
18
|
+
return function(o) {
|
|
19
|
+
o instanceof RegExp && (o.lastIndex = 0);
|
|
20
|
+
for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++) a[c - 1] = arguments[c];
|
|
21
|
+
return ve(s2, o, a);
|
|
1112
22
|
};
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
return s.size === 0 && super.delete(t), r4;
|
|
1221
|
-
}
|
|
1222
|
-
return false;
|
|
1223
|
-
}
|
|
1224
|
-
get [Symbol.toStringTag]() {
|
|
1225
|
-
return "SetMultiMap";
|
|
1226
|
-
}
|
|
1227
|
-
};
|
|
1228
|
-
var o2 = class {
|
|
1229
|
-
context;
|
|
1230
|
-
eventHandler;
|
|
1231
|
-
constructor(t, e) {
|
|
1232
|
-
this.context = t, this.eventHandler = e;
|
|
1233
|
-
}
|
|
1234
|
-
handle(t, e) {
|
|
1235
|
-
this.eventHandler.call(this.context, t, e);
|
|
1236
|
-
}
|
|
1237
|
-
get [Symbol.toStringTag]() {
|
|
1238
|
-
return "ContextEventHandler";
|
|
1239
|
-
}
|
|
1240
|
-
};
|
|
1241
|
-
var l = class {
|
|
1242
|
-
_eventName;
|
|
1243
|
-
_contextEventHandler;
|
|
1244
|
-
constructor(t, e) {
|
|
1245
|
-
this._eventName = t, this._contextEventHandler = e;
|
|
1246
|
-
}
|
|
1247
|
-
get eventName() {
|
|
1248
|
-
return this._eventName;
|
|
1249
|
-
}
|
|
1250
|
-
get contextEventHandler() {
|
|
1251
|
-
return this._contextEventHandler;
|
|
1252
|
-
}
|
|
1253
|
-
get [Symbol.toStringTag]() {
|
|
1254
|
-
return "Subscription";
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
var d2 = class {
|
|
1258
|
-
subscribers = new n();
|
|
1259
|
-
errorHandler;
|
|
1260
|
-
setErrorHandler(t) {
|
|
1261
|
-
this.errorHandler = t;
|
|
1262
|
-
}
|
|
1263
|
-
subscribe(t, e, s = e, r4) {
|
|
1264
|
-
if (this.validateEventName(t), r4?.once) {
|
|
1265
|
-
let p = e;
|
|
1266
|
-
e = (v, m2) => {
|
|
1267
|
-
p.call(s, v, m2), this.unsubscribe(h2);
|
|
1268
|
-
};
|
|
1269
|
-
}
|
|
1270
|
-
let i = new o2(s, e);
|
|
1271
|
-
this.subscribers.set(t, i);
|
|
1272
|
-
let h2 = new l(t, i);
|
|
1273
|
-
return h2;
|
|
1274
|
-
}
|
|
1275
|
-
unsubscribe({ eventName: t, contextEventHandler: e }) {
|
|
1276
|
-
let s = this.subscribers.get(t) ?? /* @__PURE__ */ new Set(), r4 = s.delete(e);
|
|
1277
|
-
return r4 && s.size === 0 && this.subscribers.delete(t), r4;
|
|
1278
|
-
}
|
|
1279
|
-
publish(t, e = new CustomEvent(t), s) {
|
|
1280
|
-
this.validateEventName(t), this.subscribers.get(t)?.forEach((r4) => {
|
|
1281
|
-
try {
|
|
1282
|
-
r4.handle(e, s);
|
|
1283
|
-
} catch (i) {
|
|
1284
|
-
this.errorHandler ? this.errorHandler(i, t, e, s) : console.error(`Error in event handler for '${t}':`, i);
|
|
1285
|
-
}
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
|
-
isSubscribed({ eventName: t, contextEventHandler: e }) {
|
|
1289
|
-
return this.subscribers.get(t)?.has(e) ?? false;
|
|
1290
|
-
}
|
|
1291
|
-
validateEventName(t) {
|
|
1292
|
-
if (!t || typeof t != "string") throw new TypeError("Event name must be a non-empty string");
|
|
1293
|
-
if (t.trim() !== t) throw new Error("Event name cannot have leading or trailing whitespace");
|
|
1294
|
-
}
|
|
1295
|
-
destroy() {
|
|
1296
|
-
this.subscribers.clear();
|
|
1297
|
-
}
|
|
1298
|
-
get [Symbol.toStringTag]() {
|
|
1299
|
-
return "Subscribr";
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
// src/http-error.ts
|
|
1304
|
-
var HttpError = class extends Error {
|
|
1305
|
-
_entity;
|
|
1306
|
-
responseStatus;
|
|
1307
|
-
_url;
|
|
1308
|
-
_method;
|
|
1309
|
-
_timing;
|
|
1310
|
-
/**
|
|
1311
|
-
* Creates an instance of HttpError.
|
|
1312
|
-
* @param status The status code and status text of the {@link Response}.
|
|
1313
|
-
* @param httpErrorOptions The http error options.
|
|
1314
|
-
*/
|
|
1315
|
-
constructor(status, { message, cause, entity, url, method, timing } = {}) {
|
|
1316
|
-
super(message, { cause });
|
|
1317
|
-
this._entity = entity;
|
|
1318
|
-
this.responseStatus = status;
|
|
1319
|
-
this._url = url;
|
|
1320
|
-
this._method = method;
|
|
1321
|
-
this._timing = timing;
|
|
1322
|
-
}
|
|
1323
|
-
/**
|
|
1324
|
-
* It returns the value of the private variable #entity.
|
|
1325
|
-
* @returns The entity property of the class.
|
|
1326
|
-
*/
|
|
1327
|
-
get entity() {
|
|
1328
|
-
return this._entity;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* It returns the status code of the {@link Response}.
|
|
1332
|
-
* @returns The status code of the {@link Response}.
|
|
1333
|
-
*/
|
|
1334
|
-
get statusCode() {
|
|
1335
|
-
return this.responseStatus.code;
|
|
1336
|
-
}
|
|
1337
|
-
/**
|
|
1338
|
-
* It returns the status text of the {@link Response}.
|
|
1339
|
-
* @returns The status code and status text of the {@link Response}.
|
|
1340
|
-
*/
|
|
1341
|
-
get statusText() {
|
|
1342
|
-
return this.responseStatus?.text;
|
|
1343
|
-
}
|
|
1344
|
-
/**
|
|
1345
|
-
* The request URL that caused the error.
|
|
1346
|
-
* @returns The URL or undefined.
|
|
1347
|
-
*/
|
|
1348
|
-
get url() {
|
|
1349
|
-
return this._url;
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* The HTTP method that was used for the failed request.
|
|
1353
|
-
* @returns The method string or undefined.
|
|
1354
|
-
*/
|
|
1355
|
-
get method() {
|
|
1356
|
-
return this._method;
|
|
1357
|
-
}
|
|
1358
|
-
/**
|
|
1359
|
-
* Timing information for the failed request.
|
|
1360
|
-
* @returns The timing object or undefined.
|
|
1361
|
-
*/
|
|
1362
|
-
get timing() {
|
|
1363
|
-
return this._timing;
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* A String value representing the name of the error.
|
|
1367
|
-
* @returns The name of the error.
|
|
1368
|
-
*/
|
|
1369
|
-
get name() {
|
|
1370
|
-
return "HttpError";
|
|
1371
|
-
}
|
|
1372
|
-
/**
|
|
1373
|
-
* A String value that is used in the creation of the default string
|
|
1374
|
-
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
1375
|
-
* @returns The default string description of this object.
|
|
1376
|
-
*/
|
|
1377
|
-
get [Symbol.toStringTag]() {
|
|
1378
|
-
return this.name;
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
|
|
1382
|
-
// src/response-status.ts
|
|
1383
|
-
var ResponseStatus = class {
|
|
1384
|
-
_code;
|
|
1385
|
-
_text;
|
|
1386
|
-
/**
|
|
1387
|
-
*
|
|
1388
|
-
* @param code The status code from the {@link Response}
|
|
1389
|
-
* @param text The status text from the {@link Response}
|
|
1390
|
-
*/
|
|
1391
|
-
constructor(code, text2) {
|
|
1392
|
-
this._code = code;
|
|
1393
|
-
this._text = text2;
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Returns the status code from the {@link Response}
|
|
1397
|
-
*
|
|
1398
|
-
* @returns The status code.
|
|
1399
|
-
*/
|
|
1400
|
-
get code() {
|
|
1401
|
-
return this._code;
|
|
1402
|
-
}
|
|
1403
|
-
/**
|
|
1404
|
-
* Returns the status text from the {@link Response}.
|
|
1405
|
-
*
|
|
1406
|
-
* @returns The status text.
|
|
1407
|
-
*/
|
|
1408
|
-
get text() {
|
|
1409
|
-
return this._text;
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* A String value that is used in the creation of the default string
|
|
1413
|
-
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
1414
|
-
*
|
|
1415
|
-
* @returns The default string description of this object.
|
|
1416
|
-
*/
|
|
1417
|
-
get [Symbol.toStringTag]() {
|
|
1418
|
-
return "ResponseStatus";
|
|
1419
|
-
}
|
|
1420
|
-
/**
|
|
1421
|
-
* tostring method for the class.
|
|
1422
|
-
*
|
|
1423
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}
|
|
1424
|
-
* @returns The status code and status text.
|
|
1425
|
-
*/
|
|
1426
|
-
toString() {
|
|
1427
|
-
return `${this._code} ${this._text}`;
|
|
1428
|
-
}
|
|
1429
|
-
};
|
|
1430
|
-
|
|
1431
|
-
// src/constants.ts
|
|
1432
|
-
var charset = { charset: "utf-8" };
|
|
1433
|
-
var endsWithSlashRegEx = /\/$/;
|
|
1434
|
-
var XSRF_COOKIE_NAME = "XSRF-TOKEN";
|
|
1435
|
-
var XSRF_HEADER_NAME = "X-XSRF-TOKEN";
|
|
1436
|
-
var mediaTypes = {
|
|
1437
|
-
PNG: new h("image/png"),
|
|
1438
|
-
TEXT: new h("text/plain", charset),
|
|
1439
|
-
JSON: new h("application/json", charset),
|
|
1440
|
-
HTML: new h("text/html", charset),
|
|
1441
|
-
JAVA_SCRIPT: new h("text/javascript", charset),
|
|
1442
|
-
CSS: new h("text/css", charset),
|
|
1443
|
-
XML: new h("application/xml", charset),
|
|
1444
|
-
BIN: new h("application/octet-stream"),
|
|
1445
|
-
EVENT_STREAM: new h("text/event-stream", charset),
|
|
1446
|
-
NDJSON: new h("application/x-ndjson", charset)
|
|
1447
|
-
};
|
|
1448
|
-
var defaultMediaType = mediaTypes.JSON.toString();
|
|
1449
|
-
var defaultOrigin = globalThis.location?.origin ?? "http://localhost";
|
|
1450
|
-
var RequestCachingPolicy = {
|
|
1451
|
-
DEFAULT: "default",
|
|
1452
|
-
FORCE_CACHE: "force-cache",
|
|
1453
|
-
NO_CACHE: "no-cache",
|
|
1454
|
-
NO_STORE: "no-store",
|
|
1455
|
-
ONLY_IF_CACHED: "only-if-cached",
|
|
1456
|
-
RELOAD: "reload"
|
|
1457
|
-
};
|
|
1458
|
-
var RequestEvent = {
|
|
1459
|
-
CONFIGURED: "configured",
|
|
1460
|
-
SUCCESS: "success",
|
|
1461
|
-
ERROR: "error",
|
|
1462
|
-
ABORTED: "aborted",
|
|
1463
|
-
TIMEOUT: "timeout",
|
|
1464
|
-
RETRY: "retry",
|
|
1465
|
-
COMPLETE: "complete",
|
|
1466
|
-
ALL_COMPLETE: "all-complete"
|
|
1467
|
-
};
|
|
1468
|
-
var SignalEvents = {
|
|
1469
|
-
ABORT: "abort",
|
|
1470
|
-
TIMEOUT: "timeout"
|
|
1471
|
-
};
|
|
1472
|
-
var SignalErrors = {
|
|
1473
|
-
ABORT: "AbortError",
|
|
1474
|
-
TIMEOUT: "TimeoutError"
|
|
1475
|
-
};
|
|
1476
|
-
var eventListenerOptions = { once: true, passive: true };
|
|
1477
|
-
var abortEvent = () => new CustomEvent(SignalEvents.ABORT, { detail: { cause: SignalErrors.ABORT } });
|
|
1478
|
-
var timeoutEvent = () => new CustomEvent(SignalEvents.TIMEOUT, { detail: { cause: SignalErrors.TIMEOUT } });
|
|
1479
|
-
var requestBodyMethods = ["POST", "PUT", "PATCH", "DELETE"];
|
|
1480
|
-
var internalServerError = new ResponseStatus(500, "Internal Server Error");
|
|
1481
|
-
var aborted = new ResponseStatus(499, "Aborted");
|
|
1482
|
-
var timedOut = new ResponseStatus(504, "Request Timeout");
|
|
1483
|
-
var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
|
|
1484
|
-
var retryMethods = ["GET", "PUT", "HEAD", "DELETE", "OPTIONS"];
|
|
1485
|
-
var retryDelay = 300;
|
|
1486
|
-
var retryBackoffFactor = 2;
|
|
1487
|
-
|
|
1488
|
-
// src/signal-controller.ts
|
|
1489
|
-
var SignalController = class {
|
|
1490
|
-
abortSignal;
|
|
1491
|
-
abortController = new AbortController();
|
|
1492
|
-
events = /* @__PURE__ */ new Map();
|
|
1493
|
-
/**
|
|
1494
|
-
* Creates a new SignalController instance.
|
|
1495
|
-
* @param options - The options for the SignalController.
|
|
1496
|
-
* @param options.signal - The signal to listen for abort events. Defaults to the internal abort signal.
|
|
1497
|
-
* @param options.timeout - The timeout value in milliseconds. Defaults to Infinity.
|
|
1498
|
-
* @throws {RangeError} If the timeout value is negative.
|
|
1499
|
-
*/
|
|
1500
|
-
constructor({ signal, timeout = Infinity } = {}) {
|
|
1501
|
-
if (timeout < 0) {
|
|
1502
|
-
throw new RangeError("The timeout cannot be negative");
|
|
1503
|
-
}
|
|
1504
|
-
const signals = [this.abortController.signal];
|
|
1505
|
-
if (signal != null) {
|
|
1506
|
-
signals.push(signal);
|
|
1507
|
-
}
|
|
1508
|
-
if (timeout !== Infinity) {
|
|
1509
|
-
signals.push(AbortSignal.timeout(timeout));
|
|
1510
|
-
}
|
|
1511
|
-
(this.abortSignal = AbortSignal.any(signals)).addEventListener(SignalEvents.ABORT, this, eventListenerOptions);
|
|
1512
|
-
}
|
|
1513
|
-
/**
|
|
1514
|
-
* Handles the 'abort' event. If the event is caused by a timeout, the 'timeout' event is dispatched.
|
|
1515
|
-
* Guards against a timeout firing after a manual abort to prevent spurious timeout events.
|
|
1516
|
-
* @param event The event to abort with
|
|
1517
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#specifying_this_using_bind
|
|
1518
|
-
*/
|
|
1519
|
-
handleEvent({ target: { reason } }) {
|
|
1520
|
-
if (this.abortController.signal.aborted) {
|
|
1521
|
-
return;
|
|
1522
|
-
}
|
|
1523
|
-
if (reason instanceof DOMException && reason.name === SignalErrors.TIMEOUT) {
|
|
1524
|
-
this.abortSignal.dispatchEvent(timeoutEvent());
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
/**
|
|
1528
|
-
* Gets the signal. This signal will be able to abort the request, but will not be notified if the request is aborted by the timeout.
|
|
1529
|
-
* @returns The signal
|
|
1530
|
-
*/
|
|
1531
|
-
get signal() {
|
|
1532
|
-
return this.abortSignal;
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Adds an event listener for the 'abort' event.
|
|
1536
|
-
*
|
|
1537
|
-
* @param eventListener The listener to add
|
|
1538
|
-
* @returns The SignalController
|
|
1539
|
-
*/
|
|
1540
|
-
onAbort(eventListener) {
|
|
1541
|
-
return this.addEventListener(SignalEvents.ABORT, eventListener);
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Adds an event listener for the 'timeout' event.
|
|
1545
|
-
*
|
|
1546
|
-
* @param eventListener The listener to add
|
|
1547
|
-
* @returns The SignalController
|
|
1548
|
-
*/
|
|
1549
|
-
onTimeout(eventListener) {
|
|
1550
|
-
return this.addEventListener(SignalEvents.TIMEOUT, eventListener);
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
* Aborts the signal.
|
|
1554
|
-
*
|
|
1555
|
-
* @param event The event to abort with
|
|
1556
|
-
*/
|
|
1557
|
-
abort(event = abortEvent()) {
|
|
1558
|
-
this.abortController.abort(event.detail?.cause);
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
* Removes all event listeners from the signal.
|
|
1562
|
-
*
|
|
1563
|
-
* @returns The SignalController
|
|
1564
|
-
*/
|
|
1565
|
-
destroy() {
|
|
1566
|
-
this.abortSignal.removeEventListener(SignalEvents.ABORT, this, eventListenerOptions);
|
|
1567
|
-
for (const [eventListener, type] of this.events) {
|
|
1568
|
-
this.abortSignal.removeEventListener(type, eventListener, eventListenerOptions);
|
|
1569
|
-
}
|
|
1570
|
-
this.events.clear();
|
|
1571
|
-
return this;
|
|
1572
|
-
}
|
|
1573
|
-
/**
|
|
1574
|
-
* Adds an event listener for the specified event type.
|
|
1575
|
-
*
|
|
1576
|
-
* @param type The event type to listen for
|
|
1577
|
-
* @param eventListener The listener to add
|
|
1578
|
-
* @returns The SignalController
|
|
1579
|
-
*/
|
|
1580
|
-
addEventListener(type, eventListener) {
|
|
1581
|
-
this.abortSignal.addEventListener(type, eventListener, eventListenerOptions);
|
|
1582
|
-
this.events.set(eventListener, type);
|
|
1583
|
-
return this;
|
|
1584
|
-
}
|
|
1585
|
-
/**
|
|
1586
|
-
* A String value that is used in the creation of the default string
|
|
1587
|
-
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
1588
|
-
*
|
|
1589
|
-
* @returns The default string description of this object.
|
|
1590
|
-
*/
|
|
1591
|
-
get [Symbol.toStringTag]() {
|
|
1592
|
-
return "SignalController";
|
|
1593
|
-
}
|
|
1594
|
-
};
|
|
1595
|
-
|
|
1596
|
-
// src/response-handlers.ts
|
|
1597
|
-
var domReady;
|
|
1598
|
-
var purifyReady;
|
|
1599
|
-
var getSanitize = () => purifyReady ??= Promise.resolve().then(() => (init_purify_es(), purify_es_exports)).then(({ default: p }) => (dirty) => p.sanitize(dirty));
|
|
1600
|
-
var ensureDom = async () => {
|
|
1601
|
-
if (typeof document !== "undefined" && typeof DOMParser !== "undefined" && typeof DocumentFragment !== "undefined") {
|
|
1602
|
-
return Promise.resolve();
|
|
1603
|
-
}
|
|
1604
|
-
return domReady ??= import("jsdom").then(({ JSDOM }) => {
|
|
1605
|
-
const { window: window2 } = new JSDOM("<!DOCTYPE html><html><head></head><body></body></html>", { url: "http://localhost" });
|
|
1606
|
-
globalThis.window = window2;
|
|
1607
|
-
Object.assign(globalThis, { document: window2.document, DOMParser: window2.DOMParser, DocumentFragment: window2.DocumentFragment });
|
|
1608
|
-
}).catch(() => {
|
|
1609
|
-
domReady = void 0;
|
|
1610
|
-
throw new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom");
|
|
1611
|
-
});
|
|
1612
|
-
};
|
|
1613
|
-
var handleText = async (response) => await response.text();
|
|
1614
|
-
var handleScript = async (response) => {
|
|
1615
|
-
await ensureDom();
|
|
1616
|
-
const objectURL = URL.createObjectURL(await response.blob());
|
|
1617
|
-
return new Promise((resolve, reject) => {
|
|
1618
|
-
const script = document.createElement("script");
|
|
1619
|
-
Object.assign(script, { src: objectURL, type: "text/javascript", async: true });
|
|
1620
|
-
script.onload = () => {
|
|
1621
|
-
URL.revokeObjectURL(objectURL);
|
|
1622
|
-
document.head.removeChild(script);
|
|
1623
|
-
resolve();
|
|
1624
|
-
};
|
|
1625
|
-
script.onerror = () => {
|
|
1626
|
-
URL.revokeObjectURL(objectURL);
|
|
1627
|
-
document.head.removeChild(script);
|
|
1628
|
-
reject(new Error("Script failed to load"));
|
|
1629
|
-
};
|
|
1630
|
-
document.head.appendChild(script);
|
|
1631
|
-
});
|
|
1632
|
-
};
|
|
1633
|
-
var handleCss = async (response) => {
|
|
1634
|
-
await ensureDom();
|
|
1635
|
-
const objectURL = URL.createObjectURL(await response.blob());
|
|
1636
|
-
return new Promise((resolve, reject) => {
|
|
1637
|
-
const link = document.createElement("link");
|
|
1638
|
-
Object.assign(link, { href: objectURL, type: "text/css", rel: "stylesheet" });
|
|
1639
|
-
link.onload = () => resolve(URL.revokeObjectURL(objectURL));
|
|
1640
|
-
link.onerror = () => {
|
|
1641
|
-
URL.revokeObjectURL(objectURL);
|
|
1642
|
-
document.head.removeChild(link);
|
|
1643
|
-
reject(new Error("Stylesheet load failed"));
|
|
1644
|
-
};
|
|
1645
|
-
document.head.appendChild(link);
|
|
1646
|
-
});
|
|
1647
|
-
};
|
|
1648
|
-
var handleJson = async (response) => await response.json();
|
|
1649
|
-
var handleBlob = async (response) => await response.blob();
|
|
1650
|
-
var handleImage = async (response) => {
|
|
1651
|
-
await ensureDom();
|
|
1652
|
-
const objectURL = URL.createObjectURL(await response.blob());
|
|
1653
|
-
return new Promise((resolve, reject) => {
|
|
1654
|
-
const img = new Image();
|
|
1655
|
-
img.onload = () => {
|
|
1656
|
-
URL.revokeObjectURL(objectURL);
|
|
1657
|
-
resolve(img);
|
|
1658
|
-
};
|
|
1659
|
-
img.onerror = () => {
|
|
1660
|
-
URL.revokeObjectURL(objectURL);
|
|
1661
|
-
reject(new Error("Image failed to load"));
|
|
1662
|
-
};
|
|
1663
|
-
img.src = objectURL;
|
|
1664
|
-
});
|
|
1665
|
-
};
|
|
1666
|
-
var handleBuffer = async (response) => await response.arrayBuffer();
|
|
1667
|
-
var handleReadableStream = async (response) => Promise.resolve(response.body);
|
|
1668
|
-
var handleXml = async (response) => {
|
|
1669
|
-
await ensureDom();
|
|
1670
|
-
const sanitize = await getSanitize();
|
|
1671
|
-
return new DOMParser().parseFromString(sanitize(await response.text()), "application/xml");
|
|
1672
|
-
};
|
|
1673
|
-
var handleHtml = async (response) => {
|
|
1674
|
-
await ensureDom();
|
|
1675
|
-
const sanitize = await getSanitize();
|
|
1676
|
-
return new DOMParser().parseFromString(sanitize(await response.text()), "text/html");
|
|
1677
|
-
};
|
|
1678
|
-
var handleHtmlFragment = async (response) => {
|
|
1679
|
-
await ensureDom();
|
|
1680
|
-
const sanitize = await getSanitize();
|
|
1681
|
-
return document.createRange().createContextualFragment(sanitize(await response.text()));
|
|
1682
|
-
};
|
|
1683
|
-
var handleEventStream = (response) => {
|
|
1684
|
-
return {
|
|
1685
|
-
/** @returns An async iterator for SSE events. */
|
|
1686
|
-
[Symbol.asyncIterator]() {
|
|
1687
|
-
const reader = response.body.getReader();
|
|
1688
|
-
const decoder = new TextDecoder();
|
|
1689
|
-
let buffer = "";
|
|
1690
|
-
let done = false;
|
|
1691
|
-
return {
|
|
1692
|
-
/** @returns The next parsed SSE event or done signal. */
|
|
1693
|
-
async next() {
|
|
1694
|
-
while (!done) {
|
|
1695
|
-
const eventEnd = buffer.indexOf("\n\n");
|
|
1696
|
-
if (eventEnd !== -1) {
|
|
1697
|
-
const rawEvent = buffer.slice(0, eventEnd);
|
|
1698
|
-
buffer = buffer.slice(eventEnd + 2);
|
|
1699
|
-
const sse = { event: "message", data: "", id: "", retry: void 0 };
|
|
1700
|
-
const dataLines = [];
|
|
1701
|
-
const lines = rawEvent.split("\n");
|
|
1702
|
-
for (let i = 0; i < lines.length; i++) {
|
|
1703
|
-
const line = lines[i];
|
|
1704
|
-
if (line.startsWith(":")) {
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
const colonIndex = line.indexOf(":");
|
|
1708
|
-
let field;
|
|
1709
|
-
let value;
|
|
1710
|
-
if (colonIndex === -1) {
|
|
1711
|
-
field = line;
|
|
1712
|
-
value = "";
|
|
1713
|
-
} else {
|
|
1714
|
-
field = line.slice(0, colonIndex);
|
|
1715
|
-
value = line.slice(colonIndex + 1);
|
|
1716
|
-
if (value.charCodeAt(0) === 32) {
|
|
1717
|
-
value = value.slice(1);
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
switch (field) {
|
|
1721
|
-
case "event":
|
|
1722
|
-
sse.event = value;
|
|
1723
|
-
break;
|
|
1724
|
-
case "data":
|
|
1725
|
-
dataLines.push(value);
|
|
1726
|
-
break;
|
|
1727
|
-
case "id":
|
|
1728
|
-
sse.id = value;
|
|
1729
|
-
break;
|
|
1730
|
-
case "retry": {
|
|
1731
|
-
const n2 = parseInt(value, 10);
|
|
1732
|
-
if (!isNaN(n2)) sse.retry = n2;
|
|
1733
|
-
break;
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
sse.data = dataLines.join("\n");
|
|
1738
|
-
if (sse.data || sse.event !== "message") {
|
|
1739
|
-
return { value: sse, done: false };
|
|
1740
|
-
}
|
|
1741
|
-
continue;
|
|
1742
|
-
}
|
|
1743
|
-
const result = await reader.read();
|
|
1744
|
-
if (result.done) {
|
|
1745
|
-
done = true;
|
|
1746
|
-
break;
|
|
1747
|
-
}
|
|
1748
|
-
buffer += decoder.decode(result.value, { stream: true });
|
|
1749
|
-
}
|
|
1750
|
-
return { value: void 0, done: true };
|
|
1751
|
-
},
|
|
1752
|
-
/** @returns Done signal after cancelling the reader. */
|
|
1753
|
-
async return() {
|
|
1754
|
-
await reader.cancel();
|
|
1755
|
-
done = true;
|
|
1756
|
-
return { value: void 0, done: true };
|
|
1757
|
-
}
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1761
|
-
};
|
|
1762
|
-
var handleNdjsonStream = (response) => {
|
|
1763
|
-
return {
|
|
1764
|
-
/** @returns An async iterator for NDJSON lines. */
|
|
1765
|
-
[Symbol.asyncIterator]() {
|
|
1766
|
-
const reader = response.body.getReader();
|
|
1767
|
-
const decoder = new TextDecoder();
|
|
1768
|
-
let buffer = "";
|
|
1769
|
-
let done = false;
|
|
1770
|
-
return {
|
|
1771
|
-
/** @returns The next parsed JSON value or done signal. */
|
|
1772
|
-
async next() {
|
|
1773
|
-
while (!done) {
|
|
1774
|
-
const lineEnd = buffer.indexOf("\n");
|
|
1775
|
-
if (lineEnd !== -1) {
|
|
1776
|
-
const line = buffer.slice(0, lineEnd).trim();
|
|
1777
|
-
buffer = buffer.slice(lineEnd + 1);
|
|
1778
|
-
if (line) {
|
|
1779
|
-
return { value: JSON.parse(line), done: false };
|
|
1780
|
-
}
|
|
1781
|
-
continue;
|
|
1782
|
-
}
|
|
1783
|
-
const result = await reader.read();
|
|
1784
|
-
if (result.done) {
|
|
1785
|
-
done = true;
|
|
1786
|
-
const remaining = (buffer + decoder.decode()).trim();
|
|
1787
|
-
buffer = "";
|
|
1788
|
-
if (remaining) {
|
|
1789
|
-
return { value: JSON.parse(remaining), done: false };
|
|
1790
|
-
}
|
|
1791
|
-
break;
|
|
1792
|
-
}
|
|
1793
|
-
buffer += decoder.decode(result.value, { stream: true });
|
|
1794
|
-
}
|
|
1795
|
-
return { value: void 0, done: true };
|
|
1796
|
-
},
|
|
1797
|
-
/** @returns Done signal after cancelling the reader. */
|
|
1798
|
-
async return() {
|
|
1799
|
-
await reader.cancel();
|
|
1800
|
-
done = true;
|
|
1801
|
-
return { value: void 0, done: true };
|
|
1802
|
-
}
|
|
1803
|
-
};
|
|
1804
|
-
}
|
|
1805
|
-
};
|
|
1806
|
-
};
|
|
1807
|
-
|
|
1808
|
-
// src/utils.ts
|
|
1809
|
-
var isRequestBodyMethod = (method) => method !== void 0 && requestBodyMethods.includes(method);
|
|
1810
|
-
var isRawBody = (body) => body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof ReadableStream || body instanceof URLSearchParams || ArrayBuffer.isView(body);
|
|
1811
|
-
var getCookieValue = (name) => {
|
|
1812
|
-
if (typeof document === "undefined" || !document.cookie) {
|
|
1813
|
-
return;
|
|
1814
|
-
}
|
|
1815
|
-
const prefix = `${name}=`;
|
|
1816
|
-
const cookies = document.cookie.split(";");
|
|
1817
|
-
for (let i = 0, length = cookies.length; i < length; i++) {
|
|
1818
|
-
const cookie = cookies[i].trim();
|
|
1819
|
-
if (cookie.startsWith(prefix)) {
|
|
1820
|
-
return decodeURIComponent(cookie.slice(prefix.length));
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
return void 0;
|
|
1824
|
-
};
|
|
1825
|
-
var serialize = (data) => JSON.stringify(data);
|
|
1826
|
-
var isString = (value) => value !== null && typeof value === "string";
|
|
1827
|
-
var isArrayBuffer = (value) => value instanceof ArrayBuffer || Object.prototype.toString.call(value) === "[object ArrayBuffer]";
|
|
1828
|
-
var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
1829
|
-
var objectMerge = (...objects) => {
|
|
1830
|
-
const length = objects.length;
|
|
1831
|
-
if (length === 0) {
|
|
1832
|
-
return void 0;
|
|
1833
|
-
}
|
|
1834
|
-
if (length === 1) {
|
|
1835
|
-
const [obj] = objects;
|
|
1836
|
-
if (!isObject(obj)) {
|
|
1837
|
-
return obj;
|
|
1838
|
-
}
|
|
1839
|
-
return deepClone(obj);
|
|
1840
|
-
}
|
|
1841
|
-
const target = {};
|
|
1842
|
-
for (const source of objects) {
|
|
1843
|
-
if (!isObject(source)) {
|
|
1844
|
-
return void 0;
|
|
1845
|
-
}
|
|
1846
|
-
for (const [property, sourceValue] of Object.entries(source)) {
|
|
1847
|
-
const targetValue = target[property];
|
|
1848
|
-
if (Array.isArray(sourceValue)) {
|
|
1849
|
-
target[property] = [...sourceValue, ...Array.isArray(targetValue) ? targetValue.filter((item) => !sourceValue.includes(item)) : []];
|
|
1850
|
-
} else if (isObject(sourceValue)) {
|
|
1851
|
-
target[property] = isObject(targetValue) ? objectMerge(targetValue, sourceValue) : deepClone(sourceValue);
|
|
1852
|
-
} else {
|
|
1853
|
-
target[property] = sourceValue;
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
return target;
|
|
1858
|
-
};
|
|
1859
|
-
function deepClone(object) {
|
|
1860
|
-
if (isObject(object)) {
|
|
1861
|
-
const cloned = {};
|
|
1862
|
-
const keys = Object.keys(object);
|
|
1863
|
-
for (let i = 0, length = keys.length, key; i < length; i++) {
|
|
1864
|
-
key = keys[i];
|
|
1865
|
-
cloned[key] = deepClone(object[key]);
|
|
1866
|
-
}
|
|
1867
|
-
return cloned;
|
|
1868
|
-
}
|
|
1869
|
-
return object;
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
// src/transportr.ts
|
|
1873
|
-
var Transportr = class _Transportr {
|
|
1874
|
-
_baseUrl;
|
|
1875
|
-
_options;
|
|
1876
|
-
subscribr;
|
|
1877
|
-
hooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
|
|
1878
|
-
static globalSubscribr = new d2();
|
|
1879
|
-
static globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
|
|
1880
|
-
static signalControllers = /* @__PURE__ */ new Set();
|
|
1881
|
-
/** Map of in-flight deduplicated requests keyed by URL + method */
|
|
1882
|
-
static inflightRequests = /* @__PURE__ */ new Map();
|
|
1883
|
-
/** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */
|
|
1884
|
-
static mediaTypeCache = new Map(Object.values(mediaTypes).map((mediaType) => [mediaType.toString(), mediaType]));
|
|
1885
|
-
static contentTypeHandlers = [
|
|
1886
|
-
[mediaTypes.TEXT.type, handleText],
|
|
1887
|
-
[mediaTypes.JSON.subtype, handleJson],
|
|
1888
|
-
[mediaTypes.BIN.subtype, handleReadableStream],
|
|
1889
|
-
[mediaTypes.HTML.subtype, handleHtml],
|
|
1890
|
-
[mediaTypes.XML.subtype, handleXml],
|
|
1891
|
-
[mediaTypes.PNG.type, handleImage],
|
|
1892
|
-
[mediaTypes.JAVA_SCRIPT.subtype, handleScript],
|
|
1893
|
-
[mediaTypes.CSS.subtype, handleCss]
|
|
1894
|
-
];
|
|
1895
|
-
/**
|
|
1896
|
-
* Create a new Transportr instance with the provided location or origin and context path.
|
|
1897
|
-
*
|
|
1898
|
-
* @param url The URL for {@link fetch} requests.
|
|
1899
|
-
* @param options The default {@link RequestOptions} for this instance.
|
|
1900
|
-
*/
|
|
1901
|
-
constructor(url = defaultOrigin, options = {}) {
|
|
1902
|
-
if (isObject(url)) {
|
|
1903
|
-
[url, options] = [defaultOrigin, url];
|
|
1904
|
-
}
|
|
1905
|
-
this._baseUrl = _Transportr.getBaseUrl(url);
|
|
1906
|
-
this._options = _Transportr.createOptions(options, _Transportr.defaultRequestOptions);
|
|
1907
|
-
this.subscribr = new d2();
|
|
1908
|
-
}
|
|
1909
|
-
/** Credentials Policy */
|
|
1910
|
-
static CredentialsPolicy = {
|
|
1911
|
-
INCLUDE: "include",
|
|
1912
|
-
OMIT: "omit",
|
|
1913
|
-
SAME_ORIGIN: "same-origin"
|
|
1914
|
-
};
|
|
1915
|
-
/** Request Mode */
|
|
1916
|
-
static RequestMode = {
|
|
1917
|
-
CORS: "cors",
|
|
1918
|
-
NAVIGATE: "navigate",
|
|
1919
|
-
NO_CORS: "no-cors",
|
|
1920
|
-
SAME_ORIGIN: "same-origin"
|
|
1921
|
-
};
|
|
1922
|
-
/** Request Priority */
|
|
1923
|
-
static RequestPriority = {
|
|
1924
|
-
HIGH: "high",
|
|
1925
|
-
LOW: "low",
|
|
1926
|
-
AUTO: "auto"
|
|
1927
|
-
};
|
|
1928
|
-
/** Redirect Policy */
|
|
1929
|
-
static RedirectPolicy = {
|
|
1930
|
-
ERROR: "error",
|
|
1931
|
-
FOLLOW: "follow",
|
|
1932
|
-
MANUAL: "manual"
|
|
1933
|
-
};
|
|
1934
|
-
/** Referrer Policy */
|
|
1935
|
-
static ReferrerPolicy = {
|
|
1936
|
-
NO_REFERRER: "no-referrer",
|
|
1937
|
-
NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade",
|
|
1938
|
-
ORIGIN: "origin",
|
|
1939
|
-
ORIGIN_WHEN_CROSS_ORIGIN: "origin-when-cross-origin",
|
|
1940
|
-
SAME_ORIGIN: "same-origin",
|
|
1941
|
-
STRICT_ORIGIN: "strict-origin",
|
|
1942
|
-
STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin",
|
|
1943
|
-
UNSAFE_URL: "unsafe-url"
|
|
1944
|
-
};
|
|
1945
|
-
/** Request Event */
|
|
1946
|
-
static RequestEvent = RequestEvent;
|
|
1947
|
-
/** Default Request Options */
|
|
1948
|
-
static defaultRequestOptions = {
|
|
1949
|
-
body: void 0,
|
|
1950
|
-
cache: RequestCachingPolicy.NO_STORE,
|
|
1951
|
-
credentials: _Transportr.CredentialsPolicy.SAME_ORIGIN,
|
|
1952
|
-
headers: new Headers({ "content-type": defaultMediaType, "accept": defaultMediaType }),
|
|
1953
|
-
searchParams: void 0,
|
|
1954
|
-
integrity: void 0,
|
|
1955
|
-
keepalive: void 0,
|
|
1956
|
-
method: "GET",
|
|
1957
|
-
mode: _Transportr.RequestMode.CORS,
|
|
1958
|
-
priority: _Transportr.RequestPriority.AUTO,
|
|
1959
|
-
redirect: _Transportr.RedirectPolicy.FOLLOW,
|
|
1960
|
-
referrer: "about:client",
|
|
1961
|
-
referrerPolicy: _Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,
|
|
1962
|
-
signal: void 0,
|
|
1963
|
-
timeout: 3e4,
|
|
1964
|
-
global: true
|
|
1965
|
-
};
|
|
1966
|
-
/**
|
|
1967
|
-
* @internal
|
|
1968
|
-
* @param event The event to subscribe to.
|
|
1969
|
-
* @param handler The event handler.
|
|
1970
|
-
* @param context The context to bind the handler to.
|
|
1971
|
-
* @returns A new {@link EventRegistration} instance.
|
|
1972
|
-
*/
|
|
1973
|
-
static register(event, handler, context) {
|
|
1974
|
-
return _Transportr.globalSubscribr.subscribe(event, handler, context);
|
|
1975
|
-
}
|
|
1976
|
-
/**
|
|
1977
|
-
* Removes a {@link EventRegistration} from the global event handler.
|
|
1978
|
-
*
|
|
1979
|
-
* @param eventRegistration The {@link EventRegistration} to remove.
|
|
1980
|
-
* @returns True if the {@link EventRegistration} was removed, false otherwise.
|
|
1981
|
-
*/
|
|
1982
|
-
static unregister(eventRegistration) {
|
|
1983
|
-
return _Transportr.globalSubscribr.unsubscribe(eventRegistration);
|
|
1984
|
-
}
|
|
1985
|
-
/**
|
|
1986
|
-
* Aborts all active requests.
|
|
1987
|
-
* This is useful for when the user navigates away from the current page.
|
|
1988
|
-
* This will also clear the {@link Transportr#signalControllers} set.
|
|
1989
|
-
*/
|
|
1990
|
-
static abortAll() {
|
|
1991
|
-
for (const signalController of this.signalControllers) {
|
|
1992
|
-
signalController.abort(abortEvent());
|
|
1993
|
-
}
|
|
1994
|
-
this.signalControllers.clear();
|
|
1995
|
-
}
|
|
1996
|
-
/**
|
|
1997
|
-
* Executes multiple requests concurrently and resolves when all complete.
|
|
1998
|
-
* @param requests An array of promises from Transportr request methods.
|
|
1999
|
-
* @returns A promise resolving to an array of all results.
|
|
2000
|
-
*/
|
|
2001
|
-
static all(requests) {
|
|
2002
|
-
return Promise.all(requests);
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* Races multiple requests concurrently. The first to settle wins; all others are aborted.
|
|
2006
|
-
* Each factory receives an AbortSignal that the caller should pass to the request options.
|
|
2007
|
-
* @template T The expected result type.
|
|
2008
|
-
* @param requests An array of functions that accept an AbortSignal and return a promise.
|
|
2009
|
-
* @returns A promise resolving to the first settled result.
|
|
2010
|
-
* @example
|
|
2011
|
-
* ```typescript
|
|
2012
|
-
* const result = await Transportr.race([
|
|
2013
|
-
* (signal) => api.getJson('/primary', { signal }),
|
|
2014
|
-
* (signal) => api.getJson('/fallback', { signal })
|
|
2015
|
-
* ]);
|
|
2016
|
-
* ```
|
|
2017
|
-
*/
|
|
2018
|
-
static async race(requests) {
|
|
2019
|
-
const controllers = [];
|
|
2020
|
-
const promises = new Array(requests.length);
|
|
2021
|
-
for (let i = 0; i < requests.length; i++) {
|
|
2022
|
-
const controller = new AbortController();
|
|
2023
|
-
controllers.push(controller);
|
|
2024
|
-
promises[i] = requests[i](controller.signal);
|
|
2025
|
-
}
|
|
2026
|
-
try {
|
|
2027
|
-
return await Promise.race(promises);
|
|
2028
|
-
} finally {
|
|
2029
|
-
for (const controller_1 of controllers) {
|
|
2030
|
-
controller_1.abort();
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* Registers a custom content-type response handler.
|
|
2036
|
-
* The handler will be matched against response content-type headers using MediaType matching.
|
|
2037
|
-
* New handlers are prepended so they take priority over built-in handlers.
|
|
2038
|
-
*
|
|
2039
|
-
* @param contentType The content-type string to match (e.g. 'application/pdf', 'text', 'csv').
|
|
2040
|
-
* @param handler The response handler function.
|
|
2041
|
-
*/
|
|
2042
|
-
static registerContentTypeHandler(contentType, handler) {
|
|
2043
|
-
_Transportr.contentTypeHandlers.unshift([contentType, handler]);
|
|
2044
|
-
}
|
|
2045
|
-
/**
|
|
2046
|
-
* Removes a previously registered content-type response handler.
|
|
2047
|
-
*
|
|
2048
|
-
* @param contentType The content-type string to remove.
|
|
2049
|
-
* @returns True if the handler was found and removed, false otherwise.
|
|
2050
|
-
*/
|
|
2051
|
-
static unregisterContentTypeHandler(contentType) {
|
|
2052
|
-
const index = _Transportr.contentTypeHandlers.findIndex(([type]) => type === contentType);
|
|
2053
|
-
if (index === -1) {
|
|
2054
|
-
return false;
|
|
2055
|
-
}
|
|
2056
|
-
_Transportr.contentTypeHandlers.splice(index, 1);
|
|
2057
|
-
return true;
|
|
2058
|
-
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Registers global lifecycle hooks that run on all requests from all instances.
|
|
2061
|
-
* Global hooks execute before instance and per-request hooks.
|
|
2062
|
-
*
|
|
2063
|
-
* @param hooks The hooks to register globally.
|
|
2064
|
-
*/
|
|
2065
|
-
static addHooks(hooks) {
|
|
2066
|
-
if (hooks.beforeRequest) {
|
|
2067
|
-
_Transportr.globalHooks.beforeRequest.push(...hooks.beforeRequest);
|
|
2068
|
-
}
|
|
2069
|
-
if (hooks.afterResponse) {
|
|
2070
|
-
_Transportr.globalHooks.afterResponse.push(...hooks.afterResponse);
|
|
2071
|
-
}
|
|
2072
|
-
if (hooks.beforeError) {
|
|
2073
|
-
_Transportr.globalHooks.beforeError.push(...hooks.beforeError);
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
/**
|
|
2077
|
-
* Removes all global lifecycle hooks.
|
|
2078
|
-
*/
|
|
2079
|
-
static clearHooks() {
|
|
2080
|
-
_Transportr.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* Tears down all global state: aborts in-flight requests, clears global event subscriptions,
|
|
2084
|
-
* hooks, in-flight deduplication map, and media type cache (retaining built-in entries).
|
|
2085
|
-
*/
|
|
2086
|
-
static unregisterAll() {
|
|
2087
|
-
_Transportr.abortAll();
|
|
2088
|
-
_Transportr.globalSubscribr = new d2();
|
|
2089
|
-
_Transportr.clearHooks();
|
|
2090
|
-
_Transportr.inflightRequests.clear();
|
|
2091
|
-
}
|
|
2092
|
-
/**
|
|
2093
|
-
* It returns the base {@link URL} for the API.
|
|
2094
|
-
*
|
|
2095
|
-
* @returns The baseUrl property.
|
|
2096
|
-
*/
|
|
2097
|
-
get baseUrl() {
|
|
2098
|
-
return this._baseUrl;
|
|
2099
|
-
}
|
|
2100
|
-
/**
|
|
2101
|
-
* @internal
|
|
2102
|
-
* @param event The event to subscribe to.
|
|
2103
|
-
* @param handler The event handler.
|
|
2104
|
-
* @param context The context to bind the handler to.
|
|
2105
|
-
* @returns An object that can be used to remove the event handler.
|
|
2106
|
-
*/
|
|
2107
|
-
register(event, handler, context) {
|
|
2108
|
-
return this.subscribr.subscribe(event, handler, context);
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Unregisters an event handler from a {@link Transportr} instance.
|
|
2112
|
-
*
|
|
2113
|
-
* @param eventRegistration The event registration to remove.
|
|
2114
|
-
* @returns True if the {@link EventRegistration} was removed, false otherwise.
|
|
2115
|
-
*/
|
|
2116
|
-
unregister(eventRegistration) {
|
|
2117
|
-
return this.subscribr.unsubscribe(eventRegistration);
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Registers instance-level lifecycle hooks that run on all requests from this instance.
|
|
2121
|
-
* Instance hooks execute after global hooks but before per-request hooks.
|
|
2122
|
-
*
|
|
2123
|
-
* @param hooks The hooks to register on this instance.
|
|
2124
|
-
* @returns This instance for method chaining.
|
|
2125
|
-
*/
|
|
2126
|
-
addHooks(hooks) {
|
|
2127
|
-
if (hooks.beforeRequest) {
|
|
2128
|
-
this.hooks.beforeRequest.push(...hooks.beforeRequest);
|
|
2129
|
-
}
|
|
2130
|
-
if (hooks.afterResponse) {
|
|
2131
|
-
this.hooks.afterResponse.push(...hooks.afterResponse);
|
|
2132
|
-
}
|
|
2133
|
-
if (hooks.beforeError) {
|
|
2134
|
-
this.hooks.beforeError.push(...hooks.beforeError);
|
|
2135
|
-
}
|
|
2136
|
-
return this;
|
|
2137
|
-
}
|
|
2138
|
-
/**
|
|
2139
|
-
* Removes all instance-level lifecycle hooks.
|
|
2140
|
-
* @returns This instance for method chaining.
|
|
2141
|
-
*/
|
|
2142
|
-
clearHooks() {
|
|
2143
|
-
this.hooks.beforeRequest.length = 0;
|
|
2144
|
-
this.hooks.afterResponse.length = 0;
|
|
2145
|
-
this.hooks.beforeError.length = 0;
|
|
2146
|
-
return this;
|
|
2147
|
-
}
|
|
2148
|
-
/**
|
|
2149
|
-
* Updates the instance's default options after construction.
|
|
2150
|
-
* Mirrors what the constructor accepts: headers and searchParams are merged onto
|
|
2151
|
-
* the existing defaults; all other options overwrite the current value; hooks
|
|
2152
|
-
* are appended via {@link addHooks}.
|
|
2153
|
-
*
|
|
2154
|
-
* @param options The options to apply. Accepts the same shape as the constructor.
|
|
2155
|
-
* @returns This instance for method chaining.
|
|
2156
|
-
*/
|
|
2157
|
-
configure({ headers, searchParams, hooks, ...options }) {
|
|
2158
|
-
if (headers) {
|
|
2159
|
-
_Transportr.mergeHeaders(this._options.headers, headers);
|
|
2160
|
-
}
|
|
2161
|
-
if (searchParams) {
|
|
2162
|
-
_Transportr.mergeSearchParams(this._options.searchParams, searchParams);
|
|
2163
|
-
}
|
|
2164
|
-
if (Object.keys(options).length > 0) {
|
|
2165
|
-
Object.assign(this._options, options);
|
|
2166
|
-
}
|
|
2167
|
-
if (hooks) {
|
|
2168
|
-
this.addHooks(hooks);
|
|
2169
|
-
}
|
|
2170
|
-
return this;
|
|
2171
|
-
}
|
|
2172
|
-
/**
|
|
2173
|
-
* Tears down this instance: clears all instance subscriptions and hooks.
|
|
2174
|
-
* The instance should not be used after calling this method.
|
|
2175
|
-
*/
|
|
2176
|
-
destroy() {
|
|
2177
|
-
this.clearHooks();
|
|
2178
|
-
this.subscribr.destroy();
|
|
2179
|
-
}
|
|
2180
|
-
/**
|
|
2181
|
-
* This function returns a promise that resolves to the result of a request to the specified path with
|
|
2182
|
-
* the specified options, where the method is GET.
|
|
2183
|
-
*
|
|
2184
|
-
* @async
|
|
2185
|
-
* @param path The path to the resource you want to get.
|
|
2186
|
-
* @param options The options for the request.
|
|
2187
|
-
* @returns A promise that resolves to the response of the request.
|
|
2188
|
-
*/
|
|
2189
|
-
async get(path, options) {
|
|
2190
|
-
return this._get(path, options);
|
|
2191
|
-
}
|
|
2192
|
-
/**
|
|
2193
|
-
* This function makes a POST request to the given path with the given body and options.
|
|
2194
|
-
*
|
|
2195
|
-
* @async
|
|
2196
|
-
* @template T The expected response type (defaults to ResponseBody)
|
|
2197
|
-
* @param path The path to the endpoint you want to call.
|
|
2198
|
-
* @param body The body of the request.
|
|
2199
|
-
* @param options The options for the request.
|
|
2200
|
-
* @returns A promise that resolves to the response body.
|
|
2201
|
-
*/
|
|
2202
|
-
async post(path, body, options) {
|
|
2203
|
-
return this.executeBodyMethod("POST", path, body, options);
|
|
2204
|
-
}
|
|
2205
|
-
/**
|
|
2206
|
-
* This function returns a promise that resolves to the result of a request to the specified path with
|
|
2207
|
-
* the specified options, where the method is PUT.
|
|
2208
|
-
*
|
|
2209
|
-
* @async
|
|
2210
|
-
* @template T The expected response type (defaults to ResponseBody)
|
|
2211
|
-
* @param path The path to the endpoint you want to call.
|
|
2212
|
-
* @param body The body of the request.
|
|
2213
|
-
* @param options The options for the request.
|
|
2214
|
-
* @returns The return value of the #request method.
|
|
2215
|
-
*/
|
|
2216
|
-
async put(path, body, options) {
|
|
2217
|
-
return this.executeBodyMethod("PUT", path, body, options);
|
|
2218
|
-
}
|
|
2219
|
-
/**
|
|
2220
|
-
* It takes a path and options, and returns a request with the method set to PATCH.
|
|
2221
|
-
*
|
|
2222
|
-
* @async
|
|
2223
|
-
* @template T The expected response type (defaults to ResponseBody)
|
|
2224
|
-
* @param path The path to the endpoint you want to hit.
|
|
2225
|
-
* @param body The body of the request.
|
|
2226
|
-
* @param options The options for the request.
|
|
2227
|
-
* @returns A promise that resolves to the response of the request.
|
|
2228
|
-
*/
|
|
2229
|
-
async patch(path, body, options) {
|
|
2230
|
-
return this.executeBodyMethod("PATCH", path, body, options);
|
|
2231
|
-
}
|
|
2232
|
-
/**
|
|
2233
|
-
* It takes a path and options, and returns a request with the method set to DELETE.
|
|
2234
|
-
*
|
|
2235
|
-
* @async
|
|
2236
|
-
* @param path The path to the resource you want to access.
|
|
2237
|
-
* @param body The body of the request.
|
|
2238
|
-
* @param options The options for the request.
|
|
2239
|
-
* @returns The result of the request.
|
|
2240
|
-
*/
|
|
2241
|
-
async delete(path, body, options) {
|
|
2242
|
-
return this.executeBodyMethod("DELETE", path, body, options);
|
|
2243
|
-
}
|
|
2244
|
-
/**
|
|
2245
|
-
* Returns the response headers of a request to the given path.
|
|
2246
|
-
*
|
|
2247
|
-
* @async
|
|
2248
|
-
* @param path The path to the resource you want to access.
|
|
2249
|
-
* @param options The options for the request.
|
|
2250
|
-
* @returns A promise that resolves to the response object.
|
|
2251
|
-
*/
|
|
2252
|
-
async head(path, options) {
|
|
2253
|
-
return this.execute(path, options, { method: "HEAD" });
|
|
2254
|
-
}
|
|
2255
|
-
/**
|
|
2256
|
-
* It returns a promise that resolves to the allowed request methods for the given resource path.
|
|
2257
|
-
*
|
|
2258
|
-
* @async
|
|
2259
|
-
* @param path The path to the resource.
|
|
2260
|
-
* @param options The options for the request.
|
|
2261
|
-
* @returns A promise that resolves to an array of allowed request methods for this resource.
|
|
2262
|
-
*/
|
|
2263
|
-
async options(path, options = {}) {
|
|
2264
|
-
if (isObject(path)) {
|
|
2265
|
-
[path, options] = [void 0, path];
|
|
2266
|
-
}
|
|
2267
|
-
const requestConfig = this.processRequestOptions(options, { method: "OPTIONS" });
|
|
2268
|
-
const { requestOptions } = requestConfig;
|
|
2269
|
-
const unwrap = requestOptions.unwrap !== false;
|
|
2270
|
-
const requestHooks = requestOptions.hooks;
|
|
2271
|
-
try {
|
|
2272
|
-
let url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
|
|
2273
|
-
const beforeRequestHookSets = [_Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest];
|
|
2274
|
-
for (const hooks of beforeRequestHookSets) {
|
|
2275
|
-
if (!hooks) {
|
|
2276
|
-
continue;
|
|
2277
|
-
}
|
|
2278
|
-
for (const hook of hooks) {
|
|
2279
|
-
const result = await hook(requestOptions, url);
|
|
2280
|
-
if (result) {
|
|
2281
|
-
Object.assign(requestOptions, result);
|
|
2282
|
-
if (result.searchParams !== void 0) {
|
|
2283
|
-
url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
|
|
2284
|
-
}
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
let response = await this._request(path, requestConfig);
|
|
2289
|
-
const afterResponseHookSets = [_Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse];
|
|
2290
|
-
for (const hooks of afterResponseHookSets) {
|
|
2291
|
-
if (!hooks) {
|
|
2292
|
-
continue;
|
|
2293
|
-
}
|
|
2294
|
-
for (const hook of hooks) {
|
|
2295
|
-
const result = await hook(response, requestOptions);
|
|
2296
|
-
if (result) {
|
|
2297
|
-
response = result;
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
const allowedMethods = response.headers.get("allow")?.split(",").map((method) => method.trim());
|
|
2302
|
-
this.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });
|
|
2303
|
-
return unwrap ? allowedMethods : [true, allowedMethods];
|
|
2304
|
-
} catch (error) {
|
|
2305
|
-
if (!unwrap) return [false, error];
|
|
2306
|
-
throw error;
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
/**
|
|
2310
|
-
* It takes a path and options, and makes a request to the server
|
|
2311
|
-
* @async
|
|
2312
|
-
* @param path The path to the endpoint you want to hit.
|
|
2313
|
-
* @param options The options for the request.
|
|
2314
|
-
* @returns The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.
|
|
2315
|
-
* @throws {HttpError} If an error occurs during the request.
|
|
2316
|
-
*/
|
|
2317
|
-
async request(path, options = {}) {
|
|
2318
|
-
if (isObject(path)) {
|
|
2319
|
-
[path, options] = [void 0, path];
|
|
2320
|
-
}
|
|
2321
|
-
const requestConfig = this.processRequestOptions(options, {});
|
|
2322
|
-
const unwrap = requestConfig.requestOptions.unwrap !== false;
|
|
2323
|
-
try {
|
|
2324
|
-
const response = await this._request(path, requestConfig);
|
|
2325
|
-
this.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });
|
|
2326
|
-
return unwrap ? response : [true, response];
|
|
2327
|
-
} catch (error) {
|
|
2328
|
-
if (!unwrap) return [false, error];
|
|
2329
|
-
throw error;
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
/**
|
|
2333
|
-
* It gets the JSON representation of the resource at the given path.
|
|
2334
|
-
*
|
|
2335
|
-
* @async
|
|
2336
|
-
* @template T The expected JSON response type (defaults to JsonObject)
|
|
2337
|
-
* @param path The path to the resource.
|
|
2338
|
-
* @param options The options object to pass to the request.
|
|
2339
|
-
* @returns A promise that resolves to the response body as a typed JSON value.
|
|
2340
|
-
*/
|
|
2341
|
-
async getJson(path, options) {
|
|
2342
|
-
return this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* It gets the XML representation of the resource at the given path.
|
|
2346
|
-
*
|
|
2347
|
-
* @async
|
|
2348
|
-
* @param path The path to the resource you want to get.
|
|
2349
|
-
* @param options The options for the request.
|
|
2350
|
-
* @returns The result of the function call to #get.
|
|
2351
|
-
*/
|
|
2352
|
-
async getXml(path, options) {
|
|
2353
|
-
return this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);
|
|
2354
|
-
}
|
|
2355
|
-
/**
|
|
2356
|
-
* Get the HTML content of the specified path.
|
|
2357
|
-
* When a selector is provided, returns only the first matching element from the parsed document.
|
|
2358
|
-
*
|
|
2359
|
-
* @async
|
|
2360
|
-
* @param path The path to the resource.
|
|
2361
|
-
* @param options The options for the request.
|
|
2362
|
-
* @param selector An optional CSS selector to extract a specific element from the parsed HTML.
|
|
2363
|
-
* @returns A promise that resolves to a Document, an Element (if selector matched), or void.
|
|
2364
|
-
*/
|
|
2365
|
-
async getHtml(path, options, selector) {
|
|
2366
|
-
const doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);
|
|
2367
|
-
if (Array.isArray(doc)) return doc;
|
|
2368
|
-
return selector && doc ? doc.querySelector(selector) : doc;
|
|
2369
|
-
}
|
|
2370
|
-
/**
|
|
2371
|
-
* It returns a promise that resolves to the HTML fragment at the given path.
|
|
2372
|
-
* When a selector is provided, returns only the first matching element from the parsed fragment.
|
|
2373
|
-
*
|
|
2374
|
-
* @async
|
|
2375
|
-
* @param path The path to the resource.
|
|
2376
|
-
* @param options The options for the request.
|
|
2377
|
-
* @param selector An optional CSS selector to extract a specific element from the parsed fragment.
|
|
2378
|
-
* @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.
|
|
2379
|
-
*/
|
|
2380
|
-
async getHtmlFragment(path, options, selector) {
|
|
2381
|
-
const fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtmlFragment);
|
|
2382
|
-
if (Array.isArray(fragment)) return fragment;
|
|
2383
|
-
return selector && fragment ? fragment.querySelector(selector) : fragment;
|
|
2384
|
-
}
|
|
2385
|
-
/**
|
|
2386
|
-
* It gets a script from the server, and appends the script to the Document HTMLHeadElement
|
|
2387
|
-
* @param path The path to the script.
|
|
2388
|
-
* @param options The options for the request.
|
|
2389
|
-
* @returns A promise that resolves to void.
|
|
2390
|
-
*/
|
|
2391
|
-
async getScript(path, options) {
|
|
2392
|
-
return this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);
|
|
2393
|
-
}
|
|
2394
|
-
/**
|
|
2395
|
-
* Gets a stylesheet from the server, and adds it as a Blob URL.
|
|
2396
|
-
* @param path The path to the stylesheet.
|
|
2397
|
-
* @param options The options for the request.
|
|
2398
|
-
* @returns A promise that resolves to void.
|
|
2399
|
-
*/
|
|
2400
|
-
async getStylesheet(path, options) {
|
|
2401
|
-
return this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);
|
|
2402
|
-
}
|
|
2403
|
-
/**
|
|
2404
|
-
* It returns a blob from the specified path.
|
|
2405
|
-
* @param path The path to the resource.
|
|
2406
|
-
* @param options The options for the request.
|
|
2407
|
-
* @returns A promise that resolves to a Blob or void.
|
|
2408
|
-
*/
|
|
2409
|
-
async getBlob(path, options) {
|
|
2410
|
-
return this._get(path, options, { headers: { accept: "application/octet-stream" } }, handleBlob);
|
|
2411
|
-
}
|
|
2412
|
-
/**
|
|
2413
|
-
* It returns a promise that resolves to an `HTMLImageElement`.
|
|
2414
|
-
* The object URL created to load the image is automatically revoked to prevent memory leaks.
|
|
2415
|
-
* Works in both browser and Node.js (via JSDOM) environments.
|
|
2416
|
-
* @param path The path to the image.
|
|
2417
|
-
* @param options The options for the request.
|
|
2418
|
-
* @returns A promise that resolves to an `HTMLImageElement` or `void`.
|
|
2419
|
-
*/
|
|
2420
|
-
async getImage(path, options) {
|
|
2421
|
-
return this._get(path, options, { headers: { accept: "image/*" } }, handleImage);
|
|
2422
|
-
}
|
|
2423
|
-
/**
|
|
2424
|
-
* It gets a buffer from the specified path
|
|
2425
|
-
* @param path The path to the resource.
|
|
2426
|
-
* @param options The options for the request.
|
|
2427
|
-
* @returns A promise that resolves to an ArrayBuffer or void.
|
|
2428
|
-
*/
|
|
2429
|
-
async getBuffer(path, options) {
|
|
2430
|
-
return this._get(path, options, { headers: { accept: "application/octet-stream" } }, handleBuffer);
|
|
2431
|
-
}
|
|
2432
|
-
/**
|
|
2433
|
-
* It returns a readable stream of the response body from the specified path.
|
|
2434
|
-
* @param path The path to the resource.
|
|
2435
|
-
* @param options The options for the request.
|
|
2436
|
-
* @returns A promise that resolves to a ReadableStream, null, or void.
|
|
2437
|
-
*/
|
|
2438
|
-
async getStream(path, options) {
|
|
2439
|
-
return this._get(path, options, { headers: { accept: "application/octet-stream" } }, handleReadableStream);
|
|
2440
|
-
}
|
|
2441
|
-
/**
|
|
2442
|
-
* Opens a Server-Sent Events stream and returns an AsyncIterable of typed events.
|
|
2443
|
-
* Follows the EventStream specification for parsing event, data, id, and retry fields.
|
|
2444
|
-
* Iteration ends when the server closes the stream or the request is aborted.
|
|
2445
|
-
*
|
|
2446
|
-
* @async
|
|
2447
|
-
* @param path The path to the SSE endpoint.
|
|
2448
|
-
* @param options The options for the request.
|
|
2449
|
-
* @returns An AsyncIterable of parsed ServerSentEvent objects.
|
|
2450
|
-
* @example
|
|
2451
|
-
* ```typescript
|
|
2452
|
-
* for await (const event of api.getEventStream('/chat/completions', { body: { prompt } })) {
|
|
2453
|
-
* console.log(event.event, event.data);
|
|
2454
|
-
* }
|
|
2455
|
-
* ```
|
|
2456
|
-
*/
|
|
2457
|
-
async getEventStream(path, options) {
|
|
2458
|
-
if (isObject(path)) {
|
|
2459
|
-
[path, options] = [void 0, path];
|
|
2460
|
-
}
|
|
2461
|
-
const requestConfig = this.processRequestOptions(options ?? {}, { method: options?.body ? "POST" : "GET", headers: { accept: `${mediaTypes.EVENT_STREAM}` } });
|
|
2462
|
-
const { requestOptions } = requestConfig;
|
|
2463
|
-
const unwrap = requestOptions.unwrap !== false;
|
|
2464
|
-
const requestHooks = requestOptions.hooks;
|
|
23
|
+
}
|
|
24
|
+
function Zt(s2) {
|
|
25
|
+
return function() {
|
|
26
|
+
for (var o = arguments.length, l = new Array(o), a = 0; a < o; a++) l[a] = arguments[a];
|
|
27
|
+
return Ue(s2, l);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function r(s2, o) {
|
|
31
|
+
let l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : pe;
|
|
32
|
+
ct && ct(s2, null);
|
|
33
|
+
let a = o.length;
|
|
34
|
+
for (; a--; ) {
|
|
35
|
+
let c = o[a];
|
|
36
|
+
if (typeof c == "string") {
|
|
37
|
+
let D2 = l(c);
|
|
38
|
+
D2 !== c && (Yt(o) || (o[a] = D2), c = D2);
|
|
39
|
+
}
|
|
40
|
+
s2[c] = true;
|
|
41
|
+
}
|
|
42
|
+
return s2;
|
|
43
|
+
}
|
|
44
|
+
function Jt(s2) {
|
|
45
|
+
for (let o = 0; o < s2.length; o++) y(s2, o) || (s2[o] = null);
|
|
46
|
+
return s2;
|
|
47
|
+
}
|
|
48
|
+
function C(s2) {
|
|
49
|
+
let o = me(null);
|
|
50
|
+
for (let [l, a] of _t(s2)) y(s2, l) && (Array.isArray(a) ? o[l] = Jt(a) : a && typeof a == "object" && a.constructor === Object ? o[l] = C(a) : o[l] = a);
|
|
51
|
+
return o;
|
|
52
|
+
}
|
|
53
|
+
function J(s2, o) {
|
|
54
|
+
for (; s2 !== null; ) {
|
|
55
|
+
let a = jt(s2, o);
|
|
56
|
+
if (a) {
|
|
57
|
+
if (a.get) return R(a.get);
|
|
58
|
+
if (typeof a.value == "function") return R(a.value);
|
|
59
|
+
}
|
|
60
|
+
s2 = Xt(s2);
|
|
61
|
+
}
|
|
62
|
+
function l() {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return l;
|
|
66
|
+
}
|
|
67
|
+
function ht() {
|
|
68
|
+
let s2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : fn(), o = (i) => ht(i);
|
|
69
|
+
if (o.version = "3.3.3", o.removed = [], !s2 || !s2.document || s2.document.nodeType !== Q.document || !s2.Element) return o.isSupported = false, o;
|
|
70
|
+
let { document: l } = s2, a = l, c = a.currentScript, { DocumentFragment: D2, HTMLTemplateElement: v2, Node: Te2, Element: Fe, NodeFilter: B2, NamedNodeMap: St = s2.NamedNodeMap || s2.MozNamedAttrMap, HTMLFormElement: Rt, DOMParser: Dt, trustedTypes: ee2 } = s2, Y2 = Fe.prototype, Ot = J(Y2, "cloneNode"), yt = J(Y2, "remove"), bt = J(Y2, "nextSibling"), Lt = J(Y2, "childNodes"), te2 = J(Y2, "parentNode");
|
|
71
|
+
if (typeof v2 == "function") {
|
|
72
|
+
let i = l.createElement("template");
|
|
73
|
+
i.content && i.content.ownerDocument && (l = i.content.ownerDocument);
|
|
74
|
+
}
|
|
75
|
+
let g, X2 = "", { implementation: de2, createNodeIterator: Nt, createDocumentFragment: Ct, getElementsByTagName: It } = l, { importNode: Mt } = a, A2 = Et();
|
|
76
|
+
o.isSupported = typeof _t == "function" && typeof te2 == "function" && de2 && de2.createHTMLDocument !== void 0;
|
|
77
|
+
let { MUSTACHE_EXPR: Ee2, ERB_EXPR: _e2, TMPLIT_EXPR: ge2, DATA_ATTR: wt, ARIA_ATTR: xt, IS_SCRIPT_OR_DATA: Pt, ATTR_WHITESPACE: He2, CUSTOM_ELEMENT: kt } = dt, { IS_ALLOWED_URI: ze } = dt, T2 = null, Ge = r({}, [...ut, ...we, ...xe, ...Pe, ...mt]), d = null, We = r({}, [...pt, ...ke, ...Tt, ...ue]), u = Object.seal(me(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false } })), j2 = null, ne = null, x = Object.seal(me(null, { tagCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeCheck: { writable: true, configurable: false, enumerable: true, value: null } })), Be = true, Ae2 = true, Ye = false, Xe = true, U2 = false, oe = true, P = false, he2 = false, Se2 = false, F2 = false, ie2 = false, ae2 = false, je2 = true, Ve = false, vt = "user-content-", Re2 = true, V2 = false, H2 = {}, L2 = null, De2 = r({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]), $e = null, qe2 = r({}, ["audio", "video", "img", "source", "image", "track"]), Oe2 = null, Ke = r({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), re = "http://www.w3.org/1998/Math/MathML", se2 = "http://www.w3.org/2000/svg", I2 = "http://www.w3.org/1999/xhtml", z2 = I2, ye2 = false, be2 = null, Ut = r({}, [re, se2, I2], Ie), le2 = r({}, ["mi", "mo", "mn", "ms", "mtext"]), ce2 = r({}, ["annotation-xml"]), Ft = r({}, ["title", "style", "font", "a", "script"]), $2 = null, Ht = ["application/xhtml+xml", "text/html"], zt = "text/html", p = null, G2 = null, Gt = l.createElement("form"), Ze = function(e) {
|
|
78
|
+
return e instanceof RegExp || e instanceof Function;
|
|
79
|
+
}, Le2 = function() {
|
|
80
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
81
|
+
if (!(G2 && G2 === e)) {
|
|
82
|
+
if ((!e || typeof e != "object") && (e = {}), e = C(e), $2 = Ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? zt : e.PARSER_MEDIA_TYPE, p = $2 === "application/xhtml+xml" ? Ie : pe, T2 = y(e, "ALLOWED_TAGS") ? r({}, e.ALLOWED_TAGS, p) : Ge, d = y(e, "ALLOWED_ATTR") ? r({}, e.ALLOWED_ATTR, p) : We, be2 = y(e, "ALLOWED_NAMESPACES") ? r({}, e.ALLOWED_NAMESPACES, Ie) : Ut, Oe2 = y(e, "ADD_URI_SAFE_ATTR") ? r(C(Ke), e.ADD_URI_SAFE_ATTR, p) : Ke, $e = y(e, "ADD_DATA_URI_TAGS") ? r(C(qe2), e.ADD_DATA_URI_TAGS, p) : qe2, L2 = y(e, "FORBID_CONTENTS") ? r({}, e.FORBID_CONTENTS, p) : De2, j2 = y(e, "FORBID_TAGS") ? r({}, e.FORBID_TAGS, p) : C({}), ne = y(e, "FORBID_ATTR") ? r({}, e.FORBID_ATTR, p) : C({}), H2 = y(e, "USE_PROFILES") ? e.USE_PROFILES : false, Be = e.ALLOW_ARIA_ATTR !== false, Ae2 = e.ALLOW_DATA_ATTR !== false, Ye = e.ALLOW_UNKNOWN_PROTOCOLS || false, Xe = e.ALLOW_SELF_CLOSE_IN_ATTR !== false, U2 = e.SAFE_FOR_TEMPLATES || false, oe = e.SAFE_FOR_XML !== false, P = e.WHOLE_DOCUMENT || false, F2 = e.RETURN_DOM || false, ie2 = e.RETURN_DOM_FRAGMENT || false, ae2 = e.RETURN_TRUSTED_TYPE || false, Se2 = e.FORCE_BODY || false, je2 = e.SANITIZE_DOM !== false, Ve = e.SANITIZE_NAMED_PROPS || false, Re2 = e.KEEP_CONTENT !== false, V2 = e.IN_PLACE || false, ze = e.ALLOWED_URI_REGEXP || gt, z2 = e.NAMESPACE || I2, le2 = e.MATHML_TEXT_INTEGRATION_POINTS || le2, ce2 = e.HTML_INTEGRATION_POINTS || ce2, u = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && Ze(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (u.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && Ze(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (u.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (u.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), U2 && (Ae2 = false), ie2 && (F2 = true), H2 && (T2 = r({}, mt), d = me(null), H2.html === true && (r(T2, ut), r(d, pt)), H2.svg === true && (r(T2, we), r(d, ke), r(d, ue)), H2.svgFilters === true && (r(T2, xe), r(d, ke), r(d, ue)), H2.mathMl === true && (r(T2, Pe), r(d, Tt), r(d, ue))), y(e, "ADD_TAGS") || (x.tagCheck = null), y(e, "ADD_ATTR") || (x.attributeCheck = null), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? x.tagCheck = e.ADD_TAGS : (T2 === Ge && (T2 = C(T2)), r(T2, e.ADD_TAGS, p))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? x.attributeCheck = e.ADD_ATTR : (d === We && (d = C(d)), r(d, e.ADD_ATTR, p))), e.ADD_URI_SAFE_ATTR && r(Oe2, e.ADD_URI_SAFE_ATTR, p), e.FORBID_CONTENTS && (L2 === De2 && (L2 = C(L2)), r(L2, e.FORBID_CONTENTS, p)), e.ADD_FORBID_CONTENTS && (L2 === De2 && (L2 = C(L2)), r(L2, e.ADD_FORBID_CONTENTS, p)), Re2 && (T2["#text"] = true), P && r(T2, ["html", "head", "body"]), T2.table && (r(T2, ["tbody"]), delete j2.tbody), e.TRUSTED_TYPES_POLICY) {
|
|
83
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
84
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
85
|
+
g = e.TRUSTED_TYPES_POLICY, X2 = g.createHTML("");
|
|
86
|
+
} else g === void 0 && (g = un(ee2, c)), g !== null && typeof X2 == "string" && (X2 = g.createHTML(""));
|
|
87
|
+
S && S(e), G2 = e;
|
|
88
|
+
}
|
|
89
|
+
}, Je = r({}, [...we, ...xe, ...Qt]), Qe = r({}, [...Pe, ...en]), Wt = function(e) {
|
|
90
|
+
let t = te2(e);
|
|
91
|
+
(!t || !t.tagName) && (t = { namespaceURI: z2, tagName: "template" });
|
|
92
|
+
let n = pe(e.tagName), f = pe(t.tagName);
|
|
93
|
+
return be2[e.namespaceURI] ? e.namespaceURI === se2 ? t.namespaceURI === I2 ? n === "svg" : t.namespaceURI === re ? n === "svg" && (f === "annotation-xml" || le2[f]) : !!Je[n] : e.namespaceURI === re ? t.namespaceURI === I2 ? n === "math" : t.namespaceURI === se2 ? n === "math" && ce2[f] : !!Qe[n] : e.namespaceURI === I2 ? t.namespaceURI === se2 && !ce2[f] || t.namespaceURI === re && !le2[f] ? false : !Qe[n] && (Ft[n] || !Je[n]) : !!($2 === "application/xhtml+xml" && be2[e.namespaceURI]) : false;
|
|
94
|
+
}, N2 = function(e) {
|
|
95
|
+
q(o.removed, { element: e });
|
|
96
|
+
try {
|
|
97
|
+
te2(e).removeChild(e);
|
|
98
|
+
} catch {
|
|
99
|
+
yt(e);
|
|
100
|
+
}
|
|
101
|
+
}, k2 = function(e, t) {
|
|
102
|
+
try {
|
|
103
|
+
q(o.removed, { attribute: t.getAttributeNode(e), from: t });
|
|
104
|
+
} catch {
|
|
105
|
+
q(o.removed, { attribute: null, from: t });
|
|
106
|
+
}
|
|
107
|
+
if (t.removeAttribute(e), e === "is") if (F2 || ie2) try {
|
|
108
|
+
N2(t);
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
else try {
|
|
112
|
+
t.setAttribute(e, "");
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
}, et = function(e) {
|
|
116
|
+
let t = null, n = null;
|
|
117
|
+
if (Se2) e = "<remove></remove>" + e;
|
|
118
|
+
else {
|
|
119
|
+
let m2 = Me(e, /^[\r\n\t ]+/);
|
|
120
|
+
n = m2 && m2[0];
|
|
121
|
+
}
|
|
122
|
+
$2 === "application/xhtml+xml" && z2 === I2 && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
|
|
123
|
+
let f = g ? g.createHTML(e) : e;
|
|
124
|
+
if (z2 === I2) try {
|
|
125
|
+
t = new Dt().parseFromString(f, $2);
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
if (!t || !t.documentElement) {
|
|
129
|
+
t = de2.createDocument(z2, "template", null);
|
|
2465
130
|
try {
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
131
|
+
t.documentElement.innerHTML = ye2 ? X2 : f;
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
let _2 = t.body || t.documentElement;
|
|
136
|
+
return e && n && _2.insertBefore(l.createTextNode(n), _2.childNodes[0] || null), z2 === I2 ? It.call(t, P ? "html" : "body")[0] : P ? t.documentElement : _2;
|
|
137
|
+
}, tt = function(e) {
|
|
138
|
+
return Nt.call(e.ownerDocument || e, e, B2.SHOW_ELEMENT | B2.SHOW_COMMENT | B2.SHOW_TEXT | B2.SHOW_PROCESSING_INSTRUCTION | B2.SHOW_CDATA_SECTION, null);
|
|
139
|
+
}, Ne2 = function(e) {
|
|
140
|
+
return e instanceof Rt && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof St) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
|
|
141
|
+
}, nt = function(e) {
|
|
142
|
+
return typeof Te2 == "function" && e instanceof Te2;
|
|
143
|
+
};
|
|
144
|
+
function M2(i, e, t) {
|
|
145
|
+
fe(i, (n) => {
|
|
146
|
+
n.call(o, e, t, G2);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
let ot = function(e) {
|
|
150
|
+
let t = null;
|
|
151
|
+
if (M2(A2.beforeSanitizeElements, e, null), Ne2(e)) return N2(e), true;
|
|
152
|
+
let n = p(e.nodeName);
|
|
153
|
+
if (M2(A2.uponSanitizeElement, e, { tagName: n, allowedTags: T2 }), oe && e.hasChildNodes() && !nt(e.firstElementChild) && h(/<[/\w!]/g, e.innerHTML) && h(/<[/\w!]/g, e.textContent) || e.nodeType === Q.progressingInstruction || oe && e.nodeType === Q.comment && h(/<[/\w]/g, e.data)) return N2(e), true;
|
|
154
|
+
if (!(x.tagCheck instanceof Function && x.tagCheck(n)) && (!T2[n] || j2[n])) {
|
|
155
|
+
if (!j2[n] && at(n) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n))) return false;
|
|
156
|
+
if (Re2 && !L2[n]) {
|
|
157
|
+
let f = te2(e) || e.parentNode, _2 = Lt(e) || e.childNodes;
|
|
158
|
+
if (_2 && f) {
|
|
159
|
+
let m2 = _2.length;
|
|
160
|
+
for (let O = m2 - 1; O >= 0; --O) {
|
|
161
|
+
let w2 = Ot(_2[O], true);
|
|
162
|
+
w2.__removalCount = (e.__removalCount || 0) + 1, f.insertBefore(w2, bt(e));
|
|
2480
163
|
}
|
|
2481
164
|
}
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
165
|
+
}
|
|
166
|
+
return N2(e), true;
|
|
167
|
+
}
|
|
168
|
+
return e instanceof Fe && !Wt(e) || (n === "noscript" || n === "noembed" || n === "noframes") && h(/<\/no(script|embed|frames)/i, e.innerHTML) ? (N2(e), true) : (U2 && e.nodeType === Q.text && (t = e.textContent, fe([Ee2, _e2, ge2], (f) => {
|
|
169
|
+
t = K(t, f, " ");
|
|
170
|
+
}), e.textContent !== t && (q(o.removed, { element: e.cloneNode() }), e.textContent = t)), M2(A2.afterSanitizeElements, e, null), false);
|
|
171
|
+
}, it = function(e, t, n) {
|
|
172
|
+
if (ne[t] || je2 && (t === "id" || t === "name") && (n in l || n in Gt)) return false;
|
|
173
|
+
if (!(Ae2 && !ne[t] && h(wt, t))) {
|
|
174
|
+
if (!(Be && h(xt, t))) {
|
|
175
|
+
if (!(x.attributeCheck instanceof Function && x.attributeCheck(t, e))) {
|
|
176
|
+
if (!d[t] || ne[t]) {
|
|
177
|
+
if (!(at(e) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, e) || u.tagNameCheck instanceof Function && u.tagNameCheck(e)) && (u.attributeNameCheck instanceof RegExp && h(u.attributeNameCheck, t) || u.attributeNameCheck instanceof Function && u.attributeNameCheck(t, e)) || t === "is" && u.allowCustomizedBuiltInElements && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n)))) return false;
|
|
178
|
+
} else if (!Oe2[t]) {
|
|
179
|
+
if (!h(ze, K(n, He2, ""))) {
|
|
180
|
+
if (!((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && qt(n, "data:") === 0 && $e[e])) {
|
|
181
|
+
if (!(Ye && !h(Pt, K(n, He2, "")))) {
|
|
182
|
+
if (n) return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
2493
185
|
}
|
|
2494
186
|
}
|
|
2495
187
|
}
|
|
2496
|
-
this.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });
|
|
2497
|
-
const stream = handleEventStream(afterResponse);
|
|
2498
|
-
return unwrap ? stream : [true, stream];
|
|
2499
|
-
} catch (error) {
|
|
2500
|
-
if (!unwrap) return [false, error];
|
|
2501
|
-
throw error;
|
|
2502
188
|
}
|
|
2503
189
|
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
if (
|
|
2523
|
-
|
|
190
|
+
return true;
|
|
191
|
+
}, at = function(e) {
|
|
192
|
+
return e !== "annotation-xml" && Me(e, kt);
|
|
193
|
+
}, rt = function(e) {
|
|
194
|
+
M2(A2.beforeSanitizeAttributes, e, null);
|
|
195
|
+
let { attributes: t } = e;
|
|
196
|
+
if (!t || Ne2(e)) return;
|
|
197
|
+
let n = { attrName: "", attrValue: "", keepAttr: true, allowedAttributes: d, forceKeepAttr: void 0 }, f = t.length;
|
|
198
|
+
for (; f--; ) {
|
|
199
|
+
let _2 = t[f], { name: m2, namespaceURI: O, value: w2 } = _2, W2 = p(m2), Ce2 = w2, E = m2 === "value" ? Ce2 : Kt(Ce2);
|
|
200
|
+
if (n.attrName = W2, n.attrValue = E, n.keepAttr = true, n.forceKeepAttr = void 0, M2(A2.uponSanitizeAttribute, e, n), E = n.attrValue, Ve && (W2 === "id" || W2 === "name") && (k2(m2, e), E = vt + E), oe && h(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, E)) {
|
|
201
|
+
k2(m2, e);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (W2 === "attributename" && Me(E, "href")) {
|
|
205
|
+
k2(m2, e);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (n.forceKeepAttr) continue;
|
|
209
|
+
if (!n.keepAttr) {
|
|
210
|
+
k2(m2, e);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (!Xe && h(/\/>/i, E)) {
|
|
214
|
+
k2(m2, e);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
U2 && fe([Ee2, _e2, ge2], (lt) => {
|
|
218
|
+
E = K(E, lt, " ");
|
|
219
|
+
});
|
|
220
|
+
let st = p(e.nodeName);
|
|
221
|
+
if (!it(st, W2, E)) {
|
|
222
|
+
k2(m2, e);
|
|
223
|
+
continue;
|
|
2524
224
|
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
try {
|
|
2530
|
-
let url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
|
|
2531
|
-
const beforeRequestHookSets = [_Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest];
|
|
2532
|
-
for (const hooks of beforeRequestHookSets) {
|
|
2533
|
-
if (!hooks) {
|
|
2534
|
-
continue;
|
|
2535
|
-
}
|
|
2536
|
-
for (const hook of hooks) {
|
|
2537
|
-
const result = await hook(requestOptions, url);
|
|
2538
|
-
if (result) {
|
|
2539
|
-
Object.assign(requestOptions, result);
|
|
2540
|
-
if (result.searchParams !== void 0) {
|
|
2541
|
-
url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
225
|
+
if (g && typeof ee2 == "object" && typeof ee2.getAttributeType == "function" && !O) switch (ee2.getAttributeType(st, W2)) {
|
|
226
|
+
case "TrustedHTML": {
|
|
227
|
+
E = g.createHTML(E);
|
|
228
|
+
break;
|
|
2545
229
|
}
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
for (const hooks of afterResponseHookSets) {
|
|
2550
|
-
if (!hooks) {
|
|
2551
|
-
continue;
|
|
2552
|
-
}
|
|
2553
|
-
for (const hook of hooks) {
|
|
2554
|
-
const result = await hook(afterResponse, requestOptions);
|
|
2555
|
-
if (result) {
|
|
2556
|
-
afterResponse = result;
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
230
|
+
case "TrustedScriptURL": {
|
|
231
|
+
E = g.createScriptURL(E);
|
|
232
|
+
break;
|
|
2559
233
|
}
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
} catch
|
|
2564
|
-
|
|
2565
|
-
throw error;
|
|
234
|
+
}
|
|
235
|
+
if (E !== Ce2) try {
|
|
236
|
+
O ? e.setAttributeNS(O, m2, E) : e.setAttribute(m2, E), Ne2(e) ? N2(e) : ft(o.removed);
|
|
237
|
+
} catch {
|
|
238
|
+
k2(m2, e);
|
|
2566
239
|
}
|
|
2567
240
|
}
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
241
|
+
M2(A2.afterSanitizeAttributes, e, null);
|
|
242
|
+
}, Bt = function i(e) {
|
|
243
|
+
let t = null, n = tt(e);
|
|
244
|
+
for (M2(A2.beforeSanitizeShadowDOM, e, null); t = n.nextNode(); ) M2(A2.uponSanitizeShadowNode, t, null), ot(t), rt(t), t.content instanceof D2 && i(t.content);
|
|
245
|
+
M2(A2.afterSanitizeShadowDOM, e, null);
|
|
246
|
+
};
|
|
247
|
+
return o.sanitize = function(i) {
|
|
248
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = null, n = null, f = null, _2 = null;
|
|
249
|
+
if (ye2 = !i, ye2 && (i = "<!-->"), typeof i != "string" && !nt(i)) if (typeof i.toString == "function") {
|
|
250
|
+
if (i = i.toString(), typeof i != "string") throw Z("dirty is not a string, aborting");
|
|
251
|
+
} else throw Z("toString is not a function");
|
|
252
|
+
if (!o.isSupported) return i;
|
|
253
|
+
if (he2 || Le2(e), o.removed = [], typeof i == "string" && (V2 = false), V2) {
|
|
254
|
+
if (i.nodeName) {
|
|
255
|
+
let w2 = p(i.nodeName);
|
|
256
|
+
if (!T2[w2] || j2[w2]) throw Z("root node is forbidden and cannot be sanitized in-place");
|
|
257
|
+
}
|
|
258
|
+
} else if (i instanceof Te2) t = et("<!---->"), n = t.ownerDocument.importNode(i, true), n.nodeType === Q.element && n.nodeName === "BODY" || n.nodeName === "HTML" ? t = n : t.appendChild(n);
|
|
259
|
+
else {
|
|
260
|
+
if (!F2 && !U2 && !P && i.indexOf("<") === -1) return g && ae2 ? g.createHTML(i) : i;
|
|
261
|
+
if (t = et(i), !t) return F2 ? null : ae2 ? X2 : "";
|
|
262
|
+
}
|
|
263
|
+
t && Se2 && N2(t.firstChild);
|
|
264
|
+
let m2 = tt(V2 ? i : t);
|
|
265
|
+
for (; f = m2.nextNode(); ) ot(f), rt(f), f.content instanceof D2 && Bt(f.content);
|
|
266
|
+
if (V2) return i;
|
|
267
|
+
if (F2) {
|
|
268
|
+
if (ie2) for (_2 = Ct.call(t.ownerDocument); t.firstChild; ) _2.appendChild(t.firstChild);
|
|
269
|
+
else _2 = t;
|
|
270
|
+
return (d.shadowroot || d.shadowrootmode) && (_2 = Mt.call(a, _2, true)), _2;
|
|
271
|
+
}
|
|
272
|
+
let O = P ? t.outerHTML : t.innerHTML;
|
|
273
|
+
return P && T2["!doctype"] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && h(At, t.ownerDocument.doctype.name) && (O = "<!DOCTYPE " + t.ownerDocument.doctype.name + `>
|
|
274
|
+
` + O), U2 && fe([Ee2, _e2, ge2], (w2) => {
|
|
275
|
+
O = K(O, w2, " ");
|
|
276
|
+
}), g && ae2 ? g.createHTML(O) : O;
|
|
277
|
+
}, o.setConfig = function() {
|
|
278
|
+
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
279
|
+
Le2(i), he2 = true;
|
|
280
|
+
}, o.clearConfig = function() {
|
|
281
|
+
G2 = null, he2 = false;
|
|
282
|
+
}, o.isValidAttribute = function(i, e, t) {
|
|
283
|
+
G2 || Le2({});
|
|
284
|
+
let n = p(i), f = p(e);
|
|
285
|
+
return it(n, f, t);
|
|
286
|
+
}, o.addHook = function(i, e) {
|
|
287
|
+
typeof e == "function" && q(A2[i], e);
|
|
288
|
+
}, o.removeHook = function(i, e) {
|
|
289
|
+
if (e !== void 0) {
|
|
290
|
+
let t = Vt(A2[i], e);
|
|
291
|
+
return t === -1 ? void 0 : $t(A2[i], t, 1)[0];
|
|
292
|
+
}
|
|
293
|
+
return ft(A2[i]);
|
|
294
|
+
}, o.removeHooks = function(i) {
|
|
295
|
+
A2[i] = [];
|
|
296
|
+
}, o.removeAllHooks = function() {
|
|
297
|
+
A2 = Et();
|
|
298
|
+
}, o;
|
|
299
|
+
}
|
|
300
|
+
var _t, ct, Yt, Xt, jt, S, b, me, ve, Ue, fe, Vt, ft, q, $t, pe, Ie, Me, K, qt, Kt, y, h, Z, ut, we, xe, Qt, Pe, en, mt, pt, ke, Tt, ue, tn, nn, on, an, rn, gt, sn, ln, At, cn, dt, Q, fn, un, Et, mn;
|
|
301
|
+
var init_OP3JQ447 = __esm({
|
|
302
|
+
"iife:/home/runner/work/transportr/transportr/dist/OP3JQ447.js"() {
|
|
303
|
+
({ entries: _t, setPrototypeOf: ct, isFrozen: Yt, getPrototypeOf: Xt, getOwnPropertyDescriptor: jt } = Object);
|
|
304
|
+
({ freeze: S, seal: b, create: me } = Object);
|
|
305
|
+
({ apply: ve, construct: Ue } = typeof Reflect < "u" && Reflect);
|
|
306
|
+
S || (S = function(o) {
|
|
307
|
+
return o;
|
|
308
|
+
});
|
|
309
|
+
b || (b = function(o) {
|
|
310
|
+
return o;
|
|
311
|
+
});
|
|
312
|
+
ve || (ve = function(o, l) {
|
|
313
|
+
for (var a = arguments.length, c = new Array(a > 2 ? a - 2 : 0), D2 = 2; D2 < a; D2++) c[D2 - 2] = arguments[D2];
|
|
314
|
+
return o.apply(l, c);
|
|
315
|
+
});
|
|
316
|
+
Ue || (Ue = function(o) {
|
|
317
|
+
for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++) a[c - 1] = arguments[c];
|
|
318
|
+
return new o(...a);
|
|
319
|
+
});
|
|
320
|
+
fe = R(Array.prototype.forEach);
|
|
321
|
+
Vt = R(Array.prototype.lastIndexOf);
|
|
322
|
+
ft = R(Array.prototype.pop);
|
|
323
|
+
q = R(Array.prototype.push);
|
|
324
|
+
$t = R(Array.prototype.splice);
|
|
325
|
+
pe = R(String.prototype.toLowerCase);
|
|
326
|
+
Ie = R(String.prototype.toString);
|
|
327
|
+
Me = R(String.prototype.match);
|
|
328
|
+
K = R(String.prototype.replace);
|
|
329
|
+
qt = R(String.prototype.indexOf);
|
|
330
|
+
Kt = R(String.prototype.trim);
|
|
331
|
+
y = R(Object.prototype.hasOwnProperty);
|
|
332
|
+
h = R(RegExp.prototype.test);
|
|
333
|
+
Z = Zt(TypeError);
|
|
334
|
+
ut = S(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
|
|
335
|
+
we = S(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
|
|
336
|
+
xe = S(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
|
|
337
|
+
Qt = S(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
|
|
338
|
+
Pe = S(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
|
|
339
|
+
en = S(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
340
|
+
mt = S(["#text"]);
|
|
341
|
+
pt = S(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
|
|
342
|
+
ke = S(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
|
|
343
|
+
Tt = S(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
|
|
344
|
+
ue = S(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
345
|
+
tn = b(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
|
|
346
|
+
nn = b(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
347
|
+
on = b(/\$\{[\w\W]*/gm);
|
|
348
|
+
an = b(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
349
|
+
rn = b(/^aria-[\-\w]+$/);
|
|
350
|
+
gt = b(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
|
|
351
|
+
sn = b(/^(?:\w+script|data):/i);
|
|
352
|
+
ln = b(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
|
|
353
|
+
At = b(/^html$/i);
|
|
354
|
+
cn = b(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
355
|
+
dt = Object.freeze({ __proto__: null, ARIA_ATTR: rn, ATTR_WHITESPACE: ln, CUSTOM_ELEMENT: cn, DATA_ATTR: an, DOCTYPE_NAME: At, ERB_EXPR: nn, IS_ALLOWED_URI: gt, IS_SCRIPT_OR_DATA: sn, MUSTACHE_EXPR: tn, TMPLIT_EXPR: on });
|
|
356
|
+
Q = { element: 1, attribute: 2, text: 3, cdataSection: 4, entityReference: 5, entityNode: 6, progressingInstruction: 7, comment: 8, document: 9, documentType: 10, documentFragment: 11, notation: 12 };
|
|
357
|
+
fn = function() {
|
|
358
|
+
return typeof window > "u" ? null : window;
|
|
359
|
+
};
|
|
360
|
+
un = function(o, l) {
|
|
361
|
+
if (typeof o != "object" || typeof o.createPolicy != "function") return null;
|
|
362
|
+
let a = null, c = "data-tt-policy-suffix";
|
|
363
|
+
l && l.hasAttribute(c) && (a = l.getAttribute(c));
|
|
364
|
+
let D2 = "dompurify" + (a ? "#" + a : "");
|
|
365
|
+
try {
|
|
366
|
+
return o.createPolicy(D2, { createHTML(v2) {
|
|
367
|
+
return v2;
|
|
368
|
+
}, createScriptURL(v2) {
|
|
369
|
+
return v2;
|
|
370
|
+
} });
|
|
371
|
+
} catch {
|
|
372
|
+
return console.warn("TrustedTypes policy " + D2 + " could not be created."), null;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
Et = function() {
|
|
376
|
+
return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] };
|
|
377
|
+
};
|
|
378
|
+
mn = ht();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// iife:/home/runner/work/transportr/transportr/dist/transportr.js
|
|
383
|
+
var L = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
|
|
384
|
+
var Ce = /(["\\])/ug;
|
|
385
|
+
var Ue2 = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
|
|
386
|
+
var ie = class ae extends Map {
|
|
387
|
+
constructor(e = []) {
|
|
388
|
+
super(e);
|
|
389
|
+
}
|
|
390
|
+
static isValid(e, t) {
|
|
391
|
+
return L.test(e) && Ue2.test(t);
|
|
392
|
+
}
|
|
393
|
+
get(e) {
|
|
394
|
+
return super.get(e.toLowerCase());
|
|
395
|
+
}
|
|
396
|
+
has(e) {
|
|
397
|
+
return super.has(e.toLowerCase());
|
|
398
|
+
}
|
|
399
|
+
set(e, t) {
|
|
400
|
+
if (!ae.isValid(e, t)) throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);
|
|
401
|
+
return super.set(e.toLowerCase(), t), this;
|
|
402
|
+
}
|
|
403
|
+
delete(e) {
|
|
404
|
+
return super.delete(e.toLowerCase());
|
|
405
|
+
}
|
|
406
|
+
toString() {
|
|
407
|
+
return Array.from(this).map(([e, t]) => `;${e}=${!t || !L.test(t) ? `"${t.replace(Ce, "\\$1")}"` : t}`).join("");
|
|
408
|
+
}
|
|
409
|
+
get [Symbol.toStringTag]() {
|
|
410
|
+
return "MediaTypeParameters";
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var xe2 = /* @__PURE__ */ new Set([" ", " ", `
|
|
414
|
+
`, "\r"]);
|
|
415
|
+
var Le = /[ \t\n\r]+$/u;
|
|
416
|
+
var Ie2 = /^[ \t\n\r]+|[ \t\n\r]+$/ug;
|
|
417
|
+
var Me2 = class w {
|
|
418
|
+
static parse(e) {
|
|
419
|
+
e = e.replace(Ie2, "");
|
|
420
|
+
let t = 0, [n, r2] = w.collect(e, t, ["/"]);
|
|
421
|
+
if (t = r2, !n.length || t >= e.length || !L.test(n)) throw new TypeError(w.generateErrorMessage("type", n));
|
|
422
|
+
++t;
|
|
423
|
+
let [o, i] = w.collect(e, t, [";"], true, true);
|
|
424
|
+
if (t = i, !o.length || !L.test(o)) throw new TypeError(w.generateErrorMessage("subtype", o));
|
|
425
|
+
let a = new ie();
|
|
426
|
+
for (; t < e.length; ) {
|
|
427
|
+
for (++t; xe2.has(e[t]); ) ++t;
|
|
428
|
+
let d;
|
|
429
|
+
if ([d, t] = w.collect(e, t, [";", "="], false), t >= e.length || e[t] === ";") continue;
|
|
430
|
+
++t;
|
|
431
|
+
let R2;
|
|
432
|
+
if (e[t] === '"') for ([R2, t] = w.collectHttpQuotedString(e, t); t < e.length && e[t] !== ";"; ) ++t;
|
|
433
|
+
else if ([R2, t] = w.collect(e, t, [";"], false, true), !R2) continue;
|
|
434
|
+
d && ie.isValid(d, R2) && !a.has(d) && a.set(d, R2);
|
|
435
|
+
}
|
|
436
|
+
return { type: n, subtype: o, parameters: a };
|
|
437
|
+
}
|
|
438
|
+
get [Symbol.toStringTag]() {
|
|
439
|
+
return "MediaTypeParser";
|
|
440
|
+
}
|
|
441
|
+
static collect(e, t, n, r2 = true, o = false) {
|
|
442
|
+
let i = "";
|
|
443
|
+
for (let { length: a } = e; t < a && !n.includes(e[t]); t++) i += e[t];
|
|
444
|
+
return r2 && (i = i.toLowerCase()), o && (i = i.replace(Le, "")), [i, t];
|
|
445
|
+
}
|
|
446
|
+
static collectHttpQuotedString(e, t) {
|
|
447
|
+
let n = "";
|
|
448
|
+
for (let r2 = e.length, o; ++t < r2 && (o = e[t]) !== '"'; ) n += o == "\\" && ++t < r2 ? e[t] : o;
|
|
449
|
+
return [n, t];
|
|
450
|
+
}
|
|
451
|
+
static generateErrorMessage(e, t) {
|
|
452
|
+
return `Invalid ${e} "${t}": only HTTP token code points are valid.`;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
var T = class ue2 {
|
|
456
|
+
_type;
|
|
457
|
+
_subtype;
|
|
458
|
+
_parameters;
|
|
459
|
+
constructor(e, t = {}) {
|
|
460
|
+
if (t === null || typeof t != "object" || Array.isArray(t)) throw new TypeError("The parameters argument must be an object");
|
|
461
|
+
({ type: this._type, subtype: this._subtype, parameters: this._parameters } = Me2.parse(e));
|
|
462
|
+
for (let [n, r2] of Object.entries(t)) this._parameters.set(n, r2);
|
|
463
|
+
}
|
|
464
|
+
static parse(e) {
|
|
465
|
+
try {
|
|
466
|
+
return new ue2(e);
|
|
467
|
+
} catch {
|
|
2579
468
|
}
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
get type() {
|
|
472
|
+
return this._type;
|
|
473
|
+
}
|
|
474
|
+
get subtype() {
|
|
475
|
+
return this._subtype;
|
|
476
|
+
}
|
|
477
|
+
get essence() {
|
|
478
|
+
return `${this._type}/${this._subtype}`;
|
|
479
|
+
}
|
|
480
|
+
get parameters() {
|
|
481
|
+
return this._parameters;
|
|
482
|
+
}
|
|
483
|
+
matches(e) {
|
|
484
|
+
return typeof e == "string" ? this.essence.includes(e) : this._type === e._type && this._subtype === e._subtype;
|
|
485
|
+
}
|
|
486
|
+
toString() {
|
|
487
|
+
return `${this.essence}${this._parameters.toString()}`;
|
|
488
|
+
}
|
|
489
|
+
get [Symbol.toStringTag]() {
|
|
490
|
+
return "MediaType";
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
var Ne = class extends Map {
|
|
494
|
+
set(s2, e) {
|
|
495
|
+
return super.set(s2, e instanceof Set ? e : (super.get(s2) ?? /* @__PURE__ */ new Set()).add(e)), this;
|
|
496
|
+
}
|
|
497
|
+
getOrInsert(s2, e) {
|
|
498
|
+
return this.has(s2) ? super.get(s2) : (super.set(s2, e instanceof Set ? e : (super.get(s2) ?? /* @__PURE__ */ new Set()).add(e)), e);
|
|
499
|
+
}
|
|
500
|
+
getOrInsertComputed(s2, e) {
|
|
501
|
+
if (this.has(s2)) return super.get(s2);
|
|
502
|
+
let t = e(s2);
|
|
503
|
+
return super.set(s2, t instanceof Set ? t : (super.get(s2) ?? /* @__PURE__ */ new Set()).add(t)), t;
|
|
504
|
+
}
|
|
505
|
+
find(s2, e) {
|
|
506
|
+
let t = this.get(s2);
|
|
507
|
+
if (t !== void 0) return Array.from(t).find(e);
|
|
508
|
+
}
|
|
509
|
+
hasValue(s2, e) {
|
|
510
|
+
let t = super.get(s2);
|
|
511
|
+
return t ? t.has(e) : false;
|
|
512
|
+
}
|
|
513
|
+
deleteValue(s2, e) {
|
|
514
|
+
if (e === void 0) return this.delete(s2);
|
|
515
|
+
let t = super.get(s2);
|
|
516
|
+
if (t) {
|
|
517
|
+
let n = t.delete(e);
|
|
518
|
+
return t.size === 0 && super.delete(s2), n;
|
|
519
|
+
}
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
get [Symbol.toStringTag]() {
|
|
523
|
+
return "SetMultiMap";
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
var De = class {
|
|
527
|
+
context;
|
|
528
|
+
eventHandler;
|
|
529
|
+
constructor(s2, e) {
|
|
530
|
+
this.context = s2, this.eventHandler = e;
|
|
531
|
+
}
|
|
532
|
+
handle(s2, e) {
|
|
533
|
+
this.eventHandler.call(this.context, s2, e);
|
|
534
|
+
}
|
|
535
|
+
get [Symbol.toStringTag]() {
|
|
536
|
+
return "ContextEventHandler";
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
var _e = class {
|
|
540
|
+
_eventName;
|
|
541
|
+
_contextEventHandler;
|
|
542
|
+
constructor(s2, e) {
|
|
543
|
+
this._eventName = s2, this._contextEventHandler = e;
|
|
544
|
+
}
|
|
545
|
+
get eventName() {
|
|
546
|
+
return this._eventName;
|
|
547
|
+
}
|
|
548
|
+
get contextEventHandler() {
|
|
549
|
+
return this._contextEventHandler;
|
|
550
|
+
}
|
|
551
|
+
get [Symbol.toStringTag]() {
|
|
552
|
+
return "Subscription";
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var I = class {
|
|
556
|
+
subscribers = new Ne();
|
|
557
|
+
errorHandler;
|
|
558
|
+
setErrorHandler(s2) {
|
|
559
|
+
this.errorHandler = s2;
|
|
560
|
+
}
|
|
561
|
+
subscribe(s2, e, t = e, n) {
|
|
562
|
+
if (this.validateEventName(s2), n?.once) {
|
|
563
|
+
let i = e;
|
|
564
|
+
e = (a, d) => {
|
|
565
|
+
i.call(t, a, d), this.unsubscribe(o);
|
|
2597
566
|
};
|
|
567
|
+
}
|
|
568
|
+
let r2 = new De(t, e);
|
|
569
|
+
this.subscribers.set(s2, r2);
|
|
570
|
+
let o = new _e(s2, r2);
|
|
571
|
+
return o;
|
|
572
|
+
}
|
|
573
|
+
unsubscribe({ eventName: s2, contextEventHandler: e }) {
|
|
574
|
+
let t = this.subscribers.get(s2) ?? /* @__PURE__ */ new Set(), n = t.delete(e);
|
|
575
|
+
return n && t.size === 0 && this.subscribers.delete(s2), n;
|
|
576
|
+
}
|
|
577
|
+
publish(s2, e = new CustomEvent(s2), t) {
|
|
578
|
+
this.validateEventName(s2), this.subscribers.get(s2)?.forEach((n) => {
|
|
2598
579
|
try {
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
580
|
+
n.handle(e, t);
|
|
581
|
+
} catch (r2) {
|
|
582
|
+
this.errorHandler ? this.errorHandler(r2, s2, e, t) : console.error(`Error in event handler for '${s2}':`, r2);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
isSubscribed({ eventName: s2, contextEventHandler: e }) {
|
|
587
|
+
return this.subscribers.get(s2)?.has(e) ?? false;
|
|
588
|
+
}
|
|
589
|
+
validateEventName(s2) {
|
|
590
|
+
if (!s2 || typeof s2 != "string") throw new TypeError("Event name must be a non-empty string");
|
|
591
|
+
if (s2.trim() !== s2) throw new Error("Event name cannot have leading or trailing whitespace");
|
|
592
|
+
}
|
|
593
|
+
destroy() {
|
|
594
|
+
this.subscribers.clear();
|
|
595
|
+
}
|
|
596
|
+
get [Symbol.toStringTag]() {
|
|
597
|
+
return "Subscribr";
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
var k = class extends Error {
|
|
601
|
+
_entity;
|
|
602
|
+
responseStatus;
|
|
603
|
+
_url;
|
|
604
|
+
_method;
|
|
605
|
+
_timing;
|
|
606
|
+
constructor(e, { message: t, cause: n, entity: r2, url: o, method: i, timing: a } = {}) {
|
|
607
|
+
super(t, { cause: n }), this._entity = r2, this.responseStatus = e, this._url = o, this._method = i, this._timing = a;
|
|
608
|
+
}
|
|
609
|
+
get entity() {
|
|
610
|
+
return this._entity;
|
|
611
|
+
}
|
|
612
|
+
get statusCode() {
|
|
613
|
+
return this.responseStatus.code;
|
|
614
|
+
}
|
|
615
|
+
get statusText() {
|
|
616
|
+
return this.responseStatus?.text;
|
|
617
|
+
}
|
|
618
|
+
get url() {
|
|
619
|
+
return this._url;
|
|
620
|
+
}
|
|
621
|
+
get method() {
|
|
622
|
+
return this._method;
|
|
623
|
+
}
|
|
624
|
+
get timing() {
|
|
625
|
+
return this._timing;
|
|
626
|
+
}
|
|
627
|
+
get name() {
|
|
628
|
+
return "HttpError";
|
|
629
|
+
}
|
|
630
|
+
get [Symbol.toStringTag]() {
|
|
631
|
+
return this.name;
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
var v = class {
|
|
635
|
+
_code;
|
|
636
|
+
_text;
|
|
637
|
+
constructor(e, t) {
|
|
638
|
+
this._code = e, this._text = t;
|
|
639
|
+
}
|
|
640
|
+
get code() {
|
|
641
|
+
return this._code;
|
|
642
|
+
}
|
|
643
|
+
get text() {
|
|
644
|
+
return this._text;
|
|
645
|
+
}
|
|
646
|
+
get [Symbol.toStringTag]() {
|
|
647
|
+
return "ResponseStatus";
|
|
648
|
+
}
|
|
649
|
+
toString() {
|
|
650
|
+
return `${this._code} ${this._text}`;
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
var q2 = { charset: "utf-8" };
|
|
654
|
+
var de = /\/$/;
|
|
655
|
+
var le = "XSRF-TOKEN";
|
|
656
|
+
var ce = "X-XSRF-TOKEN";
|
|
657
|
+
var m = { PNG: new T("image/png"), TEXT: new T("text/plain", q2), JSON: new T("application/json", q2), HTML: new T("text/html", q2), JAVA_SCRIPT: new T("text/javascript", q2), CSS: new T("text/css", q2), XML: new T("application/xml", q2), BIN: new T("application/octet-stream"), EVENT_STREAM: new T("text/event-stream", q2), NDJSON: new T("application/x-ndjson", q2) };
|
|
658
|
+
var $ = m.JSON.toString();
|
|
659
|
+
var G = globalThis.location?.origin ?? "http://localhost";
|
|
660
|
+
var pe2 = { DEFAULT: "default", FORCE_CACHE: "force-cache", NO_CACHE: "no-cache", NO_STORE: "no-store", ONLY_IF_CACHED: "only-if-cached", RELOAD: "reload" };
|
|
661
|
+
var b2 = { CONFIGURED: "configured", SUCCESS: "success", ERROR: "error", ABORTED: "aborted", TIMEOUT: "timeout", RETRY: "retry", COMPLETE: "complete", ALL_COMPLETE: "all-complete" };
|
|
662
|
+
var H = { ABORT: "abort", TIMEOUT: "timeout" };
|
|
663
|
+
var A = { ABORT: "AbortError", TIMEOUT: "TimeoutError" };
|
|
664
|
+
var U = { once: true, passive: true };
|
|
665
|
+
var M = () => new CustomEvent(H.ABORT, { detail: { cause: A.ABORT } });
|
|
666
|
+
var fe2 = () => new CustomEvent(H.TIMEOUT, { detail: { cause: A.TIMEOUT } });
|
|
667
|
+
var Re = ["POST", "PUT", "PATCH", "DELETE"];
|
|
668
|
+
var he = new v(500, "Internal Server Error");
|
|
669
|
+
var ge = new v(499, "Aborted");
|
|
670
|
+
var me2 = new v(504, "Request Timeout");
|
|
671
|
+
var X = [408, 413, 429, 500, 502, 503, 504];
|
|
672
|
+
var V = ["GET", "PUT", "HEAD", "DELETE", "OPTIONS"];
|
|
673
|
+
var N = 300;
|
|
674
|
+
var D = 2;
|
|
675
|
+
var _ = class {
|
|
676
|
+
abortSignal;
|
|
677
|
+
abortController = new AbortController();
|
|
678
|
+
events = /* @__PURE__ */ new Map();
|
|
679
|
+
constructor({ signal: e, timeout: t = 1 / 0 } = {}) {
|
|
680
|
+
if (t < 0) throw new RangeError("The timeout cannot be negative");
|
|
681
|
+
let n = [this.abortController.signal];
|
|
682
|
+
e != null && n.push(e), t !== 1 / 0 && n.push(AbortSignal.timeout(t)), (this.abortSignal = AbortSignal.any(n)).addEventListener(H.ABORT, this, U);
|
|
683
|
+
}
|
|
684
|
+
handleEvent({ target: { reason: e } }) {
|
|
685
|
+
this.abortController.signal.aborted || e instanceof DOMException && e.name === A.TIMEOUT && this.abortSignal.dispatchEvent(fe2());
|
|
686
|
+
}
|
|
687
|
+
get signal() {
|
|
688
|
+
return this.abortSignal;
|
|
689
|
+
}
|
|
690
|
+
onAbort(e) {
|
|
691
|
+
return this.addEventListener(H.ABORT, e);
|
|
692
|
+
}
|
|
693
|
+
onTimeout(e) {
|
|
694
|
+
return this.addEventListener(H.TIMEOUT, e);
|
|
695
|
+
}
|
|
696
|
+
abort(e = M()) {
|
|
697
|
+
this.abortController.abort(e.detail?.cause);
|
|
698
|
+
}
|
|
699
|
+
destroy() {
|
|
700
|
+
this.abortSignal.removeEventListener(H.ABORT, this, U);
|
|
701
|
+
for (let [e, t] of this.events) this.abortSignal.removeEventListener(t, e, U);
|
|
702
|
+
return this.events.clear(), this;
|
|
703
|
+
}
|
|
704
|
+
addEventListener(e, t) {
|
|
705
|
+
return this.abortSignal.addEventListener(e, t, U), this.events.set(t, e), this;
|
|
706
|
+
}
|
|
707
|
+
get [Symbol.toStringTag]() {
|
|
708
|
+
return "SignalController";
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
var ye;
|
|
712
|
+
var je;
|
|
713
|
+
var z = () => je ??= Promise.resolve().then(() => (init_OP3JQ447(), OP3JQ447_exports)).then(({ default: s2 }) => (e) => s2.sanitize(e));
|
|
714
|
+
var B = async () => typeof document < "u" && typeof DOMParser < "u" && typeof DocumentFragment < "u" ? Promise.resolve() : ye ??= import("jsdom").then(({ JSDOM: s2 }) => {
|
|
715
|
+
let { window: e } = new s2("<!DOCTYPE html><html><head></head><body></body></html>", { url: "http://localhost" });
|
|
716
|
+
globalThis.window = e, Object.assign(globalThis, { document: e.document, DOMParser: e.DOMParser, DocumentFragment: e.DocumentFragment });
|
|
717
|
+
}).catch(() => {
|
|
718
|
+
throw ye = void 0, new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom");
|
|
719
|
+
});
|
|
720
|
+
var be = async (s2) => await s2.text();
|
|
721
|
+
var K2 = async (s2) => {
|
|
722
|
+
await B();
|
|
723
|
+
let e = URL.createObjectURL(await s2.blob());
|
|
724
|
+
return new Promise((t, n) => {
|
|
725
|
+
let r2 = document.createElement("script");
|
|
726
|
+
Object.assign(r2, { src: e, type: "text/javascript", async: true }), r2.onload = () => {
|
|
727
|
+
URL.revokeObjectURL(e), document.head.removeChild(r2), t();
|
|
728
|
+
}, r2.onerror = () => {
|
|
729
|
+
URL.revokeObjectURL(e), document.head.removeChild(r2), n(new Error("Script failed to load"));
|
|
730
|
+
}, document.head.appendChild(r2);
|
|
731
|
+
});
|
|
732
|
+
};
|
|
733
|
+
var W = async (s2) => {
|
|
734
|
+
await B();
|
|
735
|
+
let e = URL.createObjectURL(await s2.blob());
|
|
736
|
+
return new Promise((t, n) => {
|
|
737
|
+
let r2 = document.createElement("link");
|
|
738
|
+
Object.assign(r2, { href: e, type: "text/css", rel: "stylesheet" }), r2.onload = () => t(URL.revokeObjectURL(e)), r2.onerror = () => {
|
|
739
|
+
URL.revokeObjectURL(e), document.head.removeChild(r2), n(new Error("Stylesheet load failed"));
|
|
740
|
+
}, document.head.appendChild(r2);
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
var Y = async (s2) => await s2.json();
|
|
744
|
+
var Te = async (s2) => await s2.blob();
|
|
745
|
+
var Q2 = async (s2) => {
|
|
746
|
+
await B();
|
|
747
|
+
let e = URL.createObjectURL(await s2.blob());
|
|
748
|
+
return new Promise((t, n) => {
|
|
749
|
+
let r2 = new Image();
|
|
750
|
+
r2.onload = () => {
|
|
751
|
+
URL.revokeObjectURL(e), t(r2);
|
|
752
|
+
}, r2.onerror = () => {
|
|
753
|
+
URL.revokeObjectURL(e), n(new Error("Image failed to load"));
|
|
754
|
+
}, r2.src = e;
|
|
755
|
+
});
|
|
756
|
+
};
|
|
757
|
+
var Ee = async (s2) => await s2.arrayBuffer();
|
|
758
|
+
var Z2 = async (s2) => Promise.resolve(s2.body);
|
|
759
|
+
var ee = async (s2) => {
|
|
760
|
+
await B();
|
|
761
|
+
let e = await z();
|
|
762
|
+
return new DOMParser().parseFromString(e(await s2.text()), "application/xml");
|
|
763
|
+
};
|
|
764
|
+
var te = async (s2) => {
|
|
765
|
+
await B();
|
|
766
|
+
let e = await z();
|
|
767
|
+
return new DOMParser().parseFromString(e(await s2.text()), "text/html");
|
|
768
|
+
};
|
|
769
|
+
var Se = async (s2) => {
|
|
770
|
+
await B();
|
|
771
|
+
let e = await z();
|
|
772
|
+
return document.createRange().createContextualFragment(e(await s2.text()));
|
|
773
|
+
};
|
|
774
|
+
var Oe = (s2) => ({ [Symbol.asyncIterator]() {
|
|
775
|
+
let e = s2.body.getReader(), t = new TextDecoder(), n = "", r2 = false;
|
|
776
|
+
return { async next() {
|
|
777
|
+
for (; !r2; ) {
|
|
778
|
+
let o = n.indexOf(`
|
|
779
|
+
|
|
780
|
+
`);
|
|
781
|
+
if (o !== -1) {
|
|
782
|
+
let a = n.slice(0, o);
|
|
783
|
+
n = n.slice(o + 2);
|
|
784
|
+
let d = { event: "message", data: "", id: "", retry: void 0 }, R2 = [], g = a.split(`
|
|
785
|
+
`);
|
|
786
|
+
for (let h2 = 0; h2 < g.length; h2++) {
|
|
787
|
+
let p = g[h2];
|
|
788
|
+
if (p.startsWith(":")) continue;
|
|
789
|
+
let l = p.indexOf(":"), u, c;
|
|
790
|
+
switch (l === -1 ? (u = p, c = "") : (u = p.slice(0, l), c = p.slice(l + 1), c.charCodeAt(0) === 32 && (c = c.slice(1))), u) {
|
|
791
|
+
case "event":
|
|
792
|
+
d.event = c;
|
|
793
|
+
break;
|
|
794
|
+
case "data":
|
|
795
|
+
R2.push(c);
|
|
796
|
+
break;
|
|
797
|
+
case "id":
|
|
798
|
+
d.id = c;
|
|
799
|
+
break;
|
|
800
|
+
case "retry": {
|
|
801
|
+
let S2 = parseInt(c, 10);
|
|
802
|
+
isNaN(S2) || (d.retry = S2);
|
|
803
|
+
break;
|
|
2707
804
|
}
|
|
2708
|
-
});
|
|
2709
|
-
const body = response.body.pipeThrough(transform);
|
|
2710
|
-
return new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
|
|
2711
|
-
};
|
|
2712
|
-
if (canDedupe) {
|
|
2713
|
-
const promise = doFetch();
|
|
2714
|
-
_Transportr.inflightRequests.set(dedupeKey, promise);
|
|
2715
|
-
try {
|
|
2716
|
-
const response = await promise;
|
|
2717
|
-
return wrapProgress(response);
|
|
2718
|
-
} finally {
|
|
2719
|
-
_Transportr.inflightRequests.delete(dedupeKey);
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
return wrapProgress(await doFetch());
|
|
2723
|
-
} finally {
|
|
2724
|
-
_Transportr.signalControllers.delete(signalController.destroy());
|
|
2725
|
-
if (!requestOptions.signal?.aborted) {
|
|
2726
|
-
const timing = getTiming();
|
|
2727
|
-
this.publish({ name: RequestEvent.COMPLETE, data: { timing }, global });
|
|
2728
|
-
if (_Transportr.signalControllers.size === 0) {
|
|
2729
|
-
this.publish({ name: RequestEvent.ALL_COMPLETE, global });
|
|
2730
805
|
}
|
|
2731
806
|
}
|
|
2732
|
-
|
|
807
|
+
if (d.data = R2.join(`
|
|
808
|
+
`), d.data || d.event !== "message") return { value: d, done: false };
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
let i = await e.read();
|
|
812
|
+
if (i.done) {
|
|
813
|
+
r2 = true;
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
n += t.decode(i.value, { stream: true });
|
|
817
|
+
}
|
|
818
|
+
return { value: void 0, done: true };
|
|
819
|
+
}, async return() {
|
|
820
|
+
return await e.cancel(), r2 = true, { value: void 0, done: true };
|
|
821
|
+
} };
|
|
822
|
+
} });
|
|
823
|
+
var we2 = (s2) => ({ [Symbol.asyncIterator]() {
|
|
824
|
+
let e = s2.body.getReader(), t = new TextDecoder(), n = "", r2 = false;
|
|
825
|
+
return { async next() {
|
|
826
|
+
for (; !r2; ) {
|
|
827
|
+
let o = n.indexOf(`
|
|
828
|
+
`);
|
|
829
|
+
if (o !== -1) {
|
|
830
|
+
let a = n.slice(0, o).trim();
|
|
831
|
+
if (n = n.slice(o + 1), a) return { value: JSON.parse(a), done: false };
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
let i = await e.read();
|
|
835
|
+
if (i.done) {
|
|
836
|
+
r2 = true;
|
|
837
|
+
let a = (n + t.decode()).trim();
|
|
838
|
+
if (n = "", a) return { value: JSON.parse(a), done: false };
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
n += t.decode(i.value, { stream: true });
|
|
842
|
+
}
|
|
843
|
+
return { value: void 0, done: true };
|
|
844
|
+
}, async return() {
|
|
845
|
+
return await e.cancel(), r2 = true, { value: void 0, done: true };
|
|
846
|
+
} };
|
|
847
|
+
} });
|
|
848
|
+
var ve2 = (s2) => s2 !== void 0 && Re.includes(s2);
|
|
849
|
+
var qe = (s2) => s2 instanceof FormData || s2 instanceof Blob || s2 instanceof ArrayBuffer || s2 instanceof ReadableStream || s2 instanceof URLSearchParams || ArrayBuffer.isView(s2);
|
|
850
|
+
var Pe2 = (s2) => {
|
|
851
|
+
if (typeof document > "u" || !document.cookie) return;
|
|
852
|
+
let e = `${s2}=`, t = document.cookie.split(";");
|
|
853
|
+
for (let n = 0, r2 = t.length; n < r2; n++) {
|
|
854
|
+
let o = t[n].trim();
|
|
855
|
+
if (o.startsWith(e)) return decodeURIComponent(o.slice(e.length));
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
var He = (s2) => JSON.stringify(s2);
|
|
859
|
+
var j = (s2) => s2 !== null && typeof s2 == "string";
|
|
860
|
+
var Ae = (s2) => s2 instanceof ArrayBuffer || Object.prototype.toString.call(s2) === "[object ArrayBuffer]";
|
|
861
|
+
var y2 = (s2) => s2 !== null && typeof s2 == "object" && !Array.isArray(s2) && Object.getPrototypeOf(s2) === Object.prototype;
|
|
862
|
+
var F = (...s2) => {
|
|
863
|
+
let e = s2.length;
|
|
864
|
+
if (e === 0) return;
|
|
865
|
+
if (e === 1) {
|
|
866
|
+
let [n] = s2;
|
|
867
|
+
return y2(n) ? se(n) : n;
|
|
868
|
+
}
|
|
869
|
+
let t = {};
|
|
870
|
+
for (let n of s2) {
|
|
871
|
+
if (!y2(n)) return;
|
|
872
|
+
for (let [r2, o] of Object.entries(n)) {
|
|
873
|
+
let i = t[r2];
|
|
874
|
+
Array.isArray(o) ? t[r2] = [...o, ...Array.isArray(i) ? i.filter((a) => !o.includes(a)) : []] : y2(o) ? t[r2] = y2(i) ? F(i, o) : se(o) : t[r2] = o;
|
|
2733
875
|
}
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
876
|
+
}
|
|
877
|
+
return t;
|
|
878
|
+
};
|
|
879
|
+
function se(s2) {
|
|
880
|
+
if (y2(s2)) {
|
|
881
|
+
let e = {}, t = Object.keys(s2);
|
|
882
|
+
for (let n = 0, r2 = t.length, o; n < r2; n++) o = t[n], e[o] = se(s2[o]);
|
|
883
|
+
return e;
|
|
884
|
+
}
|
|
885
|
+
return s2;
|
|
886
|
+
}
|
|
887
|
+
var ke2 = class s {
|
|
888
|
+
_baseUrl;
|
|
889
|
+
_options;
|
|
890
|
+
subscribr;
|
|
891
|
+
hooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
|
|
892
|
+
static globalSubscribr = new I();
|
|
893
|
+
static globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
|
|
894
|
+
static signalControllers = /* @__PURE__ */ new Set();
|
|
895
|
+
static inflightRequests = /* @__PURE__ */ new Map();
|
|
896
|
+
static mediaTypeCache = new Map(Object.values(m).map((e) => [e.toString(), e]));
|
|
897
|
+
static contentTypeHandlers = [[m.TEXT.type, be], [m.JSON.subtype, Y], [m.BIN.subtype, Z2], [m.HTML.subtype, te], [m.XML.subtype, ee], [m.PNG.type, Q2], [m.JAVA_SCRIPT.subtype, K2], [m.CSS.subtype, W]];
|
|
898
|
+
constructor(e = G, t = {}) {
|
|
899
|
+
y2(e) && ([e, t] = [G, e]), this._baseUrl = s.getBaseUrl(e), this._options = s.createOptions(t, s.defaultRequestOptions), this.subscribr = new I();
|
|
900
|
+
}
|
|
901
|
+
static CredentialsPolicy = { INCLUDE: "include", OMIT: "omit", SAME_ORIGIN: "same-origin" };
|
|
902
|
+
static RequestMode = { CORS: "cors", NAVIGATE: "navigate", NO_CORS: "no-cors", SAME_ORIGIN: "same-origin" };
|
|
903
|
+
static RequestPriority = { HIGH: "high", LOW: "low", AUTO: "auto" };
|
|
904
|
+
static RedirectPolicy = { ERROR: "error", FOLLOW: "follow", MANUAL: "manual" };
|
|
905
|
+
static ReferrerPolicy = { NO_REFERRER: "no-referrer", NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade", ORIGIN: "origin", ORIGIN_WHEN_CROSS_ORIGIN: "origin-when-cross-origin", SAME_ORIGIN: "same-origin", STRICT_ORIGIN: "strict-origin", STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin", UNSAFE_URL: "unsafe-url" };
|
|
906
|
+
static RequestEvent = b2;
|
|
907
|
+
static defaultRequestOptions = { body: void 0, cache: pe2.NO_STORE, credentials: s.CredentialsPolicy.SAME_ORIGIN, headers: new Headers({ "content-type": $, accept: $ }), searchParams: void 0, integrity: void 0, keepalive: void 0, method: "GET", mode: s.RequestMode.CORS, priority: s.RequestPriority.AUTO, redirect: s.RedirectPolicy.FOLLOW, referrer: "about:client", referrerPolicy: s.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN, signal: void 0, timeout: 3e4, global: true };
|
|
908
|
+
static register(e, t, n) {
|
|
909
|
+
return s.globalSubscribr.subscribe(e, t, n);
|
|
910
|
+
}
|
|
911
|
+
static unregister(e) {
|
|
912
|
+
return s.globalSubscribr.unsubscribe(e);
|
|
913
|
+
}
|
|
914
|
+
static abortAll() {
|
|
915
|
+
for (let e of this.signalControllers) e.abort(M());
|
|
916
|
+
this.signalControllers.clear();
|
|
917
|
+
}
|
|
918
|
+
static all(e) {
|
|
919
|
+
return Promise.all(e);
|
|
920
|
+
}
|
|
921
|
+
static async race(e) {
|
|
922
|
+
let t = [], n = new Array(e.length);
|
|
923
|
+
for (let r2 = 0; r2 < e.length; r2++) {
|
|
924
|
+
let o = new AbortController();
|
|
925
|
+
t.push(o), n[r2] = e[r2](o.signal);
|
|
2753
926
|
}
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
927
|
+
try {
|
|
928
|
+
return await Promise.race(n);
|
|
929
|
+
} finally {
|
|
930
|
+
for (let r2 of t) r2.abort();
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
static registerContentTypeHandler(e, t) {
|
|
934
|
+
s.contentTypeHandlers.unshift([e, t]);
|
|
935
|
+
}
|
|
936
|
+
static unregisterContentTypeHandler(e) {
|
|
937
|
+
let t = s.contentTypeHandlers.findIndex(([n]) => n === e);
|
|
938
|
+
return t === -1 ? false : (s.contentTypeHandlers.splice(t, 1), true);
|
|
939
|
+
}
|
|
940
|
+
static addHooks(e) {
|
|
941
|
+
e.beforeRequest && s.globalHooks.beforeRequest.push(...e.beforeRequest), e.afterResponse && s.globalHooks.afterResponse.push(...e.afterResponse), e.beforeError && s.globalHooks.beforeError.push(...e.beforeError);
|
|
942
|
+
}
|
|
943
|
+
static clearHooks() {
|
|
944
|
+
s.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
|
|
945
|
+
}
|
|
946
|
+
static unregisterAll() {
|
|
947
|
+
s.abortAll(), s.globalSubscribr = new I(), s.clearHooks(), s.inflightRequests.clear();
|
|
948
|
+
}
|
|
949
|
+
get baseUrl() {
|
|
950
|
+
return this._baseUrl;
|
|
951
|
+
}
|
|
952
|
+
register(e, t, n) {
|
|
953
|
+
return this.subscribr.subscribe(e, t, n);
|
|
954
|
+
}
|
|
955
|
+
unregister(e) {
|
|
956
|
+
return this.subscribr.unsubscribe(e);
|
|
957
|
+
}
|
|
958
|
+
addHooks(e) {
|
|
959
|
+
return e.beforeRequest && this.hooks.beforeRequest.push(...e.beforeRequest), e.afterResponse && this.hooks.afterResponse.push(...e.afterResponse), e.beforeError && this.hooks.beforeError.push(...e.beforeError), this;
|
|
960
|
+
}
|
|
961
|
+
clearHooks() {
|
|
962
|
+
return this.hooks.beforeRequest.length = 0, this.hooks.afterResponse.length = 0, this.hooks.beforeError.length = 0, this;
|
|
963
|
+
}
|
|
964
|
+
configure({ headers: e, searchParams: t, hooks: n, ...r2 }) {
|
|
965
|
+
return e && s.mergeHeaders(this._options.headers, e), t && s.mergeSearchParams(this._options.searchParams, t), Object.keys(r2).length > 0 && Object.assign(this._options, r2), n && this.addHooks(n), this;
|
|
966
|
+
}
|
|
967
|
+
destroy() {
|
|
968
|
+
this.clearHooks(), this.subscribr.destroy();
|
|
969
|
+
}
|
|
970
|
+
async get(e, t) {
|
|
971
|
+
return this._get(e, t);
|
|
972
|
+
}
|
|
973
|
+
async post(e, t, n) {
|
|
974
|
+
return this.executeBodyMethod("POST", e, t, n);
|
|
975
|
+
}
|
|
976
|
+
async put(e, t, n) {
|
|
977
|
+
return this.executeBodyMethod("PUT", e, t, n);
|
|
978
|
+
}
|
|
979
|
+
async patch(e, t, n) {
|
|
980
|
+
return this.executeBodyMethod("PATCH", e, t, n);
|
|
981
|
+
}
|
|
982
|
+
async delete(e, t, n) {
|
|
983
|
+
return this.executeBodyMethod("DELETE", e, t, n);
|
|
984
|
+
}
|
|
985
|
+
async head(e, t) {
|
|
986
|
+
return this.execute(e, t, { method: "HEAD" });
|
|
987
|
+
}
|
|
988
|
+
async options(e, t = {}) {
|
|
989
|
+
y2(e) && ([e, t] = [void 0, e]);
|
|
990
|
+
let n = this.processRequestOptions(t, { method: "OPTIONS" }), { requestOptions: r2 } = n, o = r2.unwrap !== false, i = r2.hooks;
|
|
991
|
+
try {
|
|
992
|
+
let a = s.createUrl(this._baseUrl, e, r2.searchParams), d = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, i?.beforeRequest];
|
|
993
|
+
for (let p of d) if (p) for (let l of p) {
|
|
994
|
+
let u = await l(r2, a);
|
|
995
|
+
u && (Object.assign(r2, u), u.searchParams !== void 0 && (a = s.createUrl(this._baseUrl, e, r2.searchParams)));
|
|
996
|
+
}
|
|
997
|
+
let R2 = await this._request(e, n), g = [s.globalHooks.afterResponse, this.hooks.afterResponse, i?.afterResponse];
|
|
998
|
+
for (let p of g) if (p) for (let l of p) {
|
|
999
|
+
let u = await l(R2, r2);
|
|
1000
|
+
u && (R2 = u);
|
|
1001
|
+
}
|
|
1002
|
+
let h2 = R2.headers.get("allow")?.split(",").map((p) => p.trim());
|
|
1003
|
+
return this.publish({ name: b2.SUCCESS, data: h2, global: t.global }), o ? h2 : [true, h2];
|
|
1004
|
+
} catch (a) {
|
|
1005
|
+
if (!o) return [false, a];
|
|
1006
|
+
throw a;
|
|
2763
1007
|
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
const [resolvedPath, resolvedBody, resolvedOptions] = isString(path) ? [path, body, options] : [void 0, path, body];
|
|
2775
|
-
return this.execute(resolvedPath, Object.assign(resolvedOptions ?? {}, { body: resolvedBody, method }), {}, responseHandler);
|
|
1008
|
+
}
|
|
1009
|
+
async request(e, t = {}) {
|
|
1010
|
+
y2(e) && ([e, t] = [void 0, e]);
|
|
1011
|
+
let n = this.processRequestOptions(t, {}), r2 = n.requestOptions.unwrap !== false;
|
|
1012
|
+
try {
|
|
1013
|
+
let o = await this._request(e, n);
|
|
1014
|
+
return this.publish({ name: b2.SUCCESS, data: o, global: t.global }), r2 ? o : [true, o];
|
|
1015
|
+
} catch (o) {
|
|
1016
|
+
if (!r2) return [false, o];
|
|
1017
|
+
throw o;
|
|
2776
1018
|
}
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
} catch (cause) {
|
|
2831
|
-
throw await this.handleError(path, response, { cause }, requestOptions);
|
|
2832
|
-
}
|
|
2833
|
-
} catch (error) {
|
|
2834
|
-
if (!unwrap) return [false, error];
|
|
2835
|
-
throw error;
|
|
2836
|
-
}
|
|
1019
|
+
}
|
|
1020
|
+
async getJson(e, t) {
|
|
1021
|
+
return this._get(e, t, { headers: { accept: `${m.JSON}` } }, Y);
|
|
1022
|
+
}
|
|
1023
|
+
async getXml(e, t) {
|
|
1024
|
+
return this._get(e, t, { headers: { accept: `${m.XML}` } }, ee);
|
|
1025
|
+
}
|
|
1026
|
+
async getHtml(e, t, n) {
|
|
1027
|
+
let r2 = await this._get(e, t, { headers: { accept: `${m.HTML}` } }, te);
|
|
1028
|
+
return Array.isArray(r2) ? r2 : n && r2 ? r2.querySelector(n) : r2;
|
|
1029
|
+
}
|
|
1030
|
+
async getHtmlFragment(e, t, n) {
|
|
1031
|
+
let r2 = await this._get(e, t, { headers: { accept: `${m.HTML}` } }, Se);
|
|
1032
|
+
return Array.isArray(r2) ? r2 : n && r2 ? r2.querySelector(n) : r2;
|
|
1033
|
+
}
|
|
1034
|
+
async getScript(e, t) {
|
|
1035
|
+
return this._get(e, t, { headers: { accept: `${m.JAVA_SCRIPT}` } }, K2);
|
|
1036
|
+
}
|
|
1037
|
+
async getStylesheet(e, t) {
|
|
1038
|
+
return this._get(e, t, { headers: { accept: `${m.CSS}` } }, W);
|
|
1039
|
+
}
|
|
1040
|
+
async getBlob(e, t) {
|
|
1041
|
+
return this._get(e, t, { headers: { accept: "application/octet-stream" } }, Te);
|
|
1042
|
+
}
|
|
1043
|
+
async getImage(e, t) {
|
|
1044
|
+
return this._get(e, t, { headers: { accept: "image/*" } }, Q2);
|
|
1045
|
+
}
|
|
1046
|
+
async getBuffer(e, t) {
|
|
1047
|
+
return this._get(e, t, { headers: { accept: "application/octet-stream" } }, Ee);
|
|
1048
|
+
}
|
|
1049
|
+
async getStream(e, t) {
|
|
1050
|
+
return this._get(e, t, { headers: { accept: "application/octet-stream" } }, Z2);
|
|
1051
|
+
}
|
|
1052
|
+
async getEventStream(e, t) {
|
|
1053
|
+
y2(e) && ([e, t] = [void 0, e]);
|
|
1054
|
+
let n = this.processRequestOptions(t ?? {}, { method: t?.body ? "POST" : "GET", headers: { accept: `${m.EVENT_STREAM}` } }), { requestOptions: r2 } = n, o = r2.unwrap !== false, i = r2.hooks;
|
|
1055
|
+
try {
|
|
1056
|
+
let a = s.createUrl(this._baseUrl, e, r2.searchParams), d = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, i?.beforeRequest];
|
|
1057
|
+
for (let l of d) if (l) for (let u of l) {
|
|
1058
|
+
let c = await u(r2, a);
|
|
1059
|
+
c && (Object.assign(r2, c), c.searchParams !== void 0 && (a = s.createUrl(this._baseUrl, e, r2.searchParams)));
|
|
1060
|
+
}
|
|
1061
|
+
let g = await this._request(e, n), h2 = [s.globalHooks.afterResponse, this.hooks.afterResponse, i?.afterResponse];
|
|
1062
|
+
for (let l of h2) if (l) for (let u of l) {
|
|
1063
|
+
let c = await u(g, r2);
|
|
1064
|
+
c && (g = c);
|
|
1065
|
+
}
|
|
1066
|
+
this.publish({ name: b2.SUCCESS, data: g, global: n.global });
|
|
1067
|
+
let p = Oe(g);
|
|
1068
|
+
return o ? p : [true, p];
|
|
1069
|
+
} catch (a) {
|
|
1070
|
+
if (!o) return [false, a];
|
|
1071
|
+
throw a;
|
|
2837
1072
|
}
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
1073
|
+
}
|
|
1074
|
+
async getJsonStream(e, t) {
|
|
1075
|
+
y2(e) && ([e, t] = [void 0, e]);
|
|
1076
|
+
let n = this.processRequestOptions(t ?? {}, { method: "GET", headers: { accept: `${m.NDJSON}` } }), { requestOptions: r2 } = n, o = r2.unwrap !== false, i = r2.hooks;
|
|
1077
|
+
try {
|
|
1078
|
+
let a = s.createUrl(this._baseUrl, e, r2.searchParams), d = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, i?.beforeRequest];
|
|
1079
|
+
for (let l of d) if (l) for (let u of l) {
|
|
1080
|
+
let c = await u(r2, a);
|
|
1081
|
+
c && (Object.assign(r2, c), c.searchParams !== void 0 && (a = s.createUrl(this._baseUrl, e, r2.searchParams)));
|
|
1082
|
+
}
|
|
1083
|
+
let g = await this._request(e, n), h2 = [s.globalHooks.afterResponse, this.hooks.afterResponse, i?.afterResponse];
|
|
1084
|
+
for (let l of h2) if (l) for (let u of l) {
|
|
1085
|
+
let c = await u(g, r2);
|
|
1086
|
+
c && (g = c);
|
|
1087
|
+
}
|
|
1088
|
+
this.publish({ name: b2.SUCCESS, data: g, global: n.global });
|
|
1089
|
+
let p = we2(g);
|
|
1090
|
+
return o ? p : [true, p];
|
|
1091
|
+
} catch (a) {
|
|
1092
|
+
if (!o) return [false, a];
|
|
1093
|
+
throw a;
|
|
2848
1094
|
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
1095
|
+
}
|
|
1096
|
+
async _get(e, t, n = {}, r2) {
|
|
1097
|
+
return this.execute(e, t, { ...n, method: "GET", body: void 0 }, r2);
|
|
1098
|
+
}
|
|
1099
|
+
async _request(e, { signalController: t, requestOptions: n, global: r2 }) {
|
|
1100
|
+
s.signalControllers.add(t);
|
|
1101
|
+
let o = s.normalizeRetryOptions(n.retry), i = n.method ?? "GET", a = o.limit > 0 && o.methods.includes(i), d = n.dedupe === true && (i === "GET" || i === "HEAD"), R2 = 0, g = performance.now(), h2 = () => {
|
|
1102
|
+
let p = performance.now();
|
|
1103
|
+
return { start: g, end: p, duration: p - g };
|
|
1104
|
+
};
|
|
1105
|
+
try {
|
|
1106
|
+
let p = s.createUrl(this._baseUrl, e, n.searchParams), l = d ? `${i}:${p.href}` : "";
|
|
1107
|
+
if (d) {
|
|
1108
|
+
let f = s.inflightRequests.get(l);
|
|
1109
|
+
if (f) return (await f).clone();
|
|
1110
|
+
}
|
|
1111
|
+
let u = n.body, c = n.onUploadProgress, S2 = async () => {
|
|
1112
|
+
if (!c || u == null) return;
|
|
1113
|
+
let f = null;
|
|
1114
|
+
if (typeof u == "string") f = new TextEncoder().encode(u);
|
|
1115
|
+
else if (u instanceof Blob) f = new Uint8Array(await u.arrayBuffer());
|
|
1116
|
+
else if (Ae(u)) f = new Uint8Array(u);
|
|
1117
|
+
else if (ArrayBuffer.isView(u)) f = new Uint8Array(u.buffer, u.byteOffset, u.byteLength);
|
|
1118
|
+
else if (!(u instanceof ReadableStream)) return;
|
|
1119
|
+
let E = f ? f.byteLength : null, x = f ? new ReadableStream({ start(P) {
|
|
1120
|
+
P.enqueue(f), P.close();
|
|
1121
|
+
} }) : u, O = 0, C2 = new TransformStream({ transform(P, J2) {
|
|
1122
|
+
O += P.byteLength, c({ loaded: O, total: E, percentage: E !== null && E > 0 ? Math.round(O / E * 100) : null }), J2.enqueue(P);
|
|
1123
|
+
} });
|
|
1124
|
+
n.body = x.pipeThrough(C2), Object.assign(n, { duplex: "half" });
|
|
1125
|
+
}, ne = async () => {
|
|
1126
|
+
for (; ; ) try {
|
|
1127
|
+
await S2();
|
|
1128
|
+
let f = await fetch(p, n);
|
|
1129
|
+
if (!f.ok) {
|
|
1130
|
+
if (a && R2 < o.limit && o.statusCodes.includes(f.status)) {
|
|
1131
|
+
R2++, this.publish({ name: b2.RETRY, data: { attempt: R2, status: f.status, method: i, path: e, timing: h2() }, global: r2 }), await s.retryDelay(o, R2);
|
|
1132
|
+
continue;
|
|
2870
1133
|
}
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
}
|
|
2876
|
-
/**
|
|
2877
|
-
* Merges user and request search parameters into the target URLSearchParams object.
|
|
2878
|
-
* @param target The target URLSearchParams object.
|
|
2879
|
-
* @param sources The search parameters to merge.
|
|
2880
|
-
* @returns The merged URLSearchParams object.
|
|
2881
|
-
*/
|
|
2882
|
-
static mergeSearchParams(target, ...sources) {
|
|
2883
|
-
for (const searchParams of sources) {
|
|
2884
|
-
if (searchParams === void 0) {
|
|
2885
|
-
continue;
|
|
2886
|
-
}
|
|
2887
|
-
if (searchParams instanceof URLSearchParams) {
|
|
2888
|
-
searchParams.forEach((value, name) => target.set(name, value));
|
|
2889
|
-
} else if (isString(searchParams) || Array.isArray(searchParams)) {
|
|
2890
|
-
for (const [name, value] of new URLSearchParams(searchParams)) {
|
|
2891
|
-
target.set(name, value);
|
|
2892
|
-
}
|
|
2893
|
-
} else {
|
|
2894
|
-
const keys = Object.keys(searchParams);
|
|
2895
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2896
|
-
const name = keys[i];
|
|
2897
|
-
const value = searchParams[name];
|
|
2898
|
-
if (value !== void 0) {
|
|
2899
|
-
target.set(name, String(value));
|
|
1134
|
+
let E;
|
|
1135
|
+
try {
|
|
1136
|
+
E = await f.text();
|
|
1137
|
+
} catch {
|
|
2900
1138
|
}
|
|
1139
|
+
throw await this.handleError(e, f, { entity: E, url: p, method: i, timing: h2() }, n);
|
|
2901
1140
|
}
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
// Spread user options (shallow merge, sufficient for flat properties)
|
|
2919
|
-
...userOptions,
|
|
2920
|
-
// Spread method-specific options (e.g., method: 'POST')
|
|
2921
|
-
...options,
|
|
2922
|
-
// Deep merge required for headers and searchParams
|
|
2923
|
-
headers: _Transportr.mergeHeaders(new Headers(), this._options.headers, userHeaders, headers),
|
|
2924
|
-
searchParams: _Transportr.mergeSearchParams(new URLSearchParams(), this._options.searchParams, userSearchParams, searchParams)
|
|
1141
|
+
return f;
|
|
1142
|
+
} catch (f) {
|
|
1143
|
+
if (f instanceof k) throw f;
|
|
1144
|
+
if (a && R2 < o.limit) {
|
|
1145
|
+
R2++, this.publish({ name: b2.RETRY, data: { attempt: R2, error: f.message, method: i, path: e, timing: h2() }, global: r2 }), await s.retryDelay(o, R2);
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
throw await this.handleError(e, void 0, { cause: f, url: p, method: i, timing: h2() }, n);
|
|
1149
|
+
}
|
|
1150
|
+
}, re = (f) => {
|
|
1151
|
+
let E = n.onDownloadProgress;
|
|
1152
|
+
if (!E || !f.body) return f;
|
|
1153
|
+
let x = f.headers.get("content-length"), O = x ? parseInt(x, 10) : null, C2 = 0, P = new TransformStream({ transform(oe, Be) {
|
|
1154
|
+
C2 += oe.byteLength, E({ loaded: C2, total: O, percentage: O !== null && O > 0 ? Math.round(C2 / O * 100) : null }), Be.enqueue(oe);
|
|
1155
|
+
} }), J2 = f.body.pipeThrough(P);
|
|
1156
|
+
return new Response(J2, { status: f.status, statusText: f.statusText, headers: f.headers });
|
|
2925
1157
|
};
|
|
2926
|
-
if (
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
Object.assign(requestOptions, { body: isJson && isObject(body) ? serialize(body) : body });
|
|
2935
|
-
}
|
|
2936
|
-
} else {
|
|
2937
|
-
requestOptions.headers.delete("content-type");
|
|
2938
|
-
if (requestOptions.body instanceof URLSearchParams) {
|
|
2939
|
-
_Transportr.mergeSearchParams(requestOptions.searchParams, requestOptions.body);
|
|
2940
|
-
}
|
|
2941
|
-
requestOptions.body = void 0;
|
|
2942
|
-
}
|
|
2943
|
-
const { signal, timeout, global = false, xsrf } = requestOptions;
|
|
2944
|
-
if (xsrf) {
|
|
2945
|
-
const { cookieName, headerName } = typeof xsrf === "object" ? xsrf : {};
|
|
2946
|
-
const token = getCookieValue(cookieName ?? XSRF_COOKIE_NAME);
|
|
2947
|
-
if (token) {
|
|
2948
|
-
requestOptions.headers.set(headerName ?? XSRF_HEADER_NAME, token);
|
|
1158
|
+
if (d) {
|
|
1159
|
+
let f = ne();
|
|
1160
|
+
s.inflightRequests.set(l, f);
|
|
1161
|
+
try {
|
|
1162
|
+
let E = await f;
|
|
1163
|
+
return re(E);
|
|
1164
|
+
} finally {
|
|
1165
|
+
s.inflightRequests.delete(l);
|
|
2949
1166
|
}
|
|
2950
1167
|
}
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
/**
|
|
2957
|
-
* Gets the base URL from a URL or string.
|
|
2958
|
-
* @param url The URL or string to parse.
|
|
2959
|
-
* @returns The base URL.
|
|
2960
|
-
*/
|
|
2961
|
-
static getBaseUrl(url) {
|
|
2962
|
-
if (url instanceof URL) {
|
|
2963
|
-
return url;
|
|
2964
|
-
}
|
|
2965
|
-
if (!isString(url)) {
|
|
2966
|
-
throw new TypeError("Invalid URL");
|
|
1168
|
+
return re(await ne());
|
|
1169
|
+
} finally {
|
|
1170
|
+
if (s.signalControllers.delete(t.destroy()), !n.signal?.aborted) {
|
|
1171
|
+
let p = h2();
|
|
1172
|
+
this.publish({ name: b2.COMPLETE, data: { timing: p }, global: r2 }), s.signalControllers.size === 0 && this.publish({ name: b2.ALL_COMPLETE, global: r2 });
|
|
2967
1173
|
}
|
|
2968
|
-
return new URL(url, url.startsWith("/") ? globalThis.location.origin : void 0);
|
|
2969
1174
|
}
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
1175
|
+
}
|
|
1176
|
+
static normalizeRetryOptions(e) {
|
|
1177
|
+
return e === void 0 ? { limit: 0, statusCodes: [], methods: [], delay: N, backoffFactor: D } : typeof e == "number" ? { limit: e, statusCodes: [...X], methods: [...V], delay: N, backoffFactor: D } : { limit: e.limit ?? 0, statusCodes: e.statusCodes ?? [...X], methods: e.methods ?? [...V], delay: e.delay ?? N, backoffFactor: e.backoffFactor ?? D };
|
|
1178
|
+
}
|
|
1179
|
+
static retryDelay(e, t) {
|
|
1180
|
+
let n = typeof e.delay == "function" ? e.delay(t) : e.delay * e.backoffFactor ** (t - 1);
|
|
1181
|
+
return new Promise((r2) => setTimeout(r2, n));
|
|
1182
|
+
}
|
|
1183
|
+
executeBodyMethod(e, t, n, r2, o) {
|
|
1184
|
+
let [i, a, d] = j(t) ? [t, n, r2] : [void 0, t, n];
|
|
1185
|
+
return this.execute(i, Object.assign(d ?? {}, { body: a, method: e }), {}, o);
|
|
1186
|
+
}
|
|
1187
|
+
async execute(e, t = {}, n = {}, r2) {
|
|
1188
|
+
y2(e) && ([e, t] = [void 0, e]);
|
|
1189
|
+
let o = this.processRequestOptions(t, n), { requestOptions: i } = o, a = i.unwrap !== false, d = i.hooks;
|
|
1190
|
+
try {
|
|
1191
|
+
let R2 = s.createUrl(this._baseUrl, e, i.searchParams), g = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, d?.beforeRequest];
|
|
1192
|
+
for (let l of g) if (l) for (let u of l) {
|
|
1193
|
+
let c = await u(i, R2);
|
|
1194
|
+
c && (Object.assign(i, c), c.searchParams !== void 0 && (R2 = s.createUrl(this._baseUrl, e, i.searchParams)));
|
|
1195
|
+
}
|
|
1196
|
+
let h2 = await this._request(e, o), p = [s.globalHooks.afterResponse, this.hooks.afterResponse, d?.afterResponse];
|
|
1197
|
+
for (let l of p) if (l) for (let u of l) {
|
|
1198
|
+
let c = await u(h2, i);
|
|
1199
|
+
c && (h2 = c);
|
|
2994
1200
|
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
* @param searchParams The search parameters to append to the URL.
|
|
3002
|
-
* @returns A new URL with the given path and search parameters.
|
|
3003
|
-
*/
|
|
3004
|
-
static createUrl(url, path, searchParams) {
|
|
3005
|
-
const requestUrl = path ? new URL(`${url.pathname.replace(endsWithSlashRegEx, "")}${path}`, url.origin) : new URL(url);
|
|
3006
|
-
if (searchParams) {
|
|
3007
|
-
_Transportr.mergeSearchParams(requestUrl.searchParams, searchParams);
|
|
1201
|
+
try {
|
|
1202
|
+
!r2 && h2.status !== 204 && (r2 = this.getResponseHandler(h2.headers.get("content-type")));
|
|
1203
|
+
let l = await r2?.(h2);
|
|
1204
|
+
return this.publish({ name: b2.SUCCESS, data: l, global: o.global }), a ? l : [true, l];
|
|
1205
|
+
} catch (l) {
|
|
1206
|
+
throw await this.handleError(e, h2, { cause: l }, i);
|
|
3008
1207
|
}
|
|
3009
|
-
|
|
1208
|
+
} catch (R2) {
|
|
1209
|
+
if (!a) return [false, R2];
|
|
1210
|
+
throw R2;
|
|
3010
1211
|
}
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
return aborted;
|
|
3021
|
-
case SignalErrors.TIMEOUT:
|
|
3022
|
-
return timedOut;
|
|
3023
|
-
default:
|
|
3024
|
-
return status >= 400 ? new ResponseStatus(status, statusText) : internalServerError;
|
|
3025
|
-
}
|
|
1212
|
+
}
|
|
1213
|
+
static createOptions({ headers: e, searchParams: t, ...n }, { headers: r2, searchParams: o, ...i }) {
|
|
1214
|
+
return r2 = s.mergeHeaders(new Headers(), e, r2), o = s.mergeSearchParams(new URLSearchParams(), t, o), { ...F(i, n), headers: r2, searchParams: o };
|
|
1215
|
+
}
|
|
1216
|
+
static mergeHeaders(e, ...t) {
|
|
1217
|
+
for (let n of t) if (n !== void 0) {
|
|
1218
|
+
if (n instanceof Headers) n.forEach((r2, o) => e.set(o, r2));
|
|
1219
|
+
else if (Array.isArray(n)) for (let [r2, o] of n) e.set(r2, o);
|
|
1220
|
+
else if (y2(n)) for (let [r2, o] of Object.entries(n)) o !== void 0 && e.set(r2, o);
|
|
3026
1221
|
}
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
let error = new HttpError(_Transportr.generateResponseStatusFromError(cause?.name, response), { message, cause, entity, url, method, timing });
|
|
3038
|
-
const beforeErrorHookSets = [_Transportr.globalHooks.beforeError, this.hooks.beforeError, requestOptions?.hooks?.beforeError];
|
|
3039
|
-
for (const hooks of beforeErrorHookSets) {
|
|
3040
|
-
if (!hooks) {
|
|
3041
|
-
continue;
|
|
3042
|
-
}
|
|
3043
|
-
for (const hook of hooks) {
|
|
3044
|
-
const result = await hook(error);
|
|
3045
|
-
if (result instanceof HttpError) {
|
|
3046
|
-
error = result;
|
|
3047
|
-
}
|
|
3048
|
-
}
|
|
1222
|
+
return e;
|
|
1223
|
+
}
|
|
1224
|
+
static mergeSearchParams(e, ...t) {
|
|
1225
|
+
for (let n of t) if (n !== void 0) if (n instanceof URLSearchParams) n.forEach((r2, o) => e.set(o, r2));
|
|
1226
|
+
else if (j(n) || Array.isArray(n)) for (let [r2, o] of new URLSearchParams(n)) e.set(r2, o);
|
|
1227
|
+
else {
|
|
1228
|
+
let r2 = Object.keys(n);
|
|
1229
|
+
for (let o = 0; o < r2.length; o++) {
|
|
1230
|
+
let i = r2[o], a = n[i];
|
|
1231
|
+
a !== void 0 && e.set(i, String(a));
|
|
3049
1232
|
}
|
|
3050
|
-
this.publish({ name: RequestEvent.ERROR, data: error });
|
|
3051
|
-
return error;
|
|
3052
1233
|
}
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
}
|
|
3061
|
-
|
|
1234
|
+
return e;
|
|
1235
|
+
}
|
|
1236
|
+
processRequestOptions({ body: e, headers: t, searchParams: n, ...r2 }, { headers: o, searchParams: i, ...a }) {
|
|
1237
|
+
let d = { ...this._options, ...r2, ...a, headers: s.mergeHeaders(new Headers(), this._options.headers, t, o), searchParams: s.mergeSearchParams(new URLSearchParams(), this._options.searchParams, n, i) };
|
|
1238
|
+
if (ve2(d.method)) if (qe(e)) Object.assign(d, { body: e }), d.headers.delete("content-type");
|
|
1239
|
+
else {
|
|
1240
|
+
let u = this._options.body, c = y2(u) && y2(e) ? F(u, e) : e !== void 0 ? e : u, S2 = d.headers.get("content-type")?.includes("json") ?? false;
|
|
1241
|
+
Object.assign(d, { body: S2 && y2(c) ? He(c) : c });
|
|
1242
|
+
}
|
|
1243
|
+
else d.headers.delete("content-type"), d.body instanceof URLSearchParams && s.mergeSearchParams(d.searchParams, d.body), d.body = void 0;
|
|
1244
|
+
let { signal: R2, timeout: g, global: h2 = false, xsrf: p } = d;
|
|
1245
|
+
if (p) {
|
|
1246
|
+
let { cookieName: u, headerName: c } = typeof p == "object" ? p : {}, S2 = Pe2(u ?? le);
|
|
1247
|
+
S2 && d.headers.set(c ?? ce, S2);
|
|
1248
|
+
}
|
|
1249
|
+
let l = new _({ signal: R2, timeout: g }).onAbort((u) => this.publish({ name: b2.ABORTED, event: u, global: h2 })).onTimeout((u) => this.publish({ name: b2.TIMEOUT, event: u, global: h2 }));
|
|
1250
|
+
return d.signal = l.signal, this.publish({ name: b2.CONFIGURED, data: d, global: h2 }), { signalController: l, requestOptions: d, global: h2 };
|
|
1251
|
+
}
|
|
1252
|
+
static getBaseUrl(e) {
|
|
1253
|
+
if (e instanceof URL) return e;
|
|
1254
|
+
if (!j(e)) throw new TypeError("Invalid URL");
|
|
1255
|
+
return new URL(e, e.startsWith("/") ? globalThis.location.origin : void 0);
|
|
1256
|
+
}
|
|
1257
|
+
static getOrParseMediaType(e) {
|
|
1258
|
+
if (e === null) return;
|
|
1259
|
+
let t = s.mediaTypeCache.get(e);
|
|
1260
|
+
if (t !== void 0) return t;
|
|
1261
|
+
if (t = T.parse(e) ?? void 0, t !== void 0) {
|
|
1262
|
+
if (s.mediaTypeCache.size >= 100) {
|
|
1263
|
+
let n = s.mediaTypeCache.keys().next();
|
|
1264
|
+
n.done || s.mediaTypeCache.delete(n.value);
|
|
1265
|
+
}
|
|
1266
|
+
s.mediaTypeCache.set(e, t);
|
|
1267
|
+
}
|
|
1268
|
+
return t;
|
|
1269
|
+
}
|
|
1270
|
+
static createUrl(e, t, n) {
|
|
1271
|
+
let r2 = t ? new URL(`${e.pathname.replace(de, "")}${t}`, e.origin) : new URL(e);
|
|
1272
|
+
return n && s.mergeSearchParams(r2.searchParams, n), r2;
|
|
1273
|
+
}
|
|
1274
|
+
static generateResponseStatusFromError(e, { status: t, statusText: n } = new Response()) {
|
|
1275
|
+
switch (e) {
|
|
1276
|
+
case A.ABORT:
|
|
1277
|
+
return ge;
|
|
1278
|
+
case A.TIMEOUT:
|
|
1279
|
+
return me2;
|
|
1280
|
+
default:
|
|
1281
|
+
return t >= 400 ? new v(t, n) : he;
|
|
3062
1282
|
}
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
if (!contentType) {
|
|
3070
|
-
return;
|
|
3071
|
-
}
|
|
3072
|
-
const mediaType = _Transportr.getOrParseMediaType(contentType);
|
|
3073
|
-
if (!mediaType) {
|
|
3074
|
-
return;
|
|
3075
|
-
}
|
|
3076
|
-
for (const [contentType2, responseHandler] of _Transportr.contentTypeHandlers) {
|
|
3077
|
-
if (mediaType.matches(contentType2)) {
|
|
3078
|
-
return responseHandler;
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
return void 0;
|
|
1283
|
+
}
|
|
1284
|
+
async handleError(e, t, { cause: n, entity: r2, url: o, method: i, timing: a } = {}, d) {
|
|
1285
|
+
let R2 = i && o ? `${i} ${o.href} failed${t ? ` with status ${t.status}` : ""}` : `An error has occurred with your request to: '${e}'`, g = new k(s.generateResponseStatusFromError(n?.name, t), { message: R2, cause: n, entity: r2, url: o, method: i, timing: a }), h2 = [s.globalHooks.beforeError, this.hooks.beforeError, d?.hooks?.beforeError];
|
|
1286
|
+
for (let p of h2) if (p) for (let l of p) {
|
|
1287
|
+
let u = await l(g);
|
|
1288
|
+
u instanceof k && (g = u);
|
|
3082
1289
|
}
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
1290
|
+
return this.publish({ name: b2.ERROR, data: g }), g;
|
|
1291
|
+
}
|
|
1292
|
+
publish({ name: e, event: t = new CustomEvent(e), data: n, global: r2 = true }) {
|
|
1293
|
+
r2 && s.globalSubscribr.publish(e, t, n), this.subscribr.publish(e, t, n);
|
|
1294
|
+
}
|
|
1295
|
+
getResponseHandler(e) {
|
|
1296
|
+
if (!e) return;
|
|
1297
|
+
let t = s.getOrParseMediaType(e);
|
|
1298
|
+
if (t) {
|
|
1299
|
+
for (let [n, r2] of s.contentTypeHandlers) if (t.matches(n)) return r2;
|
|
3089
1300
|
}
|
|
3090
|
-
}
|
|
3091
|
-
|
|
1301
|
+
}
|
|
1302
|
+
get [Symbol.toStringTag]() {
|
|
1303
|
+
return "Transportr";
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
Object.assign(globalThis, { ke2 });
|
|
3092
1307
|
})();
|
|
3093
1308
|
/*! Bundled license information:
|
|
3094
1309
|
|
|
3095
1310
|
dompurify/dist/purify.es.mjs:
|
|
3096
1311
|
(*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE *)
|
|
3097
1312
|
*/
|
|
3098
|
-
globalThis.Transportr = __mod.Transportr;
|