@midscene/visualizer 1.7.7 → 1.7.10-beta-20260507030203.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.
Files changed (34) hide show
  1. package/dist/es/component/playground/index.css +61 -11
  2. package/dist/es/component/prompt-input/index.css +61 -11
  3. package/dist/es/component/prompt-input/index.mjs +144 -111
  4. package/dist/es/component/screenshot-viewer/index.css +6 -0
  5. package/dist/es/component/universal-playground/empty-state.mjs +5 -0
  6. package/dist/es/component/universal-playground/index.css +8 -0
  7. package/dist/es/component/universal-playground/index.mjs +53 -1
  8. package/dist/es/icons/action-chevron.mjs +61 -0
  9. package/dist/es/icons/prompt-history.mjs +70 -0
  10. package/dist/es/utils/empty-state-scroll.mjs +8 -0
  11. package/dist/es/utils/playground-utils.mjs +1 -18
  12. package/dist/es/utils/prompt-input-utils.mjs +9 -1
  13. package/dist/es/utils/prompt-placeholder.mjs +19 -0
  14. package/dist/lib/component/playground/index.css +61 -11
  15. package/dist/lib/component/prompt-input/index.css +61 -11
  16. package/dist/lib/component/prompt-input/index.js +145 -111
  17. package/dist/lib/component/screenshot-viewer/index.css +6 -0
  18. package/dist/lib/component/universal-playground/empty-state.js +39 -0
  19. package/dist/lib/component/universal-playground/index.css +8 -0
  20. package/dist/lib/component/universal-playground/index.js +53 -1
  21. package/dist/lib/icons/action-chevron.js +95 -0
  22. package/dist/lib/icons/prompt-history.js +104 -0
  23. package/dist/lib/utils/empty-state-scroll.js +42 -0
  24. package/dist/lib/utils/playground-utils.js +2 -19
  25. package/dist/lib/utils/prompt-input-utils.js +12 -1
  26. package/dist/lib/utils/prompt-placeholder.js +53 -0
  27. package/dist/types/component/prompt-input/index.d.ts +1 -2
  28. package/dist/types/component/universal-playground/empty-state.d.ts +3 -0
  29. package/dist/types/types.d.ts +6 -0
  30. package/dist/types/utils/empty-state-scroll.d.ts +11 -0
  31. package/dist/types/utils/playground-utils.d.ts +1 -1
  32. package/dist/types/utils/prompt-input-utils.d.ts +1 -0
  33. package/dist/types/utils/prompt-placeholder.d.ts +1 -0
  34. package/package.json +13 -6
