@midscene/shared 1.6.0 → 1.6.1-beta-20260327104111.0

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/index.mjs CHANGED
@@ -1,4 +1,2 @@
1
- import { createCopyStaticPlugin, createPlaygroundCopyPlugin } from "./build/copy-static.mjs";
2
- import { commonIgnoreWarnings } from "./build/rspack-config.mjs";
3
1
  const src = {};
4
- export { commonIgnoreWarnings, createCopyStaticPlugin, createPlaygroundCopyPlugin, src as default };
2
+ export { src as default };
@@ -61,10 +61,4 @@ function enableDebug(topic) {
61
61
  if (ifInNode) return;
62
62
  debug.enable(`${topicPrefix}:${topic}`);
63
63
  }
64
- function cleanupLogStreams() {
65
- if (!ifInNode) return;
66
- for (const stream of logStreams.values())stream.end();
67
- logStreams.clear();
68
- debugInstances.clear();
69
- }
70
- export { cleanupLogStreams, enableDebug, getDebug };
64
+ export { enableDebug, getDebug };
package/dist/es/utils.mjs CHANGED
@@ -34,11 +34,6 @@ function generateHashId(rect, content = '') {
34
34
  function assert(condition, message) {
35
35
  if (!condition) throw new Error(message || 'Assertion failed');
36
36
  }
37
- function getGlobalScope() {
38
- if ('undefined' != typeof window) return window;
39
- if ('undefined' != typeof globalThis) return globalThis;
40
- if ('undefined' != typeof self) return self;
41
- }
42
37
  let isMcp = false;
43
38
  function setIsMcp(value) {
44
39
  isMcp = value;
@@ -74,4 +69,4 @@ function mergeAndNormalizeAppNameMapping(defaultMapping, userMapping) {
74
69
  if (userMapping) for (const [key, value] of Object.entries(userMapping))result[normalizeForComparison(key)] = value;
75
70
  return result;
76
71
  }
77
- export { antiEscapeScriptTag, assert, escapeScriptTag, generateHashId, getGlobalScope, ifInBrowser, ifInNode, ifInWorker, isPlainObject, logMsg, mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat, replaceIllegalPathCharsAndSpace, setIsMcp, uuid };
72
+ export { antiEscapeScriptTag, assert, escapeScriptTag, generateHashId, ifInBrowser, ifInNode, ifInWorker, isPlainObject, logMsg, mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat, replaceIllegalPathCharsAndSpace, setIsMcp, uuid };
package/dist/lib/index.js CHANGED
@@ -24,22 +24,11 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- commonIgnoreWarnings: ()=>rspack_config_js_namespaceObject.commonIgnoreWarnings,
28
- createCopyStaticPlugin: ()=>copy_static_js_namespaceObject.createCopyStaticPlugin,
29
- default: ()=>src,
30
- createPlaygroundCopyPlugin: ()=>copy_static_js_namespaceObject.createPlaygroundCopyPlugin
27
+ default: ()=>__rspack_default_export
31
28
  });
32
- const copy_static_js_namespaceObject = require("./build/copy-static.js");
33
- const rspack_config_js_namespaceObject = require("./build/rspack-config.js");
34
- const src = {};
35
- exports.commonIgnoreWarnings = __webpack_exports__.commonIgnoreWarnings;
36
- exports.createCopyStaticPlugin = __webpack_exports__.createCopyStaticPlugin;
37
- exports.createPlaygroundCopyPlugin = __webpack_exports__.createPlaygroundCopyPlugin;
29
+ const __rspack_default_export = {};
38
30
  exports["default"] = __webpack_exports__["default"];
