msw 0.33.2 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/RequestHandler-deps.js +447 -82
- package/lib/esm/errors-deps.js +15 -1
- package/lib/esm/fetch-deps.js +9 -5
- package/lib/esm/graphql-deps.js +15 -10
- package/lib/esm/graphql.js +1 -0
- package/lib/esm/index-deps.js +2 -1
- package/lib/esm/index.js +90 -3880
- package/lib/esm/index2.js +1 -1
- package/lib/esm/mockServiceWorker.js +21 -12
- package/lib/esm/rest-deps.js +8 -15
- package/lib/esm/rest.js +1 -0
- package/lib/iife/index.js +3 -3
- package/lib/iife/mockServiceWorker.js +21 -12
- package/lib/types/context/data.d.ts +2 -3
- package/lib/types/context/extensions.d.ts +8 -0
- package/lib/types/context/index.d.ts +1 -0
- package/lib/types/graphql.d.ts +2 -1
- package/lib/types/handlers/GraphQLHandler.d.ts +5 -4
- package/lib/types/handlers/RequestHandler.d.ts +1 -1
- package/lib/types/handlers/RestHandler.d.ts +8 -10
- package/lib/types/index.d.ts +17 -7
- package/lib/types/node/glossary.d.ts +4 -14
- package/lib/types/node/index.d.ts +1 -1
- package/lib/types/rest.d.ts +10 -9
- package/lib/types/setupWorker/glossary.d.ts +16 -26
- package/lib/types/setupWorker/start/utils/prepareStartHandler.d.ts +3 -3
- package/lib/types/sharedOptions.d.ts +12 -1
- package/lib/types/typeUtils.d.ts +5 -3
- package/lib/types/utils/handleRequest.d.ts +4 -4
- package/lib/types/utils/internal/getCallFrame.d.ts +1 -1
- package/lib/types/utils/internal/jsonParse.d.ts +2 -2
- package/lib/types/utils/internal/pipeEvents.d.ts +6 -0
- package/lib/types/utils/logging/prepareResponse.d.ts +1 -1
- package/lib/types/utils/matching/matchRequestUrl.d.ts +12 -2
- package/lib/types/utils/matching/normalizePath.d.ts +1 -1
- package/lib/types/utils/request/parseBody.d.ts +2 -2
- package/lib/types/utils/request/parseWorkerRequest.d.ts +2 -2
- package/lib/types/utils/worker/createFallbackRequestListener.d.ts +2 -1
- package/lib/types/utils/worker/createRequestListener.d.ts +2 -1
- package/lib/umd/index.js +1131 -249
- package/lib/umd/mockServiceWorker.js +21 -12
- package/native/lib/index.js +551 -508
- package/node/lib/index.js +553 -510
- package/package.json +19 -19
package/lib/umd/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MockServiceWorker = {}));
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var statuses = {
|
|
8
8
|
"100": "Continue",
|
|
@@ -652,7 +652,7 @@
|
|
|
652
652
|
* @public
|
|
653
653
|
*/
|
|
654
654
|
|
|
655
|
-
var parse_1 = parse$
|
|
655
|
+
var parse_1 = parse$5;
|
|
656
656
|
var serialize_1 = serialize;
|
|
657
657
|
|
|
658
658
|
/**
|
|
@@ -686,7 +686,7 @@
|
|
|
686
686
|
* @public
|
|
687
687
|
*/
|
|
688
688
|
|
|
689
|
-
function parse$
|
|
689
|
+
function parse$5(str, options) {
|
|
690
690
|
if (typeof str !== 'string') {
|
|
691
691
|
throw new TypeError('argument str must be a string');
|
|
692
692
|
}
|
|
@@ -871,12 +871,12 @@
|
|
|
871
871
|
};
|
|
872
872
|
|
|
873
873
|
/**
|
|
874
|
-
* Parses a given
|
|
874
|
+
* Parses a given value into a JSON.
|
|
875
875
|
* Does not throw an exception on an invalid JSON string.
|
|
876
876
|
*/
|
|
877
|
-
function jsonParse(
|
|
877
|
+
function jsonParse(value) {
|
|
878
878
|
try {
|
|
879
|
-
return JSON.parse(
|
|
879
|
+
return JSON.parse(value);
|
|
880
880
|
}
|
|
881
881
|
catch (error) {
|
|
882
882
|
return undefined;
|
|
@@ -942,6 +942,20 @@
|
|
|
942
942
|
};
|
|
943
943
|
};
|
|
944
944
|
|
|
945
|
+
/**
|
|
946
|
+
* Sets the GraphQL extensions on a given response.
|
|
947
|
+
* @example
|
|
948
|
+
* res(ctx.extensions({ tracing: { version: 1 }}))
|
|
949
|
+
* @see {@link https://mswjs.io/docs/api/context/extensions `ctx.extensions()`}
|
|
950
|
+
*/
|
|
951
|
+
const extensions = (payload) => {
|
|
952
|
+
return (res) => {
|
|
953
|
+
const prevBody = jsonParse(res.body) || {};
|
|
954
|
+
const nextBody = mergeRight(prevBody, { extensions: payload });
|
|
955
|
+
return json(nextBody)(res);
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
|
|
945
959
|
var lib$5 = {exports: {}};
|
|
946
960
|
|
|
947
961
|
(function (module, exports) {
|
|
@@ -1051,8 +1065,12 @@
|
|
|
1051
1065
|
if (['GET', 'HEAD'].includes(method)) {
|
|
1052
1066
|
return requestParameters;
|
|
1053
1067
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1068
|
+
if (typeof body === 'object' || typeof body === 'number') {
|
|
1069
|
+
requestParameters.body = JSON.stringify(body);
|
|
1070
|
+
}
|
|
1071
|
+
else {
|
|
1072
|
+
requestParameters.body = body;
|
|
1073
|
+
}
|
|
1056
1074
|
return requestParameters;
|
|
1057
1075
|
};
|
|
1058
1076
|
/**
|
|
@@ -1106,6 +1124,7 @@
|
|
|
1106
1124
|
cookie: cookie,
|
|
1107
1125
|
body: body,
|
|
1108
1126
|
data: data,
|
|
1127
|
+
extensions: extensions,
|
|
1109
1128
|
delay: delay,
|
|
1110
1129
|
errors: errors,
|
|
1111
1130
|
fetch: fetch$1,
|
|
@@ -1754,6 +1773,65 @@
|
|
|
1754
1773
|
|
|
1755
1774
|
var invariant$3 = {};
|
|
1756
1775
|
|
|
1776
|
+
var format$1 = {};
|
|
1777
|
+
|
|
1778
|
+
Object.defineProperty(format$1, "__esModule", { value: true });
|
|
1779
|
+
format$1.format = void 0;
|
|
1780
|
+
var POSITIONALS_EXP = /(%?)(%([sdjo]))/g;
|
|
1781
|
+
function serializePositional(positional, flag) {
|
|
1782
|
+
switch (flag) {
|
|
1783
|
+
// Strings.
|
|
1784
|
+
case 's':
|
|
1785
|
+
return positional;
|
|
1786
|
+
// Digits.
|
|
1787
|
+
case 'd':
|
|
1788
|
+
case 'i':
|
|
1789
|
+
return Number(positional);
|
|
1790
|
+
// JSON.
|
|
1791
|
+
case 'j':
|
|
1792
|
+
return JSON.stringify(positional);
|
|
1793
|
+
// Objects.
|
|
1794
|
+
case 'o': {
|
|
1795
|
+
// Preserve stings to prevent extra quotes around them.
|
|
1796
|
+
if (typeof positional === 'string') {
|
|
1797
|
+
return positional;
|
|
1798
|
+
}
|
|
1799
|
+
var json = JSON.stringify(positional);
|
|
1800
|
+
// If the positional isn't serializable, return it as-is.
|
|
1801
|
+
if (json === '{}' || json === '[]' || /^\[object .+?\]$/.test(json)) {
|
|
1802
|
+
return positional;
|
|
1803
|
+
}
|
|
1804
|
+
return json;
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
function format(message) {
|
|
1809
|
+
var positionals = [];
|
|
1810
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1811
|
+
positionals[_i - 1] = arguments[_i];
|
|
1812
|
+
}
|
|
1813
|
+
if (positionals.length === 0) {
|
|
1814
|
+
return message;
|
|
1815
|
+
}
|
|
1816
|
+
var positionalIndex = 0;
|
|
1817
|
+
var formattedMessage = message.replace(POSITIONALS_EXP, function (match, isEscaped, _, flag) {
|
|
1818
|
+
var positional = positionals[positionalIndex];
|
|
1819
|
+
var value = serializePositional(positional, flag);
|
|
1820
|
+
if (!isEscaped) {
|
|
1821
|
+
positionalIndex++;
|
|
1822
|
+
return value;
|
|
1823
|
+
}
|
|
1824
|
+
return match;
|
|
1825
|
+
});
|
|
1826
|
+
// Append unresolved positionals to string as-is.
|
|
1827
|
+
if (positionalIndex < positionals.length) {
|
|
1828
|
+
formattedMessage += " " + positionals.slice(positionalIndex).join(' ');
|
|
1829
|
+
}
|
|
1830
|
+
formattedMessage = formattedMessage.replace(/%{2,2}/g, '%');
|
|
1831
|
+
return formattedMessage;
|
|
1832
|
+
}
|
|
1833
|
+
format$1.format = format;
|
|
1834
|
+
|
|
1757
1835
|
var __extends$1 = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
1758
1836
|
var extendStatics = function (d, b) {
|
|
1759
1837
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -1775,21 +1853,9 @@
|
|
|
1775
1853
|
return to;
|
|
1776
1854
|
};
|
|
1777
1855
|
Object.defineProperty(invariant$3, "__esModule", { value: true });
|
|
1778
|
-
invariant$3.invariant = invariant$3.InvariantError =
|
|
1856
|
+
invariant$3.invariant = invariant$3.InvariantError = void 0;
|
|
1857
|
+
var format_1 = format$1;
|
|
1779
1858
|
var STACK_FRAMES_TO_IGNORE = 2;
|
|
1780
|
-
function interpolate(message) {
|
|
1781
|
-
var positionals = [];
|
|
1782
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1783
|
-
positionals[_i - 1] = arguments[_i];
|
|
1784
|
-
}
|
|
1785
|
-
var index = 0;
|
|
1786
|
-
return message.replace(/%[s|d|o]/g, function (match) {
|
|
1787
|
-
var _a;
|
|
1788
|
-
var value = (_a = positionals[index++]) !== null && _a !== void 0 ? _a : match;
|
|
1789
|
-
return typeof value === 'object' ? JSON.stringify(value) : value;
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
|
-
invariant$3.interpolate = interpolate;
|
|
1793
1859
|
var InvariantError = /** @class */ (function (_super) {
|
|
1794
1860
|
__extends$1(InvariantError, _super);
|
|
1795
1861
|
function InvariantError(message) {
|
|
@@ -1799,7 +1865,7 @@
|
|
|
1799
1865
|
}
|
|
1800
1866
|
var _this = _super.call(this, message) || this;
|
|
1801
1867
|
_this.name = 'Invariant Violation';
|
|
1802
|
-
_this.message =
|
|
1868
|
+
_this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
|
|
1803
1869
|
if (_this.stack) {
|
|
1804
1870
|
var prevStack = _this.stack;
|
|
1805
1871
|
_this.stack = prevStack
|
|
@@ -1836,6 +1902,7 @@
|
|
|
1836
1902
|
};
|
|
1837
1903
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1838
1904
|
__exportStar(invariant$3, exports);
|
|
1905
|
+
__exportStar(format$1, exports);
|
|
1839
1906
|
}(lib$2));
|
|
1840
1907
|
|
|
1841
1908
|
const LIBRARY_PREFIX = '[MSW]';
|
|
@@ -1843,7 +1910,7 @@
|
|
|
1843
1910
|
* Formats a given message by appending the library's prefix string.
|
|
1844
1911
|
*/
|
|
1845
1912
|
function formatMessage(message, ...positionals) {
|
|
1846
|
-
const interpolatedMessage = lib$2.
|
|
1913
|
+
const interpolatedMessage = lib$2.format(message, ...positionals);
|
|
1847
1914
|
return `${LIBRARY_PREFIX} ${interpolatedMessage}`;
|
|
1848
1915
|
}
|
|
1849
1916
|
/**
|
|
@@ -2038,7 +2105,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
2038
2105
|
return cookie;
|
|
2039
2106
|
}
|
|
2040
2107
|
|
|
2041
|
-
function parse$
|
|
2108
|
+
function parse$4(input, options) {
|
|
2042
2109
|
options = options
|
|
2043
2110
|
? Object.assign({}, defaultParseOptions, options)
|
|
2044
2111
|
: defaultParseOptions;
|
|
@@ -2176,8 +2243,8 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
2176
2243
|
return cookiesStrings;
|
|
2177
2244
|
}
|
|
2178
2245
|
|
|
2179
|
-
setCookie.exports = parse$
|
|
2180
|
-
setCookie.exports.parse = parse$
|
|
2246
|
+
setCookie.exports = parse$4;
|
|
2247
|
+
setCookie.exports.parse = parse$4;
|
|
2181
2248
|
setCookie.exports.parseString = parseString;
|
|
2182
2249
|
setCookie.exports.splitCookiesString = splitCookiesString;
|
|
2183
2250
|
|
|
@@ -2357,7 +2424,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
2357
2424
|
/**
|
|
2358
2425
|
* @note No cookies persist on the document in Node.js: no document.
|
|
2359
2426
|
*/
|
|
2360
|
-
if (typeof location === 'undefined') {
|
|
2427
|
+
if (typeof document === 'undefined' || typeof location === 'undefined') {
|
|
2361
2428
|
return {};
|
|
2362
2429
|
}
|
|
2363
2430
|
switch (request.credentials) {
|
|
@@ -2458,25 +2525,25 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
2458
2525
|
}
|
|
2459
2526
|
|
|
2460
2527
|
/**
|
|
2461
|
-
* Parses a given request/response body based on the
|
|
2528
|
+
* Parses a given request/response body based on the "Content-Type" header.
|
|
2462
2529
|
*/
|
|
2463
2530
|
function parseBody(body, headers) {
|
|
2464
2531
|
// Return whatever falsey body value is given.
|
|
2465
2532
|
if (!body) {
|
|
2466
2533
|
return body;
|
|
2467
2534
|
}
|
|
2468
|
-
const contentType = headers === null || headers === void 0 ? void 0 : headers.get('content-type');
|
|
2535
|
+
const contentType = (headers === null || headers === void 0 ? void 0 : headers.get('content-type')) || '';
|
|
2469
2536
|
// If the body has a Multipart Content-Type
|
|
2470
2537
|
// parse it into an object.
|
|
2471
|
-
const hasMultipartContent = contentType
|
|
2538
|
+
const hasMultipartContent = contentType.startsWith('multipart/form-data');
|
|
2472
2539
|
if (hasMultipartContent && typeof body !== 'object') {
|
|
2473
|
-
return parseMultipartData(body, headers) || body;
|
|
2540
|
+
return parseMultipartData(body.toString(), headers) || body;
|
|
2474
2541
|
}
|
|
2475
2542
|
// If the intercepted request's body has a JSON Content-Type
|
|
2476
2543
|
// parse it into an object.
|
|
2477
|
-
const hasJsonContent = contentType
|
|
2544
|
+
const hasJsonContent = contentType.includes('json');
|
|
2478
2545
|
if (hasJsonContent && typeof body !== 'object') {
|
|
2479
|
-
return jsonParse(body) || body;
|
|
2546
|
+
return jsonParse(body.toString()) || body;
|
|
2480
2547
|
}
|
|
2481
2548
|
// Otherwise leave as-is.
|
|
2482
2549
|
return body;
|
|
@@ -3778,7 +3845,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
3778
3845
|
|
|
3779
3846
|
directiveLocation.DirectiveLocation = DirectiveLocation;
|
|
3780
3847
|
|
|
3781
|
-
var lexer = {};
|
|
3848
|
+
var lexer$1 = {};
|
|
3782
3849
|
|
|
3783
3850
|
var blockString = {};
|
|
3784
3851
|
|
|
@@ -3915,11 +3982,11 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
3915
3982
|
return '"""' + result.replace(/"""/g, '\\"""') + '"""';
|
|
3916
3983
|
}
|
|
3917
3984
|
|
|
3918
|
-
Object.defineProperty(lexer, "__esModule", {
|
|
3985
|
+
Object.defineProperty(lexer$1, "__esModule", {
|
|
3919
3986
|
value: true
|
|
3920
3987
|
});
|
|
3921
|
-
lexer.isPunctuatorTokenKind = isPunctuatorTokenKind;
|
|
3922
|
-
lexer.Lexer = void 0;
|
|
3988
|
+
lexer$1.isPunctuatorTokenKind = isPunctuatorTokenKind;
|
|
3989
|
+
lexer$1.Lexer = void 0;
|
|
3923
3990
|
|
|
3924
3991
|
var _syntaxError$1 = syntaxError$1;
|
|
3925
3992
|
|
|
@@ -4001,7 +4068,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
4001
4068
|
*/
|
|
4002
4069
|
|
|
4003
4070
|
|
|
4004
|
-
lexer.Lexer = Lexer;
|
|
4071
|
+
lexer$1.Lexer = Lexer;
|
|
4005
4072
|
|
|
4006
4073
|
function isPunctuatorTokenKind(kind) {
|
|
4007
4074
|
return kind === _tokenKind$3.TokenKind.BANG || kind === _tokenKind$3.TokenKind.DOLLAR || kind === _tokenKind$3.TokenKind.AMP || kind === _tokenKind$3.TokenKind.PAREN_L || kind === _tokenKind$3.TokenKind.PAREN_R || kind === _tokenKind$3.TokenKind.SPREAD || kind === _tokenKind$3.TokenKind.COLON || kind === _tokenKind$3.TokenKind.EQUALS || kind === _tokenKind$3.TokenKind.AT || kind === _tokenKind$3.TokenKind.BRACKET_L || kind === _tokenKind$3.TokenKind.BRACKET_R || kind === _tokenKind$3.TokenKind.BRACE_L || kind === _tokenKind$3.TokenKind.PIPE || kind === _tokenKind$3.TokenKind.BRACE_R;
|
|
@@ -4607,7 +4674,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
4607
4674
|
Object.defineProperty(parser, "__esModule", {
|
|
4608
4675
|
value: true
|
|
4609
4676
|
});
|
|
4610
|
-
parser.parse = parse$
|
|
4677
|
+
parser.parse = parse$3;
|
|
4611
4678
|
parser.parseValue = parseValue;
|
|
4612
4679
|
parser.parseType = parseType;
|
|
4613
4680
|
parser.Parser = void 0;
|
|
@@ -4624,13 +4691,13 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
4624
4691
|
|
|
4625
4692
|
var _directiveLocation$3 = directiveLocation;
|
|
4626
4693
|
|
|
4627
|
-
var _lexer$1 = lexer;
|
|
4694
|
+
var _lexer$1 = lexer$1;
|
|
4628
4695
|
|
|
4629
4696
|
/**
|
|
4630
4697
|
* Given a GraphQL source, parses it into a Document.
|
|
4631
4698
|
* Throws GraphQLError if a syntax error is encountered.
|
|
4632
4699
|
*/
|
|
4633
|
-
function parse$
|
|
4700
|
+
function parse$3(source, options) {
|
|
4634
4701
|
var parser = new Parser(source, options);
|
|
4635
4702
|
return parser.parseDocument();
|
|
4636
4703
|
}
|
|
@@ -17289,7 +17356,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
17289
17356
|
|
|
17290
17357
|
var _tokenKind = tokenKind;
|
|
17291
17358
|
|
|
17292
|
-
var _lexer = lexer;
|
|
17359
|
+
var _lexer = lexer$1;
|
|
17293
17360
|
|
|
17294
17361
|
var _parser = parser;
|
|
17295
17362
|
|
|
@@ -20105,7 +20172,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
20105
20172
|
|
|
20106
20173
|
var _tokenKind = tokenKind;
|
|
20107
20174
|
|
|
20108
|
-
var _lexer = lexer;
|
|
20175
|
+
var _lexer = lexer$1;
|
|
20109
20176
|
|
|
20110
20177
|
var _blockString = blockString;
|
|
20111
20178
|
|
|
@@ -22328,7 +22395,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22328
22395
|
const parsedResult = parseQuery(query);
|
|
22329
22396
|
if (parsedResult instanceof Error) {
|
|
22330
22397
|
const requestPublicUrl = getPublicUrlFromRequest(request);
|
|
22331
|
-
throw new Error(devUtils.formatMessage('Failed to intercept a GraphQL request to "%s %s": cannot parse query. See the error message from the parser below.\n\n%
|
|
22398
|
+
throw new Error(devUtils.formatMessage('Failed to intercept a GraphQL request to "%s %s": cannot parse query. See the error message from the parser below.\n\n%s', request.method, requestPublicUrl, parsedResult.message));
|
|
22332
22399
|
}
|
|
22333
22400
|
return {
|
|
22334
22401
|
operationType: parsedResult.operationType,
|
|
@@ -22385,51 +22452,414 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22385
22452
|
body: parseBody(res.body, responseHeaders) });
|
|
22386
22453
|
}
|
|
22387
22454
|
|
|
22388
|
-
var
|
|
22389
|
-
|
|
22390
|
-
Object.defineProperty(cjs, '__esModule', { value: true });
|
|
22391
|
-
|
|
22392
|
-
/**
|
|
22393
|
-
* Converts a string path to a Regular Expression.
|
|
22394
|
-
* Transforms path parameters into named RegExp groups.
|
|
22395
|
-
*/
|
|
22396
|
-
const pathToRegExp = (path) => {
|
|
22397
|
-
const pattern = path
|
|
22398
|
-
// Escape literal dots
|
|
22399
|
-
.replace(/\./g, '\\.')
|
|
22400
|
-
// Escape literal slashes
|
|
22401
|
-
.replace(/\//g, '/')
|
|
22402
|
-
// Escape literal question marks
|
|
22403
|
-
.replace(/\?/g, '\\?')
|
|
22404
|
-
// Ignore trailing slashes
|
|
22405
|
-
.replace(/\/+$/, '')
|
|
22406
|
-
// Replace wildcard with any zero-to-any character sequence
|
|
22407
|
-
.replace(/\*+/g, '.*')
|
|
22408
|
-
// Replace parameters with named capturing groups
|
|
22409
|
-
.replace(/:([^\d|^\/][a-zA-Z0-9_]*(?=(?:\/|\\.)|$))/g, (_, paramName) => `(?<${paramName}>[^\/]+?)`)
|
|
22410
|
-
// Allow optional trailing slash
|
|
22411
|
-
.concat('(\\/|$)');
|
|
22412
|
-
return new RegExp(pattern, 'gi');
|
|
22413
|
-
};
|
|
22414
|
-
|
|
22415
|
-
/**
|
|
22416
|
-
* Matches a given url against a path.
|
|
22417
|
-
*/
|
|
22418
|
-
const match = (path, url) => {
|
|
22419
|
-
const expression = path instanceof RegExp ? path : pathToRegExp(path);
|
|
22420
|
-
const match = expression.exec(url) || false;
|
|
22421
|
-
// Matches in strict mode: match string should equal to input (url)
|
|
22422
|
-
// Otherwise loose matches will be considered truthy:
|
|
22423
|
-
// match('/messages/:id', '/messages/123/users') // true
|
|
22424
|
-
const matches = path instanceof RegExp ? !!match : !!match && match[0] === match.input;
|
|
22425
|
-
return {
|
|
22426
|
-
matches,
|
|
22427
|
-
params: match && matches ? match.groups || null : null,
|
|
22428
|
-
};
|
|
22429
|
-
};
|
|
22455
|
+
var dist = {};
|
|
22430
22456
|
|
|
22431
|
-
|
|
22432
|
-
|
|
22457
|
+
Object.defineProperty(dist, "__esModule", { value: true });
|
|
22458
|
+
dist.pathToRegexp = dist.tokensToRegexp = dist.regexpToFunction = match_1 = dist.match = dist.tokensToFunction = dist.compile = dist.parse = void 0;
|
|
22459
|
+
/**
|
|
22460
|
+
* Tokenize input string.
|
|
22461
|
+
*/
|
|
22462
|
+
function lexer(str) {
|
|
22463
|
+
var tokens = [];
|
|
22464
|
+
var i = 0;
|
|
22465
|
+
while (i < str.length) {
|
|
22466
|
+
var char = str[i];
|
|
22467
|
+
if (char === "*" || char === "+" || char === "?") {
|
|
22468
|
+
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
|
22469
|
+
continue;
|
|
22470
|
+
}
|
|
22471
|
+
if (char === "\\") {
|
|
22472
|
+
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
|
22473
|
+
continue;
|
|
22474
|
+
}
|
|
22475
|
+
if (char === "{") {
|
|
22476
|
+
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
|
22477
|
+
continue;
|
|
22478
|
+
}
|
|
22479
|
+
if (char === "}") {
|
|
22480
|
+
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
|
22481
|
+
continue;
|
|
22482
|
+
}
|
|
22483
|
+
if (char === ":") {
|
|
22484
|
+
var name = "";
|
|
22485
|
+
var j = i + 1;
|
|
22486
|
+
while (j < str.length) {
|
|
22487
|
+
var code = str.charCodeAt(j);
|
|
22488
|
+
if (
|
|
22489
|
+
// `0-9`
|
|
22490
|
+
(code >= 48 && code <= 57) ||
|
|
22491
|
+
// `A-Z`
|
|
22492
|
+
(code >= 65 && code <= 90) ||
|
|
22493
|
+
// `a-z`
|
|
22494
|
+
(code >= 97 && code <= 122) ||
|
|
22495
|
+
// `_`
|
|
22496
|
+
code === 95) {
|
|
22497
|
+
name += str[j++];
|
|
22498
|
+
continue;
|
|
22499
|
+
}
|
|
22500
|
+
break;
|
|
22501
|
+
}
|
|
22502
|
+
if (!name)
|
|
22503
|
+
throw new TypeError("Missing parameter name at " + i);
|
|
22504
|
+
tokens.push({ type: "NAME", index: i, value: name });
|
|
22505
|
+
i = j;
|
|
22506
|
+
continue;
|
|
22507
|
+
}
|
|
22508
|
+
if (char === "(") {
|
|
22509
|
+
var count = 1;
|
|
22510
|
+
var pattern = "";
|
|
22511
|
+
var j = i + 1;
|
|
22512
|
+
if (str[j] === "?") {
|
|
22513
|
+
throw new TypeError("Pattern cannot start with \"?\" at " + j);
|
|
22514
|
+
}
|
|
22515
|
+
while (j < str.length) {
|
|
22516
|
+
if (str[j] === "\\") {
|
|
22517
|
+
pattern += str[j++] + str[j++];
|
|
22518
|
+
continue;
|
|
22519
|
+
}
|
|
22520
|
+
if (str[j] === ")") {
|
|
22521
|
+
count--;
|
|
22522
|
+
if (count === 0) {
|
|
22523
|
+
j++;
|
|
22524
|
+
break;
|
|
22525
|
+
}
|
|
22526
|
+
}
|
|
22527
|
+
else if (str[j] === "(") {
|
|
22528
|
+
count++;
|
|
22529
|
+
if (str[j + 1] !== "?") {
|
|
22530
|
+
throw new TypeError("Capturing groups are not allowed at " + j);
|
|
22531
|
+
}
|
|
22532
|
+
}
|
|
22533
|
+
pattern += str[j++];
|
|
22534
|
+
}
|
|
22535
|
+
if (count)
|
|
22536
|
+
throw new TypeError("Unbalanced pattern at " + i);
|
|
22537
|
+
if (!pattern)
|
|
22538
|
+
throw new TypeError("Missing pattern at " + i);
|
|
22539
|
+
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
|
22540
|
+
i = j;
|
|
22541
|
+
continue;
|
|
22542
|
+
}
|
|
22543
|
+
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
|
22544
|
+
}
|
|
22545
|
+
tokens.push({ type: "END", index: i, value: "" });
|
|
22546
|
+
return tokens;
|
|
22547
|
+
}
|
|
22548
|
+
/**
|
|
22549
|
+
* Parse a string for the raw tokens.
|
|
22550
|
+
*/
|
|
22551
|
+
function parse$2(str, options) {
|
|
22552
|
+
if (options === void 0) { options = {}; }
|
|
22553
|
+
var tokens = lexer(str);
|
|
22554
|
+
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
|
|
22555
|
+
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
|
|
22556
|
+
var result = [];
|
|
22557
|
+
var key = 0;
|
|
22558
|
+
var i = 0;
|
|
22559
|
+
var path = "";
|
|
22560
|
+
var tryConsume = function (type) {
|
|
22561
|
+
if (i < tokens.length && tokens[i].type === type)
|
|
22562
|
+
return tokens[i++].value;
|
|
22563
|
+
};
|
|
22564
|
+
var mustConsume = function (type) {
|
|
22565
|
+
var value = tryConsume(type);
|
|
22566
|
+
if (value !== undefined)
|
|
22567
|
+
return value;
|
|
22568
|
+
var _a = tokens[i], nextType = _a.type, index = _a.index;
|
|
22569
|
+
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
|
|
22570
|
+
};
|
|
22571
|
+
var consumeText = function () {
|
|
22572
|
+
var result = "";
|
|
22573
|
+
var value;
|
|
22574
|
+
// tslint:disable-next-line
|
|
22575
|
+
while ((value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR"))) {
|
|
22576
|
+
result += value;
|
|
22577
|
+
}
|
|
22578
|
+
return result;
|
|
22579
|
+
};
|
|
22580
|
+
while (i < tokens.length) {
|
|
22581
|
+
var char = tryConsume("CHAR");
|
|
22582
|
+
var name = tryConsume("NAME");
|
|
22583
|
+
var pattern = tryConsume("PATTERN");
|
|
22584
|
+
if (name || pattern) {
|
|
22585
|
+
var prefix = char || "";
|
|
22586
|
+
if (prefixes.indexOf(prefix) === -1) {
|
|
22587
|
+
path += prefix;
|
|
22588
|
+
prefix = "";
|
|
22589
|
+
}
|
|
22590
|
+
if (path) {
|
|
22591
|
+
result.push(path);
|
|
22592
|
+
path = "";
|
|
22593
|
+
}
|
|
22594
|
+
result.push({
|
|
22595
|
+
name: name || key++,
|
|
22596
|
+
prefix: prefix,
|
|
22597
|
+
suffix: "",
|
|
22598
|
+
pattern: pattern || defaultPattern,
|
|
22599
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
22600
|
+
});
|
|
22601
|
+
continue;
|
|
22602
|
+
}
|
|
22603
|
+
var value = char || tryConsume("ESCAPED_CHAR");
|
|
22604
|
+
if (value) {
|
|
22605
|
+
path += value;
|
|
22606
|
+
continue;
|
|
22607
|
+
}
|
|
22608
|
+
if (path) {
|
|
22609
|
+
result.push(path);
|
|
22610
|
+
path = "";
|
|
22611
|
+
}
|
|
22612
|
+
var open = tryConsume("OPEN");
|
|
22613
|
+
if (open) {
|
|
22614
|
+
var prefix = consumeText();
|
|
22615
|
+
var name_1 = tryConsume("NAME") || "";
|
|
22616
|
+
var pattern_1 = tryConsume("PATTERN") || "";
|
|
22617
|
+
var suffix = consumeText();
|
|
22618
|
+
mustConsume("CLOSE");
|
|
22619
|
+
result.push({
|
|
22620
|
+
name: name_1 || (pattern_1 ? key++ : ""),
|
|
22621
|
+
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
|
|
22622
|
+
prefix: prefix,
|
|
22623
|
+
suffix: suffix,
|
|
22624
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
22625
|
+
});
|
|
22626
|
+
continue;
|
|
22627
|
+
}
|
|
22628
|
+
mustConsume("END");
|
|
22629
|
+
}
|
|
22630
|
+
return result;
|
|
22631
|
+
}
|
|
22632
|
+
dist.parse = parse$2;
|
|
22633
|
+
/**
|
|
22634
|
+
* Compile a string to a template function for the path.
|
|
22635
|
+
*/
|
|
22636
|
+
function compile(str, options) {
|
|
22637
|
+
return tokensToFunction(parse$2(str, options), options);
|
|
22638
|
+
}
|
|
22639
|
+
dist.compile = compile;
|
|
22640
|
+
/**
|
|
22641
|
+
* Expose a method for transforming tokens into the path function.
|
|
22642
|
+
*/
|
|
22643
|
+
function tokensToFunction(tokens, options) {
|
|
22644
|
+
if (options === void 0) { options = {}; }
|
|
22645
|
+
var reFlags = flags(options);
|
|
22646
|
+
var _a = options.encode, encode = _a === void 0 ? function (x) { return x; } : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
|
|
22647
|
+
// Compile all the tokens into regexps.
|
|
22648
|
+
var matches = tokens.map(function (token) {
|
|
22649
|
+
if (typeof token === "object") {
|
|
22650
|
+
return new RegExp("^(?:" + token.pattern + ")$", reFlags);
|
|
22651
|
+
}
|
|
22652
|
+
});
|
|
22653
|
+
return function (data) {
|
|
22654
|
+
var path = "";
|
|
22655
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
22656
|
+
var token = tokens[i];
|
|
22657
|
+
if (typeof token === "string") {
|
|
22658
|
+
path += token;
|
|
22659
|
+
continue;
|
|
22660
|
+
}
|
|
22661
|
+
var value = data ? data[token.name] : undefined;
|
|
22662
|
+
var optional = token.modifier === "?" || token.modifier === "*";
|
|
22663
|
+
var repeat = token.modifier === "*" || token.modifier === "+";
|
|
22664
|
+
if (Array.isArray(value)) {
|
|
22665
|
+
if (!repeat) {
|
|
22666
|
+
throw new TypeError("Expected \"" + token.name + "\" to not repeat, but got an array");
|
|
22667
|
+
}
|
|
22668
|
+
if (value.length === 0) {
|
|
22669
|
+
if (optional)
|
|
22670
|
+
continue;
|
|
22671
|
+
throw new TypeError("Expected \"" + token.name + "\" to not be empty");
|
|
22672
|
+
}
|
|
22673
|
+
for (var j = 0; j < value.length; j++) {
|
|
22674
|
+
var segment = encode(value[j], token);
|
|
22675
|
+
if (validate && !matches[i].test(segment)) {
|
|
22676
|
+
throw new TypeError("Expected all \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
|
|
22677
|
+
}
|
|
22678
|
+
path += token.prefix + segment + token.suffix;
|
|
22679
|
+
}
|
|
22680
|
+
continue;
|
|
22681
|
+
}
|
|
22682
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
22683
|
+
var segment = encode(String(value), token);
|
|
22684
|
+
if (validate && !matches[i].test(segment)) {
|
|
22685
|
+
throw new TypeError("Expected \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
|
|
22686
|
+
}
|
|
22687
|
+
path += token.prefix + segment + token.suffix;
|
|
22688
|
+
continue;
|
|
22689
|
+
}
|
|
22690
|
+
if (optional)
|
|
22691
|
+
continue;
|
|
22692
|
+
var typeOfMessage = repeat ? "an array" : "a string";
|
|
22693
|
+
throw new TypeError("Expected \"" + token.name + "\" to be " + typeOfMessage);
|
|
22694
|
+
}
|
|
22695
|
+
return path;
|
|
22696
|
+
};
|
|
22697
|
+
}
|
|
22698
|
+
dist.tokensToFunction = tokensToFunction;
|
|
22699
|
+
/**
|
|
22700
|
+
* Create path match function from `path-to-regexp` spec.
|
|
22701
|
+
*/
|
|
22702
|
+
function match(str, options) {
|
|
22703
|
+
var keys = [];
|
|
22704
|
+
var re = pathToRegexp(str, keys, options);
|
|
22705
|
+
return regexpToFunction(re, keys, options);
|
|
22706
|
+
}
|
|
22707
|
+
var match_1 = dist.match = match;
|
|
22708
|
+
/**
|
|
22709
|
+
* Create a path match function from `path-to-regexp` output.
|
|
22710
|
+
*/
|
|
22711
|
+
function regexpToFunction(re, keys, options) {
|
|
22712
|
+
if (options === void 0) { options = {}; }
|
|
22713
|
+
var _a = options.decode, decode = _a === void 0 ? function (x) { return x; } : _a;
|
|
22714
|
+
return function (pathname) {
|
|
22715
|
+
var m = re.exec(pathname);
|
|
22716
|
+
if (!m)
|
|
22717
|
+
return false;
|
|
22718
|
+
var path = m[0], index = m.index;
|
|
22719
|
+
var params = Object.create(null);
|
|
22720
|
+
var _loop_1 = function (i) {
|
|
22721
|
+
// tslint:disable-next-line
|
|
22722
|
+
if (m[i] === undefined)
|
|
22723
|
+
return "continue";
|
|
22724
|
+
var key = keys[i - 1];
|
|
22725
|
+
if (key.modifier === "*" || key.modifier === "+") {
|
|
22726
|
+
params[key.name] = m[i].split(key.prefix + key.suffix).map(function (value) {
|
|
22727
|
+
return decode(value, key);
|
|
22728
|
+
});
|
|
22729
|
+
}
|
|
22730
|
+
else {
|
|
22731
|
+
params[key.name] = decode(m[i], key);
|
|
22732
|
+
}
|
|
22733
|
+
};
|
|
22734
|
+
for (var i = 1; i < m.length; i++) {
|
|
22735
|
+
_loop_1(i);
|
|
22736
|
+
}
|
|
22737
|
+
return { path: path, index: index, params: params };
|
|
22738
|
+
};
|
|
22739
|
+
}
|
|
22740
|
+
dist.regexpToFunction = regexpToFunction;
|
|
22741
|
+
/**
|
|
22742
|
+
* Escape a regular expression string.
|
|
22743
|
+
*/
|
|
22744
|
+
function escapeString(str) {
|
|
22745
|
+
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
22746
|
+
}
|
|
22747
|
+
/**
|
|
22748
|
+
* Get the flags for a regexp from the options.
|
|
22749
|
+
*/
|
|
22750
|
+
function flags(options) {
|
|
22751
|
+
return options && options.sensitive ? "" : "i";
|
|
22752
|
+
}
|
|
22753
|
+
/**
|
|
22754
|
+
* Pull out keys from a regexp.
|
|
22755
|
+
*/
|
|
22756
|
+
function regexpToRegexp(path, keys) {
|
|
22757
|
+
if (!keys)
|
|
22758
|
+
return path;
|
|
22759
|
+
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
|
|
22760
|
+
var index = 0;
|
|
22761
|
+
var execResult = groupsRegex.exec(path.source);
|
|
22762
|
+
while (execResult) {
|
|
22763
|
+
keys.push({
|
|
22764
|
+
// Use parenthesized substring match if available, index otherwise
|
|
22765
|
+
name: execResult[1] || index++,
|
|
22766
|
+
prefix: "",
|
|
22767
|
+
suffix: "",
|
|
22768
|
+
modifier: "",
|
|
22769
|
+
pattern: ""
|
|
22770
|
+
});
|
|
22771
|
+
execResult = groupsRegex.exec(path.source);
|
|
22772
|
+
}
|
|
22773
|
+
return path;
|
|
22774
|
+
}
|
|
22775
|
+
/**
|
|
22776
|
+
* Transform an array into a regexp.
|
|
22777
|
+
*/
|
|
22778
|
+
function arrayToRegexp(paths, keys, options) {
|
|
22779
|
+
var parts = paths.map(function (path) { return pathToRegexp(path, keys, options).source; });
|
|
22780
|
+
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
|
|
22781
|
+
}
|
|
22782
|
+
/**
|
|
22783
|
+
* Create a path regexp from string input.
|
|
22784
|
+
*/
|
|
22785
|
+
function stringToRegexp(path, keys, options) {
|
|
22786
|
+
return tokensToRegexp(parse$2(path, options), keys, options);
|
|
22787
|
+
}
|
|
22788
|
+
/**
|
|
22789
|
+
* Expose a function for taking tokens and returning a RegExp.
|
|
22790
|
+
*/
|
|
22791
|
+
function tokensToRegexp(tokens, keys, options) {
|
|
22792
|
+
if (options === void 0) { options = {}; }
|
|
22793
|
+
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function (x) { return x; } : _d;
|
|
22794
|
+
var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
|
|
22795
|
+
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
|
|
22796
|
+
var route = start ? "^" : "";
|
|
22797
|
+
// Iterate over the tokens and create our regexp string.
|
|
22798
|
+
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
22799
|
+
var token = tokens_1[_i];
|
|
22800
|
+
if (typeof token === "string") {
|
|
22801
|
+
route += escapeString(encode(token));
|
|
22802
|
+
}
|
|
22803
|
+
else {
|
|
22804
|
+
var prefix = escapeString(encode(token.prefix));
|
|
22805
|
+
var suffix = escapeString(encode(token.suffix));
|
|
22806
|
+
if (token.pattern) {
|
|
22807
|
+
if (keys)
|
|
22808
|
+
keys.push(token);
|
|
22809
|
+
if (prefix || suffix) {
|
|
22810
|
+
if (token.modifier === "+" || token.modifier === "*") {
|
|
22811
|
+
var mod = token.modifier === "*" ? "?" : "";
|
|
22812
|
+
route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
|
|
22813
|
+
}
|
|
22814
|
+
else {
|
|
22815
|
+
route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
|
|
22816
|
+
}
|
|
22817
|
+
}
|
|
22818
|
+
else {
|
|
22819
|
+
route += "(" + token.pattern + ")" + token.modifier;
|
|
22820
|
+
}
|
|
22821
|
+
}
|
|
22822
|
+
else {
|
|
22823
|
+
route += "(?:" + prefix + suffix + ")" + token.modifier;
|
|
22824
|
+
}
|
|
22825
|
+
}
|
|
22826
|
+
}
|
|
22827
|
+
if (end) {
|
|
22828
|
+
if (!strict)
|
|
22829
|
+
route += delimiter + "?";
|
|
22830
|
+
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
|
|
22831
|
+
}
|
|
22832
|
+
else {
|
|
22833
|
+
var endToken = tokens[tokens.length - 1];
|
|
22834
|
+
var isEndDelimited = typeof endToken === "string"
|
|
22835
|
+
? delimiter.indexOf(endToken[endToken.length - 1]) > -1
|
|
22836
|
+
: // tslint:disable-next-line
|
|
22837
|
+
endToken === undefined;
|
|
22838
|
+
if (!strict) {
|
|
22839
|
+
route += "(?:" + delimiter + "(?=" + endsWith + "))?";
|
|
22840
|
+
}
|
|
22841
|
+
if (!isEndDelimited) {
|
|
22842
|
+
route += "(?=" + delimiter + "|" + endsWith + ")";
|
|
22843
|
+
}
|
|
22844
|
+
}
|
|
22845
|
+
return new RegExp(route, flags(options));
|
|
22846
|
+
}
|
|
22847
|
+
dist.tokensToRegexp = tokensToRegexp;
|
|
22848
|
+
/**
|
|
22849
|
+
* Normalize the given path string, returning a regular expression.
|
|
22850
|
+
*
|
|
22851
|
+
* An empty array can be passed in for the keys, which will hold the
|
|
22852
|
+
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
|
|
22853
|
+
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
|
|
22854
|
+
*/
|
|
22855
|
+
function pathToRegexp(path, keys, options) {
|
|
22856
|
+
if (path instanceof RegExp)
|
|
22857
|
+
return regexpToRegexp(path, keys);
|
|
22858
|
+
if (Array.isArray(path))
|
|
22859
|
+
return arrayToRegexp(path, keys, options);
|
|
22860
|
+
return stringToRegexp(path, keys, options);
|
|
22861
|
+
}
|
|
22862
|
+
dist.pathToRegexp = pathToRegexp;
|
|
22433
22863
|
|
|
22434
22864
|
var getCleanUrl$1 = {};
|
|
22435
22865
|
|
|
@@ -22464,9 +22894,12 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22464
22894
|
return path;
|
|
22465
22895
|
}
|
|
22466
22896
|
// Resolve a relative request URL against a given custom "baseUrl"
|
|
22467
|
-
// or the
|
|
22468
|
-
const origin = baseUrl || (typeof
|
|
22469
|
-
return origin
|
|
22897
|
+
// or the document baseURI (in the case of browser/browser-like environments).
|
|
22898
|
+
const origin = baseUrl || (typeof document !== 'undefined' && document.baseURI);
|
|
22899
|
+
return origin
|
|
22900
|
+
? // Encode and decode the path to preserve escaped characters.
|
|
22901
|
+
decodeURI(new URL(encodeURI(path), origin).href)
|
|
22902
|
+
: path;
|
|
22470
22903
|
}
|
|
22471
22904
|
|
|
22472
22905
|
/**
|
|
@@ -22485,12 +22918,40 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22485
22918
|
return cleanUrl(maybeAbsoluteUrl);
|
|
22486
22919
|
}
|
|
22487
22920
|
|
|
22921
|
+
/**
|
|
22922
|
+
* Coerce a path supported by MSW into a path
|
|
22923
|
+
* supported by "path-to-regexp".
|
|
22924
|
+
*/
|
|
22925
|
+
function coercePath(path) {
|
|
22926
|
+
return (path
|
|
22927
|
+
/**
|
|
22928
|
+
* Escape the protocol so that "path-to-regexp" could match
|
|
22929
|
+
* absolute URL.
|
|
22930
|
+
* @see https://github.com/pillarjs/path-to-regexp/issues/259
|
|
22931
|
+
*/
|
|
22932
|
+
.replace(/^([^\/]+)(:)(?=\/\/)/g, '$1\\$2')
|
|
22933
|
+
/**
|
|
22934
|
+
* Replace wildcards ("*") with unnamed capturing groups
|
|
22935
|
+
* because "path-to-regexp" doesn't support wildcards.
|
|
22936
|
+
* Ignore path parameter' modifiers (i.e. ":name*").
|
|
22937
|
+
*/
|
|
22938
|
+
.replace(/(?<!(^|\/|\*+):[\w]+)(\*{1,2})/g, '(.*)'));
|
|
22939
|
+
}
|
|
22488
22940
|
/**
|
|
22489
22941
|
* Returns the result of matching given request URL against a mask.
|
|
22490
22942
|
*/
|
|
22491
22943
|
function matchRequestUrl(url, path, baseUrl) {
|
|
22492
22944
|
const normalizedPath = normalizePath(path, baseUrl);
|
|
22493
|
-
|
|
22945
|
+
const cleanPath = typeof normalizedPath === 'string'
|
|
22946
|
+
? coercePath(normalizedPath)
|
|
22947
|
+
: normalizedPath;
|
|
22948
|
+
const cleanUrl = getCleanUrl_2(url);
|
|
22949
|
+
const result = match_1(cleanPath, { decode: decodeURIComponent })(cleanUrl);
|
|
22950
|
+
const params = (result && result.params) || {};
|
|
22951
|
+
return {
|
|
22952
|
+
matches: result !== false,
|
|
22953
|
+
params,
|
|
22954
|
+
};
|
|
22494
22955
|
}
|
|
22495
22956
|
|
|
22496
22957
|
/**
|
|
@@ -22539,18 +23000,21 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22539
23000
|
},
|
|
22540
23001
|
});
|
|
22541
23002
|
|
|
23003
|
+
const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
|
|
22542
23004
|
/**
|
|
22543
23005
|
* Return the stack trace frame of a function's invocation.
|
|
22544
23006
|
*/
|
|
22545
|
-
function getCallFrame() {
|
|
23007
|
+
function getCallFrame(error) {
|
|
22546
23008
|
// In <IE11, new Error may return an undefined stack
|
|
22547
|
-
const stack =
|
|
22548
|
-
|
|
23009
|
+
const stack = error.stack;
|
|
23010
|
+
if (!stack) {
|
|
23011
|
+
return;
|
|
23012
|
+
}
|
|
23013
|
+
const frames = stack.split('\n').slice(1);
|
|
22549
23014
|
// Get the first frame that doesn't reference the library's internal trace.
|
|
22550
23015
|
// Assume that frame is the invocation frame.
|
|
22551
|
-
const
|
|
22552
|
-
|
|
22553
|
-
return !ignoreFrameRegExp.test(frame);
|
|
23016
|
+
const declarationFrame = frames.find((frame) => {
|
|
23017
|
+
return !BUILD_FRAME.test(frame);
|
|
22554
23018
|
});
|
|
22555
23019
|
if (!declarationFrame) {
|
|
22556
23020
|
return;
|
|
@@ -22583,7 +23047,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22583
23047
|
this.shouldSkip = false;
|
|
22584
23048
|
this.ctx = options.ctx || defaultContext;
|
|
22585
23049
|
this.resolver = options.resolver;
|
|
22586
|
-
const callFrame = getCallFrame();
|
|
23050
|
+
const callFrame = getCallFrame(new Error());
|
|
22587
23051
|
this.info = Object.assign(Object.assign({}, options.info), { callFrame });
|
|
22588
23052
|
}
|
|
22589
23053
|
/**
|
|
@@ -22710,21 +23174,9 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22710
23174
|
return;
|
|
22711
23175
|
}
|
|
22712
23176
|
const searchParams = getSearchParams(path);
|
|
22713
|
-
const queryParams = [];
|
|
22714
23177
|
searchParams.forEach((_, paramName) => {
|
|
22715
|
-
queryParams.push(paramName);
|
|
22716
23178
|
});
|
|
22717
|
-
devUtils.warn(
|
|
22718
|
-
Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead, and access query parameters in the response resolver function:
|
|
22719
|
-
|
|
22720
|
-
rest.${method.toLowerCase()}("${url}", (req, res, ctx) => {
|
|
22721
|
-
const query = req.url.searchParams
|
|
22722
|
-
${queryParams
|
|
22723
|
-
.map((paramName) => `\
|
|
22724
|
-
const ${paramName} = query.get("${paramName}")`)
|
|
22725
|
-
.join('\n')}
|
|
22726
|
-
})\
|
|
22727
|
-
`);
|
|
23179
|
+
devUtils.warn(`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters in the response resolver function using "req.url.searchParams".`);
|
|
22728
23180
|
}
|
|
22729
23181
|
parse(request, resolutionContext) {
|
|
22730
23182
|
return matchRequestUrl(request.url, this.info.path, resolutionContext === null || resolutionContext === void 0 ? void 0 : resolutionContext.baseUrl);
|
|
@@ -22733,7 +23185,11 @@ ${queryParams
|
|
|
22733
23185
|
return Object.assign(Object.assign({}, request), { params: parsedResult.params || {} });
|
|
22734
23186
|
}
|
|
22735
23187
|
predicate(request, parsedResult) {
|
|
22736
|
-
|
|
23188
|
+
const matchesMethod = this.info.method instanceof RegExp
|
|
23189
|
+
? this.info.method.test(request.method)
|
|
23190
|
+
: isStringEqual(this.info.method, request.method);
|
|
23191
|
+
// console.log({ request, matchesMethod, parsedResult })
|
|
23192
|
+
return matchesMethod && parsedResult.matches;
|
|
22737
23193
|
}
|
|
22738
23194
|
log(request, response) {
|
|
22739
23195
|
const publicUrl = getPublicUrlFromRequest(request);
|
|
@@ -22767,6 +23223,7 @@ ${queryParams
|
|
|
22767
23223
|
delay,
|
|
22768
23224
|
fetch: fetch$1,
|
|
22769
23225
|
data,
|
|
23226
|
+
extensions,
|
|
22770
23227
|
errors,
|
|
22771
23228
|
cookie,
|
|
22772
23229
|
};
|
|
@@ -22813,10 +23270,10 @@ ${queryParams
|
|
|
22813
23270
|
if (!parsedResult) {
|
|
22814
23271
|
return false;
|
|
22815
23272
|
}
|
|
22816
|
-
if (!parsedResult.operationName) {
|
|
23273
|
+
if (!parsedResult.operationName && this.info.operationType !== 'all') {
|
|
22817
23274
|
const publicUrl = getPublicUrlFromRequest(request);
|
|
22818
23275
|
devUtils.warn(`\
|
|
22819
|
-
Failed to intercept a GraphQL request at "${request.method} ${publicUrl}":
|
|
23276
|
+
Failed to intercept a GraphQL request at "${request.method} ${publicUrl}": anonymous GraphQL operations are not supported.
|
|
22820
23277
|
|
|
22821
23278
|
Consider naming this operation or using "graphql.operation" request handler to intercept GraphQL requests regardless of their operation name/type. Read more: https://mswjs.io/docs/api/graphql/operation\
|
|
22822
23279
|
`);
|
|
@@ -22826,7 +23283,7 @@ Consider naming this operation or using "graphql.operation" request handler to i
|
|
|
22826
23283
|
const hasMatchingOperationType = this.info.operationType === 'all' ||
|
|
22827
23284
|
parsedResult.operationType === this.info.operationType;
|
|
22828
23285
|
const hasMatchingOperationName = this.info.operationName instanceof RegExp
|
|
22829
|
-
? this.info.operationName.test(parsedResult.operationName)
|
|
23286
|
+
? this.info.operationName.test(parsedResult.operationName || '')
|
|
22830
23287
|
: parsedResult.operationName === this.info.operationName;
|
|
22831
23288
|
return (hasMatchingUrl.matches &&
|
|
22832
23289
|
hasMatchingOperationType &&
|
|
@@ -22836,7 +23293,10 @@ Consider naming this operation or using "graphql.operation" request handler to i
|
|
|
22836
23293
|
const loggedRequest = prepareRequest(request);
|
|
22837
23294
|
const loggedResponse = prepareResponse(response);
|
|
22838
23295
|
const statusColor = getStatusCodeColor(response.status);
|
|
22839
|
-
|
|
23296
|
+
const requestInfo = (parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName)
|
|
23297
|
+
? `${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType} ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName}`
|
|
23298
|
+
: `anonymous ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType}`;
|
|
23299
|
+
console.groupCollapsed(devUtils.formatMessage('%s %s (%c%s%c)'), getTimestamp(), `${requestInfo}`, `color:${statusColor}`, `${response.status} ${response.statusText}`, 'color:inherit');
|
|
22840
23300
|
console.log('Request:', loggedRequest);
|
|
22841
23301
|
console.log('Handler:', this);
|
|
22842
23302
|
console.log('Response:', loggedResponse);
|
|
@@ -22950,8 +23410,10 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
22950
23410
|
const message = messageTemplate.join('\n\n');
|
|
22951
23411
|
switch (strategy) {
|
|
22952
23412
|
case 'error': {
|
|
23413
|
+
// Print a developer-friendly error.
|
|
22953
23414
|
devUtils.error('Error: %s', message);
|
|
22954
|
-
|
|
23415
|
+
// Throw an exception to halt request processing and not perform the original request.
|
|
23416
|
+
throw new Error('Cannot bypass a request when using the "error" strategy for the "onUnhandledRequest" option.');
|
|
22955
23417
|
}
|
|
22956
23418
|
case 'warn': {
|
|
22957
23419
|
devUtils.warn('Warning: %s', message);
|
|
@@ -22994,7 +23456,12 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
22994
23456
|
// When the handled request returned no mocked response, warn the developer,
|
|
22995
23457
|
// as it may be an oversight on their part. Perform the request as-is.
|
|
22996
23458
|
if (!response) {
|
|
22997
|
-
devUtils.warn(
|
|
23459
|
+
devUtils.warn(`\
|
|
23460
|
+
Expected response resolver to return a mocked response Object, but got %s. The original response is going to be used instead.\
|
|
23461
|
+
\n
|
|
23462
|
+
\u2022 %s
|
|
23463
|
+
%s\
|
|
23464
|
+
`, response, handler.info.header, handler.info.callFrame);
|
|
22998
23465
|
emitter.emit('request:end', request);
|
|
22999
23466
|
(_c = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onBypassResponse) === null || _c === void 0 ? void 0 : _c.call(handleRequestOptions, request);
|
|
23000
23467
|
return;
|
|
@@ -23081,8 +23548,8 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
23081
23548
|
const { payload: actualChecksum } = yield context.events.once('INTEGRITY_CHECK_RESPONSE');
|
|
23082
23549
|
// Compare the response from the Service Worker and the
|
|
23083
23550
|
// global variable set by Rollup during the build.
|
|
23084
|
-
if (actualChecksum !== "
|
|
23085
|
-
throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"
|
|
23551
|
+
if (actualChecksum !== "02f4ad4a2797f85668baf196e553d929") {
|
|
23552
|
+
throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"02f4ad4a2797f85668baf196e553d929"}).`);
|
|
23086
23553
|
}
|
|
23087
23554
|
return serviceWorker;
|
|
23088
23555
|
});
|
|
@@ -23231,16 +23698,14 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23231
23698
|
}
|
|
23232
23699
|
|
|
23233
23700
|
const createStop = (context) => {
|
|
23234
|
-
/**
|
|
23235
|
-
* Signal the Service Worker to disable mocking for this client.
|
|
23236
|
-
* Use this an an explicit way to stop the mocking, while preserving
|
|
23237
|
-
* the worker-client relation. Does not affect the worker's lifecycle.
|
|
23238
|
-
*/
|
|
23239
23701
|
return function stop() {
|
|
23240
23702
|
var _a;
|
|
23703
|
+
/**
|
|
23704
|
+
* Signal the Service Worker to disable mocking for this client.
|
|
23705
|
+
* Use this an an explicit way to stop the mocking, while preserving
|
|
23706
|
+
* the worker-client relation. Does not affect the worker's lifecycle.
|
|
23707
|
+
*/
|
|
23241
23708
|
context.workerChannel.send('MOCK_DEACTIVATE');
|
|
23242
|
-
context.events.removeAllListeners();
|
|
23243
|
-
context.emitter.removeAllListeners();
|
|
23244
23709
|
window.clearInterval(context.keepAliveInterval);
|
|
23245
23710
|
printStopMessage({ quiet: (_a = context.startOptions) === null || _a === void 0 ? void 0 : _a.quiet });
|
|
23246
23711
|
};
|
|
@@ -23773,6 +24238,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23773
24238
|
function createDebug(namespace) {
|
|
23774
24239
|
let prevTime;
|
|
23775
24240
|
let enableOverride = null;
|
|
24241
|
+
let namespacesCache;
|
|
24242
|
+
let enabledCache;
|
|
23776
24243
|
|
|
23777
24244
|
function debug(...args) {
|
|
23778
24245
|
// Disabled?
|
|
@@ -23833,7 +24300,17 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23833
24300
|
Object.defineProperty(debug, 'enabled', {
|
|
23834
24301
|
enumerable: true,
|
|
23835
24302
|
configurable: false,
|
|
23836
|
-
get: () =>
|
|
24303
|
+
get: () => {
|
|
24304
|
+
if (enableOverride !== null) {
|
|
24305
|
+
return enableOverride;
|
|
24306
|
+
}
|
|
24307
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
24308
|
+
namespacesCache = createDebug.namespaces;
|
|
24309
|
+
enabledCache = createDebug.enabled(namespace);
|
|
24310
|
+
}
|
|
24311
|
+
|
|
24312
|
+
return enabledCache;
|
|
24313
|
+
},
|
|
23837
24314
|
set: v => {
|
|
23838
24315
|
enableOverride = v;
|
|
23839
24316
|
}
|
|
@@ -23862,6 +24339,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23862
24339
|
*/
|
|
23863
24340
|
function enable(namespaces) {
|
|
23864
24341
|
createDebug.save(namespaces);
|
|
24342
|
+
createDebug.namespaces = namespaces;
|
|
23865
24343
|
|
|
23866
24344
|
createDebug.names = [];
|
|
23867
24345
|
createDebug.skips = [];
|
|
@@ -24340,15 +24818,16 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24340
24818
|
}
|
|
24341
24819
|
debug$1('no mocked response found, bypassing...');
|
|
24342
24820
|
return [2 /*return*/, pureFetch(input, init).then(function (response) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
24343
|
-
var _a, _b, _c;
|
|
24821
|
+
var cloneResponse, _a, _b, _c;
|
|
24344
24822
|
return __generator$1(this, function (_d) {
|
|
24345
24823
|
switch (_d.label) {
|
|
24346
24824
|
case 0:
|
|
24347
|
-
|
|
24825
|
+
cloneResponse = response.clone();
|
|
24826
|
+
debug$1('original fetch performed', cloneResponse);
|
|
24348
24827
|
_b = (_a = observer).emit;
|
|
24349
24828
|
_c = ['response',
|
|
24350
24829
|
isoRequest];
|
|
24351
|
-
return [4 /*yield*/, normalizeFetchResponse(
|
|
24830
|
+
return [4 /*yield*/, normalizeFetchResponse(cloneResponse)];
|
|
24352
24831
|
case 1:
|
|
24353
24832
|
_b.apply(_a, _c.concat([_d.sent()]));
|
|
24354
24833
|
return [2 /*return*/, response];
|
|
@@ -24389,9 +24868,179 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24389
24868
|
|
|
24390
24869
|
var domParser = {};
|
|
24391
24870
|
|
|
24392
|
-
var
|
|
24871
|
+
var conventions$2 = {};
|
|
24872
|
+
|
|
24873
|
+
/**
|
|
24874
|
+
* "Shallow freezes" an object to render it immutable.
|
|
24875
|
+
* Uses `Object.freeze` if available,
|
|
24876
|
+
* otherwise the immutability is only in the type.
|
|
24877
|
+
*
|
|
24878
|
+
* Is used to create "enum like" objects.
|
|
24879
|
+
*
|
|
24880
|
+
* @template T
|
|
24881
|
+
* @param {T} object the object to freeze
|
|
24882
|
+
* @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
|
|
24883
|
+
* allows to inject custom object constructor for tests
|
|
24884
|
+
* @returns {Readonly<T>}
|
|
24885
|
+
*
|
|
24886
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
|
|
24887
|
+
*/
|
|
24888
|
+
function freeze(object, oc) {
|
|
24889
|
+
if (oc === undefined) {
|
|
24890
|
+
oc = Object;
|
|
24891
|
+
}
|
|
24892
|
+
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
|
|
24893
|
+
}
|
|
24894
|
+
|
|
24895
|
+
/**
|
|
24896
|
+
* All mime types that are allowed as input to `DOMParser.parseFromString`
|
|
24897
|
+
*
|
|
24898
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
|
|
24899
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
|
|
24900
|
+
* @see DOMParser.prototype.parseFromString
|
|
24901
|
+
*/
|
|
24902
|
+
var MIME_TYPE = freeze({
|
|
24903
|
+
/**
|
|
24904
|
+
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
|
24905
|
+
*
|
|
24906
|
+
* @see DOMParser.SupportedType.isHTML
|
|
24907
|
+
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
24908
|
+
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
24909
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
24910
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
|
|
24911
|
+
*/
|
|
24912
|
+
HTML: 'text/html',
|
|
24913
|
+
|
|
24914
|
+
/**
|
|
24915
|
+
* Helper method to check a mime type if it indicates an HTML document
|
|
24916
|
+
*
|
|
24917
|
+
* @param {string} [value]
|
|
24918
|
+
* @returns {boolean}
|
|
24919
|
+
*
|
|
24920
|
+
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
24921
|
+
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
24922
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
24923
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
|
|
24924
|
+
isHTML: function (value) {
|
|
24925
|
+
return value === MIME_TYPE.HTML
|
|
24926
|
+
},
|
|
24927
|
+
|
|
24928
|
+
/**
|
|
24929
|
+
* `application/xml`, the standard mime type for XML documents.
|
|
24930
|
+
*
|
|
24931
|
+
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
|
|
24932
|
+
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
|
|
24933
|
+
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
24934
|
+
*/
|
|
24935
|
+
XML_APPLICATION: 'application/xml',
|
|
24936
|
+
|
|
24937
|
+
/**
|
|
24938
|
+
* `text/html`, an alias for `application/xml`.
|
|
24939
|
+
*
|
|
24940
|
+
* @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
|
|
24941
|
+
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
|
|
24942
|
+
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
24943
|
+
*/
|
|
24944
|
+
XML_TEXT: 'text/xml',
|
|
24945
|
+
|
|
24946
|
+
/**
|
|
24947
|
+
* `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
|
|
24948
|
+
* but is parsed as an XML document.
|
|
24949
|
+
*
|
|
24950
|
+
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
|
|
24951
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
|
|
24952
|
+
* @see https://en.wikipedia.org/wiki/XHTML Wikipedia
|
|
24953
|
+
*/
|
|
24954
|
+
XML_XHTML_APPLICATION: 'application/xhtml+xml',
|
|
24955
|
+
|
|
24956
|
+
/**
|
|
24957
|
+
* `image/svg+xml`,
|
|
24958
|
+
*
|
|
24959
|
+
* @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
|
|
24960
|
+
* @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
|
|
24961
|
+
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
|
|
24962
|
+
*/
|
|
24963
|
+
XML_SVG_IMAGE: 'image/svg+xml',
|
|
24964
|
+
});
|
|
24965
|
+
|
|
24966
|
+
/**
|
|
24967
|
+
* Namespaces that are used in this code base.
|
|
24968
|
+
*
|
|
24969
|
+
* @see http://www.w3.org/TR/REC-xml-names
|
|
24970
|
+
*/
|
|
24971
|
+
var NAMESPACE$3 = freeze({
|
|
24972
|
+
/**
|
|
24973
|
+
* The XHTML namespace.
|
|
24974
|
+
*
|
|
24975
|
+
* @see http://www.w3.org/1999/xhtml
|
|
24976
|
+
*/
|
|
24977
|
+
HTML: 'http://www.w3.org/1999/xhtml',
|
|
24978
|
+
|
|
24979
|
+
/**
|
|
24980
|
+
* Checks if `uri` equals `NAMESPACE.HTML`.
|
|
24981
|
+
*
|
|
24982
|
+
* @param {string} [uri]
|
|
24983
|
+
*
|
|
24984
|
+
* @see NAMESPACE.HTML
|
|
24985
|
+
*/
|
|
24986
|
+
isHTML: function (uri) {
|
|
24987
|
+
return uri === NAMESPACE$3.HTML
|
|
24988
|
+
},
|
|
24989
|
+
|
|
24990
|
+
/**
|
|
24991
|
+
* The SVG namespace.
|
|
24992
|
+
*
|
|
24993
|
+
* @see http://www.w3.org/2000/svg
|
|
24994
|
+
*/
|
|
24995
|
+
SVG: 'http://www.w3.org/2000/svg',
|
|
24996
|
+
|
|
24997
|
+
/**
|
|
24998
|
+
* The `xml:` namespace.
|
|
24999
|
+
*
|
|
25000
|
+
* @see http://www.w3.org/XML/1998/namespace
|
|
25001
|
+
*/
|
|
25002
|
+
XML: 'http://www.w3.org/XML/1998/namespace',
|
|
25003
|
+
|
|
25004
|
+
/**
|
|
25005
|
+
* The `xmlns:` namespace
|
|
25006
|
+
*
|
|
25007
|
+
* @see https://www.w3.org/2000/xmlns/
|
|
25008
|
+
*/
|
|
25009
|
+
XMLNS: 'http://www.w3.org/2000/xmlns/',
|
|
25010
|
+
});
|
|
24393
25011
|
|
|
24394
|
-
|
|
25012
|
+
conventions$2.freeze = freeze;
|
|
25013
|
+
conventions$2.MIME_TYPE = MIME_TYPE;
|
|
25014
|
+
conventions$2.NAMESPACE = NAMESPACE$3;
|
|
25015
|
+
|
|
25016
|
+
var entities$1 = {};
|
|
25017
|
+
|
|
25018
|
+
(function (exports) {
|
|
25019
|
+
var freeze = conventions$2.freeze;
|
|
25020
|
+
|
|
25021
|
+
/**
|
|
25022
|
+
* The entities that are predefined in every XML document.
|
|
25023
|
+
*
|
|
25024
|
+
* @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
|
|
25025
|
+
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
|
|
25026
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
|
|
25027
|
+
*/
|
|
25028
|
+
exports.XML_ENTITIES = freeze({amp:'&', apos:"'", gt:'>', lt:'<', quot:'"'});
|
|
25029
|
+
|
|
25030
|
+
/**
|
|
25031
|
+
* A map of currently 241 entities that are detected in an HTML document.
|
|
25032
|
+
* They contain all entries from `XML_ENTITIES`.
|
|
25033
|
+
*
|
|
25034
|
+
* @see XML_ENTITIES
|
|
25035
|
+
* @see DOMParser.parseFromString
|
|
25036
|
+
* @see DOMImplementation.prototype.createHTMLDocument
|
|
25037
|
+
* @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
|
|
25038
|
+
* @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
|
|
25039
|
+
* @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
|
|
25040
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
|
|
25041
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
|
|
25042
|
+
*/
|
|
25043
|
+
exports.HTML_ENTITIES = freeze({
|
|
24395
25044
|
lt: '<',
|
|
24396
25045
|
gt: '>',
|
|
24397
25046
|
amp: '&',
|
|
@@ -24633,10 +25282,19 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24633
25282
|
clubs: "♣",
|
|
24634
25283
|
hearts: "♥",
|
|
24635
25284
|
diams: "♦"
|
|
24636
|
-
};
|
|
25285
|
+
});
|
|
25286
|
+
|
|
25287
|
+
/**
|
|
25288
|
+
* @deprecated use `HTML_ENTITIES` instead
|
|
25289
|
+
* @see HTML_ENTITIES
|
|
25290
|
+
*/
|
|
25291
|
+
exports.entityMap = exports.HTML_ENTITIES;
|
|
25292
|
+
}(entities$1));
|
|
24637
25293
|
|
|
24638
25294
|
var sax$1 = {};
|
|
24639
25295
|
|
|
25296
|
+
var NAMESPACE$2 = conventions$2.NAMESPACE;
|
|
25297
|
+
|
|
24640
25298
|
//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
24641
25299
|
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
24642
25300
|
//[5] Name ::= NameStartChar (NameChar)*
|
|
@@ -24754,7 +25412,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24754
25412
|
switch(source.charAt(tagStart+1)){
|
|
24755
25413
|
case '/':
|
|
24756
25414
|
var end = source.indexOf('>',tagStart+3);
|
|
24757
|
-
var tagName = source.substring(tagStart+2,end);
|
|
25415
|
+
var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
|
|
24758
25416
|
var config = parseStack.pop();
|
|
24759
25417
|
if(end<0){
|
|
24760
25418
|
|
|
@@ -24827,12 +25485,10 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24827
25485
|
parseStack.push(el);
|
|
24828
25486
|
}
|
|
24829
25487
|
}
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
24833
|
-
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
|
|
25488
|
+
|
|
25489
|
+
if (NAMESPACE$2.isHTML(el.uri) && !el.closed) {
|
|
24834
25490
|
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder);
|
|
24835
|
-
}else {
|
|
25491
|
+
} else {
|
|
24836
25492
|
end++;
|
|
24837
25493
|
}
|
|
24838
25494
|
}
|
|
@@ -24968,7 +25624,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24968
25624
|
errorHandler.warning('attribute "'+value+'" missed quot(")!');
|
|
24969
25625
|
addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start);
|
|
24970
25626
|
}else {
|
|
24971
|
-
if(currentNSMap['']
|
|
25627
|
+
if(!NAMESPACE$2.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
|
|
24972
25628
|
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!');
|
|
24973
25629
|
}
|
|
24974
25630
|
addAttribute(value, value, start);
|
|
@@ -25016,7 +25672,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25016
25672
|
//case S_ATTR_NOQUOT_VALUE:void();break;
|
|
25017
25673
|
case S_ATTR_SPACE:
|
|
25018
25674
|
el.tagName;
|
|
25019
|
-
if(currentNSMap['']
|
|
25675
|
+
if (!NAMESPACE$2.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
|
25020
25676
|
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!');
|
|
25021
25677
|
}
|
|
25022
25678
|
addAttribute(attrName, attrName, start);
|
|
@@ -25075,7 +25731,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25075
25731
|
//console.log(currentNSMap,1)
|
|
25076
25732
|
}
|
|
25077
25733
|
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
25078
|
-
a.uri =
|
|
25734
|
+
a.uri = NAMESPACE$2.XMLNS;
|
|
25079
25735
|
domBuilder.startPrefixMapping(nsPrefix, value);
|
|
25080
25736
|
}
|
|
25081
25737
|
}
|
|
@@ -25085,7 +25741,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25085
25741
|
var prefix = a.prefix;
|
|
25086
25742
|
if(prefix){//no prefix attribute has no namespace
|
|
25087
25743
|
if(prefix === 'xml'){
|
|
25088
|
-
a.uri =
|
|
25744
|
+
a.uri = NAMESPACE$2.XML;
|
|
25089
25745
|
}if(prefix !== 'xmlns'){
|
|
25090
25746
|
a.uri = currentNSMap[prefix || ''];
|
|
25091
25747
|
|
|
@@ -25282,11 +25938,74 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25282
25938
|
|
|
25283
25939
|
var dom = {};
|
|
25284
25940
|
|
|
25941
|
+
var conventions$1 = conventions$2;
|
|
25942
|
+
|
|
25943
|
+
var NAMESPACE$1 = conventions$1.NAMESPACE;
|
|
25944
|
+
|
|
25945
|
+
/**
|
|
25946
|
+
* A prerequisite for `[].filter`, to drop elements that are empty
|
|
25947
|
+
* @param {string} input
|
|
25948
|
+
* @returns {boolean}
|
|
25949
|
+
*/
|
|
25950
|
+
function notEmptyString (input) {
|
|
25951
|
+
return input !== ''
|
|
25952
|
+
}
|
|
25953
|
+
/**
|
|
25954
|
+
* @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
|
|
25955
|
+
* @see https://infra.spec.whatwg.org/#ascii-whitespace
|
|
25956
|
+
*
|
|
25957
|
+
* @param {string} input
|
|
25958
|
+
* @returns {string[]} (can be empty)
|
|
25959
|
+
*/
|
|
25960
|
+
function splitOnASCIIWhitespace(input) {
|
|
25961
|
+
// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
|
|
25962
|
+
return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
|
|
25963
|
+
}
|
|
25964
|
+
|
|
25965
|
+
/**
|
|
25966
|
+
* Adds element as a key to current if it is not already present.
|
|
25967
|
+
*
|
|
25968
|
+
* @param {Record<string, boolean | undefined>} current
|
|
25969
|
+
* @param {string} element
|
|
25970
|
+
* @returns {Record<string, boolean | undefined>}
|
|
25971
|
+
*/
|
|
25972
|
+
function orderedSetReducer (current, element) {
|
|
25973
|
+
if (!current.hasOwnProperty(element)) {
|
|
25974
|
+
current[element] = true;
|
|
25975
|
+
}
|
|
25976
|
+
return current;
|
|
25977
|
+
}
|
|
25978
|
+
|
|
25979
|
+
/**
|
|
25980
|
+
* @see https://infra.spec.whatwg.org/#ordered-set
|
|
25981
|
+
* @param {string} input
|
|
25982
|
+
* @returns {string[]}
|
|
25983
|
+
*/
|
|
25984
|
+
function toOrderedSet(input) {
|
|
25985
|
+
if (!input) return [];
|
|
25986
|
+
var list = splitOnASCIIWhitespace(input);
|
|
25987
|
+
return Object.keys(list.reduce(orderedSetReducer, {}))
|
|
25988
|
+
}
|
|
25989
|
+
|
|
25990
|
+
/**
|
|
25991
|
+
* Uses `list.indexOf` to implement something like `Array.prototype.includes`,
|
|
25992
|
+
* which we can not rely on being available.
|
|
25993
|
+
*
|
|
25994
|
+
* @param {any[]} list
|
|
25995
|
+
* @returns {function(any): boolean}
|
|
25996
|
+
*/
|
|
25997
|
+
function arrayIncludes (list) {
|
|
25998
|
+
return function(element) {
|
|
25999
|
+
return list && list.indexOf(element) !== -1;
|
|
26000
|
+
}
|
|
26001
|
+
}
|
|
26002
|
+
|
|
25285
26003
|
function copy(src,dest){
|
|
25286
26004
|
for(var p in src){
|
|
25287
26005
|
dest[p] = src[p];
|
|
25288
26006
|
}
|
|
25289
26007
|
}
|
|
26008
|
+
|
|
25290
26009
|
/**
|
|
25291
26010
|
^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
|
|
25292
26011
|
^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
|
|
@@ -25306,7 +26025,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25306
26025
|
pt.constructor = Class;
|
|
25307
26026
|
}
|
|
25308
26027
|
}
|
|
25309
|
-
|
|
26028
|
+
|
|
25310
26029
|
// Node Types
|
|
25311
26030
|
var NodeType = {};
|
|
25312
26031
|
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
|
@@ -25362,6 +26081,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25362
26081
|
return error;
|
|
25363
26082
|
}DOMException.prototype = Error.prototype;
|
|
25364
26083
|
copy(ExceptionCode,DOMException);
|
|
26084
|
+
|
|
25365
26085
|
/**
|
|
25366
26086
|
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
|
|
25367
26087
|
* The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
|
|
@@ -25392,6 +26112,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25392
26112
|
return buf.join('');
|
|
25393
26113
|
}
|
|
25394
26114
|
};
|
|
26115
|
+
|
|
25395
26116
|
function LiveNodeList(node,refresh){
|
|
25396
26117
|
this._node = node;
|
|
25397
26118
|
this._refresh = refresh;
|
|
@@ -25413,9 +26134,15 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25413
26134
|
};
|
|
25414
26135
|
|
|
25415
26136
|
_extends(LiveNodeList,NodeList);
|
|
26137
|
+
|
|
25416
26138
|
/**
|
|
25417
|
-
*
|
|
25418
|
-
*
|
|
26139
|
+
* Objects implementing the NamedNodeMap interface are used
|
|
26140
|
+
* to represent collections of nodes that can be accessed by name.
|
|
26141
|
+
* Note that NamedNodeMap does not inherit from NodeList;
|
|
26142
|
+
* NamedNodeMaps are not maintained in any particular order.
|
|
26143
|
+
* Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
|
|
26144
|
+
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
|
|
26145
|
+
* and does not imply that the DOM specifies an order to these Nodes.
|
|
25419
26146
|
* NamedNodeMap objects in the DOM are live.
|
|
25420
26147
|
* used for attributes or DocumentType entities
|
|
25421
26148
|
*/
|
|
@@ -25526,54 +26253,108 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25526
26253
|
return null;
|
|
25527
26254
|
}
|
|
25528
26255
|
};
|
|
26256
|
+
|
|
25529
26257
|
/**
|
|
25530
|
-
*
|
|
26258
|
+
* The DOMImplementation interface represents an object providing methods
|
|
26259
|
+
* which are not dependent on any particular document.
|
|
26260
|
+
* Such an object is returned by the `Document.implementation` property.
|
|
26261
|
+
*
|
|
26262
|
+
* __The individual methods describe the differences compared to the specs.__
|
|
26263
|
+
*
|
|
26264
|
+
* @constructor
|
|
26265
|
+
*
|
|
26266
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
|
|
26267
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
|
|
26268
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
|
|
26269
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
|
|
26270
|
+
* @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
|
|
25531
26271
|
*/
|
|
25532
|
-
function DOMImplementation$1(
|
|
25533
|
-
this._features = {};
|
|
25534
|
-
if (features) {
|
|
25535
|
-
for (var feature in features) {
|
|
25536
|
-
this._features = features[feature];
|
|
25537
|
-
}
|
|
25538
|
-
}
|
|
26272
|
+
function DOMImplementation$1() {
|
|
25539
26273
|
}
|
|
26274
|
+
|
|
25540
26275
|
DOMImplementation$1.prototype = {
|
|
25541
|
-
|
|
25542
|
-
|
|
25543
|
-
|
|
26276
|
+
/**
|
|
26277
|
+
* The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
|
|
26278
|
+
* The different implementations fairly diverged in what kind of features were reported.
|
|
26279
|
+
* The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
|
|
26280
|
+
*
|
|
26281
|
+
* @deprecated It is deprecated and modern browsers return true in all cases.
|
|
26282
|
+
*
|
|
26283
|
+
* @param {string} feature
|
|
26284
|
+
* @param {string} [version]
|
|
26285
|
+
* @returns {boolean} always true
|
|
26286
|
+
*
|
|
26287
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
|
|
26288
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
|
|
26289
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
|
|
26290
|
+
*/
|
|
26291
|
+
hasFeature: function(feature, version) {
|
|
25544
26292
|
return true;
|
|
25545
|
-
} else {
|
|
25546
|
-
return false;
|
|
25547
|
-
}
|
|
25548
26293
|
},
|
|
25549
|
-
|
|
25550
|
-
|
|
26294
|
+
/**
|
|
26295
|
+
* Creates an XML Document object of the specified type with its document element.
|
|
26296
|
+
*
|
|
26297
|
+
* __It behaves slightly different from the description in the living standard__:
|
|
26298
|
+
* - There is no interface/class `XMLDocument`, it returns a `Document` instance.
|
|
26299
|
+
* - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
|
|
26300
|
+
* - this implementation is not validating names or qualified names
|
|
26301
|
+
* (when parsing XML strings, the SAX parser takes care of that)
|
|
26302
|
+
*
|
|
26303
|
+
* @param {string|null} namespaceURI
|
|
26304
|
+
* @param {string} qualifiedName
|
|
26305
|
+
* @param {DocumentType=null} doctype
|
|
26306
|
+
* @returns {Document}
|
|
26307
|
+
*
|
|
26308
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
|
|
26309
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
|
|
26310
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
|
|
26311
|
+
*
|
|
26312
|
+
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
|
|
26313
|
+
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
|
|
26314
|
+
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
|
|
26315
|
+
*/
|
|
26316
|
+
createDocument: function(namespaceURI, qualifiedName, doctype){
|
|
25551
26317
|
var doc = new Document();
|
|
25552
26318
|
doc.implementation = this;
|
|
25553
26319
|
doc.childNodes = new NodeList();
|
|
25554
|
-
doc.doctype = doctype;
|
|
25555
|
-
if(doctype){
|
|
26320
|
+
doc.doctype = doctype || null;
|
|
26321
|
+
if (doctype){
|
|
25556
26322
|
doc.appendChild(doctype);
|
|
25557
26323
|
}
|
|
25558
|
-
if(qualifiedName){
|
|
25559
|
-
var root = doc.createElementNS(namespaceURI,qualifiedName);
|
|
26324
|
+
if (qualifiedName){
|
|
26325
|
+
var root = doc.createElementNS(namespaceURI, qualifiedName);
|
|
25560
26326
|
doc.appendChild(root);
|
|
25561
26327
|
}
|
|
25562
26328
|
return doc;
|
|
25563
26329
|
},
|
|
25564
|
-
|
|
25565
|
-
|
|
26330
|
+
/**
|
|
26331
|
+
* Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
|
|
26332
|
+
*
|
|
26333
|
+
* __This behavior is slightly different from the in the specs__:
|
|
26334
|
+
* - this implementation is not validating names or qualified names
|
|
26335
|
+
* (when parsing XML strings, the SAX parser takes care of that)
|
|
26336
|
+
*
|
|
26337
|
+
* @param {string} qualifiedName
|
|
26338
|
+
* @param {string} [publicId]
|
|
26339
|
+
* @param {string} [systemId]
|
|
26340
|
+
* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
|
|
26341
|
+
* or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
|
|
26342
|
+
*
|
|
26343
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
|
|
26344
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
|
|
26345
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
|
|
26346
|
+
*
|
|
26347
|
+
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
|
|
26348
|
+
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
|
|
26349
|
+
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
|
|
26350
|
+
*/
|
|
26351
|
+
createDocumentType: function(qualifiedName, publicId, systemId){
|
|
25566
26352
|
var node = new DocumentType();
|
|
25567
26353
|
node.name = qualifiedName;
|
|
25568
26354
|
node.nodeName = qualifiedName;
|
|
25569
|
-
node.publicId = publicId;
|
|
25570
|
-
node.systemId = systemId;
|
|
25571
|
-
|
|
25572
|
-
//readonly attribute DOMString internalSubset;
|
|
25573
|
-
|
|
25574
|
-
//TODO:..
|
|
25575
|
-
// readonly attribute NamedNodeMap entities;
|
|
25576
|
-
// readonly attribute NamedNodeMap notations;
|
|
26355
|
+
node.publicId = publicId || '';
|
|
26356
|
+
node.systemId = systemId || '';
|
|
26357
|
+
|
|
25577
26358
|
return node;
|
|
25578
26359
|
}
|
|
25579
26360
|
};
|
|
@@ -25712,22 +26493,25 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25712
26493
|
|
|
25713
26494
|
function Document(){
|
|
25714
26495
|
}
|
|
26496
|
+
|
|
25715
26497
|
function _onAddAttribute(doc,el,newAttr){
|
|
25716
26498
|
doc && doc._inc++;
|
|
25717
26499
|
var ns = newAttr.namespaceURI ;
|
|
25718
|
-
if(ns
|
|
26500
|
+
if(ns === NAMESPACE$1.XMLNS){
|
|
25719
26501
|
//update namespace
|
|
25720
26502
|
el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value;
|
|
25721
26503
|
}
|
|
25722
26504
|
}
|
|
26505
|
+
|
|
25723
26506
|
function _onRemoveAttribute(doc,el,newAttr,remove){
|
|
25724
26507
|
doc && doc._inc++;
|
|
25725
26508
|
var ns = newAttr.namespaceURI ;
|
|
25726
|
-
if(ns
|
|
26509
|
+
if(ns === NAMESPACE$1.XMLNS){
|
|
25727
26510
|
//update namespace
|
|
25728
26511
|
delete el._nsMap[newAttr.prefix?newAttr.localName:''];
|
|
25729
26512
|
}
|
|
25730
26513
|
}
|
|
26514
|
+
|
|
25731
26515
|
function _onUpdateChild(doc,el,newChild){
|
|
25732
26516
|
if(doc && doc._inc){
|
|
25733
26517
|
doc._inc++;
|
|
@@ -25843,8 +26627,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25843
26627
|
doctype : null,
|
|
25844
26628
|
documentElement : null,
|
|
25845
26629
|
_inc : 1,
|
|
25846
|
-
|
|
25847
|
-
insertBefore : function(newChild, refChild){//raises
|
|
26630
|
+
|
|
26631
|
+
insertBefore : function(newChild, refChild){//raises
|
|
25848
26632
|
if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
|
|
25849
26633
|
var child = newChild.firstChild;
|
|
25850
26634
|
while(child){
|
|
@@ -25857,7 +26641,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25857
26641
|
if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
|
|
25858
26642
|
this.documentElement = newChild;
|
|
25859
26643
|
}
|
|
25860
|
-
|
|
26644
|
+
|
|
25861
26645
|
return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
|
|
25862
26646
|
},
|
|
25863
26647
|
removeChild : function(oldChild){
|
|
@@ -25883,28 +26667,58 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25883
26667
|
});
|
|
25884
26668
|
return rtv;
|
|
25885
26669
|
},
|
|
25886
|
-
|
|
25887
|
-
|
|
25888
|
-
|
|
26670
|
+
|
|
26671
|
+
/**
|
|
26672
|
+
* The `getElementsByClassName` method of `Document` interface returns an array-like object
|
|
26673
|
+
* of all child elements which have **all** of the given class name(s).
|
|
26674
|
+
*
|
|
26675
|
+
* Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
|
|
26676
|
+
*
|
|
26677
|
+
*
|
|
26678
|
+
* Warning: This is a live LiveNodeList.
|
|
26679
|
+
* Changes in the DOM will reflect in the array as the changes occur.
|
|
26680
|
+
* If an element selected by this array no longer qualifies for the selector,
|
|
26681
|
+
* it will automatically be removed. Be aware of this for iteration purposes.
|
|
26682
|
+
*
|
|
26683
|
+
* @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
|
|
26684
|
+
*
|
|
26685
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
|
|
26686
|
+
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
|
|
26687
|
+
*/
|
|
26688
|
+
getElementsByClassName: function(classNames) {
|
|
26689
|
+
var classNamesSet = toOrderedSet(classNames);
|
|
25889
26690
|
return new LiveNodeList(this, function(base) {
|
|
25890
26691
|
var ls = [];
|
|
25891
|
-
|
|
25892
|
-
|
|
25893
|
-
if(
|
|
25894
|
-
|
|
26692
|
+
if (classNamesSet.length > 0) {
|
|
26693
|
+
_visitNode(base.documentElement, function(node) {
|
|
26694
|
+
if(node !== base && node.nodeType === ELEMENT_NODE) {
|
|
26695
|
+
var nodeClassNames = node.getAttribute('class');
|
|
26696
|
+
// can be null if the attribute does not exist
|
|
26697
|
+
if (nodeClassNames) {
|
|
26698
|
+
// before splitting and iterating just compare them for the most common case
|
|
26699
|
+
var matches = classNames === nodeClassNames;
|
|
26700
|
+
if (!matches) {
|
|
26701
|
+
var nodeClassNamesSet = toOrderedSet(nodeClassNames);
|
|
26702
|
+
matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
|
|
26703
|
+
}
|
|
26704
|
+
if(matches) {
|
|
26705
|
+
ls.push(node);
|
|
26706
|
+
}
|
|
26707
|
+
}
|
|
25895
26708
|
}
|
|
25896
|
-
}
|
|
25897
|
-
}
|
|
26709
|
+
});
|
|
26710
|
+
}
|
|
25898
26711
|
return ls;
|
|
25899
26712
|
});
|
|
25900
26713
|
},
|
|
25901
|
-
|
|
26714
|
+
|
|
25902
26715
|
//document factory method:
|
|
25903
26716
|
createElement : function(tagName){
|
|
25904
26717
|
var node = new Element();
|
|
25905
26718
|
node.ownerDocument = this;
|
|
25906
26719
|
node.nodeName = tagName;
|
|
25907
26720
|
node.tagName = tagName;
|
|
26721
|
+
node.localName = tagName;
|
|
25908
26722
|
node.childNodes = new NodeList();
|
|
25909
26723
|
var attrs = node.attributes = new NamedNodeMap();
|
|
25910
26724
|
attrs._ownerElement = node;
|
|
@@ -26211,36 +27025,49 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26211
27025
|
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
|
|
26212
27026
|
return buf.join('');
|
|
26213
27027
|
}
|
|
26214
|
-
|
|
26215
|
-
|
|
27028
|
+
|
|
27029
|
+
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
|
27030
|
+
var prefix = node.prefix || '';
|
|
26216
27031
|
var uri = node.namespaceURI;
|
|
26217
|
-
|
|
27032
|
+
// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
|
|
27033
|
+
// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
|
|
27034
|
+
// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
|
|
27035
|
+
// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
|
|
27036
|
+
// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
|
|
27037
|
+
// > [...] Furthermore, the attribute value [...] must not be an empty string.
|
|
27038
|
+
// so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
|
|
27039
|
+
if (!uri) {
|
|
26218
27040
|
return false;
|
|
26219
27041
|
}
|
|
26220
|
-
if (prefix === "xml" && uri ===
|
|
26221
|
-
|| uri == 'http://www.w3.org/2000/xmlns/'){
|
|
27042
|
+
if (prefix === "xml" && uri === NAMESPACE$1.XML || uri === NAMESPACE$1.XMLNS) {
|
|
26222
27043
|
return false;
|
|
26223
27044
|
}
|
|
26224
27045
|
|
|
26225
27046
|
var i = visibleNamespaces.length;
|
|
26226
|
-
//console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
|
|
26227
27047
|
while (i--) {
|
|
26228
27048
|
var ns = visibleNamespaces[i];
|
|
26229
27049
|
// get namespace prefix
|
|
26230
|
-
|
|
26231
|
-
|
|
26232
|
-
return ns.namespace != uri;
|
|
27050
|
+
if (ns.prefix === prefix) {
|
|
27051
|
+
return ns.namespace !== uri;
|
|
26233
27052
|
}
|
|
26234
27053
|
}
|
|
26235
|
-
//console.log(isHTML,uri,prefix=='')
|
|
26236
|
-
//if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
|
|
26237
|
-
// return false;
|
|
26238
|
-
//}
|
|
26239
|
-
//node.flag = '11111'
|
|
26240
|
-
//console.error(3,true,node.flag,node.prefix,node.namespaceURI)
|
|
26241
27054
|
return true;
|
|
26242
27055
|
}
|
|
27056
|
+
/**
|
|
27057
|
+
* Well-formed constraint: No < in Attribute Values
|
|
27058
|
+
* The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
|
|
27059
|
+
* @see https://www.w3.org/TR/xml/#CleanAttrVals
|
|
27060
|
+
* @see https://www.w3.org/TR/xml/#NT-AttValue
|
|
27061
|
+
*/
|
|
27062
|
+
function addSerializedAttribute(buf, qualifiedName, value) {
|
|
27063
|
+
buf.push(' ', qualifiedName, '="', value.replace(/[<&"]/g,_xmlEncoder), '"');
|
|
27064
|
+
}
|
|
27065
|
+
|
|
26243
27066
|
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
27067
|
+
if (!visibleNamespaces) {
|
|
27068
|
+
visibleNamespaces = [];
|
|
27069
|
+
}
|
|
27070
|
+
|
|
26244
27071
|
if(nodeFilter){
|
|
26245
27072
|
node = nodeFilter(node);
|
|
26246
27073
|
if(node){
|
|
@@ -26253,20 +27080,40 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26253
27080
|
}
|
|
26254
27081
|
//buf.sort.apply(attrs, attributeSorter);
|
|
26255
27082
|
}
|
|
27083
|
+
|
|
26256
27084
|
switch(node.nodeType){
|
|
26257
27085
|
case ELEMENT_NODE:
|
|
26258
|
-
if (!visibleNamespaces) visibleNamespaces = [];
|
|
26259
|
-
visibleNamespaces.length;
|
|
26260
27086
|
var attrs = node.attributes;
|
|
26261
27087
|
var len = attrs.length;
|
|
26262
27088
|
var child = node.firstChild;
|
|
26263
27089
|
var nodeName = node.tagName;
|
|
26264
27090
|
|
|
26265
|
-
isHTML =
|
|
26266
|
-
|
|
26267
|
-
|
|
26268
|
-
|
|
26269
|
-
|
|
27091
|
+
isHTML = NAMESPACE$1.isHTML(node.namespaceURI) || isHTML;
|
|
27092
|
+
|
|
27093
|
+
var prefixedNodeName = nodeName;
|
|
27094
|
+
if (!isHTML && !node.prefix && node.namespaceURI) {
|
|
27095
|
+
var defaultNS;
|
|
27096
|
+
for (var ai = 0; ai < attrs.length; ai++) {
|
|
27097
|
+
if (attrs.item(ai).name === 'xmlns') {
|
|
27098
|
+
defaultNS = attrs.item(ai).value;
|
|
27099
|
+
break
|
|
27100
|
+
}
|
|
27101
|
+
}
|
|
27102
|
+
if (defaultNS !== node.namespaceURI) {
|
|
27103
|
+
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
27104
|
+
var namespace = visibleNamespaces[nsi];
|
|
27105
|
+
if (namespace.namespace === node.namespaceURI) {
|
|
27106
|
+
if (namespace.prefix) {
|
|
27107
|
+
prefixedNodeName = namespace.prefix + ':' + nodeName;
|
|
27108
|
+
}
|
|
27109
|
+
break
|
|
27110
|
+
}
|
|
27111
|
+
}
|
|
27112
|
+
}
|
|
27113
|
+
}
|
|
27114
|
+
|
|
27115
|
+
buf.push('<', prefixedNodeName);
|
|
27116
|
+
|
|
26270
27117
|
for(var i=0;i<len;i++){
|
|
26271
27118
|
// add namespaces for attributes
|
|
26272
27119
|
var attr = attrs.item(i);
|
|
@@ -26276,28 +27123,24 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26276
27123
|
visibleNamespaces.push({ prefix: '', namespace: attr.value });
|
|
26277
27124
|
}
|
|
26278
27125
|
}
|
|
27126
|
+
|
|
26279
27127
|
for(var i=0;i<len;i++){
|
|
26280
27128
|
var attr = attrs.item(i);
|
|
26281
27129
|
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
|
|
26282
27130
|
var prefix = attr.prefix||'';
|
|
26283
27131
|
var uri = attr.namespaceURI;
|
|
26284
|
-
|
|
26285
|
-
buf.push(ns, '="' , uri , '"');
|
|
27132
|
+
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
|
26286
27133
|
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
26287
27134
|
}
|
|
26288
27135
|
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
26289
27136
|
}
|
|
27137
|
+
|
|
26290
27138
|
// add namespace for current node
|
|
26291
|
-
if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
|
|
27139
|
+
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
|
26292
27140
|
var prefix = node.prefix||'';
|
|
26293
27141
|
var uri = node.namespaceURI;
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
// Empty namespace URL will we produce an invalid XML document
|
|
26297
|
-
var ns = prefix ? ' xmlns:' + prefix : " xmlns";
|
|
26298
|
-
buf.push(ns, '="' , uri , '"');
|
|
26299
|
-
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
26300
|
-
}
|
|
27142
|
+
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
|
27143
|
+
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
26301
27144
|
}
|
|
26302
27145
|
|
|
26303
27146
|
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
|
|
@@ -26308,18 +27151,18 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26308
27151
|
if(child.data){
|
|
26309
27152
|
buf.push(child.data);
|
|
26310
27153
|
}else {
|
|
26311
|
-
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
27154
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
26312
27155
|
}
|
|
26313
27156
|
child = child.nextSibling;
|
|
26314
27157
|
}
|
|
26315
27158
|
}else
|
|
26316
27159
|
{
|
|
26317
27160
|
while(child){
|
|
26318
|
-
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
27161
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
26319
27162
|
child = child.nextSibling;
|
|
26320
27163
|
}
|
|
26321
27164
|
}
|
|
26322
|
-
buf.push('</',
|
|
27165
|
+
buf.push('</',prefixedNodeName,'>');
|
|
26323
27166
|
}else {
|
|
26324
27167
|
buf.push('/>');
|
|
26325
27168
|
}
|
|
@@ -26330,18 +27173,12 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26330
27173
|
case DOCUMENT_FRAGMENT_NODE:
|
|
26331
27174
|
var child = node.firstChild;
|
|
26332
27175
|
while(child){
|
|
26333
|
-
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
27176
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
26334
27177
|
child = child.nextSibling;
|
|
26335
27178
|
}
|
|
26336
27179
|
return;
|
|
26337
27180
|
case ATTRIBUTE_NODE:
|
|
26338
|
-
|
|
26339
|
-
* Well-formedness constraint: No < in Attribute Values
|
|
26340
|
-
* The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
|
|
26341
|
-
* @see https://www.w3.org/TR/xml/#CleanAttrVals
|
|
26342
|
-
* @see https://www.w3.org/TR/xml/#NT-AttValue
|
|
26343
|
-
*/
|
|
26344
|
-
return buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g,_xmlEncoder), '"');
|
|
27181
|
+
return addSerializedAttribute(buf, node.name, node.value);
|
|
26345
27182
|
case TEXT_NODE:
|
|
26346
27183
|
/**
|
|
26347
27184
|
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
@@ -26492,10 +27329,12 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26492
27329
|
return this.$$length;
|
|
26493
27330
|
}
|
|
26494
27331
|
});
|
|
27332
|
+
|
|
26495
27333
|
Object.defineProperty(Node.prototype,'textContent',{
|
|
26496
27334
|
get:function(){
|
|
26497
27335
|
return getTextContent(this);
|
|
26498
27336
|
},
|
|
27337
|
+
|
|
26499
27338
|
set:function(data){
|
|
26500
27339
|
switch(this.nodeType){
|
|
26501
27340
|
case ELEMENT_NODE:
|
|
@@ -26507,8 +27346,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26507
27346
|
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
26508
27347
|
}
|
|
26509
27348
|
break;
|
|
27349
|
+
|
|
26510
27350
|
default:
|
|
26511
|
-
//TODO:
|
|
26512
27351
|
this.data = data;
|
|
26513
27352
|
this.value = data;
|
|
26514
27353
|
this.nodeValue = data;
|
|
@@ -26533,6 +27372,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26533
27372
|
return node.nodeValue;
|
|
26534
27373
|
}
|
|
26535
27374
|
}
|
|
27375
|
+
|
|
26536
27376
|
__set__ = function(object,key,value){
|
|
26537
27377
|
//console.log(value)
|
|
26538
27378
|
object['$$'+key] = value;
|
|
@@ -26542,11 +27382,19 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26542
27382
|
}
|
|
26543
27383
|
|
|
26544
27384
|
//if(typeof require == 'function'){
|
|
26545
|
-
dom.
|
|
27385
|
+
dom.DocumentType = DocumentType;
|
|
26546
27386
|
dom.DOMException = DOMException;
|
|
26547
27387
|
dom.DOMImplementation = DOMImplementation$1;
|
|
27388
|
+
dom.Element = Element;
|
|
27389
|
+
dom.Node = Node;
|
|
27390
|
+
dom.NodeList = NodeList;
|
|
26548
27391
|
dom.XMLSerializer = XMLSerializer;
|
|
26549
27392
|
|
|
27393
|
+
var conventions = conventions$2;
|
|
27394
|
+
var entities = entities$1;
|
|
27395
|
+
|
|
27396
|
+
var NAMESPACE = conventions.NAMESPACE;
|
|
27397
|
+
|
|
26550
27398
|
function DOMParser(options){
|
|
26551
27399
|
this.options = options ||{locator:{}};
|
|
26552
27400
|
}
|
|
@@ -26559,7 +27407,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26559
27407
|
var locator = options.locator;
|
|
26560
27408
|
var defaultNSMap = options.xmlns||{};
|
|
26561
27409
|
var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
|
|
26562
|
-
var entityMap = isHTML?
|
|
27410
|
+
var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
|
|
26563
27411
|
if(locator){
|
|
26564
27412
|
domBuilder.setDocumentLocator(locator);
|
|
26565
27413
|
}
|
|
@@ -26567,9 +27415,9 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26567
27415
|
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
|
26568
27416
|
sax.domBuilder = options.domBuilder || domBuilder;
|
|
26569
27417
|
if(isHTML){
|
|
26570
|
-
defaultNSMap['']=
|
|
27418
|
+
defaultNSMap[''] = NAMESPACE.HTML;
|
|
26571
27419
|
}
|
|
26572
|
-
defaultNSMap.xml = defaultNSMap.xml ||
|
|
27420
|
+
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
|
26573
27421
|
if(source && typeof source === 'string'){
|
|
26574
27422
|
sax.parse(source,defaultNSMap,entityMap);
|
|
26575
27423
|
}else {
|
|
@@ -26791,7 +27639,6 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26791
27639
|
}//appendChild and setAttributeNS are preformance key
|
|
26792
27640
|
|
|
26793
27641
|
//if(typeof require == 'function'){
|
|
26794
|
-
var htmlEntity = entities;
|
|
26795
27642
|
var sax = sax$1;
|
|
26796
27643
|
var XMLReader = sax.XMLReader;
|
|
26797
27644
|
var ParseError = sax.ParseError;
|
|
@@ -27260,7 +28107,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27260
28107
|
debug('received original response', _this.status, _this.statusText);
|
|
27261
28108
|
debug('original response body:', _this.response);
|
|
27262
28109
|
var responseHeaders = originalRequest_1.getAllResponseHeaders();
|
|
27263
|
-
debug('original response headers', responseHeaders);
|
|
28110
|
+
debug('original response headers:\n', responseHeaders);
|
|
27264
28111
|
_this._responseHeaders = headers_utils_1.stringToHeaders(responseHeaders);
|
|
27265
28112
|
debug('original response headers (normalized)', _this._responseHeaders);
|
|
27266
28113
|
debug('original response finished');
|
|
@@ -27538,6 +28385,23 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27538
28385
|
};
|
|
27539
28386
|
}
|
|
27540
28387
|
|
|
28388
|
+
/**
|
|
28389
|
+
* Pipes all emitted events from one emitter to another.
|
|
28390
|
+
*/
|
|
28391
|
+
function pipeEvents(source, destination) {
|
|
28392
|
+
const rawEmit = source.emit;
|
|
28393
|
+
// @ts-ignore
|
|
28394
|
+
if (rawEmit._isPiped) {
|
|
28395
|
+
return;
|
|
28396
|
+
}
|
|
28397
|
+
source.emit = function (event, ...data) {
|
|
28398
|
+
destination.emit(event, ...data);
|
|
28399
|
+
return rawEmit.call(this, event, ...data);
|
|
28400
|
+
};
|
|
28401
|
+
// @ts-ignore
|
|
28402
|
+
source.emit._isPiped = true;
|
|
28403
|
+
}
|
|
28404
|
+
|
|
27541
28405
|
// Declare the list of event handlers on the module's scope
|
|
27542
28406
|
// so it persists between Fash refreshes of the application's code.
|
|
27543
28407
|
let listeners = [];
|
|
@@ -27556,12 +28420,15 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27556
28420
|
if (lib$5.exports.isNodeProcess()) {
|
|
27557
28421
|
throw new Error(devUtils.formatMessage('Failed to execute `setupWorker` in a non-browser environment. Consider using `setupServer` for Node.js environment instead.'));
|
|
27558
28422
|
}
|
|
28423
|
+
const emitter = new lib$4.StrictEventEmitter();
|
|
28424
|
+
const publicEmitter = new lib$4.StrictEventEmitter();
|
|
28425
|
+
pipeEvents(emitter, publicEmitter);
|
|
27559
28426
|
const context = {
|
|
27560
28427
|
startOptions: undefined,
|
|
27561
28428
|
worker: null,
|
|
27562
28429
|
registration: null,
|
|
27563
28430
|
requestHandlers: [...requestHandlers],
|
|
27564
|
-
emitter
|
|
28431
|
+
emitter,
|
|
27565
28432
|
workerChannel: {
|
|
27566
28433
|
on(eventType, callback) {
|
|
27567
28434
|
context.events.addListener(navigator.serviceWorker, 'message', (event) => {
|
|
@@ -27627,7 +28494,12 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27627
28494
|
: createStop(context);
|
|
27628
28495
|
return {
|
|
27629
28496
|
start: prepareStartHandler(startHandler, context),
|
|
27630
|
-
stop
|
|
28497
|
+
stop() {
|
|
28498
|
+
context.events.removeAllListeners();
|
|
28499
|
+
context.emitter.removeAllListeners();
|
|
28500
|
+
publicEmitter.removeAllListeners();
|
|
28501
|
+
stopHandler();
|
|
28502
|
+
},
|
|
27631
28503
|
use(...handlers) {
|
|
27632
28504
|
use(context.requestHandlers, ...handlers);
|
|
27633
28505
|
},
|
|
@@ -27654,8 +28526,16 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27654
28526
|
console.groupEnd();
|
|
27655
28527
|
});
|
|
27656
28528
|
},
|
|
27657
|
-
|
|
27658
|
-
|
|
28529
|
+
events: {
|
|
28530
|
+
on(...args) {
|
|
28531
|
+
return publicEmitter.on(...args);
|
|
28532
|
+
},
|
|
28533
|
+
removeListener(...args) {
|
|
28534
|
+
return publicEmitter.removeListener(...args);
|
|
28535
|
+
},
|
|
28536
|
+
removeAllListeners(...args) {
|
|
28537
|
+
return publicEmitter.removeAllListeners(...args);
|
|
28538
|
+
},
|
|
27659
28539
|
},
|
|
27660
28540
|
};
|
|
27661
28541
|
}
|
|
@@ -27666,6 +28546,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27666
28546
|
};
|
|
27667
28547
|
}
|
|
27668
28548
|
const rest = {
|
|
28549
|
+
all: createRestHandler(/.+/),
|
|
27669
28550
|
head: createRestHandler(exports.RESTMethods.HEAD),
|
|
27670
28551
|
get: createRestHandler(exports.RESTMethods.GET),
|
|
27671
28552
|
post: createRestHandler(exports.RESTMethods.POST),
|
|
@@ -27726,6 +28607,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27726
28607
|
exports.GraphQLHandler = GraphQLHandler;
|
|
27727
28608
|
exports.RequestHandler = RequestHandler;
|
|
27728
28609
|
exports.RestHandler = RestHandler;
|
|
28610
|
+
exports.cleanUrl = cleanUrl;
|
|
27729
28611
|
exports.compose = compose;
|
|
27730
28612
|
exports.context = index;
|
|
27731
28613
|
exports.createResponseComposition = createResponseComposition;
|
|
@@ -27741,4 +28623,4 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27741
28623
|
exports.restContext = restContext;
|
|
27742
28624
|
exports.setupWorker = setupWorker;
|
|
27743
28625
|
|
|
27744
|
-
}))
|
|
28626
|
+
}));
|