@@ -0,0 +1,104 @@
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
+ default: ()=>prompt_history
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ require("react");
31
+ function _define_property(obj, key, value) {
32
+ if (key in obj) Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ else obj[key] = value;
39
+ return obj;
40
+ }
41
+ function _object_spread(target) {
42
+ for(var i = 1; i < arguments.length; i++){
43
+ var source = null != arguments[i] ? arguments[i] : {};
44
+ var ownKeys = Object.keys(source);
45
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
46
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
47
+ }));
48
+ ownKeys.forEach(function(key) {
49
+ _define_property(target, key, source[key]);
50
+ });
51
+ }
52
+ return target;
53
+ }
54
+ function prompt_history_ownKeys(object, enumerableOnly) {
55
+ var keys = Object.keys(object);
56
+ if (Object.getOwnPropertySymbols) {
57
+ var symbols = Object.getOwnPropertySymbols(object);
58
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
59
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
60
+ });
61
+ keys.push.apply(keys, symbols);
62
+ }
63
+ return keys;
64
+ }
65
+ function _object_spread_props(target, source) {
66
+ source = null != source ? source : {};
67
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
68
+ else prompt_history_ownKeys(Object(source)).forEach(function(key) {
69
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
70
+ });
71
+ return target;
72
+ }
73
+ const SvgPromptHistory = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("svg", _object_spread_props(_object_spread({
74
+ xmlns: "http://www.w3.org/2000/svg",
75
+ width: 16,
76
+ height: 16,
77
+ fill: "none",
78
+ viewBox: "0 0 16 16"
79
+ }, props), {
80
+ children: [
81
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
82
+ stroke: "#878787",
83
+ strokeLinecap: "round",
84
+ strokeLinejoin: "round",
85
+ strokeWidth: 1.33,
86
+ d: "M1.505 4.164c-2.862 6.126 2.197 10.501 6.063 10.501a7 7 0 1 0-6.063-10.5"
87
+ }),
88
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
89
+ stroke: "#878787",
90
+ strokeLinecap: "round",
91
+ strokeLinejoin: "round",
92
+ strokeWidth: 1.33,
93
+ d: "M7.57 3.465v4.203l2.967 2.968"
94
+ })
95
+ ]
96
+ }));
97
+ const prompt_history = SvgPromptHistory;
98
+ exports["default"] = __webpack_exports__["default"];
99
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
100
+ "default"
101
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
102
+ Object.defineProperty(exports, '__esModule', {
103
+ value: true
104
+ });
@@ -0,0 +1,42 @@
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
+ calculateEmptyStatePromptScrollTop: ()=>calculateEmptyStatePromptScrollTop
28
+ });
29
+ const DEFAULT_SAFE_MARGIN = 24;
30
+ function calculateEmptyStatePromptScrollTop({ currentScrollTop, maxScrollTop, containerTop, containerBottom, contentStartTop, contentEndBottom, topSafeMargin = DEFAULT_SAFE_MARGIN, bottomSafeMargin = DEFAULT_SAFE_MARGIN }) {
31
+ const scrollForContentEnd = currentScrollTop + contentEndBottom - (containerBottom - bottomSafeMargin);
32
+ const maxScrollWithContentStartVisible = currentScrollTop + contentStartTop - (containerTop + topSafeMargin);
33
+ const targetScrollTop = Math.min(scrollForContentEnd, maxScrollWithContentStartVisible, maxScrollTop);
34
+ return Math.max(0, Math.round(targetScrollTop));
35
+ }
36
+ exports.calculateEmptyStatePromptScrollTop = __webpack_exports__.calculateEmptyStatePromptScrollTop;
37
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
38
+ "calculateEmptyStatePromptScrollTop"
39
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
40
+ Object.defineProperty(exports, '__esModule', {
41
+ value: true
42
+ });
@@ -26,34 +26,17 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  staticAgentFromContext: ()=>staticAgentFromContext,
28
28
  actionNameForType: ()=>external_action_label_js_namespaceObject.actionNameForType,
29
- getPlaceholderForType: ()=>getPlaceholderForType,
29
+ getPlaceholderForType: ()=>external_prompt_placeholder_js_namespaceObject.getPlaceholderForType,
30
30
  isRunButtonEnabled: ()=>isRunButtonEnabled
31
31
  });
32
32
  const static_namespaceObject = require("@midscene/web/static");
33
33
  const external_types_js_namespaceObject = require("../types.js");
34
34
  const external_action_label_js_namespaceObject = require("./action-label.js");
35
+ const external_prompt_placeholder_js_namespaceObject = require("./prompt-placeholder.js");
35
36
  const staticAgentFromContext = (context)=>{
36
37
  const page = new static_namespaceObject.StaticPage(context);
37
38
  return new static_namespaceObject.StaticPageAgent(page);
38
39
  };
39
- const getPlaceholderForType = (type)=>{
40
- if ('aiQuery' === type) return 'What do you want to query?';
41
- if ('aiAssert' === type) return 'What do you want to assert?';
42
- if ('aiTap' === type) return 'What element do you want to tap?';
43
- if ('aiDoubleClick' === type) return 'What element do you want to double-click?';
44
- if ('aiHover' === type) return 'What element do you want to hover over?';
45
- if ('aiInput' === type) return 'Format: <value> | <element>\nExample: hello world | search box';
46
- if ('aiRightClick' === type) return 'What element do you want to right-click?';
47
- if ('aiKeyboardPress' === type) return 'Format: <key> | <element (optional)>\nExample: Enter | text field';
48
- if ('aiScroll' === type) return 'Format: <direction> <amount> | <element (optional)>\nExample: down 500 | main content';
49
- if ('aiLocate' === type) return 'What element do you want to locate?';
50
- if ('aiBoolean' === type) return 'What do you want to check (returns true/false)?';
51
- if ('aiNumber' === type) return 'What number do you want to extract?';
52
- if ('aiString' === type) return 'What text do you want to extract?';
53
- if ('aiAsk' === type) return 'What do you want to ask?';
54
- if ('aiWaitFor' === type) return 'What condition do you want to wait for?';
55
- return 'What do you want to do?';
56
- };
57
40
  const isRunButtonEnabled = (runButtonEnabled, needsStructuredParams, params, actionSpace, selectedType, promptValue)=>{
58
41
  if (!runButtonEnabled) return false;
59
42
  const needsAnyInput = (()=>{
@@ -25,6 +25,7 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  getAvailablePromptActionTypes: ()=>getAvailablePromptActionTypes,
28
+ shouldOffsetEmptyStateForPromptInput: ()=>shouldOffsetEmptyStateForPromptInput,
28
29
  getInlineStructuredFieldConfig: ()=>getInlineStructuredFieldConfig
29
30
  });
30
31
  const external_types_js_namespaceObject = require("../types.js");
@@ -71,11 +72,21 @@ const getInlineStructuredFieldConfig = (actionSpace, selectedType)=>{
71
72
  placeholder
72
73
  };
73
74
  };
