@midscene/shared 1.9.5-beta-20260611045217.0 → 1.9.5
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.
|
@@ -5,7 +5,7 @@ import { assert } from "../utils.mjs";
|
|
|
5
5
|
import { maskConfig, parseJson } from "./helper.mjs";
|
|
6
6
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
7
7
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
8
|
-
const getCurrentVersion = ()=>"1.9.5
|
|
8
|
+
const getCurrentVersion = ()=>"1.9.5";
|
|
9
9
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
10
10
|
const KEYS_MAP = {
|
|
11
11
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -37,7 +37,7 @@ const external_utils_js_namespaceObject = require("../utils.js");
|
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
39
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
-
const getCurrentVersion = ()=>"1.9.5
|
|
40
|
+
const getCurrentVersion = ()=>"1.9.5";
|
|
41
41
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
42
42
|
const KEYS_MAP = {
|
|
43
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/shared",
|
|
3
|
-
"version": "1.9.5
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
5
5
|
"homepage": "https://midscenejs.com/",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -72,11 +72,6 @@
|
|
|
72
72
|
"import": "./dist/es/logger.mjs",
|
|
73
73
|
"require": "./dist/lib/logger.js"
|
|
74
74
|
},
|
|
75
|
-
"./timeout": {
|
|
76
|
-
"types": "./dist/types/timeout.d.ts",
|
|
77
|
-
"import": "./dist/es/timeout.mjs",
|
|
78
|
-
"require": "./dist/lib/timeout.js"
|
|
79
|
-
},
|
|
80
75
|
"./*": {
|
|
81
76
|
"types": "./dist/types/*.d.ts",
|
|
82
77
|
"import": "./dist/es/*.mjs",
|
package/dist/es/timeout.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
3
|
-
value: value,
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true
|
|
7
|
-
});
|
|
8
|
-
else obj[key] = value;
|
|
9
|
-
return obj;
|
|
10
|
-
}
|
|
11
|
-
class PromiseTimeoutError extends Error {
|
|
12
|
-
constructor(message, timeoutMs){
|
|
13
|
-
super(message), _define_property(this, "timeoutMs", void 0);
|
|
14
|
-
this.name = 'PromiseTimeoutError';
|
|
15
|
-
this.timeoutMs = timeoutMs;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function runTimeoutCallback(callback, context) {
|
|
19
|
-
if (!callback) return;
|
|
20
|
-
Promise.resolve().then(callback).catch((error)=>{
|
|
21
|
-
console.error(`Failed to run ${context}:`, error);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function withTimeout(promise, timeoutMs, message, options = {}) {
|
|
25
|
-
return new Promise((resolve, reject)=>{
|
|
26
|
-
let timedOut = false;
|
|
27
|
-
const timer = setTimeout(()=>{
|
|
28
|
-
timedOut = true;
|
|
29
|
-
runTimeoutCallback(options.onTimeout, 'timeout callback');
|
|
30
|
-
reject(new PromiseTimeoutError(message, timeoutMs));
|
|
31
|
-
}, timeoutMs);
|
|
32
|
-
Promise.resolve(promise).then((value)=>{
|
|
33
|
-
clearTimeout(timer);
|
|
34
|
-
if (timedOut) return void runTimeoutCallback(()=>options.onSettledAfterTimeout?.(value), 'post-timeout settle callback');
|
|
35
|
-
resolve(value);
|
|
36
|
-
}, (error)=>{
|
|
37
|
-
clearTimeout(timer);
|
|
38
|
-
if (timedOut) return void runTimeoutCallback(()=>options.onRejectedAfterTimeout?.(error), 'post-timeout rejection callback');
|
|
39
|
-
reject(error);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
export { PromiseTimeoutError, withTimeout };
|
package/dist/lib/timeout.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
PromiseTimeoutError: ()=>PromiseTimeoutError,
|
|
28
|
-
withTimeout: ()=>withTimeout
|
|
29
|
-
});
|
|
30
|
-
function _define_property(obj, key, value) {
|
|
31
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
32
|
-
value: value,
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true
|
|
36
|
-
});
|
|
37
|
-
else obj[key] = value;
|
|
38
|
-
return obj;
|
|
39
|
-
}
|
|
40
|
-
class PromiseTimeoutError extends Error {
|
|
41
|
-
constructor(message, timeoutMs){
|
|
42
|
-
super(message), _define_property(this, "timeoutMs", void 0);
|
|
43
|
-
this.name = 'PromiseTimeoutError';
|
|
44
|
-
this.timeoutMs = timeoutMs;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function runTimeoutCallback(callback, context) {
|
|
48
|
-
if (!callback) return;
|
|
49
|
-
Promise.resolve().then(callback).catch((error)=>{
|
|
50
|
-
console.error(`Failed to run ${context}:`, error);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function withTimeout(promise, timeoutMs, message, options = {}) {
|
|
54
|
-
return new Promise((resolve, reject)=>{
|
|
55
|
-
let timedOut = false;
|
|
56
|
-
const timer = setTimeout(()=>{
|
|
57
|
-
timedOut = true;
|
|
58
|
-
runTimeoutCallback(options.onTimeout, 'timeout callback');
|
|
59
|
-
reject(new PromiseTimeoutError(message, timeoutMs));
|
|
60
|
-
}, timeoutMs);
|
|
61
|
-
Promise.resolve(promise).then((value)=>{
|
|
62
|
-
clearTimeout(timer);
|
|
63
|
-
if (timedOut) return void runTimeoutCallback(()=>options.onSettledAfterTimeout?.(value), 'post-timeout settle callback');
|
|
64
|
-
resolve(value);
|
|
65
|
-
}, (error)=>{
|
|
66
|
-
clearTimeout(timer);
|
|
67
|
-
if (timedOut) return void runTimeoutCallback(()=>options.onRejectedAfterTimeout?.(error), 'post-timeout rejection callback');
|
|
68
|
-
reject(error);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.PromiseTimeoutError = __webpack_exports__.PromiseTimeoutError;
|
|
73
|
-
exports.withTimeout = __webpack_exports__.withTimeout;
|
|
74
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
75
|
-
"PromiseTimeoutError",
|
|
76
|
-
"withTimeout"
|
|
77
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
78
|
-
Object.defineProperty(exports, '__esModule', {
|
|
79
|
-
value: true
|
|
80
|
-
});
|
package/dist/types/timeout.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class PromiseTimeoutError extends Error {
|
|
2
|
-
readonly timeoutMs: number;
|
|
3
|
-
constructor(message: string, timeoutMs: number);
|
|
4
|
-
}
|
|
5
|
-
export interface WithTimeoutOptions<T> {
|
|
6
|
-
onTimeout?: () => void | Promise<void>;
|
|
7
|
-
onSettledAfterTimeout?: (value: T) => void | Promise<void>;
|
|
8
|
-
onRejectedAfterTimeout?: (error: unknown) => void | Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export declare function withTimeout<T>(promise: PromiseLike<T> | T, timeoutMs: number, message: string, options?: WithTimeoutOptions<T>): Promise<T>;
|
package/src/timeout.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export class PromiseTimeoutError extends Error {
|
|
2
|
-
readonly timeoutMs: number;
|
|
3
|
-
|
|
4
|
-
constructor(message: string, timeoutMs: number) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.name = 'PromiseTimeoutError';
|
|
7
|
-
this.timeoutMs = timeoutMs;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface WithTimeoutOptions<T> {
|
|
12
|
-
onTimeout?: () => void | Promise<void>;
|
|
13
|
-
onSettledAfterTimeout?: (value: T) => void | Promise<void>;
|
|
14
|
-
onRejectedAfterTimeout?: (error: unknown) => void | Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function runTimeoutCallback(
|
|
18
|
-
callback: (() => void | Promise<void>) | undefined,
|
|
19
|
-
context: string,
|
|
20
|
-
) {
|
|
21
|
-
if (!callback) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
void Promise.resolve()
|
|
26
|
-
.then(callback)
|
|
27
|
-
.catch((error) => {
|
|
28
|
-
console.error(`Failed to run ${context}:`, error);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function withTimeout<T>(
|
|
33
|
-
promise: PromiseLike<T> | T,
|
|
34
|
-
timeoutMs: number,
|
|
35
|
-
message: string,
|
|
36
|
-
options: WithTimeoutOptions<T> = {},
|
|
37
|
-
): Promise<T> {
|
|
38
|
-
return new Promise<T>((resolve, reject) => {
|
|
39
|
-
let timedOut = false;
|
|
40
|
-
const timer = setTimeout(() => {
|
|
41
|
-
timedOut = true;
|
|
42
|
-
runTimeoutCallback(options.onTimeout, 'timeout callback');
|
|
43
|
-
reject(new PromiseTimeoutError(message, timeoutMs));
|
|
44
|
-
}, timeoutMs);
|
|
45
|
-
|
|
46
|
-
Promise.resolve(promise).then(
|
|
47
|
-
(value) => {
|
|
48
|
-
clearTimeout(timer);
|
|
49
|
-
if (timedOut) {
|
|
50
|
-
runTimeoutCallback(
|
|
51
|
-
() => options.onSettledAfterTimeout?.(value),
|
|
52
|
-
'post-timeout settle callback',
|
|
53
|
-
);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
resolve(value);
|
|
58
|
-
},
|
|
59
|
-
(error) => {
|
|
60
|
-
clearTimeout(timer);
|
|
61
|
-
if (timedOut) {
|
|
62
|
-
runTimeoutCallback(
|
|
63
|
-
() => options.onRejectedAfterTimeout?.(error),
|
|
64
|
-
'post-timeout rejection callback',
|
|
65
|
-
);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
reject(error);
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
}
|