proto-sudoku-wc 0.0.803 → 0.0.805

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.
@@ -24,13 +24,119 @@ const NAMESPACE = 'proto-sudoku-wc';
24
24
  const BUILD = /* proto-sudoku-wc */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: false, propMutable: false, propNumber: false, propString: true, reflect: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: false, slotChildNodesFix: false, slotRelocation: false, state: false, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
25
25
 
26
26
  /*
27
- Stencil Client Platform v4.18.3 | MIT Licensed | https://stenciljs.com
27
+ Stencil Client Platform v4.19.0 | MIT Licensed | https://stenciljs.com
28
28
  */
29
29
  var __defProp = Object.defineProperty;
30
30
  var __export = (target, all) => {
31
31
  for (var name in all)
32
32
  __defProp(target, name, { get: all[name], enumerable: true });
33
33
  };
34
+ var hostRefs = /* @__PURE__ */ new WeakMap();
35
+ var getHostRef = (ref) => hostRefs.get(ref);
36
+ var registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
37
+ var registerHost = (hostElement, cmpMeta) => {
38
+ const hostRef = {
39
+ $flags$: 0,
40
+ $hostElement$: hostElement,
41
+ $cmpMeta$: cmpMeta,
42
+ $instanceValues$: /* @__PURE__ */ new Map()
43
+ };
44
+ {
45
+ hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
46
+ hostElement["s-p"] = [];
47
+ hostElement["s-rc"] = [];
48
+ }
49
+ return hostRefs.set(hostElement, hostRef);
50
+ };
51
+ var isMemberInElement = (elm, memberName) => memberName in elm;
52
+ var consoleError = (e, el) => (0, console.error)(e, el);
53
+
54
+ // src/client/client-load-module.ts
55
+ var cmpModules = /* @__PURE__ */ new Map();
56
+ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
57
+ const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
58
+ const bundleId = cmpMeta.$lazyBundleId$;
59
+ if (!bundleId) {
60
+ return void 0;
61
+ }
62
+ const module = cmpModules.get(bundleId) ;
63
+ if (module) {
64
+ return module[exportName];
65
+ }
66
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
67
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
68
+ /* @vite-ignore */
69
+ /* webpackInclude: /\.entry\.js$/ */
70
+ /* webpackExclude: /\.system\.entry\.js$/ */
71
+ /* webpackMode: "lazy" */
72
+ `./${bundleId}.entry.js${""}`
73
+ )); }).then((importedModule) => {
74
+ {
75
+ cmpModules.set(bundleId, importedModule);
76
+ }
77
+ return importedModule[exportName];
78
+ }, consoleError);
79
+ };
80
+
81
+ // src/client/client-style.ts
82
+ var styles = /* @__PURE__ */ new Map();
83
+ var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
84
+ var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
85
+ var win = typeof window !== "undefined" ? window : {};
86
+ var doc = win.document || { head: {} };
87
+ var plt = {
88
+ $flags$: 0,
89
+ $resourcesUrl$: "",
90
+ jmp: (h2) => h2(),
91
+ raf: (h2) => requestAnimationFrame(h2),
92
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
93
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
94
+ ce: (eventName, opts) => new CustomEvent(eventName, opts)
95
+ };
96
+ var promiseResolve = (v) => Promise.resolve(v);
97
+ var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
98
+ try {
99
+ new CSSStyleSheet();
100
+ return typeof new CSSStyleSheet().replaceSync === "function";
101
+ } catch (e) {
102
+ }
103
+ return false;
104
+ })() ;
105
+ var queuePending = false;
106
+ var queueDomReads = [];
107
+ var queueDomWrites = [];
108
+ var queueTask = (queue, write) => (cb) => {
109
+ queue.push(cb);
110
+ if (!queuePending) {
111
+ queuePending = true;
112
+ if (write && plt.$flags$ & 4 /* queueSync */) {
113
+ nextTick(flush);
114
+ } else {
115
+ plt.raf(flush);
116
+ }
117
+ }
118
+ };
119
+ var consume = (queue) => {
120
+ for (let i2 = 0; i2 < queue.length; i2++) {
121
+ try {
122
+ queue[i2](performance.now());
123
+ } catch (e) {
124
+ consoleError(e);
125
+ }
126
+ }
127
+ queue.length = 0;
128
+ };
129
+ var flush = () => {
130
+ consume(queueDomReads);
131
+ {
132
+ consume(queueDomWrites);
133
+ if (queuePending = queueDomReads.length > 0) {
134
+ plt.raf(flush);
135
+ }
136
+ }
137
+ };
138
+ var nextTick = (cb) => promiseResolve().then(cb);
139
+ var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
34
140
 
