@midscene/visualizer 0.27.1-beta-20250822053848.0 → 0.27.1-beta-20250822103738.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 (27) hide show
  1. package/dist/es/component/playground/FormField.mjs +122 -0
  2. package/dist/es/component/playground/HistorySelector.mjs +2 -3
  3. package/dist/es/component/playground/PromptInput.mjs +339 -58
  4. package/dist/es/component/playground/index.css +160 -2
  5. package/dist/es/component/playground/playground-constants.mjs +69 -1
  6. package/dist/es/component/playground/playground-utils.mjs +43 -1
  7. package/dist/es/component/playground/types.mjs +50 -0
  8. package/dist/es/component/replay-scripts.mjs +18 -9
  9. package/dist/es/component/store/history.mjs +42 -8
  10. package/dist/lib/component/playground/FormField.js +165 -0
  11. package/dist/lib/component/playground/HistorySelector.js +2 -3
  12. package/dist/lib/component/playground/PromptInput.js +345 -54
  13. package/dist/lib/component/playground/index.css +160 -2
  14. package/dist/lib/component/playground/playground-constants.js +76 -2
  15. package/dist/lib/component/playground/playground-utils.js +45 -0
  16. package/dist/lib/component/playground/types.js +96 -0
  17. package/dist/lib/component/replay-scripts.js +28 -19
  18. package/dist/lib/component/store/history.js +42 -8
  19. package/dist/types/component/playground/FormField.d.ts +15 -0
  20. package/dist/types/component/playground/HistorySelector.d.ts +2 -0
  21. package/dist/types/component/playground/PromptInput.d.ts +3 -1
  22. package/dist/types/component/playground/playground-constants.d.ts +63 -0
  23. package/dist/types/component/playground/playground-types.d.ts +1 -1
  24. package/dist/types/component/playground/playground-utils.d.ts +1 -0
  25. package/dist/types/component/playground/types.d.ts +58 -0
  26. package/dist/types/component/store/history.d.ts +9 -4
  27. package/package.json +4 -4
@@ -50,8 +50,31 @@ body {
50
50
  color: #fff;
51
51
  }
52
52
 
