@midscene/shared 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/utils.d.ts +3 -1
- package/dist/es/utils.js +11 -0
- package/dist/lib/utils.d.ts +3 -1
- package/dist/lib/utils.js +13 -0
- package/dist/types/utils.d.ts +3 -1
- package/package.json +1 -1
- package/src/utils.ts +13 -0
package/dist/es/utils.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ declare function generateHashId(rect: any, content?: string): string;
|
|
|
11
11
|
declare function assert(condition: any, message?: string): asserts condition;
|
|
12
12
|
type GlobalScope = typeof window | typeof globalThis | typeof self | undefined;
|
|
13
13
|
declare function getGlobalScope(): GlobalScope;
|
|
14
|
+
declare function setIsMcp(value: boolean): void;
|
|
15
|
+
declare function logMsg(...message: Parameters<typeof console.log>): void;
|
|
14
16
|
|
|
15
|
-
export { assert, generateHashId, getGlobalScope, ifInBrowser, uuid };
|
|
17
|
+
export { assert, generateHashId, getGlobalScope, ifInBrowser, logMsg, setIsMcp, uuid };
|
package/dist/es/utils.js
CHANGED
|
@@ -48,10 +48,21 @@ function getGlobalScope() {
|
|
|
48
48
|
}
|
|
49
49
|
return void 0;
|
|
50
50
|
}
|
|
51
|
+
var isMcp = false;
|
|
52
|
+
function setIsMcp(value) {
|
|
53
|
+
isMcp = value;
|
|
54
|
+
}
|
|
55
|
+
function logMsg(...message) {
|
|
56
|
+
if (!isMcp) {
|
|
57
|
+
console.log(...message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
51
60
|
export {
|
|
52
61
|
assert,
|
|
53
62
|
generateHashId,
|
|
54
63
|
getGlobalScope,
|
|
55
64
|
ifInBrowser,
|
|
65
|
+
logMsg,
|
|
66
|
+
setIsMcp,
|
|
56
67
|
uuid
|
|
57
68
|
};
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ declare function generateHashId(rect: any, content?: string): string;
|
|
|
11
11
|
declare function assert(condition: any, message?: string): asserts condition;
|
|
12
12
|
type GlobalScope = typeof window | typeof globalThis | typeof self | undefined;
|
|
13
13
|
declare function getGlobalScope(): GlobalScope;
|
|
14
|
+
declare function setIsMcp(value: boolean): void;
|
|
15
|
+
declare function logMsg(...message: Parameters<typeof console.log>): void;
|
|
14
16
|
|
|
15
|
-
export { assert, generateHashId, getGlobalScope, ifInBrowser, uuid };
|
|
17
|
+
export { assert, generateHashId, getGlobalScope, ifInBrowser, logMsg, setIsMcp, uuid };
|
package/dist/lib/utils.js
CHANGED
|
@@ -24,6 +24,8 @@ __export(utils_exports, {
|
|
|
24
24
|
generateHashId: () => generateHashId,
|
|
25
25
|
getGlobalScope: () => getGlobalScope,
|
|
26
26
|
ifInBrowser: () => ifInBrowser,
|
|
27
|
+
logMsg: () => logMsg,
|
|
28
|
+
setIsMcp: () => setIsMcp,
|
|
27
29
|
uuid: () => uuid
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -76,11 +78,22 @@ function getGlobalScope() {
|
|
|
76
78
|
}
|
|
77
79
|
return void 0;
|
|
78
80
|
}
|
|
81
|
+
var isMcp = false;
|
|
82
|
+
function setIsMcp(value) {
|
|
83
|
+
isMcp = value;
|
|
84
|
+
}
|
|
85
|
+
function logMsg(...message) {
|
|
86
|
+
if (!isMcp) {
|
|
87
|
+
console.log(...message);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
79
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
80
91
|
0 && (module.exports = {
|
|
81
92
|
assert,
|
|
82
93
|
generateHashId,
|
|
83
94
|
getGlobalScope,
|
|
84
95
|
ifInBrowser,
|
|
96
|
+
logMsg,
|
|
97
|
+
setIsMcp,
|
|
85
98
|
uuid
|
|
86
99
|
});
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ declare function generateHashId(rect: any, content?: string): string;
|
|
|
11
11
|
declare function assert(condition: any, message?: string): asserts condition;
|
|
12
12
|
type GlobalScope = typeof window | typeof globalThis | typeof self | undefined;
|
|
13
13
|
declare function getGlobalScope(): GlobalScope;
|
|
14
|
+
declare function setIsMcp(value: boolean): void;
|
|
15
|
+
declare function logMsg(...message: Parameters<typeof console.log>): void;
|
|
14
16
|
|
|
15
|
-
export { assert, generateHashId, getGlobalScope, ifInBrowser, uuid };
|
|
17
|
+
export { assert, generateHashId, getGlobalScope, ifInBrowser, logMsg, setIsMcp, uuid };
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -74,3 +74,16 @@ export function getGlobalScope(): GlobalScope {
|
|
|
74
74
|
}
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
let isMcp = false;
|
|
79
|
+
|
|
80
|
+
export function setIsMcp(value: boolean) {
|
|
81
|
+
isMcp = value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//mcp need use obj format to console msg: https://github.com/modelcontextprotocol/typescript-sdk/issues/244
|
|
85
|
+
export function logMsg(...message: Parameters<typeof console.log>) {
|
|
86
|
+
if (!isMcp) {
|
|
87
|
+
console.log(...message);
|
|
88
|
+
}
|
|
89
|
+
}
|