35
141
  // src/utils/constants.ts
36
142
  var EMPTY_OBJ = {};
@@ -112,8 +218,6 @@ var uniqueTime = (key, measureText) => {
112
218
  };
113
219
  }
114
220
  };
115
- var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
116
- var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
117
221
  var h = (nodeName, vnodeData, ...children) => {
118
222
  let child = null;
119
223
  let key = null;
@@ -246,12 +350,13 @@ var registerStyle = (scopeId2, cssText, allowCS) => {
246
350
  };
247
351
  var addStyle = (styleContainerNode, cmpMeta, mode) => {
248
352
  var _a;
353
+ const styleContainerDocument = styleContainerNode;
249
354
  const scopeId2 = getScopeId(cmpMeta);
250
355
  const style = styles.get(scopeId2);
251
356
  styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
252
357
  if (style) {
253
358
  if (typeof style === "string") {
254
- styleContainerNode = styleContainerNode.head || styleContainerNode;
359
+ styleContainerNode = styleContainerDocument.head || styleContainerNode;
255
360
  let appliedStyles = rootAppliedStyles.get(styleContainerNode);
256
361
  let styleElm;
257
362
  if (!appliedStyles) {
@@ -274,8 +379,8 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
274
379
  appliedStyles.add(scopeId2);
275
380
  }
276
381
  }
277
- } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
278
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
382
+ } else if (!styleContainerDocument.adoptedStyleSheets.includes(style)) {
383
+ styleContainerDocument.adoptedStyleSheets = [...styleContainerDocument.adoptedStyleSheets, style];
279
384
  }
280
385
  }
281
386
  return scopeId2;
@@ -389,6 +494,7 @@ function sortedAttrNames(attrNames) {
389
494
  // src/runtime/vdom/vdom-render.ts
390
495
  var scopeId;
391
496
  var hostTagName;
497
+ var useNativeShadowDom = false;
392
498
  var isSvgMode = false;
393
499
  var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
394
500
  const newVNode2 = newParentVNode.$children$[childIndex];
@@ -403,7 +509,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
403
509
  }
404
510
  elm = newVNode2.$elm$ = doc.createElementNS(
405
511
  isSvgMode ? SVG_NS : HTML_NS,
406
- newVNode2.$tag$
512
+ !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
407
513
  ) ;
408
514
  if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
409
515
  isSvgMode = false;
@@ -591,6 +697,7 @@ var insertBefore = (parent, newNode, reference) => {
591
697
  };
592
698
  var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
593
699
  const hostElm = hostRef.$hostElement$;
700
+ const cmpMeta = hostRef.$cmpMeta$;
594
701
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
595
702
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
596
703
  hostTagName = hostElm.tagName;
@@ -608,6 +715,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
608
715
  {
609
716
  scopeId = hostElm["s-sc"];
610
717
  }
718
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
611
719
  patch(oldVNode, rootVnode, isInitialLoad);
612
720
  };
613
721
 
@@ -642,7 +750,10 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
642
750
  endSchedule();
643
751
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
644
752
  };
645
- var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
753
+ var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
754
+ console.error(err2);
755
+ fn();
756
+ }) : fn();
646
757
  var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