53
- .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper:hover {
54
- color: #2b83ff;
53
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button {
54
+ height: 24px;
55
+ box-shadow: none;
56
+ background-color: #f7f7f7;
57
+ border: none;
58
+ border-radius: 11px;
59
+ align-items: center;
60
+ gap: 2px;
61
+ padding: 0 8px;
62
+ font-size: 12px;
63
+ display: inline-flex;
64
+ }
65
+
66
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button:hover {
67
+ background-color: #e6e6e6;
68
+ }
69
+
70
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button.selected-from-dropdown {
71
+ color: #fff;
72
+ background-color: #2b83ff;
73
+ font-weight: 500;
74
+ }
75
+
76
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button.selected-from-dropdown:hover {
77
+ background-color: #2b83ff;
55
78
  }
56
79
 
57
80
  .prompt-input-wrapper .mode-radio-group-wrapper .action-icons {
@@ -120,6 +143,10 @@ body {
120
143
  background-color: rgba(0, 0, 0, 0);
121
144
  }
122
145
 
146
+ .prompt-input-wrapper .ant-form-item-with-help + .form-controller-wrapper {
147
+ bottom: 22px;
148
+ }
149
+
123
150
  .prompt-input-wrapper .ant-input {
124
151
  padding-bottom: 40px;
125
152
  }
@@ -152,6 +179,137 @@ body {
152
179
  color: #3b3b3b;
153
180
  }
154
181
 
182
+ .prompt-input-wrapper .structured-params-container {
183
+ background: linear-gradient(#fff, #fff) padding-box padding-box, linear-gradient(135deg, #4285f4 0%, #06f 25%, #7b02c5 50%, #ea4335 75%, #ff7043 100%) border-box;
184
+ border: 1px solid rgba(0, 0, 0, 0);
185
+ border-radius: 12px;
186
+ padding: 16px 16px 56px;
187
+ }
188
+
189
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item {
190
+ flex-direction: column;
191
+ display: flex;
192
+ }
193
+
194
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label {
195
+ text-align: left;
196
+ flex-basis: auto;
197
+ padding-bottom: 4px;
198
+ }
199
+
200
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label {
201
+ color: rgba(0, 0, 0, .85);
202
+ height: auto;
203
+ font-size: 12px;
204
+ font-weight: 500;
205
+ line-height: 1.5;
206
+ }
207
+
208
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:after {
209
+ color: #ff4d4f;
210
+ font-family: SimSun, sans-serif;
211
+ font-size: 12px;
212
+ line-height: 1;
213
+ display: inline-block;
214
+ }
215
+
216
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:not(:-webkit-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi))):after {
217
+ margin-left: 4px;
218
+ }
219
+
220
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:not(:-moz-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi))):after {
221
+ margin-left: 4px;
222
+ }
223
+
224
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:not(:is(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi))):after {
225
+ margin-left: 4px;
226
+ }
227
+
228
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:-webkit-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi)):after {
229
+ margin-right: 4px;
230
+ }
231
+
232
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:-moz-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi)):after {
233
+ margin-right: 4px;
234
+ }
235
+
236
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:is(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi)):after {
237
+ margin-right: 4px;
238
+ }
239
+
240
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-control {
241
+ flex: 1;
242
+ margin-top: 0;
243
+ }
244
+
245
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-row {
246
+ flex-direction: column;
247
+ }
248
+
249
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-control-input {
250
+ min-height: auto;
251
+ }
252
+
253
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number, .prompt-input-wrapper .structured-params-container .structured-params .ant-select {
254
+ border: 1px solid #e1e5e9;
255
+ border-radius: 6px;
256
+ width: 100%;
257
+ }
258
+
259
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input:hover, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:hover, .prompt-input-wrapper .structured-params-container .structured-params .ant-select:hover {
260
+ border-color: #40a9ff;
261
+ }
262
+
263
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input:focus, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:focus, .prompt-input-wrapper .structured-params-container .structured-params .ant-select:focus, .prompt-input-wrapper .structured-params-container .structured-params .ant-input:focus-within, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:focus-within, .prompt-input-wrapper .structured-params-container .structured-params .ant-select:focus-within {
264
+ border-color: #40a9ff;
265
+ box-shadow: 0 0 0 2px rgba(24, 144, 255, .2);
266
+ }
267
+
268
+ .prompt-input-wrapper .structured-params-container .structured-params textarea.ant-input {
269
+ padding-bottom: 5px;
270
+ }
271
+
272
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number .ant-input-number-input {
273
+ box-shadow: none;
274
+ border: none;
275
+ }
276
+
277
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:hover .ant-input-number-input {
278
+ box-shadow: none;
279
+ }
280
+
281
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-select {
282
+ min-width: 120px;
283
+ }
284
+
285
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-select .ant-select-selector {
286
+ box-shadow: none;
287
+ border: none;
288
+ }
289
+
290
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-select:hover .ant-select-selector, .prompt-input-wrapper .structured-params-container .structured-params .ant-select.ant-select-focused .ant-select-selector {
291
+ box-shadow: none;
292
+ }
293
+
294
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group {
295
+ width: 100%;
296
+ }
297
+
298
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group .ant-radio-button-wrapper {
299
+ border: 1px solid #e1e5e9;
300
+ border-radius: 6px;
301
+ height: 32px;
302
+ margin-right: 4px;
303
+ font-size: 12px;
304
+ line-height: 30px;
305
+ }
306
+
307
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group .ant-radio-button-wrapper.ant-radio-button-wrapper-checked {
308
+ color: #fff;
309
+ background-color: #2b83ff;
310
+ border-color: #2b83ff;
311
+ }
312
+
155
313
  .selector-trigger {
156
314
  cursor: pointer;
157
315
  width: 24px;
@@ -42,4 +42,72 @@ const emptyResultTip = /*#__PURE__*/ jsx("div", {
42
42
  });
43
43
  const trackingTip = 'limit popup to current tab';
44
44
  const deepThinkTip = 'deep think';
45
- export { deepThinkTip, emptyResultTip, errorMessageServerNotReady, serverLaunchTip, trackingTip };
45
+ const apiMetadata = {
46
+ aiAction: {
47
+ group: 'interaction',
48
+ title: 'Auto Planning: plan the steps and execute'
49
+ },
50
+ aiTap: {
51
+ group: 'interaction',
52
+ title: 'Click an element'
53
+ },
54
+ aiHover: {
55
+ group: 'interaction',
56
+ title: 'Hover over an element'
57
+ },
58
+ aiInput: {
59
+ group: 'interaction',
60
+ title: 'Input text into an element'
61
+ },
62
+ aiRightClick: {
63
+ group: 'interaction',
64
+ title: 'Right-click an element'
65
+ },
66
+ aiKeyboardPress: {
67
+ group: 'interaction',
68
+ title: 'Press keyboard keys'
69
+ },
70
+ aiScroll: {
71
+ group: 'interaction',
72
+ title: 'Scroll the page or element'
73
+ },
74
+ aiLocate: {
75
+ group: 'interaction',
76
+ title: 'Locate an element on the page'
77
+ },
78
+ aiQuery: {
79
+ group: 'extraction',
80
+ title: 'Extract data directly from the UI'
81
+ },
82
+ aiBoolean: {
83
+ group: 'extraction',
84
+ title: 'Get true/false answer'
85
+ },
86
+ aiNumber: {
87
+ group: 'extraction',
88
+ title: 'Extract numeric value'
89
+ },
90
+ aiString: {
91
+ group: 'extraction',
92
+ title: 'Extract text value'
93
+ },
94
+ aiAsk: {
95
+ group: 'extraction',
96
+ title: 'Ask a question about the UI'
97
+ },
98
+ aiAssert: {
99
+ group: 'validation',
100
+ title: 'Assert a condition is true'
101
+ },
102
+ aiWaitFor: {
103
+ group: 'validation',
104
+ title: 'Wait for a condition to be met'
105
+ }
106
+ };
107
+ const defaultMainButtons = [
108
+ 'aiAction',
109
+ 'aiTap',
110
+ 'aiQuery',
111
+ 'aiAssert'
112
+ ];
113
+ export { apiMetadata, deepThinkTip, defaultMainButtons, emptyResultTip, errorMessageServerNotReady, serverLaunchTip, trackingTip };
@@ -1,5 +1,6 @@
1
1
  import { PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
2
2
  import { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED, StaticPage, StaticPageAgent } from "@midscene/web/playground";
3
+ import { isZodObjectSchema, unwrapZodType } from "./types.mjs";
3
4
  const serverBase = `http://localhost:${PLAYGROUND_SERVER_PORT}`;
4
5
  const checkServerStatus = async ()=>{
5
6
  try {
@@ -63,6 +64,17 @@ const actionNameForType = (type)=>{
63
64
  if ('aiQuery' === type) return 'Query';
64
65
  if ('aiAssert' === type) return 'Assert';
65
66
  if ('aiTap' === type) return 'Tap';
67
+ if ('aiHover' === type) return 'Hover';
68
+ if ('aiInput' === type) return 'Input';
69
+ if ('aiRightClick' === type) return 'Right Click';
70
+ if ('aiKeyboardPress' === type) return 'Keyboard Press';
71
+ if ('aiScroll' === type) return 'Scroll';
72
+ if ('aiLocate' === type) return 'Locate';
73
+ if ('aiBoolean' === type) return 'Boolean';
74
+ if ('aiNumber' === type) return 'Number';
75
+ if ('aiString' === type) return 'String';
76
+ if ('aiAsk' === type) return 'Ask';
77
+ if ('aiWaitFor' === type) return 'Wait For';
66
78
  return type;
67
79
  };
68
80
  const staticAgentFromContext = (context)=>{
@@ -78,6 +90,18 @@ const formatErrorMessage = (e)=>{
78
90
  const getPlaceholderForType = (type)=>{
79
91
  if ('aiQuery' === type) return 'What do you want to query?';
80
92
  if ('aiAssert' === type) return 'What do you want to assert?';
93
+ if ('aiTap' === type) return 'What element do you want to tap?';
94
+ if ('aiHover' === type) return 'What element do you want to hover over?';
95
+ if ('aiInput' === type) return 'Format: <value> | <element>\nExample: hello world | search box';
96
+ if ('aiRightClick' === type) return 'What element do you want to right-click?';
97
+ if ('aiKeyboardPress' === type) return 'Format: <key> | <element (optional)>\nExample: Enter | text field';
98
+ if ('aiScroll' === type) return 'Format: <direction> <amount> | <element (optional)>\nExample: down 500 | main content';
99
+ if ('aiLocate' === type) return 'What element do you want to locate?';
100
+ if ('aiBoolean' === type) return 'What do you want to check (returns true/false)?';
101
+ if ('aiNumber' === type) return 'What number do you want to extract?';
102
+ if ('aiString' === type) return 'What text do you want to extract?';
103
+ if ('aiAsk' === type) return 'What do you want to ask?';
104
+ if ('aiWaitFor' === type) return 'What condition do you want to wait for?';
81
105
  return 'What do you want to do?';
82
106
  };
83
107
  const blankResult = {
@@ -86,4 +110,22 @@ const blankResult = {
86
110
  reportHTML: null,
87
111
  error: null
88
112
  };
89
- export { actionNameForType, blankResult, cancelTask, checkServerStatus, formatErrorMessage, getPlaceholderForType, getTaskProgress, overrideServerConfig, requestPlaygroundServer, serverBase, staticAgentFromContext };
113
+ const isRunButtonEnabled = (runButtonEnabled, needsStructuredParams, params, actionSpace, selectedType, promptValue)=>{
114
+ if (!runButtonEnabled) return false;
115
+ if (needsStructuredParams) {
116
+ const currentParams = params || {};
117
+ const action = null == actionSpace ? void 0 : actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
118
+ if ((null == action ? void 0 : action.paramSchema) && isZodObjectSchema(action.paramSchema)) {
119
+ const schema = action.paramSchema;
120
+ return Object.keys(schema.shape).every((key)=>{
121
+ const field = schema.shape[key];
122
+ const { isOptional } = unwrapZodType(field);
123
+ const value = currentParams[key];
124
+ return isOptional || void 0 !== value && '' !== value && null !== value;
125
+ });
126
+ }
127
+ return true;
128
+ }
129
+ return promptValue.trim().length > 0;
130
+ };
131
+ export { actionNameForType, blankResult, cancelTask, checkServerStatus, formatErrorMessage, getPlaceholderForType, getTaskProgress, isRunButtonEnabled, overrideServerConfig, requestPlaygroundServer, serverBase, staticAgentFromContext };
@@ -0,0 +1,50 @@
1
+ const VALIDATION_CONSTANTS = {
2
+ ZOD_TYPES: {
3
+ OPTIONAL: 'ZodOptional',
4
+ DEFAULT: 'ZodDefault',
5
+ NULLABLE: 'ZodNullable',
6
+ OBJECT: 'ZodObject',
7
+ ENUM: 'ZodEnum',
8
+ NUMBER: 'ZodNumber',
9
+ STRING: 'ZodString'
10
+ },
11
+ FIELD_FLAGS: {
12
+ LOCATION: 'midscene_location_field_flag'
13
+ },
14
+ DEFAULT_VALUES: {
15
+ ACTION_TYPE: 'aiAction',
16
+ TIMEOUT_MS: 15000,
17
+ CHECK_INTERVAL_MS: 3000
18
+ }
19
+ };
20
+ const isZodObjectSchema = (schema)=>'object' == typeof schema && null !== schema && 'shape' in schema && 'parse' in schema && 'function' == typeof schema.parse;
21
+ const isLocateField = (field)=>{
22
+ var _field__def, _field__def_shape, _field__def1, _field__def_shape1, _field__def2;
23
+ return !!((null == (_field__def = field._def) ? void 0 : _field__def.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OBJECT && (null == (_field__def_shape = (_field__def1 = field._def).shape) ? void 0 : _field__def_shape.call(_field__def1)) && VALIDATION_CONSTANTS.FIELD_FLAGS.LOCATION in ((null == (_field__def_shape1 = (_field__def2 = field._def).shape) ? void 0 : _field__def_shape1.call(_field__def2)) || {}));
24
+ };
25
+ const unwrapZodType = (field)=>{
26
+ var _actualField__def, _actualField__def1, _actualField__def2;
27
+ let actualField = field;
28
+ let isOptional = false;
29
+ let hasDefault = false;
30
+ while((null == (_actualField__def = actualField._def) ? void 0 : _actualField__def.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OPTIONAL || (null == (_actualField__def1 = actualField._def) ? void 0 : _actualField__def1.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.DEFAULT || (null == (_actualField__def2 = actualField._def) ? void 0 : _actualField__def2.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.NULLABLE){
31
+ var _actualField__def3, _actualField__def4;
32
+ if ((null == (_actualField__def3 = actualField._def) ? void 0 : _actualField__def3.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OPTIONAL) isOptional = true;
33
+ if ((null == (_actualField__def4 = actualField._def) ? void 0 : _actualField__def4.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.DEFAULT) hasDefault = true;
34
+ actualField = actualField._def.innerType || actualField;
35
+ }
36
+ return {
37
+ actualField,
38
+ isOptional,
39
+ hasDefault
40
+ };
41
+ };
42
+ const extractDefaultValue = (field)=>{
43
+ var _currentField__def;
44
+ let currentField = field;
45
+ while(null == (_currentField__def = currentField._def) ? void 0 : _currentField__def.innerType){
46
+ if (currentField._def.typeName === VALIDATION_CONSTANTS.ZOD_TYPES.DEFAULT && currentField._def.defaultValue) return currentField._def.defaultValue();
47
+ currentField = currentField._def.innerType;
48
+ }
49
+ };
50
+ export { VALIDATION_CONSTANTS, extractDefaultValue, isLocateField, isZodObjectSchema, unwrapZodType };
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import "./player.css";
3
3
  import { mousePointer } from "../utils.mjs";
4
- import { paramStr, typeStr } from "@midscene/web/ui-utils";
4
+ import { paramStr, typeStr } from "@midscene/core/agent";
5
5
  import { treeToList } from "@midscene/shared/extractor";
6
6
  const stillDuration = 900;
7
7
  const actionSpinningPointerDuration = 300;
@@ -50,11 +50,10 @@ const allScriptsFromDump = (dump)=>{
50
50
  dump.executions.forEach((execution)=>{
51
51
  if (execution.sdkVersion) sdkVersion = execution.sdkVersion;
52
52
  execution.tasks.forEach((task)=>{
53
- var _insightTask_pageContext_size, _insightTask_pageContext;
54
- const insightTask = task;
55
- if (null == (_insightTask_pageContext = insightTask.pageContext) ? void 0 : null == (_insightTask_pageContext_size = _insightTask_pageContext.size) ? void 0 : _insightTask_pageContext_size.width) {
56
- width = insightTask.pageContext.size.width;
57
- height = insightTask.pageContext.size.height;
53
+ var _task_pageContext_size, _task_pageContext;
54
+ if (null == (_task_pageContext = task.pageContext) ? void 0 : null == (_task_pageContext_size = _task_pageContext.size) ? void 0 : _task_pageContext_size.width) {
55
+ width = task.pageContext.size.width;
56
+ height = task.pageContext.size.height;
58
57
  }
59
58
  });
60
59
  });
@@ -81,14 +80,24 @@ const allScriptsFromDump = (dump)=>{
81
80
  if (index !== allScripts.length - 1 && 'Done' === script.title) return false;
82
81
  return true;
83
82
  });
83
+ const modelBriefs = (()=>{
84
+ var _list_;
85
+ const list = [
86
+ ...modelBriefsSet
87
+ ];
88
+ if (!list.length) return list;
89
+ const firstOneInfo = null == (_list_ = list[0]) ? void 0 : _list_.split('/', 2)[1];
90
+ if (firstOneInfo && list.slice(1).every((item)=>(null == item ? void 0 : item.split('/', 2)[1]) === firstOneInfo)) return [
91
+ firstOneInfo
92
+ ];
93
+ return list;
94
+ })();
84
95
  return {
85
96
  scripts: allScriptsWithoutIntermediateDoneFrame,
86
97
  width,
87
98
  height,
88
99
  sdkVersion,
89
- modelBriefs: [
90
- ...modelBriefsSet
91
- ]
100
+ modelBriefs
92
101
  };
93
102
  };
94
103
  const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
@@ -27,29 +27,63 @@ __webpack_require__.d(external_zustand_namespaceObject, {
27
27
  create: ()=>create
28
28
  });
29
29
  const { create: history_create } = external_zustand_namespaceObject;
30
- const HISTORY_KEY = 'midscene-prompt-history';
30
+ const HISTORY_KEY = 'midscene-prompt-history-v2';
31
+ const LAST_SELECTED_TYPE_KEY = 'midscene-last-selected-type';
31
32
  const getHistoryFromLocalStorage = ()=>{
32
33
  const historyString = localStorage.getItem(HISTORY_KEY);
33
- return historyString ? JSON.parse(historyString) : [];
34
+ return historyString ? JSON.parse(historyString) : {};
35
+ };
36
+ const getLastSelectedType = ()=>localStorage.getItem(LAST_SELECTED_TYPE_KEY) || 'aiAction';
37
+ const setLastSelectedType = (type)=>{
38
+ localStorage.setItem(LAST_SELECTED_TYPE_KEY, type);
34
39
  };
35
40
  const useHistoryStore = history_create((set, get)=>({
36
41
  history: getHistoryFromLocalStorage(),
37
- clearHistory: ()=>{
42
+ lastSelectedType: getLastSelectedType(),
43
+ clearHistory: (type)=>{
44
+ const newHistory = {
45
+ ...get().history
46
+ };
47
+ delete newHistory[type];
38
48
  set({
39
- history: []
49
+ history: newHistory
40
50
  });
41
- localStorage.removeItem(HISTORY_KEY);
51
+ localStorage.setItem(HISTORY_KEY, JSON.stringify(newHistory));
42
52
  },
43
53
  addHistory: (historyItem)=>{
44
- const newHistory = [
54
+ const { type } = historyItem;
55
+ const currentHistory = get().history;
56
+ const typeHistory = currentHistory[type] || [];
57
+ const stringifiedNewItem = JSON.stringify({
58
+ prompt: historyItem.prompt,
59
+ params: historyItem.params
60
+ });
61
+ const newTypeHistory = [
45
62
  historyItem,
46
- ...get().history.filter((h)=>h.prompt !== historyItem.prompt)
63
+ ...typeHistory.filter((h)=>{
64
+ const stringifiedOldItem = JSON.stringify({
65
+ prompt: h.prompt,
66
+ params: h.params
67
+ });
68
+ return stringifiedOldItem !== stringifiedNewItem;
69
+ })
47
70
  ];
48
- while(newHistory.length > 10)newHistory.pop();
71
+ if (newTypeHistory.length > 10) newTypeHistory.length = 10;
72
+ const newHistory = {
73
+ ...currentHistory,
74
+ [type]: newTypeHistory
75
+ };
49
76
  set({
50
77
  history: newHistory
51
78
  });
52
79
  localStorage.setItem(HISTORY_KEY, JSON.stringify(newHistory));
80
+ },
81
+ getHistoryForType: (type)=>get().history[type] || [],
82
+ setLastSelectedType: (type)=>{
83
+ set({
84
+ lastSelectedType: type
85
+ });
86
+ setLastSelectedType(type);
53
87
  }
54
88
  }));
55
89
  export { useHistoryStore };
@@ -0,0 +1,165 @@
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
+ TextField: ()=>TextField,
28
+ NumberField: ()=>NumberField,
29
+ LocateField: ()=>LocateField,
30
+ EnumField: ()=>EnumField
31
+ });
32
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
33
+ const external_antd_namespaceObject = require("antd");
34
+ const { TextArea } = external_antd_namespaceObject.Input;
35
+ const renderLabel = (label, isOptional)=>`${label}${isOptional ? ' (Optional)' : ''}`;
36
+ const TextField = (param)=>{
37
+ let { name, label, isRequired, marginBottom } = param;
38
+ const placeholder = `Enter ${name}`;
39
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
40
+ name: [
41
+ 'params',
42
+ name
43
+ ],
44
+ label: renderLabel(label, !isRequired),
45
+ rules: isRequired ? [
46
+ {
47
+ required: true,
48
+ message: `Please input ${name}`
49
+ }
50
+ ] : [],
51
+ style: {
52
+ marginBottom
53
+ },
54
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Input, {
55
+ placeholder: placeholder
56
+ })
57
+ }, name);
58
+ };
59
+ const LocateField = (param)=>{
60
+ let { name, label, isRequired, marginBottom } = param;
61
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
62
+ name: [
63
+ 'params',
64
+ name
65
+ ],
66
+ label: renderLabel(label, !isRequired),
67
+ rules: isRequired ? [
68
+ {
69
+ required: true,
70
+ message: `Please describe the ${name}`
71
+ }
72
+ ] : [],
73
+ style: {
74
+ marginBottom
75
+ },
76
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TextArea, {
77
+ rows: 2,
78
+ placeholder: `Describe the ${name}, use natural language`
79
+ })
80
+ }, name);
81
+ };
82
+ const EnumField = (param)=>{
83
+ let { name, label, fieldSchema, isRequired, marginBottom } = param;
84
+ const enumValues = fieldSchema._def.values || [];
85
+ const selectOptions = enumValues.map((value)=>({
86
+ value,
87
+ label: value.charAt(0).toUpperCase() + value.slice(1)
88
+ }));
89
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
90
+ name: [
91
+ 'params',
92
+ name
93
+ ],
94
+ label: label,
95
+ rules: isRequired ? [
96
+ {
97
+ required: true,
98
+ message: `Please select ${name}`
99
+ }
100
+ ] : [],
101
+ style: {
102
+ marginBottom
103
+ },
104
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Select, {
105
+ placeholder: `Select ${name}`,
106
+ options: selectOptions
107
+ })
108
+ }, name);
109
+ };
110
+ const NumberField = (param)=>{
111
+ let { name, label, isRequired, marginBottom } = param;
112
+ const placeholder = 'distance' === name ? 500 : 0;
113
+ const min = 0;
114
+ const max = 'distance' === name ? 10000 : void 0;
115
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
116
+ name: [
117
+ 'params',
118
+ name
119
+ ],
120
+ label: `${label}${'distance' === name ? ' (px)' : ''}`,
121
+ rules: isRequired ? [
122
+ {
123
+ required: true,
124
+ message: `Please input ${name}`
125
+ },
126
+ {
127
+ type: 'number',
128
+ min,
129
+ message: `${label} must be at least ${min}`
130
+ }
131
+ ] : [
132
+ {
133
+ type: 'number',
134
+ min,
135
+ message: `${label} must be at least ${min}`
136
+ }
137
+ ],
138
+ style: {
139
+ flex: 'distance' === name ? 1 : void 0,
140
+ marginBottom
141
+ },
142
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.InputNumber, {
143
+ placeholder: placeholder.toString(),
144
+ min: min,
145
+ max: max,
146
+ step: 'distance' === name ? 10 : 1,
147
+ style: {
148
+ width: '100%'
149
+ }
150
+ })
151
+ }, name);
152
+ };
153
+ exports.EnumField = __webpack_exports__.EnumField;
154
+ exports.LocateField = __webpack_exports__.LocateField;
155
+ exports.NumberField = __webpack_exports__.NumberField;
156
+ exports.TextField = __webpack_exports__.TextField;
157
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
158
+ "EnumField",
159
+ "LocateField",
160
+ "NumberField",
161
+ "TextField"
162
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
163
+ Object.defineProperty(exports, '__esModule', {
164
+ value: true
165
+ });