75
+ const shouldOffsetEmptyStateForPromptInput = (actionSpace, selectedType)=>{
76
+ if (!(null == actionSpace ? void 0 : actionSpace.length) || !selectedType) return false;
77
+ if (getInlineStructuredFieldConfig(actionSpace, selectedType)) return false;
78
+ const action = actionSpace.find((item)=>item.interfaceAlias === selectedType || item.name === selectedType);
79
+ if (!(null == action ? void 0 : action.paramSchema) || !(0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) return false;
80
+ const schema = action.paramSchema;
81
+ return Object.keys(schema.shape || {}).length > 1;
82
+ };
74
83
  exports.getAvailablePromptActionTypes = __webpack_exports__.getAvailablePromptActionTypes;
75
84
  exports.getInlineStructuredFieldConfig = __webpack_exports__.getInlineStructuredFieldConfig;
85
+ exports.shouldOffsetEmptyStateForPromptInput = __webpack_exports__.shouldOffsetEmptyStateForPromptInput;
76
86
  for(var __rspack_i in __webpack_exports__)if (-1 === [
77
87
  "getAvailablePromptActionTypes",
78
- "getInlineStructuredFieldConfig"
88
+ "getInlineStructuredFieldConfig",
89
+ "shouldOffsetEmptyStateForPromptInput"
79
90
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
80
91
  Object.defineProperty(exports, '__esModule', {
81
92
  value: true
@@ -0,0 +1,53 @@
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
+ getPlaceholderForType: ()=>getPlaceholderForType
28
+ });
29
+ const getPlaceholderForType = (type)=>{
30
+ if ('aiQuery' === type) return 'What do you want to query?';
31
+ if ('aiAssert' === type) return 'What do you want to assert?';
32
+ if ('aiTap' === type) return 'What element do you want to tap?';
33
+ if ('aiDoubleClick' === type) return 'What element do you want to double-click?';
34
+ if ('aiHover' === type) return 'What element do you want to hover over?';
35
+ if ('aiInput' === type) return 'Format: <value> | <element>\nExample: hello world | search box';
36
+ if ('aiRightClick' === type) return 'What element do you want to right-click?';
37
+ if ('aiKeyboardPress' === type) return 'Format: <key> | <element (optional)>\nExample: Enter | text field';
38
+ if ('aiScroll' === type) return 'Format: <direction> <amount> | <element (optional)>\nExample: down 500 | main content';
39
+ if ('aiLocate' === type) return 'What element do you want to locate?';
40
+ if ('aiBoolean' === type) return 'What do you want to check (returns true/false)?';
41
+ if ('aiNumber' === type) return 'What number do you want to extract?';
42
+ if ('aiString' === type) return 'What text do you want to extract?';
43
+ if ('aiAsk' === type) return 'What do you want to ask?';
44
+ if ('aiWaitFor' === type) return 'What condition do you want to wait for?';
45
+ return 'What do you want to do?';
46
+ };
47
+ exports.getPlaceholderForType = __webpack_exports__.getPlaceholderForType;
48
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
49
+ "getPlaceholderForType"
50
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
51
+ Object.defineProperty(exports, '__esModule', {
52
+ value: true
53
+ });
@@ -1,9 +1,8 @@
1
- import './index.less';
1
+ import type { DeviceAction } from '@midscene/core';
2
2
  import React from 'react';
3
3
  import type { DeviceType, RunType } from '../../types';
4
4
  import type { PromptInputChromeConfig, ServiceModeType } from '../../types';
5
5
  import './index.less';
6
- import type { DeviceAction } from '@midscene/core';
7
6
  interface PromptInputProps {
8
7
  runButtonEnabled: boolean;
9
8
  form: any;
@@ -0,0 +1,3 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { InfoListItem } from '../../types';
3
+ export declare function shouldRenderCustomEmptyState(infoList: InfoListItem[], emptyState?: ReactNode): boolean;
@@ -192,6 +192,12 @@ export interface UniversalPlaygroundConfig {
192
192
  * host shell own the branding.
193
193
  */
194
194
  showSystemMessageHeader?: boolean;
195
+ /**
196
+ * Optional host-provided content rendered when the conversation has no
197
+ * user-visible chat messages yet. The internal welcome message stays in
198
+ * state, but compact hosts can replace its default text block visually.
199
+ */
200
+ emptyState?: ReactNode;
195
201
  /**
196
202
  * Opt-in controls for how consecutive progress items render in the
197
203
  * conversation log. Defaults flatten every progress step inline (no
@@ -0,0 +1,11 @@
1
+ export interface EmptyStatePromptScrollMetrics {
2
+ currentScrollTop: number;
3
+ maxScrollTop: number;
4
+ containerTop: number;
5
+ containerBottom: number;
6
+ contentStartTop: number;
7
+ contentEndBottom: number;
8
+ topSafeMargin?: number;
9
+ bottomSafeMargin?: number;
10
+ }
11
+ export declare function calculateEmptyStatePromptScrollTop({ currentScrollTop, maxScrollTop, containerTop, containerBottom, contentStartTop, contentEndBottom, topSafeMargin, bottomSafeMargin, }: EmptyStatePromptScrollMetrics): number;
@@ -6,6 +6,6 @@ import { StaticPageAgent } from '@midscene/web/static';
6
6
  * removed once all call sites are migrated.
7
7
  */
8
8
  export { actionNameForType } from './action-label';
9
+ export { getPlaceholderForType } from './prompt-placeholder';
9
10
  export declare const staticAgentFromContext: (context: UIContext) => StaticPageAgent;
10
- export declare const getPlaceholderForType: (type: string) => string;
11
11
  export declare const isRunButtonEnabled: (runButtonEnabled: boolean, needsStructuredParams: boolean, params: any, actionSpace: any[] | undefined, selectedType: string, promptValue: string) => boolean;
@@ -22,3 +22,4 @@ export interface InlineStructuredFieldConfig {
22
22
  */
23
23
  export declare const getAvailablePromptActionTypes: (actionSpace: DeviceAction<any>[] | undefined) => string[];
24
24
  export declare const getInlineStructuredFieldConfig: (actionSpace: DeviceAction<any>[] | undefined, selectedType: string) => InlineStructuredFieldConfig | null;
25
+ export declare const shouldOffsetEmptyStateForPromptInput: (actionSpace: DeviceAction<any>[] | undefined, selectedType: string) => boolean;
@@ -0,0 +1 @@
1
+ export declare const getPlaceholderForType: (type: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/visualizer",
3
- "version": "1.7.7",
3
+ "version": "1.7.10-beta-20260507030203.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",
@@ -10,7 +10,14 @@
10
10
  ".": {
11
11
  "types": "./dist/types/index.d.ts",
12
12
  "import": "./dist/es/index.mjs",
13
- "require": "./dist/es/index.js"
13
+ "require": "./dist/lib/index.js"
14
+ }
15
+ },
16
+ "typesVersions": {
17
+ "*": {
18
+ ".": [
19
+ "./dist/types/index.d.ts"
20
+ ]
14
21
  }
15
22
  },
16
23
  "files": [
@@ -58,10 +65,10 @@
58
65
  "antd": "^5.21.6",
59
66
  "buffer": "6.0.3",
60
67
  "dayjs": "^1.11.11",
61
- "@midscene/core": "1.7.7",
62
- "@midscene/playground": "1.7.7",
63
- "@midscene/web": "1.7.7",
64
- "@midscene/shared": "1.7.7"
68
+ "@midscene/playground": "1.7.10-beta-20260507030203.0",
69
+ "@midscene/core": "1.7.10-beta-20260507030203.0",
70
+ "@midscene/shared": "1.7.10-beta-20260507030203.0",
71
+ "@midscene/web": "1.7.10-beta-20260507030203.0"
65
72
  },
66
73
  "license": "MIT",
67
74
  "scripts": {