39
31
  for(var __rspack_i in __webpack_exports__)if (-1 === [
40
- "commonIgnoreWarnings",
41
- "createCopyStaticPlugin",
42
- "createPlaygroundCopyPlugin",
43
32
  "default"
44
33
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
45
34
  Object.defineProperty(exports, '__esModule', {
@@ -34,7 +34,6 @@ var __webpack_exports__ = {};
34
34
  __webpack_require__.r(__webpack_exports__);
35
35
  __webpack_require__.d(__webpack_exports__, {
36
36
  enableDebug: ()=>enableDebug,
37
- cleanupLogStreams: ()=>cleanupLogStreams,
38
37
  getDebug: ()=>getDebug
39
38
  });
40
39
  const external_node_fs_namespaceObject = require("node:fs");
@@ -104,17 +103,9 @@ function enableDebug(topic) {
104
103
  if (external_utils_js_namespaceObject.ifInNode) return;
105
104
  external_debug_default().enable(`${topicPrefix}:${topic}`);
106
105
  }
107
- function cleanupLogStreams() {
108
- if (!external_utils_js_namespaceObject.ifInNode) return;
109
- for (const stream of logStreams.values())stream.end();
110
- logStreams.clear();
111
- debugInstances.clear();
112
- }
113
- exports.cleanupLogStreams = __webpack_exports__.cleanupLogStreams;
114
106
  exports.enableDebug = __webpack_exports__.enableDebug;
115
107
  exports.getDebug = __webpack_exports__.getDebug;
116
108
  for(var __rspack_i in __webpack_exports__)if (-1 === [
117
- "cleanupLogStreams",
118
109
  "enableDebug",
119
110
  "getDebug"
120
111
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
package/dist/lib/utils.js CHANGED
@@ -37,7 +37,6 @@ __webpack_require__.d(__webpack_exports__, {
37
37
  generateHashId: ()=>generateHashId,
38
38
  normalizeForComparison: ()=>normalizeForComparison,
39
39
  ifInWorker: ()=>ifInWorker,
40
- getGlobalScope: ()=>getGlobalScope,
41
40
  setIsMcp: ()=>setIsMcp,
42
41
  antiEscapeScriptTag: ()=>antiEscapeScriptTag
43
42
  });
@@ -77,11 +76,6 @@ function generateHashId(rect, content = '') {
77
76
  function assert(condition, message) {
78
77
  if (!condition) throw new Error(message || 'Assertion failed');
79
78
  }
80
- function getGlobalScope() {
81
- if ('undefined' != typeof window) return window;
82
- if ('undefined' != typeof globalThis) return globalThis;
83
- if ('undefined' != typeof self) return self;
84
- }
85
79
  let isMcp = false;
86
80
  function setIsMcp(value) {
87
81
  isMcp = value;
@@ -121,7 +115,6 @@ exports.antiEscapeScriptTag = __webpack_exports__.antiEscapeScriptTag;
121
115
  exports.assert = __webpack_exports__.assert;
122
116
  exports.escapeScriptTag = __webpack_exports__.escapeScriptTag;
123
117
  exports.generateHashId = __webpack_exports__.generateHashId;
124
- exports.getGlobalScope = __webpack_exports__.getGlobalScope;
125
118
  exports.ifInBrowser = __webpack_exports__.ifInBrowser;
126
119
  exports.ifInNode = __webpack_exports__.ifInNode;
127
120
  exports.ifInWorker = __webpack_exports__.ifInWorker;
@@ -138,7 +131,6 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
138
131
  "assert",
139
132
  "escapeScriptTag",
140
133
  "generateHashId",
141
- "getGlobalScope",
142
134
  "ifInBrowser",
143
135
  "ifInNode",
144
136
  "ifInWorker",
@@ -1,4 +1,2 @@
1
- export { createCopyStaticPlugin, createPlaygroundCopyPlugin, } from './build/copy-static';
2
- export { commonIgnoreWarnings } from './build/rspack-config';
3
1
  declare const _default: {};
4
2
  export default _default;
@@ -3,4 +3,3 @@ export declare function getDebug(topic: string, options?: {
3
3
  console?: boolean;
4
4
  }): DebugFunction;
5
5
  export declare function enableDebug(topic: string): void;
6
- export declare function cleanupLogStreams(): void;
@@ -11,8 +11,6 @@ export declare function generateHashId(rect: any, content?: string): string;
11
11
  * @throws Error with the provided message if the condition is false
12
12
  */
13
13
  export declare function assert(condition: any, message?: string): asserts condition;
14
- type GlobalScope = typeof window | typeof globalThis | typeof self | undefined;
15
- export declare function getGlobalScope(): GlobalScope;
16
14
  export declare function setIsMcp(value: boolean): void;
17
15
  export declare function logMsg(...message: Parameters<typeof console.log>): void;
18
16
  export declare function repeat(times: number, fn: (index: number) => Promise<void>): Promise<void>;
@@ -34,4 +32,3 @@ export declare function normalizeForComparison(str: string): string;
34
32
  * User-provided mapping takes precedence over default mapping.
35
33
  */
36
34
  export declare function mergeAndNormalizeAppNameMapping(defaultMapping: Record<string, string>, userMapping?: Record<string, string>): Record<string, string>;
37
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/shared",
3
- "version": "1.6.0",
3
+ "version": "1.6.1-beta-20260327104111.0",
4
4
  "repository": "https://github.com/web-infra-dev/midscene",
5
5
  "homepage": "https://midscenejs.com/",
6
6
  "types": "./dist/types/index.d.ts",
package/src/index.ts CHANGED
@@ -1,8 +1 @@
1
- export {
2
- createCopyStaticPlugin,
3
- createPlaygroundCopyPlugin,
4
- } from './build/copy-static';
5
-
6
- export { commonIgnoreWarnings } from './build/rspack-config';
7
-
8
1
  export default {};
package/src/logger.ts CHANGED
@@ -94,14 +94,3 @@ export function enableDebug(topic: string): void {
94
94
  }
95
95
  debug.enable(`${topicPrefix}:${topic}`);
96
96
  }
97
-
98
- // Cleanup function to close all log streams
99
- export function cleanupLogStreams(): void {
100
- if (!ifInNode) return;
101
-
102
- for (const stream of logStreams.values()) {
103
- stream.end();
104
- }
105
- logStreams.clear();
106
- debugInstances.clear();
107
- }
package/src/utils.ts CHANGED
@@ -64,23 +64,6 @@ export function assert(condition: any, message?: string): asserts condition {
64
64
  }
65
65
  }
66
66
 
67
- type GlobalScope = typeof window | typeof globalThis | typeof self | undefined;
68
-
69
- export function getGlobalScope(): GlobalScope {
70
- if (typeof window !== 'undefined') {
71
- return window;
72
- }
73
-
74
- if (typeof globalThis !== 'undefined') {
75
- return globalThis;
76
- }
77
-
78
- if (typeof self !== 'undefined') {
79
- return self;
80
- }
81
- return undefined;
82
- }
83
-
84
67
  let isMcp = false;
85
68
 
86
69
  export function setIsMcp(value: boolean) {
@@ -1,31 +0,0 @@
1
- import node_fs from "node:fs";
2
- import node_path from "node:path";
3
- const createCopyStaticPlugin = (options)=>({
4
- name: options.pluginName || 'copy-static',
5
- setup (api) {
6
- api.onAfterBuild(async ()=>{
7
- const { srcDir, destDir, faviconPath } = options;
8
- const stat = await node_fs.promises.lstat(destDir).catch(()=>null);
9
- if (stat?.isSymbolicLink()) await node_fs.promises.unlink(destDir);
10
- await node_fs.promises.mkdir(destDir, {
11
- recursive: true
12
- });
13
- await node_fs.promises.cp(srcDir, destDir, {
14
- recursive: true
15
- });
16
- console.log(`Copied build artifacts from ${srcDir} to ${destDir}`);
17
- if (faviconPath) {
18
- const faviconDest = node_path.join(destDir, 'favicon.ico');
19
- await node_fs.promises.copyFile(faviconPath, faviconDest);
20
- console.log(`Copied favicon from ${faviconPath} to ${faviconDest}`);
21
- }
22
- });
23
- }
24
- });
25
- const createPlaygroundCopyPlugin = (srcDir, destDir, pluginName, faviconSrc)=>createCopyStaticPlugin({
26
- srcDir,
27
- destDir,
28
- faviconPath: faviconSrc,
29
- pluginName
30
- });
31
- export { createCopyStaticPlugin, createPlaygroundCopyPlugin };
@@ -1,4 +0,0 @@
1
- const commonIgnoreWarnings = [
2
- /Critical dependency: the request of a dependency is an expression/
3
- ];
4
- export { commonIgnoreWarnings };
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- createCopyStaticPlugin: ()=>createCopyStaticPlugin,
37
- createPlaygroundCopyPlugin: ()=>createPlaygroundCopyPlugin
38
- });
39
- const external_node_fs_namespaceObject = require("node:fs");
40
- var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
41
- const external_node_path_namespaceObject = require("node:path");
42
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
43
- const createCopyStaticPlugin = (options)=>({
44
- name: options.pluginName || 'copy-static',
45
- setup (api) {
46
- api.onAfterBuild(async ()=>{
47
- const { srcDir, destDir, faviconPath } = options;
48
- const stat = await external_node_fs_default().promises.lstat(destDir).catch(()=>null);
49
- if (stat?.isSymbolicLink()) await external_node_fs_default().promises.unlink(destDir);
50
- await external_node_fs_default().promises.mkdir(destDir, {
51
- recursive: true
52
- });
53
- await external_node_fs_default().promises.cp(srcDir, destDir, {
54
- recursive: true
55
- });
56
- console.log(`Copied build artifacts from ${srcDir} to ${destDir}`);
57
- if (faviconPath) {
58
- const faviconDest = external_node_path_default().join(destDir, 'favicon.ico');
59
- await external_node_fs_default().promises.copyFile(faviconPath, faviconDest);
60
- console.log(`Copied favicon from ${faviconPath} to ${faviconDest}`);
61
- }
62
- });
63
- }
64
- });
65
- const createPlaygroundCopyPlugin = (srcDir, destDir, pluginName, faviconSrc)=>createCopyStaticPlugin({
66
- srcDir,
67
- destDir,
68
- faviconPath: faviconSrc,
69
- pluginName
70
- });
71
- exports.createCopyStaticPlugin = __webpack_exports__.createCopyStaticPlugin;
72
- exports.createPlaygroundCopyPlugin = __webpack_exports__.createPlaygroundCopyPlugin;
73
- for(var __rspack_i in __webpack_exports__)if (-1 === [
74
- "createCopyStaticPlugin",
75
- "createPlaygroundCopyPlugin"
76
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
77
- Object.defineProperty(exports, '__esModule', {
78
- value: true
79
- });
@@ -1,38 +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
- commonIgnoreWarnings: ()=>commonIgnoreWarnings
28
- });
29
- const commonIgnoreWarnings = [
30
- /Critical dependency: the request of a dependency is an expression/
31
- ];
32
- exports.commonIgnoreWarnings = __webpack_exports__.commonIgnoreWarnings;
33
- for(var __rspack_i in __webpack_exports__)if (-1 === [
34
- "commonIgnoreWarnings"
35
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
36
- Object.defineProperty(exports, '__esModule', {
37
- value: true
38
- });
@@ -1,31 +0,0 @@
1
- export interface CopyStaticOptions {
2
- /** Source directory to copy from */
3
- srcDir: string;
4
- /** Destination directory to copy to */
5
- destDir: string;
6
- /** Optional favicon source path (relative to directory containing srcDir) */
7
- faviconPath?: string;
8
- /** Name for the rsbuild plugin */
9
- pluginName?: string;
10
- }
11
- /**
12
- * Creates an rsbuild plugin that copies static files after build
13
- * @param options Configuration options for copying static files
14
- * @returns Rsbuild plugin object
15
- */
16
- export declare const createCopyStaticPlugin: (options: CopyStaticOptions) => {
17
- name: string;
18
- setup(api: any): void;
19
- };
20
- /**
21
- * Helper function to create a copy static plugin for playground builds
22
- * @param srcDir Source directory (usually dist directory)
23
- * @param destDir Destination directory
24
- * @param pluginName Optional plugin name
25
- * @param faviconSrc Optional favicon source path
26
- * @returns Rsbuild plugin
27
- */
28
- export declare const createPlaygroundCopyPlugin: (srcDir: string, destDir: string, pluginName?: string, faviconSrc?: string) => {
29
- name: string;
30
- setup(api: any): void;
31
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Common Rspack configuration helpers for rsbuild projects
3
- */
4
- /**
5
- * Common warning patterns to ignore in Rspack builds.
6
- * These warnings are typically from optional dependencies or known non-critical issues.
7
- */
8
- export declare const commonIgnoreWarnings: RegExp[];
@@ -1,68 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
-
4
- export interface CopyStaticOptions {
5
- /** Source directory to copy from */
6
- srcDir: string;
7
- /** Destination directory to copy to */
8
- destDir: string;
9
- /** Optional favicon source path (relative to directory containing srcDir) */
10
- faviconPath?: string;
11
- /** Name for the rsbuild plugin */
12
- pluginName?: string;
13
- }
14
-
15
- /**
16
- * Creates an rsbuild plugin that copies static files after build
17
- * @param options Configuration options for copying static files
18
- * @returns Rsbuild plugin object
19
- */
20
- export const createCopyStaticPlugin = (options: CopyStaticOptions) => ({
21
- name: options.pluginName || 'copy-static',
22
- setup(api: any) {
23
- api.onAfterBuild(async () => {
24
- const { srcDir, destDir, faviconPath } = options;
25
-
26
- // Remove symlink left by dev mode before copying
27
- const stat = await fs.promises.lstat(destDir).catch(() => null);
28
- if (stat?.isSymbolicLink()) {
29
- await fs.promises.unlink(destDir);
30
- }
31
-
32
- await fs.promises.mkdir(destDir, { recursive: true });
33
-
34
- // Copy directory contents recursively
35
- await fs.promises.cp(srcDir, destDir, { recursive: true });
36
- console.log(`Copied build artifacts from ${srcDir} to ${destDir}`);
37
-
38
- // Copy favicon if specified
39
- if (faviconPath) {
40
- const faviconDest = path.join(destDir, 'favicon.ico');
41
- await fs.promises.copyFile(faviconPath, faviconDest);
42
- console.log(`Copied favicon from ${faviconPath} to ${faviconDest}`);
43
- }
44
- });
45
- },
46
- });
47
-
48
- /**
49
- * Helper function to create a copy static plugin for playground builds
50
- * @param srcDir Source directory (usually dist directory)
51
- * @param destDir Destination directory
52
- * @param pluginName Optional plugin name
53
- * @param faviconSrc Optional favicon source path
54
- * @returns Rsbuild plugin
55
- */
56
- export const createPlaygroundCopyPlugin = (
57
- srcDir: string,
58
- destDir: string,
59
- pluginName?: string,
60
- faviconSrc?: string,
61
- ) => {
62
- return createCopyStaticPlugin({
63
- srcDir,
64
- destDir,
65
- faviconPath: faviconSrc,
66
- pluginName,
67
- });
68
- };
@@ -1,12 +0,0 @@
1
- /**
2
- * Common Rspack configuration helpers for rsbuild projects
3
- */
4
-
5
- /**
6
- * Common warning patterns to ignore in Rspack builds.
7
- * These warnings are typically from optional dependencies or known non-critical issues.
8
- */
9
- export const commonIgnoreWarnings = [
10
- // Ignore dynamic import warnings from langsmith/langfuse optional dependencies
11
- /Critical dependency: the request of a dependency is an expression/,
12
- ];