hardpy 0.18.2__py3-none-any.whl → 0.19.0__py3-none-any.whl
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.
- hardpy/common/config.py +45 -2
- hardpy/hardpy_panel/api.py +100 -11
- hardpy/hardpy_panel/frontend/dist/assets/{allPaths-31ulJ0tA.js → allPaths-C_-7WXHD.js} +1 -1
- hardpy/hardpy_panel/frontend/dist/assets/{allPathsLoader-HPn4WHWu.js → allPathsLoader-DgH0Xily.js} +2 -2
- hardpy/hardpy_panel/frontend/dist/assets/{browser-ponyfill-BQ1ipruI.js → browser-ponyfill-BbOvdqIF.js} +1 -1
- hardpy/hardpy_panel/frontend/dist/assets/index-DEJb2W0B.js +4679 -0
- hardpy/hardpy_panel/frontend/dist/assets/{splitPathsBySizeLoader-ev1ZiRR9.js → splitPathsBySizeLoader-o5HCcdVL.js} +1 -1
- hardpy/hardpy_panel/frontend/dist/index.html +1 -1
- hardpy/hardpy_panel/frontend/dist/locales/de/translation.json +11 -1
- hardpy/hardpy_panel/frontend/dist/locales/en/translation.json +11 -1
- hardpy/hardpy_panel/frontend/dist/locales/es/translation.json +11 -1
- hardpy/hardpy_panel/frontend/dist/locales/fr/translation.json +11 -1
- hardpy/hardpy_panel/frontend/dist/locales/ja/translation.json +11 -1
- hardpy/hardpy_panel/frontend/dist/locales/ru/translation.json +11 -1
- hardpy/hardpy_panel/frontend/dist/locales/zh/translation.json +11 -1
- hardpy/pytest_hardpy/pytest_wrapper.py +86 -5
- hardpy/pytest_hardpy/reporter/base.py +5 -0
- hardpy/pytest_hardpy/reporter/hook_reporter.py +1 -2
- hardpy/pytest_hardpy/result/report_synchronizer/synchronizer.py +2 -1
- {hardpy-0.18.2.dist-info → hardpy-0.19.0.dist-info}/METADATA +3 -3
- {hardpy-0.18.2.dist-info → hardpy-0.19.0.dist-info}/RECORD +24 -24
- hardpy/hardpy_panel/frontend/dist/assets/index-BK2y65ib.js +0 -4673
- {hardpy-0.18.2.dist-info → hardpy-0.19.0.dist-info}/WHEEL +0 -0
- {hardpy-0.18.2.dist-info → hardpy-0.19.0.dist-info}/entry_points.txt +0 -0
- {hardpy-0.18.2.dist-info → hardpy-0.19.0.dist-info}/licenses/LICENSE +0 -0
hardpy/common/config.py
CHANGED
|
@@ -51,6 +51,7 @@ class FrontendConfig(BaseModel):
|
|
|
51
51
|
language: str = "en"
|
|
52
52
|
full_size_button: bool = False
|
|
53
53
|
sound_on: bool = False
|
|
54
|
+
manual_collect: bool = False
|
|
54
55
|
measurement_display: bool = True
|
|
55
56
|
modal_result: ModalResultConfig = Field(default_factory=lambda: ModalResultConfig())
|
|
56
57
|
|
|
@@ -77,6 +78,24 @@ class StandCloudConfig(BaseModel):
|
|
|
77
78
|
api_key: str = ""
|
|
78
79
|
|
|
79
80
|
|
|
81
|
+
class TestConfig(BaseModel):
|
|
82
|
+
"""Test configuration entry."""
|
|
83
|
+
|
|
84
|
+
model_config = ConfigDict(extra="allow")
|
|
85
|
+
|
|
86
|
+
name: str
|
|
87
|
+
description: str = ""
|
|
88
|
+
file: str | None = None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class TestConfigs(BaseModel):
|
|
92
|
+
"""Test configurations container."""
|
|
93
|
+
|
|
94
|
+
model_config = ConfigDict(extra="allow")
|
|
95
|
+
|
|
96
|
+
available: list[str] = []
|
|
97
|
+
|
|
98
|
+
|
|
80
99
|
class HardpyConfig(BaseModel, extra="allow"):
|
|
81
100
|
"""HardPy configuration."""
|
|
82
101
|
|
|
@@ -87,6 +106,8 @@ class HardpyConfig(BaseModel, extra="allow"):
|
|
|
87
106
|
database: DatabaseConfig = DatabaseConfig()
|
|
88
107
|
frontend: FrontendConfig = FrontendConfig()
|
|
89
108
|
stand_cloud: StandCloudConfig = StandCloudConfig()
|
|
109
|
+
current_test_config: str = ""
|
|
110
|
+
test_configs: list[TestConfig] = []
|
|
90
111
|
|
|
91
112
|
def model_post_init(self, __context) -> None: # noqa: ANN001,PYI063
|
|
92
113
|
"""Get database document name."""
|
|
@@ -102,7 +123,7 @@ class ConfigManager(metaclass=SingletonMeta):
|
|
|
102
123
|
|
|
103
124
|
def __init__(self) -> None:
|
|
104
125
|
self._config = HardpyConfig()
|
|
105
|
-
self.
|
|
126
|
+
self._tests_path = Path.cwd()
|
|
106
127
|
|
|
107
128
|
@property
|
|
108
129
|
def config(self) -> HardpyConfig:
|
|
@@ -176,7 +197,8 @@ class ConfigManager(metaclass=SingletonMeta):
|
|
|
176
197
|
Args:
|
|
177
198
|
parent_dir (Path): Configuration file parent directory.
|
|
178
199
|
"""
|
|
179
|
-
|
|
200
|
+
# test_config is filled in by the user as an array
|
|
201
|
+
config_str = tomli_w.dumps(self._config.model_dump(exclude="test_configs"))
|
|
180
202
|
with Path.open(parent_dir / "hardpy.toml", "w") as file:
|
|
181
203
|
file.write(config_str)
|
|
182
204
|
|
|
@@ -192,6 +214,7 @@ class ConfigManager(metaclass=SingletonMeta):
|
|
|
192
214
|
self._tests_path = toml_path
|
|
193
215
|
toml_file = toml_path / "hardpy.toml"
|
|
194
216
|
if not toml_file.exists():
|
|
217
|
+
# TODO (xorialexandrov): Add a log that cannot cause tests to fail
|
|
195
218
|
return None
|
|
196
219
|
try:
|
|
197
220
|
with Path.open(toml_path / "hardpy.toml", "rb") as f:
|
|
@@ -207,3 +230,23 @@ class ConfigManager(metaclass=SingletonMeta):
|
|
|
207
230
|
logger.exception("Error parsing TOML")
|
|
208
231
|
return None
|
|
209
232
|
return self._config
|
|
233
|
+
|
|
234
|
+
def set_current_test_config(self, config_name: str) -> None:
|
|
235
|
+
"""Set current test configuration.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
config_name (str): Test configuration name
|
|
239
|
+
"""
|
|
240
|
+
if self._config.test_configs == []:
|
|
241
|
+
logger.warning("No test configurations available.")
|
|
242
|
+
return
|
|
243
|
+
|
|
244
|
+
available_configs = [config.name for config in self._config.test_configs]
|
|
245
|
+
if config_name in available_configs:
|
|
246
|
+
self._config.current_test_config = config_name
|
|
247
|
+
else:
|
|
248
|
+
msg = (
|
|
249
|
+
f"Test configuration {config_name} not ",
|
|
250
|
+
"found among available configurations.",
|
|
251
|
+
)
|
|
252
|
+
logger.warning(msg)
|
hardpy/hardpy_panel/api.py
CHANGED
|
@@ -14,7 +14,7 @@ from pathlib import Path
|
|
|
14
14
|
from typing import TYPE_CHECKING, Annotated, Any, Final
|
|
15
15
|
from urllib.parse import unquote
|
|
16
16
|
|
|
17
|
-
from fastapi import FastAPI, Query
|
|
17
|
+
from fastapi import FastAPI, Query, Request
|
|
18
18
|
from fastapi.staticfiles import StaticFiles
|
|
19
19
|
|
|
20
20
|
from hardpy.common.config import ConfigManager
|
|
@@ -35,6 +35,7 @@ logger = logging.getLogger(__name__)
|
|
|
35
35
|
@contextlib.asynccontextmanager
|
|
36
36
|
async def lifespan_sync_scheduler(app: FastAPI) -> AsyncGenerator[Any, Any]:
|
|
37
37
|
"""Manages the lifecycle events (startup and shutdown) for background tasks."""
|
|
38
|
+
# Start StandCloud synchronization if enabled
|
|
38
39
|
config_manager = ConfigManager()
|
|
39
40
|
sc_autosync = config_manager.config.stand_cloud.autosync
|
|
40
41
|
if sc_autosync:
|
|
@@ -43,22 +44,24 @@ async def lifespan_sync_scheduler(app: FastAPI) -> AsyncGenerator[Any, Any]:
|
|
|
43
44
|
|
|
44
45
|
yield
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
logger.info("Cancelled StandCloud synchronization task.")
|
|
47
|
+
# Cleanup on shutdown
|
|
48
|
+
if sc_autosync and hasattr(app.state, "sync_task"):
|
|
49
|
+
app.state.sync_task.cancel()
|
|
50
|
+
await asyncio.gather(app.state.sync_task, return_exceptions=True)
|
|
51
|
+
logger.info("Cancelled StandCloud synchronization task.")
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if hasattr(app.state, "executor"):
|
|
54
|
+
app.state.executor.shutdown(wait=False)
|
|
55
|
+
logger.info("Shut down ThreadPoolExecutor.")
|
|
56
56
|
|
|
57
57
|
|
|
58
|
+
# Initialize application state
|
|
58
59
|
app = FastAPI(lifespan=lifespan_sync_scheduler)
|
|
59
60
|
app.state.pytest_wrp = PyTestWrapper()
|
|
60
61
|
app.state.sc_synchronizer = StandCloudSynchronizer()
|
|
61
62
|
app.state.executor = ThreadPoolExecutor(max_workers=1)
|
|
63
|
+
app.state.manual_collect_mode = False
|
|
64
|
+
app.state.selected_tests = []
|
|
62
65
|
|
|
63
66
|
|
|
64
67
|
class Status(str, Enum):
|
|
@@ -108,6 +111,25 @@ def hardpy_config() -> dict:
|
|
|
108
111
|
return app.state.pytest_wrp.get_config()
|
|
109
112
|
|
|
110
113
|
|
|
114
|
+
@app.post("/api/set_test_config/{config_name}")
|
|
115
|
+
def set_test_config(config_name: str) -> dict:
|
|
116
|
+
"""Set the current test configuration.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
config_name (str): Name of the test configuration to set
|
|
120
|
+
Returns:
|
|
121
|
+
dict: Status of the operation.
|
|
122
|
+
"""
|
|
123
|
+
config_manager = ConfigManager()
|
|
124
|
+
config_manager.set_current_test_config(config_name)
|
|
125
|
+
try:
|
|
126
|
+
app.state.pytest_wrp.collect(is_clear_database=True)
|
|
127
|
+
except (ValueError, RuntimeError) as e:
|
|
128
|
+
return {"status": "error", "message": str(e)}
|
|
129
|
+
else:
|
|
130
|
+
return {"status": "success", "current_config": config_name}
|
|
131
|
+
|
|
132
|
+
|
|
111
133
|
@app.get("/api/start")
|
|
112
134
|
def start_pytest(args: Annotated[list[str] | None, Query()] = None) -> dict:
|
|
113
135
|
"""Start pytest subprocess.
|
|
@@ -118,12 +140,18 @@ def start_pytest(args: Annotated[list[str] | None, Query()] = None) -> dict:
|
|
|
118
140
|
Returns:
|
|
119
141
|
dict[str, RunStatus]: run status
|
|
120
142
|
"""
|
|
143
|
+
if app.state.manual_collect_mode:
|
|
144
|
+
return {"status": Status.BUSY, "message": "Manual collect mode is active"}
|
|
145
|
+
|
|
121
146
|
if args is None:
|
|
122
147
|
args_dict = []
|
|
123
148
|
else:
|
|
124
149
|
args_dict = dict(arg.split("=", 1) for arg in args if "=" in arg)
|
|
125
150
|
|
|
126
|
-
if app.state.pytest_wrp.start(
|
|
151
|
+
if app.state.pytest_wrp.start(
|
|
152
|
+
start_args=args_dict,
|
|
153
|
+
selected_tests=app.state.selected_tests,
|
|
154
|
+
):
|
|
127
155
|
logger.info("Start testing process.")
|
|
128
156
|
return {"status": Status.STARTED}
|
|
129
157
|
logger.info("Testing process is already running.")
|
|
@@ -137,6 +165,9 @@ def stop_pytest() -> dict:
|
|
|
137
165
|
Returns:
|
|
138
166
|
dict[str, RunStatus]: run status
|
|
139
167
|
"""
|
|
168
|
+
if app.state.manual_collect_mode:
|
|
169
|
+
return {"status": Status.BUSY, "message": "Manual collect mode is active"}
|
|
170
|
+
|
|
140
171
|
if app.state.pytest_wrp.stop():
|
|
141
172
|
logger.info("Stop testing process.")
|
|
142
173
|
return {"status": Status.STOPPED}
|
|
@@ -272,6 +303,64 @@ def confirm_operator_msg(is_msg_visible: str) -> dict:
|
|
|
272
303
|
return {"status": Status.ERROR}
|
|
273
304
|
|
|
274
305
|
|
|
306
|
+
@app.post("/api/selected_tests")
|
|
307
|
+
async def set_selected_tests(request: Request) -> dict:
|
|
308
|
+
"""Set the selected tests in the application state.
|
|
309
|
+
|
|
310
|
+
Args:
|
|
311
|
+
request (Request): The incoming request object.
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
dict[str, str]: A dictionary containing the
|
|
315
|
+
status and message of the operation.
|
|
316
|
+
- status (str): The status of the operation.
|
|
317
|
+
Possible values are "success" or "error".
|
|
318
|
+
- message (str): A message describing the
|
|
319
|
+
result of the operation.
|
|
320
|
+
|
|
321
|
+
Raises:
|
|
322
|
+
TypeError: If the `selected_tests` is not a list.
|
|
323
|
+
"""
|
|
324
|
+
selected_tests = await request.json()
|
|
325
|
+
|
|
326
|
+
if not isinstance(selected_tests, list):
|
|
327
|
+
msg = "Expected list."
|
|
328
|
+
raise TypeError(msg)
|
|
329
|
+
|
|
330
|
+
app.state.selected_tests = selected_tests
|
|
331
|
+
app.state.pytest_wrp.collect(is_clear_database=True, selected_tests=selected_tests)
|
|
332
|
+
return {"status": "success", "message": f"Selected {len(selected_tests)} tests"}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
@app.get("/api/manual_collect_mode")
|
|
336
|
+
def get_manual_collect_mode() -> dict:
|
|
337
|
+
"""Get manual collect mode status.
|
|
338
|
+
|
|
339
|
+
Returns:
|
|
340
|
+
dict[str, bool]: manual collect mode status
|
|
341
|
+
"""
|
|
342
|
+
return {"manual_collect_mode": app.state.manual_collect_mode}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
@app.post("/api/manual_collect_mode")
|
|
346
|
+
def set_manual_collect_mode(mode_data: dict) -> dict:
|
|
347
|
+
"""Set manual collect mode.
|
|
348
|
+
|
|
349
|
+
Args:
|
|
350
|
+
mode_data: dict with 'enabled' key
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
dict[str, str]: operation status
|
|
354
|
+
"""
|
|
355
|
+
enabled = mode_data.get("enabled", False)
|
|
356
|
+
app.state.manual_collect_mode = enabled
|
|
357
|
+
|
|
358
|
+
if enabled:
|
|
359
|
+
app.state.pytest_wrp.collect()
|
|
360
|
+
|
|
361
|
+
return {"status": "success", "manual_collect_mode": enabled}
|
|
362
|
+
|
|
363
|
+
|
|
275
364
|
if "DEBUG_FRONTEND" not in os.environ:
|
|
276
365
|
app.mount(
|
|
277
366
|
"/",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as n}from"./index-DLOviMB1.js";import{I as e}from"./index-B-fsa5Ru.js";import{p as r,I as s}from"./index-
|
|
1
|
+
import{I as n}from"./index-DLOviMB1.js";import{I as e}from"./index-B-fsa5Ru.js";import{p as r,I as s}from"./index-DEJb2W0B.js";function I(o,t){var a=r(o);return t===s.STANDARD?n[a]:e[a]}function p(o){return r(o)}export{n as IconSvgPaths16,e as IconSvgPaths20,I as getIconPaths,p as iconNameToPathsRecordKey};
|
hardpy/hardpy_panel/frontend/dist/assets/{allPathsLoader-HPn4WHWu.js → allPathsLoader-DgH0Xily.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/allPaths-
|
|
2
|
-
import{_ as o,a as n,b as i}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/allPaths-C_-7WXHD.js","assets/index-DLOviMB1.js","assets/index-B-fsa5Ru.js","assets/index-DEJb2W0B.js","assets/index-B7T9xvaW.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as o,a as n,b as i}from"./index-DEJb2W0B.js";var _=function(e,a){return o(void 0,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,i(()=>import("./allPaths-C_-7WXHD.js"),__vite__mapDeps([0,1,2,3,4]))];case 1:return t=r.sent().getIconPaths,[2,t(e,a)]}})})};export{_ as allPathsLoader};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as G}from"./index-
|
|
1
|
+
import{g as G}from"./index-DEJb2W0B.js";function $(w,c){for(var m=0;m<c.length;m++){const d=c[m];if(typeof d!="string"&&!Array.isArray(d)){for(const y in d)if(y!=="default"&&!(y in w)){const p=Object.getOwnPropertyDescriptor(d,y);p&&Object.defineProperty(w,y,p.get?p:{enumerable:!0,get:()=>d[y]})}}}return Object.freeze(Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}))}var E={exports:{}},U;function X(){return U||(U=1,(function(w,c){var m={},d=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof m<"u"&&m,y=(function(){function v(){this.fetch=!1,this.DOMException=d.DOMException}return v.prototype=d,new v})();(function(v){(function(u){var a=typeof v<"u"&&v||typeof self<"u"&&self||typeof a<"u"&&a,f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function S(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer)var F=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(e){return e&&F.indexOf(Object.prototype.toString.call(e))>-1};function _(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function T(e){return typeof e!="string"&&(e=String(e)),e}function B(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return f.iterable&&(t[Symbol.iterator]=function(){return t}),t}function s(e){this.map={},e instanceof s?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}s.prototype.append=function(e,t){e=_(e),t=T(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[_(e)]},s.prototype.get=function(e){return e=_(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(_(e))},s.prototype.set=function(e,t){this.map[_(e)]=T(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),B(e)},s.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),B(e)},s.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),B(e)},f.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);function O(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function D(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function M(e){var t=new FileReader,r=D(t);return t.readAsArrayBuffer(e),r}function q(e){var t=new FileReader,r=D(t);return t.readAsText(e),r}function H(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function x(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function R(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:f.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:f.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():f.arrayBuffer&&f.blob&&S(e)?(this._bodyArrayBuffer=x(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||I(e))?this._bodyArrayBuffer=x(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=O(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function C(e){var t=e.toUpperCase();return L.indexOf(t)>-1?t:e}function b(e,t){if(!(this instanceof b))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new s(t.headers)),this.method=C(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})};function k(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),i=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function N(e){var t=new s,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
2
|
`)===0?n.substr(1,n.length):n}).forEach(function(n){var i=n.split(":"),o=i.shift().trim();if(o){var g=i.join(":").trim();t.append(o,g)}}),t}R.call(b.prototype);function l(e,t){if(!(this instanceof l))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new s(t.headers),this.url=t.url||"",this._initBody(e)}R.call(l.prototype),l.prototype.clone=function(){return new l(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})},l.error=function(){var e=new l(null,{status:0,statusText:""});return e.type="error",e};var V=[301,302,303,307,308];l.redirect=function(e,t){if(V.indexOf(t)===-1)throw new RangeError("Invalid status code");return new l(null,{status:t,headers:{location:e}})},u.DOMException=a.DOMException;try{new u.DOMException}catch{u.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function P(e,t){return new Promise(function(r,n){var i=new b(e,t);if(i.signal&&i.signal.aborted)return n(new u.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function g(){o.abort()}o.onload=function(){var h={status:o.status,statusText:o.statusText,headers:N(o.getAllResponseHeaders()||"")};h.url="responseURL"in o?o.responseURL:h.headers.get("X-Request-URL");var A="response"in o?o.response:o.responseText;setTimeout(function(){r(new l(A,h))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.onabort=function(){setTimeout(function(){n(new u.DOMException("Aborted","AbortError"))},0)};function z(h){try{return h===""&&a.location.href?a.location.href:h}catch{return h}}o.open(i.method,z(i.url),!0),i.credentials==="include"?o.withCredentials=!0:i.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(f.blob?o.responseType="blob":f.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof s)?Object.getOwnPropertyNames(t.headers).forEach(function(h){o.setRequestHeader(h,T(t.headers[h]))}):i.headers.forEach(function(h,A){o.setRequestHeader(A,h)}),i.signal&&(i.signal.addEventListener("abort",g),o.onreadystatechange=function(){o.readyState===4&&i.signal.removeEventListener("abort",g)}),o.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}return P.polyfill=!0,a.fetch||(a.fetch=P,a.Headers=s,a.Request=b,a.Response=l),u.Headers=s,u.Request=b,u.Response=l,u.fetch=P,u})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var p=d.fetch?d:y;c=p.fetch,c.default=p.fetch,c.fetch=p.fetch,c.Headers=p.Headers,c.Request=p.Request,c.Response=p.Response,w.exports=c})(E,E.exports)),E.exports}var j=X();const J=G(j),Q=$({__proto__:null,default:J},[j]);export{Q as b};
|