647
758
  var updateComponent = async (hostRef, instance, isInitialLoad) => {
648
759
  var _a;
@@ -792,10 +903,10 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
792
903
 
793
904
  // src/runtime/proxy-component.ts
794
905
  var proxyComponent = (Cstr, cmpMeta, flags) => {
795
- var _a;
906
+ var _a, _b;
796
907
  const prototype = Cstr.prototype;
797
- if (cmpMeta.$members$) {
798
- const members = Object.entries(cmpMeta.$members$);
908
+ if (cmpMeta.$members$ || BUILD.watchCallback ) {
909
+ const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
799
910
  members.map(([memberName, [memberFlags]]) => {
800
911
  if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
801
912
  Object.defineProperty(prototype, memberName, {
@@ -840,7 +951,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
840
951
  };
841
952
  Cstr.observedAttributes = Array.from(
842
953
  /* @__PURE__ */ new Set([
843
- ...Object.keys((_a = cmpMeta.$watchers$) != null ? _a : {}),
954
+ ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
844
955
  ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
845
956
  const attrName = m[1] || propName;
846
957
  attrNameToPropName.set(attrName, propName);
@@ -894,7 +1005,10 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
894
1005
  customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
895
1006
  }
896
1007
  if (Cstr && Cstr.style) {
897
- let style = Cstr.style;
1008
+ let style;
1009
+ if (typeof Cstr.style === "string") {
1010
+ style = Cstr.style;
1011
+ }
898
1012
  const scopeId2 = getScopeId(cmpMeta);
899
1013
  if (!styles.has(scopeId2)) {
900
1014
  const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
@@ -997,17 +1111,30 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
997
1111
  // StencilLazyHost
998
1112
  constructor(self) {
999
1113
  super(self);
1114
+ this.hasRegisteredEventListeners = false;
1000
1115
  self = this;
1001
1116
  registerHost(self, cmpMeta);
1002
1117
  if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1003
1118
  {
1004
- {
1005
- self.attachShadow({ mode: "open" });
1119
+ if (!self.shadowRoot) {
1120
+ {
1121
+ self.attachShadow({ mode: "open" });
1122
+ }
1123
+ } else {
1124
+ if (self.shadowRoot.mode !== "open") {
1125
+ throw new Error(
1126
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
1127
+ );
1128
+ }
1006
1129
  }
1007
1130
  }
1008
1131
  }
1009
1132
  }
1010
1133
  connectedCallback() {
1134
+ getHostRef(this);
1135
+ if (!this.hasRegisteredEventListeners) {
1136
+ this.hasRegisteredEventListeners = true;
1137
+ }
1011
1138
  if (appLoadFallback) {
1012
1139
  clearTimeout(appLoadFallback);
1013
1140
  appLoadFallback = null;
@@ -1040,7 +1167,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1040
1167
  dataStyles.textContent += SLOT_FB_CSS;
1041
1168
  }
1042
1169
  {
1043
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
1170
+ dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
1044
1171
  }
1045
1172
  if (dataStyles.innerHTML.length) {
1046
1173
  dataStyles.setAttribute("data-styles", "");
@@ -1065,112 +1192,6 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1065
1192
  // src/runtime/nonce.ts
1066
1193
  var setNonce = (nonce) => plt.$nonce$ = nonce;
1067
1194
 
1068
- // src/client/client-host-ref.ts
1069
- var hostRefs = /* @__PURE__ */ new WeakMap();
1070
- var getHostRef = (ref) => hostRefs.get(ref);
1071
- var registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
1072
- var registerHost = (hostElement, cmpMeta) => {
1073
- const hostRef = {
1074
- $flags$: 0,
1075
- $hostElement$: hostElement,
1076
- $cmpMeta$: cmpMeta,
1077
- $instanceValues$: /* @__PURE__ */ new Map()
1078
- };
1079
- {
1080
- hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
1081
- hostElement["s-p"] = [];
1082
- hostElement["s-rc"] = [];
1083
- }
1084
- return hostRefs.set(hostElement, hostRef);
1085
- };
1086
- var isMemberInElement = (elm, memberName) => memberName in elm;
1087
- var consoleError = (e, el) => (0, console.error)(e, el);
1088
-
1089
- // src/client/client-load-module.ts
1090
- var cmpModules = /* @__PURE__ */ new Map();
1091
- var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1092
- const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
1093
- const bundleId = cmpMeta.$lazyBundleId$;
1094
- if (!bundleId) {
1095
- return void 0;
1096
- }
1097
- const module = cmpModules.get(bundleId) ;
1098
- if (module) {
1099
- return module[exportName];
1100
- }
1101
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1102
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1103
- /* @vite-ignore */
1104
- /* webpackInclude: /\.entry\.js$/ */
1105
- /* webpackExclude: /\.system\.entry\.js$/ */
1106
- /* webpackMode: "lazy" */
1107
- `./${bundleId}.entry.js${""}`
1108
- )); }).then((importedModule) => {
1109
- {
1110
- cmpModules.set(bundleId, importedModule);
1111
- }
1112
- return importedModule[exportName];
1113
- }, consoleError);
1114
- };
1115
-
1116
- // src/client/client-style.ts
1117
- var styles = /* @__PURE__ */ new Map();
1118
- var win = typeof window !== "undefined" ? window : {};
1119
- var doc = win.document || { head: {} };
1120
- var plt = {
1121
- $flags$: 0,
1122
- $resourcesUrl$: "",
1123
- jmp: (h2) => h2(),
1124
- raf: (h2) => requestAnimationFrame(h2),
1125
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1126
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1127
- ce: (eventName, opts) => new CustomEvent(eventName, opts)
1128
- };
1129
- var promiseResolve = (v) => Promise.resolve(v);
1130
- var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
1131
- try {
1132
- new CSSStyleSheet();
1133
- return typeof new CSSStyleSheet().replaceSync === "function";
1134
- } catch (e) {
1135
- }
1136
- return false;
1137
- })() ;
1138
- var queuePending = false;
1139
- var queueDomReads = [];
1140
- var queueDomWrites = [];
1141
- var queueTask = (queue, write) => (cb) => {
1142
- queue.push(cb);
1143
- if (!queuePending) {
1144
- queuePending = true;
1145
- if (write && plt.$flags$ & 4 /* queueSync */) {
1146
- nextTick(flush);
1147
- } else {
1148
- plt.raf(flush);
1149
- }
1150
- }
1151
- };
1152
- var consume = (queue) => {
1153
- for (let i2 = 0; i2 < queue.length; i2++) {
1154
- try {
1155
- queue[i2](performance.now());
1156
- } catch (e) {
1157
- consoleError(e);
1158
- }
1159
- }
1160
- queue.length = 0;
1161
- };
1162
- var flush = () => {
1163
- consume(queueDomReads);
1164
- {
1165
- consume(queueDomWrites);
1166
- if (queuePending = queueDomReads.length > 0) {
1167
- plt.raf(flush);
1168
- }
1169
- }
1170
- };
1171
- var nextTick = (cb) => promiseResolve().then(cb);
1172
- var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
1173
-
1174
1195
  exports.bootstrapLazy = bootstrapLazy;
1175
1196
  exports.forceUpdate = forceUpdate;
1176
1197
  exports.getRenderingRef = getRenderingRef;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-25d8a5cc.js');
5
+ const index = require('./index-3f1a189c.js');
6
6
  const appGlobals = require('./app-globals-3a1e7e63.js');
7
7
 
8
8
  const defineCustomElements = async (win, options) => {
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-25d8a5cc.js');
5
+ const index = require('./index-3f1a189c.js');
6
6
  const appGlobals = require('./app-globals-3a1e7e63.js');
7
7
 
8
8
  /*
9
- Stencil Client Patch Browser v4.18.3 | MIT Licensed | https://stenciljs.com
9
+ Stencil Client Patch Browser v4.19.0 | MIT Licensed | https://stenciljs.com
10
10
  */
11
11
  var patchBrowser = () => {
12
12
  const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('proto-sudoku-wc.cjs.js', document.baseURI).href));
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-25d8a5cc.js');
5
+ const index = require('./index-3f1a189c.js');
6
6
 
7
7
  const Alien = props => {
8
8
  const hex = props.hex || 'currentColor';
@@ -257,7 +257,7 @@ class HTTPError extends Error {
257
257
  const title = response.statusText || '';
258
258
  const status = `${code} ${title}`.trim();
259
259
  const reason = status ? `status code ${status}` : 'an unknown error';
260
- super(`Request failed with ${reason}`);
260
+ super(`Request failed with ${reason}: ${request.method} ${request.url}`);
261
261
  Object.defineProperty(this, "response", {
262
262
  enumerable: true,
263
263
  configurable: true,
@@ -285,7 +285,7 @@ class HTTPError extends Error {
285
285
 
286
286
  class TimeoutError extends Error {
287
287
  constructor(request) {
288
- super('Request timed out');
288
+ super(`Request timed out: ${request.method} ${request.url}`);
289
289
  Object.defineProperty(this, "request", {
290
290
  enumerable: true,
291
291
  configurable: true,
@@ -355,15 +355,24 @@ const supportsRequestStreams = (() => {
355
355
  const supportsReadableStream = typeof globalThis.ReadableStream === 'function';
356
356
  const supportsRequest = typeof globalThis.Request === 'function';
357
357
  if (supportsReadableStream && supportsRequest) {
358
- hasContentType = new globalThis.Request('https://empty.invalid', {
359
- body: new globalThis.ReadableStream(),
360
- method: 'POST',
361
- // @ts-expect-error - Types are outdated.
362
- get duplex() {
363
- duplexAccessed = true;
364
- return 'half';
365
- },
366
- }).headers.has('Content-Type');
358
+ try {
359
+ hasContentType = new globalThis.Request('https://empty.invalid', {
360
+ body: new globalThis.ReadableStream(),
361
+ method: 'POST',
362
+ // @ts-expect-error - Types are outdated.
363
+ get duplex() {
364
+ duplexAccessed = true;
365
+ return 'half';
366
+ },
367
+ }).headers.has('Content-Type');
368
+ }
369
+ catch (error) {
370
+ // QQBrowser on iOS throws "unsupported BodyInit type" error (see issue #581)
371
+ if (error instanceof Error && error.message === 'unsupported BodyInit type') {
372
+ return false;
373
+ }
374
+ throw error;
375
+ }
367
376
  }
368
377
  return duplexAccessed && !hasContentType;
369
378
  })();
@@ -638,6 +647,10 @@ class Ky {
638
647
  // @ts-expect-error - Types are outdated.
639
648
  this._options.duplex = 'half';
640
649
  }
650
+ if (this._options.json !== undefined) {
651
+ this._options.body = this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json);
652
+ this._options.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');
653
+ }
641
654
  this.request = new globalThis.Request(this._input, this._options);
642
655
  if (this._options.searchParams) {
643
656
  // eslint-disable-next-line unicorn/prevent-abbreviations
@@ -655,11 +668,6 @@ class Ky {
655
668
  // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.
656
669
  this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);
657
670
  }
658
- if (this._options.json !== undefined) {
659
- this._options.body = this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json);
660
- this.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');
661
- this.request = new globalThis.Request(this.request, { body: this._options.body });
662
- }
663
671
  }
664
672
  _calculateRetryDelay(error) {
665
673
  this._retryCount++;
@@ -670,17 +678,12 @@ class Ky {
670
678
  }
671
679
  const retryAfter = error.response.headers.get('Retry-After');
672
680
  if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {
673
- let after = Number(retryAfter);
681
+ let after = Number(retryAfter) * 1000;
674
682
  if (Number.isNaN(after)) {
675
683
  after = Date.parse(retryAfter) - Date.now();
676
684
  }
677
- else {
678
- after *= 1000;
679
- }
680
- if (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {
681
- return 0;
682
- }
683
- return after;
685
+ const max = this._options.retry.maxRetryAfter ?? after;
686
+ return after < max ? after : max;
684
687
  }
685
688
  if (error.response.status === 413) {
686
689
  return 0;
@@ -736,10 +739,13 @@ class Ky {
736
739
  }
737
740
  }
738
741
  const nonRequestOptions = findUnknownOptions(this.request, this._options);
742
+ // Cloning is done here to prepare in advance for retries
743
+ const mainRequest = this.request;
744
+ this.request = mainRequest.clone();
739
745
  if (this._options.timeout === false) {
740
- return this._options.fetch(this.request.clone(), nonRequestOptions);
746
+ return this._options.fetch(mainRequest, nonRequestOptions);
741
747
  }
742
- return timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options);
748
+ return timeout(mainRequest, nonRequestOptions, this.abortController, this._options);
743
749
  }
744
750
  /* istanbul ignore next */
745
751
  _stream(response, onDownloadProgress) {
@@ -4,7 +4,7 @@
4
4
  ],
5
5
  "compiler": {
6
6
  "name": "@stencil/core",
7
- "version": "4.18.3",
7
+ "version": "4.19.0",
8
8
  "typescriptVersion": "5.4.5"
9
9
  },
10
10
  "collections": [],