msw 0.34.0 → 0.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/lib/esm/RequestHandler-deps.js +391 -66
  2. package/lib/esm/errors-deps.js +15 -1
  3. package/lib/esm/fetch-deps.js +9 -5
  4. package/lib/esm/graphql-deps.js +10 -6
  5. package/lib/esm/graphql.js +1 -0
  6. package/lib/esm/index-deps.js +2 -1
  7. package/lib/esm/index.js +102 -3893
  8. package/lib/esm/index2.js +1 -1
  9. package/lib/esm/mockServiceWorker.js +5 -5
  10. package/lib/esm/rest-deps.js +7 -15
  11. package/lib/esm/rest.js +1 -0
  12. package/lib/iife/index.js +3 -3
  13. package/lib/iife/mockServiceWorker.js +5 -5
  14. package/lib/types/context/data.d.ts +2 -3
  15. package/lib/types/context/extensions.d.ts +8 -0
  16. package/lib/types/context/index.d.ts +1 -0
  17. package/lib/types/graphql.d.ts +2 -1
  18. package/lib/types/handlers/GraphQLHandler.d.ts +7 -6
  19. package/lib/types/handlers/RequestHandler.d.ts +8 -8
  20. package/lib/types/handlers/RestHandler.d.ts +10 -12
  21. package/lib/types/index.d.ts +17 -7
  22. package/lib/types/native/index.d.ts +1 -1
  23. package/lib/types/node/glossary.d.ts +4 -14
  24. package/lib/types/node/index.d.ts +1 -1
  25. package/lib/types/node/setupServer.d.ts +1 -1
  26. package/lib/types/rest.d.ts +10 -9
  27. package/lib/types/setupWorker/glossary.d.ts +16 -26
  28. package/lib/types/setupWorker/start/utils/prepareStartHandler.d.ts +3 -3
  29. package/lib/types/sharedOptions.d.ts +12 -1
  30. package/lib/types/typeUtils.d.ts +5 -3
  31. package/lib/types/utils/getResponse.d.ts +1 -1
  32. package/lib/types/utils/handleRequest.d.ts +4 -4
  33. package/lib/types/utils/internal/getCallFrame.d.ts +1 -1
  34. package/lib/types/utils/internal/jsonParse.d.ts +2 -2
  35. package/lib/types/utils/internal/pipeEvents.d.ts +6 -0
  36. package/lib/types/utils/internal/requestHandlerUtils.d.ts +1 -1
  37. package/lib/types/utils/logging/prepareResponse.d.ts +1 -1
  38. package/lib/types/utils/matching/matchRequestUrl.d.ts +12 -2
  39. package/lib/types/utils/matching/normalizePath.d.ts +1 -1
  40. package/lib/types/utils/request/onUnhandledRequest.d.ts +1 -2
  41. package/lib/types/utils/request/parseBody.d.ts +2 -2
  42. package/lib/types/utils/request/parseWorkerRequest.d.ts +2 -2
  43. package/lib/types/utils/worker/createFallbackRequestListener.d.ts +2 -1
  44. package/lib/types/utils/worker/createRequestListener.d.ts +2 -1
  45. package/lib/umd/index.js +1070 -243
  46. package/lib/umd/mockServiceWorker.js +5 -5
  47. package/native/lib/index.js +501 -501
  48. package/node/lib/index.js +503 -503
  49. 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$4;
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$4(str, options) {
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 string into a JSON.
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(str) {
877
+ function jsonParse(value) {
878
878
  try {
879
- return JSON.parse(str);
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
- requestParameters.body =
1055
- typeof body === 'object' ? JSON.stringify(body) : body;
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,
@@ -2086,7 +2105,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
2086
2105
  return cookie;
2087
2106
  }
2088
2107
 
2089
- function parse$3(input, options) {
2108
+ function parse$4(input, options) {
2090
2109
  options = options
2091
2110
  ? Object.assign({}, defaultParseOptions, options)
2092
2111
  : defaultParseOptions;
@@ -2224,8 +2243,8 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
2224
2243
  return cookiesStrings;
2225
2244
  }
2226
2245
 
2227
- setCookie.exports = parse$3;
2228
- setCookie.exports.parse = parse$3;
2246
+ setCookie.exports = parse$4;
2247
+ setCookie.exports.parse = parse$4;
2229
2248
  setCookie.exports.parseString = parseString;
2230
2249
  setCookie.exports.splitCookiesString = splitCookiesString;
2231
2250
 
@@ -2405,7 +2424,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2405
2424
  /**
2406
2425
  * @note No cookies persist on the document in Node.js: no document.
2407
2426
  */
2408
- if (typeof location === 'undefined') {
2427
+ if (typeof document === 'undefined' || typeof location === 'undefined') {
2409
2428
  return {};
2410
2429
  }
2411
2430
  switch (request.credentials) {
@@ -2506,25 +2525,25 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2506
2525
  }
2507
2526
 
2508
2527
  /**
2509
- * Parses a given request/response body based on the `Content-Type` header.
2528
+ * Parses a given request/response body based on the "Content-Type" header.
2510
2529
  */
2511
2530
  function parseBody(body, headers) {
2512
2531
  // Return whatever falsey body value is given.
2513
2532
  if (!body) {
2514
2533
  return body;
2515
2534
  }
2516
- 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')) || '';
2517
2536
  // If the body has a Multipart Content-Type
2518
2537
  // parse it into an object.
2519
- const hasMultipartContent = contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('multipart/form-data');
2538
+ const hasMultipartContent = contentType.startsWith('multipart/form-data');
2520
2539
  if (hasMultipartContent && typeof body !== 'object') {
2521
- return parseMultipartData(body, headers) || body;
2540
+ return parseMultipartData(body.toString(), headers) || body;
2522
2541
  }
2523
2542
  // If the intercepted request's body has a JSON Content-Type
2524
2543
  // parse it into an object.
2525
- const hasJsonContent = contentType === null || contentType === void 0 ? void 0 : contentType.includes('json');
2544
+ const hasJsonContent = contentType.includes('json');
2526
2545
  if (hasJsonContent && typeof body !== 'object') {
2527
- return jsonParse(body) || body;
2546
+ return jsonParse(body.toString()) || body;
2528
2547
  }
2529
2548
  // Otherwise leave as-is.
2530
2549
  return body;
@@ -3826,7 +3845,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3826
3845
 
3827
3846
  directiveLocation.DirectiveLocation = DirectiveLocation;
3828
3847
 
3829
- var lexer = {};
3848
+ var lexer$1 = {};
3830
3849
 
3831
3850
  var blockString = {};
3832
3851
 
@@ -3963,11 +3982,11 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3963
3982
  return '"""' + result.replace(/"""/g, '\\"""') + '"""';
3964
3983
  }
3965
3984
 
3966
- Object.defineProperty(lexer, "__esModule", {
3985
+ Object.defineProperty(lexer$1, "__esModule", {
3967
3986
  value: true
3968
3987
  });
3969
- lexer.isPunctuatorTokenKind = isPunctuatorTokenKind;
3970
- lexer.Lexer = void 0;
3988
+ lexer$1.isPunctuatorTokenKind = isPunctuatorTokenKind;
3989
+ lexer$1.Lexer = void 0;
3971
3990
 
3972
3991
  var _syntaxError$1 = syntaxError$1;
3973
3992
 
@@ -4049,7 +4068,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
4049
4068
  */
4050
4069
 
4051
4070
 
4052
- lexer.Lexer = Lexer;
4071
+ lexer$1.Lexer = Lexer;
4053
4072
 
4054
4073
  function isPunctuatorTokenKind(kind) {
4055
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;
@@ -4655,7 +4674,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
4655
4674
  Object.defineProperty(parser, "__esModule", {
4656
4675
  value: true
4657
4676
  });
4658
- parser.parse = parse$2;
4677
+ parser.parse = parse$3;
4659
4678
  parser.parseValue = parseValue;
4660
4679
  parser.parseType = parseType;
4661
4680
  parser.Parser = void 0;
@@ -4672,13 +4691,13 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
4672
4691
 
4673
4692
  var _directiveLocation$3 = directiveLocation;
4674
4693
 
4675
- var _lexer$1 = lexer;
4694
+ var _lexer$1 = lexer$1;
4676
4695
 
4677
4696
  /**
4678
4697
  * Given a GraphQL source, parses it into a Document.
4679
4698
  * Throws GraphQLError if a syntax error is encountered.
4680
4699
  */
4681
- function parse$2(source, options) {
4700
+ function parse$3(source, options) {
4682
4701
  var parser = new Parser(source, options);
4683
4702
  return parser.parseDocument();
4684
4703
  }
@@ -17337,7 +17356,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
17337
17356
 
17338
17357
  var _tokenKind = tokenKind;
17339
17358
 
17340
- var _lexer = lexer;
17359
+ var _lexer = lexer$1;
17341
17360
 
17342
17361
  var _parser = parser;
17343
17362
 
@@ -20153,7 +20172,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
20153
20172
 
20154
20173
  var _tokenKind = tokenKind;
20155
20174
 
20156
- var _lexer = lexer;
20175
+ var _lexer = lexer$1;
20157
20176
 
20158
20177
  var _blockString = blockString;
20159
20178
 
@@ -22433,51 +22452,414 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
22433
22452
  body: parseBody(res.body, responseHeaders) });
22434
22453
  }
22435
22454
 
22436
- var cjs = {};
22437
-
22438
- Object.defineProperty(cjs, '__esModule', { value: true });
22439
-
22440
- /**
22441
- * Converts a string path to a Regular Expression.
22442
- * Transforms path parameters into named RegExp groups.
22443
- */
22444
- const pathToRegExp = (path) => {
22445
- const pattern = path
22446
- // Escape literal dots
22447
- .replace(/\./g, '\\.')
22448
- // Escape literal slashes
22449
- .replace(/\//g, '/')
22450
- // Escape literal question marks
22451
- .replace(/\?/g, '\\?')
22452
- // Ignore trailing slashes
22453
- .replace(/\/+$/, '')
22454
- // Replace wildcard with any zero-to-any character sequence
22455
- .replace(/\*+/g, '.*')
22456
- // Replace parameters with named capturing groups
22457
- .replace(/:([^\d|^\/][a-zA-Z0-9_]*(?=(?:\/|\\.)|$))/g, (_, paramName) => `(?<${paramName}>[^\/]+?)`)
22458
- // Allow optional trailing slash
22459
- .concat('(\\/|$)');
22460
- return new RegExp(pattern, 'gi');
22461
- };
22462
-
22463
- /**
22464
- * Matches a given url against a path.
22465
- */
22466
- const match = (path, url) => {
22467
- const expression = path instanceof RegExp ? path : pathToRegExp(path);
22468
- const match = expression.exec(url) || false;
22469
- // Matches in strict mode: match string should equal to input (url)
22470
- // Otherwise loose matches will be considered truthy:
22471
- // match('/messages/:id', '/messages/123/users') // true
22472
- const matches = path instanceof RegExp ? !!match : !!match && match[0] === match.input;
22473
- return {
22474
- matches,
22475
- params: match && matches ? match.groups || null : null,
22476
- };
22477
- };
22455
+ var dist = {};
22478
22456
 
22479
- var match_1 = cjs.match = match;
22480
- cjs.pathToRegExp = pathToRegExp;
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;
22481
22863
 
22482
22864
  var getCleanUrl$1 = {};
22483
22865
 
@@ -22512,9 +22894,12 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
22512
22894
  return path;
22513
22895
  }
22514
22896
  // Resolve a relative request URL against a given custom "baseUrl"
22515
- // or the current location (in the case of browser/browser-like environments).
22516
- const origin = baseUrl || (typeof location !== 'undefined' && location.origin);
22517
- return origin ? new URL(path, origin).href : path;
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;
22518
22903
  }
22519
22904
 
22520
22905
  /**
@@ -22533,12 +22918,48 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
22533
22918
  return cleanUrl(maybeAbsoluteUrl);
22534
22919
  }
22535
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
+ * Replace wildcards ("*") with unnamed capturing groups
22929
+ * because "path-to-regexp" doesn't support wildcards.
22930
+ * Ignore path parameter' modifiers (i.e. ":name*").
22931
+ */
22932
+ .replace(/([:a-zA-Z_-]*)(\*{1,2})+/g, (_, parameterName, wildcard) => {
22933
+ const expression = '(.*)';
22934
+ if (!parameterName) {
22935
+ return expression;
22936
+ }
22937
+ return parameterName.startsWith(':')
22938
+ ? `${parameterName}${wildcard}`
22939
+ : `${parameterName}${expression}`;
22940
+ })
22941
+ /**
22942
+ * Escape the protocol so that "path-to-regexp" could match
22943
+ * absolute URL.
22944
+ * @see https://github.com/pillarjs/path-to-regexp/issues/259
22945
+ */
22946
+ .replace(/^([^\/]+)(:)(?=\/\/)/g, '$1\\$2'));
22947
+ }
22536
22948
  /**
22537
22949
  * Returns the result of matching given request URL against a mask.
22538
22950
  */
22539
22951
  function matchRequestUrl(url, path, baseUrl) {
22540
22952
  const normalizedPath = normalizePath(path, baseUrl);
22541
- return match_1(normalizedPath, getCleanUrl_2(url));
22953
+ const cleanPath = typeof normalizedPath === 'string'
22954
+ ? coercePath(normalizedPath)
22955
+ : normalizedPath;
22956
+ const cleanUrl = getCleanUrl_2(url);
22957
+ const result = match_1(cleanPath, { decode: decodeURIComponent })(cleanUrl);
22958
+ const params = (result && result.params) || {};
22959
+ return {
22960
+ matches: result !== false,
22961
+ params,
22962
+ };
22542
22963
  }
22543
22964
 
22544
22965
  /**
@@ -22587,18 +23008,21 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
22587
23008
  },
22588
23009
  });
22589
23010
 
23011
+ const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
22590
23012
  /**
22591
23013
  * Return the stack trace frame of a function's invocation.
22592
23014
  */
22593
- function getCallFrame() {
23015
+ function getCallFrame(error) {
22594
23016
  // In <IE11, new Error may return an undefined stack
22595
- const stack = (new Error().stack || '');
22596
- const frames = stack.split('\n');
23017
+ const stack = error.stack;
23018
+ if (!stack) {
23019
+ return;
23020
+ }
23021
+ const frames = stack.split('\n').slice(1);
22597
23022
  // Get the first frame that doesn't reference the library's internal trace.
22598
23023
  // Assume that frame is the invocation frame.
22599
- const ignoreFrameRegExp = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
22600
- const declarationFrame = frames.slice(1).find((frame) => {
22601
- return !ignoreFrameRegExp.test(frame);
23024
+ const declarationFrame = frames.find((frame) => {
23025
+ return !BUILD_FRAME.test(frame);
22602
23026
  });
22603
23027
  if (!declarationFrame) {
22604
23028
  return;
@@ -22631,7 +23055,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
22631
23055
  this.shouldSkip = false;
22632
23056
  this.ctx = options.ctx || defaultContext;
22633
23057
  this.resolver = options.resolver;
22634
- const callFrame = getCallFrame();
23058
+ const callFrame = getCallFrame(new Error());
22635
23059
  this.info = Object.assign(Object.assign({}, options.info), { callFrame });
22636
23060
  }
22637
23061
  /**
@@ -22758,21 +23182,9 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
22758
23182
  return;
22759
23183
  }
22760
23184
  const searchParams = getSearchParams(path);
22761
- const queryParams = [];
22762
23185
  searchParams.forEach((_, paramName) => {
22763
- queryParams.push(paramName);
22764
23186
  });
22765
- devUtils.warn(`\
22766
- 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:
22767
-
22768
- rest.${method.toLowerCase()}("${url}", (req, res, ctx) => {
22769
- const query = req.url.searchParams
22770
- ${queryParams
22771
- .map((paramName) => `\
22772
- const ${paramName} = query.get("${paramName}")`)
22773
- .join('\n')}
22774
- })\
22775
- `);
23187
+ 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".`);
22776
23188
  }
22777
23189
  parse(request, resolutionContext) {
22778
23190
  return matchRequestUrl(request.url, this.info.path, resolutionContext === null || resolutionContext === void 0 ? void 0 : resolutionContext.baseUrl);
@@ -22781,7 +23193,10 @@ ${queryParams
22781
23193
  return Object.assign(Object.assign({}, request), { params: parsedResult.params || {} });
22782
23194
  }
22783
23195
  predicate(request, parsedResult) {
22784
- return (isStringEqual(this.info.method, request.method) && parsedResult.matches);
23196
+ const matchesMethod = this.info.method instanceof RegExp
23197
+ ? this.info.method.test(request.method)
23198
+ : isStringEqual(this.info.method, request.method);
23199
+ return matchesMethod && parsedResult.matches;
22785
23200
  }
22786
23201
  log(request, response) {
22787
23202
  const publicUrl = getPublicUrlFromRequest(request);
@@ -22815,6 +23230,7 @@ ${queryParams
22815
23230
  delay,
22816
23231
  fetch: fetch$1,
22817
23232
  data,
23233
+ extensions,
22818
23234
  errors,
22819
23235
  cookie,
22820
23236
  };
@@ -22861,10 +23277,10 @@ ${queryParams
22861
23277
  if (!parsedResult) {
22862
23278
  return false;
22863
23279
  }
22864
- if (!parsedResult.operationName) {
23280
+ if (!parsedResult.operationName && this.info.operationType !== 'all') {
22865
23281
  const publicUrl = getPublicUrlFromRequest(request);
22866
23282
  devUtils.warn(`\
22867
- Failed to intercept a GraphQL request at "${request.method} ${publicUrl}": unnamed GraphQL operations are not supported.
23283
+ Failed to intercept a GraphQL request at "${request.method} ${publicUrl}": anonymous GraphQL operations are not supported.
22868
23284
 
22869
23285
  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\
22870
23286
  `);
@@ -22874,7 +23290,7 @@ Consider naming this operation or using "graphql.operation" request handler to i
22874
23290
  const hasMatchingOperationType = this.info.operationType === 'all' ||
22875
23291
  parsedResult.operationType === this.info.operationType;
22876
23292
  const hasMatchingOperationName = this.info.operationName instanceof RegExp
22877
- ? this.info.operationName.test(parsedResult.operationName)
23293
+ ? this.info.operationName.test(parsedResult.operationName || '')
22878
23294
  : parsedResult.operationName === this.info.operationName;
22879
23295
  return (hasMatchingUrl.matches &&
22880
23296
  hasMatchingOperationType &&
@@ -22884,7 +23300,10 @@ Consider naming this operation or using "graphql.operation" request handler to i
22884
23300
  const loggedRequest = prepareRequest(request);
22885
23301
  const loggedResponse = prepareResponse(response);
22886
23302
  const statusColor = getStatusCodeColor(response.status);
22887
- console.groupCollapsed(devUtils.formatMessage('%s %s (%c%s%c)'), getTimestamp(), `${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType} ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName}`, `color:${statusColor}`, `${response.status} ${response.statusText}`, 'color:inherit');
23303
+ const requestInfo = (parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName)
23304
+ ? `${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType} ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName}`
23305
+ : `anonymous ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType}`;
23306
+ console.groupCollapsed(devUtils.formatMessage('%s %s (%c%s%c)'), getTimestamp(), `${requestInfo}`, `color:${statusColor}`, `${response.status} ${response.statusText}`, 'color:inherit');
22888
23307
  console.log('Request:', loggedRequest);
22889
23308
  console.log('Handler:', this);
22890
23309
  console.log('Response:', loggedResponse);
@@ -22909,10 +23328,10 @@ Consider naming this operation or using "graphql.operation" request handler to i
22909
23328
  graphql: [],
22910
23329
  });
22911
23330
  }
22912
- function getScoreForRestHandler() {
23331
+ function getRestHandlerScore() {
22913
23332
  return (request, handler) => {
22914
23333
  const { path, method } = handler.info;
22915
- if (path instanceof RegExp) {
23334
+ if (path instanceof RegExp || method instanceof RegExp) {
22916
23335
  return Infinity;
22917
23336
  }
22918
23337
  const hasSameMethod = isStringEqual(request.method, method);
@@ -22923,12 +23342,15 @@ Consider naming this operation or using "graphql.operation" request handler to i
22923
23342
  return score - methodScoreDelta;
22924
23343
  };
22925
23344
  }
22926
- function getScoreForGraphQLHandler(parsedQuery) {
23345
+ function getGraphQLHandlerScore(parsedQuery) {
22927
23346
  return (_, handler) => {
22928
23347
  if (typeof parsedQuery.operationName === 'undefined') {
22929
23348
  return Infinity;
22930
23349
  }
22931
23350
  const { operationType, operationName } = handler.info;
23351
+ if (typeof operationName !== 'string') {
23352
+ return Infinity;
23353
+ }
22932
23354
  const hasSameOperationType = parsedQuery.operationType === operationType;
22933
23355
  // Always treat a handler with the same operation type as a more similar one.
22934
23356
  const operationTypeScoreDelta = hasSameOperationType ? TYPE_MATCH_DELTA : 0;
@@ -22938,16 +23360,12 @@ Consider naming this operation or using "graphql.operation" request handler to i
22938
23360
  }
22939
23361
  function getSuggestedHandler(request, handlers, getScore) {
22940
23362
  const suggestedHandlers = handlers
22941
- .reduce((acc, handler) => {
23363
+ .reduce((suggestions, handler) => {
22942
23364
  const score = getScore(request, handler);
22943
- return acc.concat([[score, handler]]);
23365
+ return suggestions.concat([[score, handler]]);
22944
23366
  }, [])
22945
- .sort(([leftScore], [rightScore]) => {
22946
- return leftScore - rightScore;
22947
- })
22948
- .filter(([score]) => {
22949
- return score <= MAX_MATCH_SCORE;
22950
- })
23367
+ .sort(([leftScore], [rightScore]) => leftScore - rightScore)
23368
+ .filter(([score]) => score <= MAX_MATCH_SCORE)
22951
23369
  .slice(0, MAX_SUGGESTION_COUNT)
22952
23370
  .map(([, handler]) => handler);
22953
23371
  return suggestedHandlers;
@@ -22977,8 +23395,8 @@ ${handlers.map((handler) => ` • ${handler.info.header}`).join('\n')}`;
22977
23395
  ? handlerGroups.graphql
22978
23396
  : handlerGroups.rest;
22979
23397
  const suggestedHandlers = getSuggestedHandler(request, relevantHandlers, parsedGraphQLQuery
22980
- ? getScoreForGraphQLHandler(parsedGraphQLQuery)
22981
- : getScoreForRestHandler());
23398
+ ? getGraphQLHandlerScore(parsedGraphQLQuery)
23399
+ : getRestHandlerScore());
22982
23400
  const handlerSuggestion = suggestedHandlers.length > 0
22983
23401
  ? getSuggestedHandlersMessage(suggestedHandlers)
22984
23402
  : '';
@@ -22998,8 +23416,10 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
22998
23416
  const message = messageTemplate.join('\n\n');
22999
23417
  switch (strategy) {
23000
23418
  case 'error': {
23419
+ // Print a developer-friendly error.
23001
23420
  devUtils.error('Error: %s', message);
23002
- break;
23421
+ // Throw an exception to halt request processing and not perform the original request.
23422
+ throw new Error(devUtils.formatMessage('Cannot bypass a request when using the "error" strategy for the "onUnhandledRequest" option.'));
23003
23423
  }
23004
23424
  case 'warn': {
23005
23425
  devUtils.warn('Warning: %s', message);
@@ -23042,7 +23462,12 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
23042
23462
  // When the handled request returned no mocked response, warn the developer,
23043
23463
  // as it may be an oversight on their part. Perform the request as-is.
23044
23464
  if (!response) {
23045
- devUtils.warn('Expected a mocking resolver function to return a mocked response Object, but got: %s. Original response is going to be used instead.', response);
23465
+ devUtils.warn(`\
23466
+ Expected response resolver to return a mocked response Object, but got %s. The original response is going to be used instead.\
23467
+ \n
23468
+ \u2022 %s
23469
+ %s\
23470
+ `, response, handler.info.header, handler.info.callFrame);
23046
23471
  emitter.emit('request:end', request);
23047
23472
  (_c = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onBypassResponse) === null || _c === void 0 ? void 0 : _c.call(handleRequestOptions, request);
23048
23473
  return;
@@ -23129,8 +23554,8 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
23129
23554
  const { payload: actualChecksum } = yield context.events.once('INTEGRITY_CHECK_RESPONSE');
23130
23555
  // Compare the response from the Service Worker and the
23131
23556
  // global variable set by Rollup during the build.
23132
- if (actualChecksum !== "f0a916b13c8acc2b526a03a6d26df85f") {
23133
- throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"f0a916b13c8acc2b526a03a6d26df85f"}).`);
23557
+ if (actualChecksum !== "02f4ad4a2797f85668baf196e553d929") {
23558
+ throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"02f4ad4a2797f85668baf196e553d929"}).`);
23134
23559
  }
23135
23560
  return serviceWorker;
23136
23561
  });
@@ -23279,16 +23704,14 @@ If this message still persists after updating, please report an issue: https://g
23279
23704
  }
23280
23705
 
23281
23706
  const createStop = (context) => {
23282
- /**
23283
- * Signal the Service Worker to disable mocking for this client.
23284
- * Use this an an explicit way to stop the mocking, while preserving
23285
- * the worker-client relation. Does not affect the worker's lifecycle.
23286
- */
23287
23707
  return function stop() {
23288
23708
  var _a;
23709
+ /**
23710
+ * Signal the Service Worker to disable mocking for this client.
23711
+ * Use this an an explicit way to stop the mocking, while preserving
23712
+ * the worker-client relation. Does not affect the worker's lifecycle.
23713
+ */
23289
23714
  context.workerChannel.send('MOCK_DEACTIVATE');
23290
- context.events.removeAllListeners();
23291
- context.emitter.removeAllListeners();
23292
23715
  window.clearInterval(context.keepAliveInterval);
23293
23716
  printStopMessage({ quiet: (_a = context.startOptions) === null || _a === void 0 ? void 0 : _a.quiet });
23294
23717
  };
@@ -24401,15 +24824,16 @@ If this message still persists after updating, please report an issue: https://g
24401
24824
  }
24402
24825
  debug$1('no mocked response found, bypassing...');
24403
24826
  return [2 /*return*/, pureFetch(input, init).then(function (response) { return __awaiter$1(void 0, void 0, void 0, function () {
24404
- var _a, _b, _c;
24827
+ var cloneResponse, _a, _b, _c;
24405
24828
  return __generator$1(this, function (_d) {
24406
24829
  switch (_d.label) {
24407
24830
  case 0:
24408
- debug$1('original fetch performed', response);
24831
+ cloneResponse = response.clone();
24832
+ debug$1('original fetch performed', cloneResponse);
24409
24833
  _b = (_a = observer).emit;
24410
24834
  _c = ['response',
24411
24835
  isoRequest];
24412
- return [4 /*yield*/, normalizeFetchResponse(response)];
24836
+ return [4 /*yield*/, normalizeFetchResponse(cloneResponse)];
24413
24837
  case 1:
24414
24838
  _b.apply(_a, _c.concat([_d.sent()]));
24415
24839
  return [2 /*return*/, response];
@@ -24450,9 +24874,179 @@ If this message still persists after updating, please report an issue: https://g
24450
24874
 
24451
24875
  var domParser = {};
24452
24876
 
24453
- var entities = {};
24877
+ var conventions$2 = {};
24878
+
24879
+ /**
24880
+ * "Shallow freezes" an object to render it immutable.
24881
+ * Uses `Object.freeze` if available,
24882
+ * otherwise the immutability is only in the type.
24883
+ *
24884
+ * Is used to create "enum like" objects.
24885
+ *
24886
+ * @template T
24887
+ * @param {T} object the object to freeze
24888
+ * @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
24889
+ * allows to inject custom object constructor for tests
24890
+ * @returns {Readonly<T>}
24891
+ *
24892
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
24893
+ */
24894
+ function freeze(object, oc) {
24895
+ if (oc === undefined) {
24896
+ oc = Object;
24897
+ }
24898
+ return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
24899
+ }
24900
+
24901
+ /**
24902
+ * All mime types that are allowed as input to `DOMParser.parseFromString`
24903
+ *
24904
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
24905
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
24906
+ * @see DOMParser.prototype.parseFromString
24907
+ */
24908
+ var MIME_TYPE = freeze({
24909
+ /**
24910
+ * `text/html`, the only mime type that triggers treating an XML document as HTML.
24911
+ *
24912
+ * @see DOMParser.SupportedType.isHTML
24913
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
24914
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
24915
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
24916
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
24917
+ */
24918
+ HTML: 'text/html',
24919
+
24920
+ /**
24921
+ * Helper method to check a mime type if it indicates an HTML document
24922
+ *
24923
+ * @param {string} [value]
24924
+ * @returns {boolean}
24925
+ *
24926
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
24927
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
24928
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
24929
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
24930
+ isHTML: function (value) {
24931
+ return value === MIME_TYPE.HTML
24932
+ },
24933
+
24934
+ /**
24935
+ * `application/xml`, the standard mime type for XML documents.
24936
+ *
24937
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
24938
+ * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
24939
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
24940
+ */
24941
+ XML_APPLICATION: 'application/xml',
24942
+
24943
+ /**
24944
+ * `text/html`, an alias for `application/xml`.
24945
+ *
24946
+ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
24947
+ * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
24948
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
24949
+ */
24950
+ XML_TEXT: 'text/xml',
24951
+
24952
+ /**
24953
+ * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
24954
+ * but is parsed as an XML document.
24955
+ *
24956
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
24957
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
24958
+ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
24959
+ */
24960
+ XML_XHTML_APPLICATION: 'application/xhtml+xml',
24961
+
24962
+ /**
24963
+ * `image/svg+xml`,
24964
+ *
24965
+ * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
24966
+ * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
24967
+ * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
24968
+ */
24969
+ XML_SVG_IMAGE: 'image/svg+xml',
24970
+ });
24971
+
24972
+ /**
24973
+ * Namespaces that are used in this code base.
24974
+ *
24975
+ * @see http://www.w3.org/TR/REC-xml-names
24976
+ */
24977
+ var NAMESPACE$3 = freeze({
24978
+ /**
24979
+ * The XHTML namespace.
24980
+ *
24981
+ * @see http://www.w3.org/1999/xhtml
24982
+ */
24983
+ HTML: 'http://www.w3.org/1999/xhtml',
24984
+
24985
+ /**
24986
+ * Checks if `uri` equals `NAMESPACE.HTML`.
24987
+ *
24988
+ * @param {string} [uri]
24989
+ *
24990
+ * @see NAMESPACE.HTML
24991
+ */
24992
+ isHTML: function (uri) {
24993
+ return uri === NAMESPACE$3.HTML
24994
+ },
24995
+
24996
+ /**
24997
+ * The SVG namespace.
24998
+ *
24999
+ * @see http://www.w3.org/2000/svg
25000
+ */
25001
+ SVG: 'http://www.w3.org/2000/svg',
25002
+
25003
+ /**
25004
+ * The `xml:` namespace.
25005
+ *
25006
+ * @see http://www.w3.org/XML/1998/namespace
25007
+ */
25008
+ XML: 'http://www.w3.org/XML/1998/namespace',
25009
+
25010
+ /**
25011
+ * The `xmlns:` namespace
25012
+ *
25013
+ * @see https://www.w3.org/2000/xmlns/
25014
+ */
25015
+ XMLNS: 'http://www.w3.org/2000/xmlns/',
25016
+ });
25017
+
25018
+ conventions$2.freeze = freeze;
25019
+ conventions$2.MIME_TYPE = MIME_TYPE;
25020
+ conventions$2.NAMESPACE = NAMESPACE$3;
25021
+
25022
+ var entities$1 = {};
25023
+
25024
+ (function (exports) {
25025
+ var freeze = conventions$2.freeze;
25026
+
25027
+ /**
25028
+ * The entities that are predefined in every XML document.
25029
+ *
25030
+ * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
25031
+ * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
25032
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
25033
+ */
25034
+ exports.XML_ENTITIES = freeze({amp:'&', apos:"'", gt:'>', lt:'<', quot:'"'});
24454
25035
 
24455
- entities.entityMap = {
25036
+ /**
25037
+ * A map of currently 241 entities that are detected in an HTML document.
25038
+ * They contain all entries from `XML_ENTITIES`.
25039
+ *
25040
+ * @see XML_ENTITIES
25041
+ * @see DOMParser.parseFromString
25042
+ * @see DOMImplementation.prototype.createHTMLDocument
25043
+ * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
25044
+ * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
25045
+ * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
25046
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
25047
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
25048
+ */
25049
+ exports.HTML_ENTITIES = freeze({
24456
25050
  lt: '<',
24457
25051
  gt: '>',
24458
25052
  amp: '&',
@@ -24694,10 +25288,19 @@ If this message still persists after updating, please report an issue: https://g
24694
25288
  clubs: "♣",
24695
25289
  hearts: "♥",
24696
25290
  diams: "♦"
24697
- };
25291
+ });
25292
+
25293
+ /**
25294
+ * @deprecated use `HTML_ENTITIES` instead
25295
+ * @see HTML_ENTITIES
25296
+ */
25297
+ exports.entityMap = exports.HTML_ENTITIES;
25298
+ }(entities$1));
24698
25299
 
24699
25300
  var sax$1 = {};
24700
25301
 
25302
+ var NAMESPACE$2 = conventions$2.NAMESPACE;
25303
+
24701
25304
  //[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]
24702
25305
  //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
24703
25306
  //[5] Name ::= NameStartChar (NameChar)*
@@ -24815,7 +25418,7 @@ If this message still persists after updating, please report an issue: https://g
24815
25418
  switch(source.charAt(tagStart+1)){
24816
25419
  case '/':
24817
25420
  var end = source.indexOf('>',tagStart+3);
24818
- var tagName = source.substring(tagStart+2,end);
25421
+ var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
24819
25422
  var config = parseStack.pop();
24820
25423
  if(end<0){
24821
25424
 
@@ -24888,12 +25491,10 @@ If this message still persists after updating, please report an issue: https://g
24888
25491
  parseStack.push(el);
24889
25492
  }
24890
25493
  }
24891
-
24892
-
24893
-
24894
- if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
25494
+
25495
+ if (NAMESPACE$2.isHTML(el.uri) && !el.closed) {
24895
25496
  end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder);
24896
- }else {
25497
+ } else {
24897
25498
  end++;
24898
25499
  }
24899
25500
  }
@@ -25029,7 +25630,7 @@ If this message still persists after updating, please report an issue: https://g
25029
25630
  errorHandler.warning('attribute "'+value+'" missed quot(")!');
25030
25631
  addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start);
25031
25632
  }else {
25032
- if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
25633
+ if(!NAMESPACE$2.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
25033
25634
  errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!');
25034
25635
  }
25035
25636
  addAttribute(value, value, start);
@@ -25077,7 +25678,7 @@ If this message still persists after updating, please report an issue: https://g
25077
25678
  //case S_ATTR_NOQUOT_VALUE:void();break;
25078
25679
  case S_ATTR_SPACE:
25079
25680
  el.tagName;
25080
- if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
25681
+ if (!NAMESPACE$2.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
25081
25682
  errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!');
25082
25683
  }
25083
25684
  addAttribute(attrName, attrName, start);
@@ -25136,7 +25737,7 @@ If this message still persists after updating, please report an issue: https://g
25136
25737
  //console.log(currentNSMap,1)
25137
25738
  }
25138
25739
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
25139
- a.uri = 'http://www.w3.org/2000/xmlns/';
25740
+ a.uri = NAMESPACE$2.XMLNS;
25140
25741
  domBuilder.startPrefixMapping(nsPrefix, value);
25141
25742
  }
25142
25743
  }
@@ -25146,7 +25747,7 @@ If this message still persists after updating, please report an issue: https://g
25146
25747
  var prefix = a.prefix;
25147
25748
  if(prefix){//no prefix attribute has no namespace
25148
25749
  if(prefix === 'xml'){
25149
- a.uri = 'http://www.w3.org/XML/1998/namespace';
25750
+ a.uri = NAMESPACE$2.XML;
25150
25751
  }if(prefix !== 'xmlns'){
25151
25752
  a.uri = currentNSMap[prefix || ''];
25152
25753
 
@@ -25343,11 +25944,74 @@ If this message still persists after updating, please report an issue: https://g
25343
25944
 
25344
25945
  var dom = {};
25345
25946
 
25947
+ var conventions$1 = conventions$2;
25948
+
25949
+ var NAMESPACE$1 = conventions$1.NAMESPACE;
25950
+
25951
+ /**
25952
+ * A prerequisite for `[].filter`, to drop elements that are empty
25953
+ * @param {string} input
25954
+ * @returns {boolean}
25955
+ */
25956
+ function notEmptyString (input) {
25957
+ return input !== ''
25958
+ }
25959
+ /**
25960
+ * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
25961
+ * @see https://infra.spec.whatwg.org/#ascii-whitespace
25962
+ *
25963
+ * @param {string} input
25964
+ * @returns {string[]} (can be empty)
25965
+ */
25966
+ function splitOnASCIIWhitespace(input) {
25967
+ // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
25968
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
25969
+ }
25970
+
25971
+ /**
25972
+ * Adds element as a key to current if it is not already present.
25973
+ *
25974
+ * @param {Record<string, boolean | undefined>} current
25975
+ * @param {string} element
25976
+ * @returns {Record<string, boolean | undefined>}
25977
+ */
25978
+ function orderedSetReducer (current, element) {
25979
+ if (!current.hasOwnProperty(element)) {
25980
+ current[element] = true;
25981
+ }
25982
+ return current;
25983
+ }
25984
+
25985
+ /**
25986
+ * @see https://infra.spec.whatwg.org/#ordered-set
25987
+ * @param {string} input
25988
+ * @returns {string[]}
25989
+ */
25990
+ function toOrderedSet(input) {
25991
+ if (!input) return [];
25992
+ var list = splitOnASCIIWhitespace(input);
25993
+ return Object.keys(list.reduce(orderedSetReducer, {}))
25994
+ }
25995
+
25996
+ /**
25997
+ * Uses `list.indexOf` to implement something like `Array.prototype.includes`,
25998
+ * which we can not rely on being available.
25999
+ *
26000
+ * @param {any[]} list
26001
+ * @returns {function(any): boolean}
26002
+ */
26003
+ function arrayIncludes (list) {
26004
+ return function(element) {
26005
+ return list && list.indexOf(element) !== -1;
26006
+ }
26007
+ }
26008
+
25346
26009
  function copy(src,dest){
25347
26010
  for(var p in src){
25348
26011
  dest[p] = src[p];
25349
26012
  }
25350
26013
  }
26014
+
25351
26015
  /**
25352
26016
  ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
25353
26017
  ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
@@ -25367,7 +26031,7 @@ If this message still persists after updating, please report an issue: https://g
25367
26031
  pt.constructor = Class;
25368
26032
  }
25369
26033
  }
25370
- var htmlns = 'http://www.w3.org/1999/xhtml' ;
26034
+
25371
26035
  // Node Types
25372
26036
  var NodeType = {};
25373
26037
  var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
@@ -25423,6 +26087,7 @@ If this message still persists after updating, please report an issue: https://g
25423
26087
  return error;
25424
26088
  }DOMException.prototype = Error.prototype;
25425
26089
  copy(ExceptionCode,DOMException);
26090
+
25426
26091
  /**
25427
26092
  * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
25428
26093
  * 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.
@@ -25453,6 +26118,7 @@ If this message still persists after updating, please report an issue: https://g
25453
26118
  return buf.join('');
25454
26119
  }
25455
26120
  };
26121
+
25456
26122
  function LiveNodeList(node,refresh){
25457
26123
  this._node = node;
25458
26124
  this._refresh = refresh;
@@ -25474,9 +26140,15 @@ If this message still persists after updating, please report an issue: https://g
25474
26140
  };
25475
26141
 
25476
26142
  _extends(LiveNodeList,NodeList);
26143
+
25477
26144
  /**
25478
- *
25479
- * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
26145
+ * Objects implementing the NamedNodeMap interface are used
26146
+ * to represent collections of nodes that can be accessed by name.
26147
+ * Note that NamedNodeMap does not inherit from NodeList;
26148
+ * NamedNodeMaps are not maintained in any particular order.
26149
+ * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
26150
+ * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
26151
+ * and does not imply that the DOM specifies an order to these Nodes.
25480
26152
  * NamedNodeMap objects in the DOM are live.
25481
26153
  * used for attributes or DocumentType entities
25482
26154
  */
@@ -25587,54 +26259,108 @@ If this message still persists after updating, please report an issue: https://g
25587
26259
  return null;
25588
26260
  }
25589
26261
  };
26262
+
25590
26263
  /**
25591
- * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
26264
+ * The DOMImplementation interface represents an object providing methods
26265
+ * which are not dependent on any particular document.
26266
+ * Such an object is returned by the `Document.implementation` property.
26267
+ *
26268
+ * __The individual methods describe the differences compared to the specs.__
26269
+ *
26270
+ * @constructor
26271
+ *
26272
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
26273
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
26274
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
26275
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
26276
+ * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
25592
26277
  */
25593
- function DOMImplementation$1(/* Object */ features) {
25594
- this._features = {};
25595
- if (features) {
25596
- for (var feature in features) {
25597
- this._features = features[feature];
25598
- }
25599
- }
26278
+ function DOMImplementation$1() {
25600
26279
  }
26280
+
25601
26281
  DOMImplementation$1.prototype = {
25602
- hasFeature: function(/* string */ feature, /* string */ version) {
25603
- var versions = this._features[feature.toLowerCase()];
25604
- if (versions && (!version || version in versions)) {
26282
+ /**
26283
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
26284
+ * The different implementations fairly diverged in what kind of features were reported.
26285
+ * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
26286
+ *
26287
+ * @deprecated It is deprecated and modern browsers return true in all cases.
26288
+ *
26289
+ * @param {string} feature
26290
+ * @param {string} [version]
26291
+ * @returns {boolean} always true
26292
+ *
26293
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
26294
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
26295
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
26296
+ */
26297
+ hasFeature: function(feature, version) {
25605
26298
  return true;
25606
- } else {
25607
- return false;
25608
- }
25609
26299
  },
25610
- // Introduced in DOM Level 2:
25611
- createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
26300
+ /**
26301
+ * Creates an XML Document object of the specified type with its document element.
26302
+ *
26303
+ * __It behaves slightly different from the description in the living standard__:
26304
+ * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
26305
+ * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
26306
+ * - this implementation is not validating names or qualified names
26307
+ * (when parsing XML strings, the SAX parser takes care of that)
26308
+ *
26309
+ * @param {string|null} namespaceURI
26310
+ * @param {string} qualifiedName
26311
+ * @param {DocumentType=null} doctype
26312
+ * @returns {Document}
26313
+ *
26314
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
26315
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
26316
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
26317
+ *
26318
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
26319
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
26320
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
26321
+ */
26322
+ createDocument: function(namespaceURI, qualifiedName, doctype){
25612
26323
  var doc = new Document();
25613
26324
  doc.implementation = this;
25614
26325
  doc.childNodes = new NodeList();
25615
- doc.doctype = doctype;
25616
- if(doctype){
26326
+ doc.doctype = doctype || null;
26327
+ if (doctype){
25617
26328
  doc.appendChild(doctype);
25618
26329
  }
25619
- if(qualifiedName){
25620
- var root = doc.createElementNS(namespaceURI,qualifiedName);
26330
+ if (qualifiedName){
26331
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
25621
26332
  doc.appendChild(root);
25622
26333
  }
25623
26334
  return doc;
25624
26335
  },
25625
- // Introduced in DOM Level 2:
25626
- createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
26336
+ /**
26337
+ * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
26338
+ *
26339
+ * __This behavior is slightly different from the in the specs__:
26340
+ * - this implementation is not validating names or qualified names
26341
+ * (when parsing XML strings, the SAX parser takes care of that)
26342
+ *
26343
+ * @param {string} qualifiedName
26344
+ * @param {string} [publicId]
26345
+ * @param {string} [systemId]
26346
+ * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
26347
+ * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
26348
+ *
26349
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
26350
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
26351
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
26352
+ *
26353
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
26354
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
26355
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
26356
+ */
26357
+ createDocumentType: function(qualifiedName, publicId, systemId){
25627
26358
  var node = new DocumentType();
25628
26359
  node.name = qualifiedName;
25629
26360
  node.nodeName = qualifiedName;
25630
- node.publicId = publicId;
25631
- node.systemId = systemId;
25632
- // Introduced in DOM Level 2:
25633
- //readonly attribute DOMString internalSubset;
25634
-
25635
- //TODO:..
25636
- // readonly attribute NamedNodeMap entities;
25637
- // readonly attribute NamedNodeMap notations;
26361
+ node.publicId = publicId || '';
26362
+ node.systemId = systemId || '';
26363
+
25638
26364
  return node;
25639
26365
  }
25640
26366
  };
@@ -25773,22 +26499,25 @@ If this message still persists after updating, please report an issue: https://g
25773
26499
 
25774
26500
  function Document(){
25775
26501
  }
26502
+
25776
26503
  function _onAddAttribute(doc,el,newAttr){
25777
26504
  doc && doc._inc++;
25778
26505
  var ns = newAttr.namespaceURI ;
25779
- if(ns == 'http://www.w3.org/2000/xmlns/'){
26506
+ if(ns === NAMESPACE$1.XMLNS){
25780
26507
  //update namespace
25781
26508
  el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value;
25782
26509
  }
25783
26510
  }
26511
+
25784
26512
  function _onRemoveAttribute(doc,el,newAttr,remove){
25785
26513
  doc && doc._inc++;
25786
26514
  var ns = newAttr.namespaceURI ;
25787
- if(ns == 'http://www.w3.org/2000/xmlns/'){
26515
+ if(ns === NAMESPACE$1.XMLNS){
25788
26516
  //update namespace
25789
26517
  delete el._nsMap[newAttr.prefix?newAttr.localName:''];
25790
26518
  }
25791
26519
  }
26520
+
25792
26521
  function _onUpdateChild(doc,el,newChild){
25793
26522
  if(doc && doc._inc){
25794
26523
  doc._inc++;
@@ -25904,8 +26633,8 @@ If this message still persists after updating, please report an issue: https://g
25904
26633
  doctype : null,
25905
26634
  documentElement : null,
25906
26635
  _inc : 1,
25907
-
25908
- insertBefore : function(newChild, refChild){//raises
26636
+
26637
+ insertBefore : function(newChild, refChild){//raises
25909
26638
  if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
25910
26639
  var child = newChild.firstChild;
25911
26640
  while(child){
@@ -25918,7 +26647,7 @@ If this message still persists after updating, please report an issue: https://g
25918
26647
  if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
25919
26648
  this.documentElement = newChild;
25920
26649
  }
25921
-
26650
+
25922
26651
  return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
25923
26652
  },
25924
26653
  removeChild : function(oldChild){
@@ -25944,28 +26673,58 @@ If this message still persists after updating, please report an issue: https://g
25944
26673
  });
25945
26674
  return rtv;
25946
26675
  },
25947
-
25948
- getElementsByClassName: function(className) {
25949
- var pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
26676
+
26677
+ /**
26678
+ * The `getElementsByClassName` method of `Document` interface returns an array-like object
26679
+ * of all child elements which have **all** of the given class name(s).
26680
+ *
26681
+ * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
26682
+ *
26683
+ *
26684
+ * Warning: This is a live LiveNodeList.
26685
+ * Changes in the DOM will reflect in the array as the changes occur.
26686
+ * If an element selected by this array no longer qualifies for the selector,
26687
+ * it will automatically be removed. Be aware of this for iteration purposes.
26688
+ *
26689
+ * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
26690
+ *
26691
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
26692
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
26693
+ */
26694
+ getElementsByClassName: function(classNames) {
26695
+ var classNamesSet = toOrderedSet(classNames);
25950
26696
  return new LiveNodeList(this, function(base) {
25951
26697
  var ls = [];
25952
- _visitNode(base.documentElement, function(node) {
25953
- if(node !== base && node.nodeType == ELEMENT_NODE) {
25954
- if(pattern.test(node.getAttribute('class'))) {
25955
- ls.push(node);
26698
+ if (classNamesSet.length > 0) {
26699
+ _visitNode(base.documentElement, function(node) {
26700
+ if(node !== base && node.nodeType === ELEMENT_NODE) {
26701
+ var nodeClassNames = node.getAttribute('class');
26702
+ // can be null if the attribute does not exist
26703
+ if (nodeClassNames) {
26704
+ // before splitting and iterating just compare them for the most common case
26705
+ var matches = classNames === nodeClassNames;
26706
+ if (!matches) {
26707
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
26708
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
26709
+ }
26710
+ if(matches) {
26711
+ ls.push(node);
26712
+ }
26713
+ }
25956
26714
  }
25957
- }
25958
- });
26715
+ });
26716
+ }
25959
26717
  return ls;
25960
26718
  });
25961
26719
  },
25962
-
26720
+
25963
26721
  //document factory method:
25964
26722
  createElement : function(tagName){
25965
26723
  var node = new Element();
25966
26724
  node.ownerDocument = this;
25967
26725
  node.nodeName = tagName;
25968
26726
  node.tagName = tagName;
26727
+ node.localName = tagName;
25969
26728
  node.childNodes = new NodeList();
25970
26729
  var attrs = node.attributes = new NamedNodeMap();
25971
26730
  attrs._ownerElement = node;
@@ -26272,36 +27031,49 @@ If this message still persists after updating, please report an issue: https://g
26272
27031
  //console.log('###',this.nodeType,uri,prefix,buf.join(''))
26273
27032
  return buf.join('');
26274
27033
  }
26275
- function needNamespaceDefine(node,isHTML, visibleNamespaces) {
26276
- var prefix = node.prefix||'';
27034
+
27035
+ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
27036
+ var prefix = node.prefix || '';
26277
27037
  var uri = node.namespaceURI;
26278
- if (!prefix && !uri){
27038
+ // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
27039
+ // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
27040
+ // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
27041
+ // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
27042
+ // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
27043
+ // > [...] Furthermore, the attribute value [...] must not be an empty string.
27044
+ // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
27045
+ if (!uri) {
26279
27046
  return false;
26280
27047
  }
26281
- if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
26282
- || uri == 'http://www.w3.org/2000/xmlns/'){
27048
+ if (prefix === "xml" && uri === NAMESPACE$1.XML || uri === NAMESPACE$1.XMLNS) {
26283
27049
  return false;
26284
27050
  }
26285
27051
 
26286
27052
  var i = visibleNamespaces.length;
26287
- //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
26288
27053
  while (i--) {
26289
27054
  var ns = visibleNamespaces[i];
26290
27055
  // get namespace prefix
26291
- //console.log(node.nodeType,node.tagName,ns.prefix,prefix)
26292
- if (ns.prefix == prefix){
26293
- return ns.namespace != uri;
27056
+ if (ns.prefix === prefix) {
27057
+ return ns.namespace !== uri;
26294
27058
  }
26295
27059
  }
26296
- //console.log(isHTML,uri,prefix=='')
26297
- //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
26298
- // return false;
26299
- //}
26300
- //node.flag = '11111'
26301
- //console.error(3,true,node.flag,node.prefix,node.namespaceURI)
26302
27060
  return true;
26303
27061
  }
27062
+ /**
27063
+ * Well-formed constraint: No < in Attribute Values
27064
+ * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
27065
+ * @see https://www.w3.org/TR/xml/#CleanAttrVals
27066
+ * @see https://www.w3.org/TR/xml/#NT-AttValue
27067
+ */
27068
+ function addSerializedAttribute(buf, qualifiedName, value) {
27069
+ buf.push(' ', qualifiedName, '="', value.replace(/[<&"]/g,_xmlEncoder), '"');
27070
+ }
27071
+
26304
27072
  function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
27073
+ if (!visibleNamespaces) {
27074
+ visibleNamespaces = [];
27075
+ }
27076
+
26305
27077
  if(nodeFilter){
26306
27078
  node = nodeFilter(node);
26307
27079
  if(node){
@@ -26314,20 +27086,40 @@ If this message still persists after updating, please report an issue: https://g
26314
27086
  }
26315
27087
  //buf.sort.apply(attrs, attributeSorter);
26316
27088
  }
27089
+
26317
27090
  switch(node.nodeType){
26318
27091
  case ELEMENT_NODE:
26319
- if (!visibleNamespaces) visibleNamespaces = [];
26320
- visibleNamespaces.length;
26321
27092
  var attrs = node.attributes;
26322
27093
  var len = attrs.length;
26323
27094
  var child = node.firstChild;
26324
27095
  var nodeName = node.tagName;
26325
27096
 
26326
- isHTML = (htmlns === node.namespaceURI) ||isHTML;
26327
- buf.push('<',nodeName);
26328
-
26329
-
26330
-
27097
+ isHTML = NAMESPACE$1.isHTML(node.namespaceURI) || isHTML;
27098
+
27099
+ var prefixedNodeName = nodeName;
27100
+ if (!isHTML && !node.prefix && node.namespaceURI) {
27101
+ var defaultNS;
27102
+ for (var ai = 0; ai < attrs.length; ai++) {
27103
+ if (attrs.item(ai).name === 'xmlns') {
27104
+ defaultNS = attrs.item(ai).value;
27105
+ break
27106
+ }
27107
+ }
27108
+ if (defaultNS !== node.namespaceURI) {
27109
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
27110
+ var namespace = visibleNamespaces[nsi];
27111
+ if (namespace.namespace === node.namespaceURI) {
27112
+ if (namespace.prefix) {
27113
+ prefixedNodeName = namespace.prefix + ':' + nodeName;
27114
+ }
27115
+ break
27116
+ }
27117
+ }
27118
+ }
27119
+ }
27120
+
27121
+ buf.push('<', prefixedNodeName);
27122
+
26331
27123
  for(var i=0;i<len;i++){
26332
27124
  // add namespaces for attributes
26333
27125
  var attr = attrs.item(i);
@@ -26337,28 +27129,24 @@ If this message still persists after updating, please report an issue: https://g
26337
27129
  visibleNamespaces.push({ prefix: '', namespace: attr.value });
26338
27130
  }
26339
27131
  }
27132
+
26340
27133
  for(var i=0;i<len;i++){
26341
27134
  var attr = attrs.item(i);
26342
27135
  if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
26343
27136
  var prefix = attr.prefix||'';
26344
27137
  var uri = attr.namespaceURI;
26345
- var ns = prefix ? ' xmlns:' + prefix : " xmlns";
26346
- buf.push(ns, '="' , uri , '"');
27138
+ addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
26347
27139
  visibleNamespaces.push({ prefix: prefix, namespace:uri });
26348
27140
  }
26349
27141
  serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
26350
27142
  }
27143
+
26351
27144
  // add namespace for current node
26352
- if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
27145
+ if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
26353
27146
  var prefix = node.prefix||'';
26354
27147
  var uri = node.namespaceURI;
26355
- if (uri) {
26356
- // Avoid empty namespace value like xmlns:ds=""
26357
- // Empty namespace URL will we produce an invalid XML document
26358
- var ns = prefix ? ' xmlns:' + prefix : " xmlns";
26359
- buf.push(ns, '="' , uri , '"');
26360
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
26361
- }
27148
+ addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
27149
+ visibleNamespaces.push({ prefix: prefix, namespace:uri });
26362
27150
  }
26363
27151
 
26364
27152
  if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
@@ -26369,18 +27157,18 @@ If this message still persists after updating, please report an issue: https://g
26369
27157
  if(child.data){
26370
27158
  buf.push(child.data);
26371
27159
  }else {
26372
- serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
27160
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
26373
27161
  }
26374
27162
  child = child.nextSibling;
26375
27163
  }
26376
27164
  }else
26377
27165
  {
26378
27166
  while(child){
26379
- serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
27167
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
26380
27168
  child = child.nextSibling;
26381
27169
  }
26382
27170
  }
26383
- buf.push('</',nodeName,'>');
27171
+ buf.push('</',prefixedNodeName,'>');
26384
27172
  }else {
26385
27173
  buf.push('/>');
26386
27174
  }
@@ -26391,18 +27179,12 @@ If this message still persists after updating, please report an issue: https://g
26391
27179
  case DOCUMENT_FRAGMENT_NODE:
26392
27180
  var child = node.firstChild;
26393
27181
  while(child){
26394
- serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
27182
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
26395
27183
  child = child.nextSibling;
26396
27184
  }
26397
27185
  return;
26398
27186
  case ATTRIBUTE_NODE:
26399
- /**
26400
- * Well-formedness constraint: No < in Attribute Values
26401
- * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
26402
- * @see https://www.w3.org/TR/xml/#CleanAttrVals
26403
- * @see https://www.w3.org/TR/xml/#NT-AttValue
26404
- */
26405
- return buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g,_xmlEncoder), '"');
27187
+ return addSerializedAttribute(buf, node.name, node.value);
26406
27188
  case TEXT_NODE:
26407
27189
  /**
26408
27190
  * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
@@ -26553,10 +27335,12 @@ If this message still persists after updating, please report an issue: https://g
26553
27335
  return this.$$length;
26554
27336
  }
26555
27337
  });
27338
+
26556
27339
  Object.defineProperty(Node.prototype,'textContent',{
26557
27340
  get:function(){
26558
27341
  return getTextContent(this);
26559
27342
  },
27343
+
26560
27344
  set:function(data){
26561
27345
  switch(this.nodeType){
26562
27346
  case ELEMENT_NODE:
@@ -26568,8 +27352,8 @@ If this message still persists after updating, please report an issue: https://g
26568
27352
  this.appendChild(this.ownerDocument.createTextNode(data));
26569
27353
  }
26570
27354
  break;
27355
+
26571
27356
  default:
26572
- //TODO:
26573
27357
  this.data = data;
26574
27358
  this.value = data;
26575
27359
  this.nodeValue = data;
@@ -26594,6 +27378,7 @@ If this message still persists after updating, please report an issue: https://g
26594
27378
  return node.nodeValue;
26595
27379
  }
26596
27380
  }
27381
+
26597
27382
  __set__ = function(object,key,value){
26598
27383
  //console.log(value)
26599
27384
  object['$$'+key] = value;
@@ -26603,11 +27388,19 @@ If this message still persists after updating, please report an issue: https://g
26603
27388
  }
26604
27389
 
26605
27390
  //if(typeof require == 'function'){
26606
- dom.Node = Node;
27391
+ dom.DocumentType = DocumentType;
26607
27392
  dom.DOMException = DOMException;
26608
27393
  dom.DOMImplementation = DOMImplementation$1;
27394
+ dom.Element = Element;
27395
+ dom.Node = Node;
27396
+ dom.NodeList = NodeList;
26609
27397
  dom.XMLSerializer = XMLSerializer;
26610
27398
 
27399
+ var conventions = conventions$2;
27400
+ var entities = entities$1;
27401
+
27402
+ var NAMESPACE = conventions.NAMESPACE;
27403
+
26611
27404
  function DOMParser(options){
26612
27405
  this.options = options ||{locator:{}};
26613
27406
  }
@@ -26620,7 +27413,7 @@ If this message still persists after updating, please report an issue: https://g
26620
27413
  var locator = options.locator;
26621
27414
  var defaultNSMap = options.xmlns||{};
26622
27415
  var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
26623
- var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"};
27416
+ var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
26624
27417
  if(locator){
26625
27418
  domBuilder.setDocumentLocator(locator);
26626
27419
  }
@@ -26628,9 +27421,9 @@ If this message still persists after updating, please report an issue: https://g
26628
27421
  sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
26629
27422
  sax.domBuilder = options.domBuilder || domBuilder;
26630
27423
  if(isHTML){
26631
- defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
27424
+ defaultNSMap[''] = NAMESPACE.HTML;
26632
27425
  }
26633
- defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
27426
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
26634
27427
  if(source && typeof source === 'string'){
26635
27428
  sax.parse(source,defaultNSMap,entityMap);
26636
27429
  }else {
@@ -26852,7 +27645,6 @@ If this message still persists after updating, please report an issue: https://g
26852
27645
  }//appendChild and setAttributeNS are preformance key
26853
27646
 
26854
27647
  //if(typeof require == 'function'){
26855
- var htmlEntity = entities;
26856
27648
  var sax = sax$1;
26857
27649
  var XMLReader = sax.XMLReader;
26858
27650
  var ParseError = sax.ParseError;
@@ -27599,6 +28391,23 @@ If this message still persists after updating, please report an issue: https://g
27599
28391
  };
27600
28392
  }
27601
28393
 
28394
+ /**
28395
+ * Pipes all emitted events from one emitter to another.
28396
+ */
28397
+ function pipeEvents(source, destination) {
28398
+ const rawEmit = source.emit;
28399
+ // @ts-ignore
28400
+ if (rawEmit._isPiped) {
28401
+ return;
28402
+ }
28403
+ source.emit = function (event, ...data) {
28404
+ destination.emit(event, ...data);
28405
+ return rawEmit.call(this, event, ...data);
28406
+ };
28407
+ // @ts-ignore
28408
+ source.emit._isPiped = true;
28409
+ }
28410
+
27602
28411
  // Declare the list of event handlers on the module's scope
27603
28412
  // so it persists between Fash refreshes of the application's code.
27604
28413
  let listeners = [];
@@ -27617,12 +28426,15 @@ If this message still persists after updating, please report an issue: https://g
27617
28426
  if (lib$5.exports.isNodeProcess()) {
27618
28427
  throw new Error(devUtils.formatMessage('Failed to execute `setupWorker` in a non-browser environment. Consider using `setupServer` for Node.js environment instead.'));
27619
28428
  }
28429
+ const emitter = new lib$4.StrictEventEmitter();
28430
+ const publicEmitter = new lib$4.StrictEventEmitter();
28431
+ pipeEvents(emitter, publicEmitter);
27620
28432
  const context = {
27621
28433
  startOptions: undefined,
27622
28434
  worker: null,
27623
28435
  registration: null,
27624
28436
  requestHandlers: [...requestHandlers],
27625
- emitter: new lib$4.StrictEventEmitter(),
28437
+ emitter,
27626
28438
  workerChannel: {
27627
28439
  on(eventType, callback) {
27628
28440
  context.events.addListener(navigator.serviceWorker, 'message', (event) => {
@@ -27688,7 +28500,12 @@ If this message still persists after updating, please report an issue: https://g
27688
28500
  : createStop(context);
27689
28501
  return {
27690
28502
  start: prepareStartHandler(startHandler, context),
27691
- stop: stopHandler,
28503
+ stop() {
28504
+ context.events.removeAllListeners();
28505
+ context.emitter.removeAllListeners();
28506
+ publicEmitter.removeAllListeners();
28507
+ stopHandler();
28508
+ },
27692
28509
  use(...handlers) {
27693
28510
  use(context.requestHandlers, ...handlers);
27694
28511
  },
@@ -27715,8 +28532,16 @@ If this message still persists after updating, please report an issue: https://g
27715
28532
  console.groupEnd();
27716
28533
  });
27717
28534
  },
27718
- on(eventType, listener) {
27719
- context.emitter.addListener(eventType, listener);
28535
+ events: {
28536
+ on(...args) {
28537
+ return publicEmitter.on(...args);
28538
+ },
28539
+ removeListener(...args) {
28540
+ return publicEmitter.removeListener(...args);
28541
+ },
28542
+ removeAllListeners(...args) {
28543
+ return publicEmitter.removeAllListeners(...args);
28544
+ },
27720
28545
  },
27721
28546
  };
27722
28547
  }
@@ -27727,6 +28552,7 @@ If this message still persists after updating, please report an issue: https://g
27727
28552
  };
27728
28553
  }
27729
28554
  const rest = {
28555
+ all: createRestHandler(/.+/),
27730
28556
  head: createRestHandler(exports.RESTMethods.HEAD),
27731
28557
  get: createRestHandler(exports.RESTMethods.GET),
27732
28558
  post: createRestHandler(exports.RESTMethods.POST),
@@ -27787,6 +28613,7 @@ If this message still persists after updating, please report an issue: https://g
27787
28613
  exports.GraphQLHandler = GraphQLHandler;
27788
28614
  exports.RequestHandler = RequestHandler;
27789
28615
  exports.RestHandler = RestHandler;
28616
+ exports.cleanUrl = cleanUrl;
27790
28617
  exports.compose = compose;
27791
28618
  exports.context = index;
27792
28619
  exports.createResponseComposition = createResponseComposition;
@@ -27802,4 +28629,4 @@ If this message still persists after updating, please report an issue: https://g
27802
28629
  exports.restContext = restContext;
27803
28630
  exports.setupWorker = setupWorker;
27804
28631
 
27805
- })));
28632
+ }));