@midscene/visualizer 0.28.10-beta-20250919084614.0 → 0.28.10-beta-20250922071252.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.
@@ -1,207 +0,0 @@
1
- import { IndexedDBManager, createCleanupFunction, withErrorHandling } from "@midscene/shared/baseDB";
2
- function _define_property(obj, key, value) {
3
- if (key in obj) Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- else obj[key] = value;
10
- return obj;
11
- }
12
- const DB_NAME = 'midscene_playground';
13
- const DB_VERSION = 1;
14
- const MESSAGES_STORE = 'playground_messages';
15
- const RESULTS_STORE = 'playground_results';
16
- const MAX_STORED_MESSAGES = 100;
17
- const MAX_STORED_RESULTS = 50;
18
- class IndexedDBStorageProvider {
19
- async saveMessages(messages) {
20
- await withErrorHandling(async ()=>{
21
- await this.dbManager.clear(MESSAGES_STORE);
22
- const messagesToSave = messages.slice(-MAX_STORED_MESSAGES);
23
- await Promise.all(messagesToSave.map((msg, index)=>{
24
- const lightMessage = {
25
- ...msg,
26
- result: void 0
27
- };
28
- const data = {
29
- id: msg.id || `msg-${index}`,
30
- data: lightMessage,
31
- timestamp: msg.timestamp ? msg.timestamp.getTime() : Date.now() + index
32
- };
33
- return this.dbManager.put(MESSAGES_STORE, data);
34
- }));
35
- }, 'Failed to save messages to IndexedDB', void 0, this.messagesCleanup);
36
- }
37
- async loadMessages() {
38
- const result = await withErrorHandling(async ()=>{
39
- const messages = await this.dbManager.getAll(MESSAGES_STORE, true);
40
- if (0 === messages.length) return [];
41
- return Promise.all(messages.map(async (msg)=>{
42
- const item = msg.data;
43
- const restoredItem = {
44
- ...item,
45
- timestamp: new Date(item.timestamp)
46
- };
47
- if ('result' === item.type && item.id) {
48
- const fullResult = await this.loadResult(item.id);
49
- if (fullResult) {
50
- restoredItem.result = fullResult.result;
51
- restoredItem.replayScriptsInfo = fullResult.replayScriptsInfo;
52
- restoredItem.replayCounter = fullResult.replayCounter;
53
- restoredItem.verticalMode = fullResult.verticalMode;
54
- }
55
- }
56
- return restoredItem;
57
- }));
58
- }, 'Failed to load messages from IndexedDB', [], this.messagesCleanup);
59
- return result || [];
60
- }
61
- async clearMessages() {
62
- await withErrorHandling(async ()=>{
63
- await Promise.all([
64
- this.dbManager.clear(MESSAGES_STORE),
65
- this.dbManager.clear(RESULTS_STORE)
66
- ]);
67
- }, 'Failed to clear messages from IndexedDB');
68
- }
69
- async saveResult(id, result) {
70
- await withErrorHandling(async ()=>{
71
- const compressedResult = this.compressResultForStorage(result);
72
- const data = {
73
- id,
74
- data: compressedResult,
75
- timestamp: Date.now(),
76
- size: JSON.stringify(compressedResult).length
77
- };
78
- await this.dbManager.put(RESULTS_STORE, data);
79
- }, 'Failed to save result to IndexedDB', void 0, this.resultsCleanup);
80
- }
81
- async loadResult(id) {
82
- const result = await withErrorHandling(async ()=>{
83
- const data = await this.dbManager.get(RESULTS_STORE, id);
84
- return (null == data ? void 0 : data.data) || null;
85
- }, 'Failed to load result from IndexedDB', null);
86
- return result || null;
87
- }
88
- compressResultForStorage(result) {
89
- var _result_result_dump, _result_result;
90
- if (!(null == (_result_result = result.result) ? void 0 : null == (_result_result_dump = _result_result.dump) ? void 0 : _result_result_dump.executions)) return result;
91
- const compressedExecutions = result.result.dump.executions.map((execution)=>{
92
- var _execution_tasks;
93
- return {
94
- ...execution,
95
- tasks: (null == (_execution_tasks = execution.tasks) ? void 0 : _execution_tasks.map((task)=>{
96
- var _task_recorder;
97
- var _this_compressScreenshotIfNeeded;
98
- return {
99
- ...task,
100
- uiContext: task.uiContext ? {
101
- ...task.uiContext,
102
- screenshotBase64: null != (_this_compressScreenshotIfNeeded = this.compressScreenshotIfNeeded(task.uiContext.screenshotBase64)) ? _this_compressScreenshotIfNeeded : task.uiContext.screenshotBase64
103
- } : task.uiContext,
104
- recorder: null == (_task_recorder = task.recorder) ? void 0 : _task_recorder.map((record)=>({
105
- ...record,
106
- screenshot: this.compressScreenshotIfNeeded(record.screenshot)
107
- }))
108
- };
109
- })) || []
110
- };
111
- });
112
- return {
113
- ...result,
114
- result: {
115
- ...result.result,
116
- dump: {
117
- ...result.result.dump,
118
- executions: compressedExecutions
119
- }
120
- }
121
- };
122
- }
123
- compressScreenshotIfNeeded(screenshot) {
124
- if (!screenshot) return screenshot;
125
- if (screenshot.length > 1048576) {
126
- const sizeKB = Math.round(screenshot.length / 1024);
127
- return `[COMPRESSED: ${sizeKB}KB screenshot removed for storage]`;
128
- }
129
- return screenshot;
130
- }
131
- async getStorageStats() {
132
- const result = await withErrorHandling(async ()=>{
133
- const [messageCount, resultCount] = await Promise.all([
134
- this.dbManager.count(MESSAGES_STORE),
135
- this.dbManager.count(RESULTS_STORE)
136
- ]);
137
- return {
138
- messageCount,
139
- resultCount
140
- };
141
- }, 'Failed to get storage statistics', {
142
- messageCount: 0,
143
- resultCount: 0
144
- });
145
- return result || {
146
- messageCount: 0,
147
- resultCount: 0
148
- };
149
- }
150
- async cleanup() {
151
- await Promise.all([
152
- this.messagesCleanup(),
153
- this.resultsCleanup()
154
- ]);
155
- }
156
- constructor(namespace = 'playground'){
157
- _define_property(this, "dbManager", void 0);
158
- _define_property(this, "namespace", void 0);
159
- _define_property(this, "messagesCleanup", void 0);
160
- _define_property(this, "resultsCleanup", void 0);
161
- this.namespace = namespace;
162
- this.dbManager = new IndexedDBManager(`${DB_NAME}_${namespace}`, DB_VERSION, [
163
- {
164
- name: MESSAGES_STORE,
165
- keyPath: 'id'
166
- },
167
- {
168
- name: RESULTS_STORE,
169
- keyPath: 'id'
170
- }
171
- ]);
172
- this.messagesCleanup = createCleanupFunction(this.dbManager, MESSAGES_STORE, MAX_STORED_MESSAGES);
173
- this.resultsCleanup = createCleanupFunction(this.dbManager, RESULTS_STORE, MAX_STORED_RESULTS);
174
- }
175
- }
176
- class MemoryStorageProvider {
177
- async saveMessages(messages) {
178
- this.messages = [
179
- ...messages
180
- ];
181
- }
182
- async loadMessages() {
183
- return [
184
- ...this.messages
185
- ];
186
- }
187
- async clearMessages() {
188
- this.messages = [];
189
- this.results.clear();
190
- }
191
- async saveResult(id, result) {
192
- this.results.set(id, result);
193
- }
194
- constructor(){
195
- _define_property(this, "messages", []);
196
- _define_property(this, "results", new Map());
197
- }
198
- }
199
- class NoOpStorageProvider {
200
- async saveMessages(_messages) {}
201
- async loadMessages() {
202
- return [];
203
- }
204
- async clearMessages() {}
205
- async saveResult(_id, _result) {}
206
- }
207
- export { IndexedDBStorageProvider, MemoryStorageProvider, NoOpStorageProvider };
@@ -1,247 +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
- IndexedDBStorageProvider: ()=>IndexedDBStorageProvider,
28
- NoOpStorageProvider: ()=>NoOpStorageProvider,
29
- MemoryStorageProvider: ()=>MemoryStorageProvider
30
- });
31
- const baseDB_namespaceObject = require("@midscene/shared/baseDB");
32
- function _define_property(obj, key, value) {
33
- if (key in obj) Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- else obj[key] = value;
40
- return obj;
41
- }
42
- const DB_NAME = 'midscene_playground';
43
- const DB_VERSION = 1;
44
- const MESSAGES_STORE = 'playground_messages';
45
- const RESULTS_STORE = 'playground_results';
46
- const MAX_STORED_MESSAGES = 100;
47
- const MAX_STORED_RESULTS = 50;
48
- class IndexedDBStorageProvider {
49
- async saveMessages(messages) {
50
- await (0, baseDB_namespaceObject.withErrorHandling)(async ()=>{
51
- await this.dbManager.clear(MESSAGES_STORE);
52
- const messagesToSave = messages.slice(-MAX_STORED_MESSAGES);
53
- await Promise.all(messagesToSave.map((msg, index)=>{
54
- const lightMessage = {
55
- ...msg,
56
- result: void 0
57
- };
58
- const data = {
59
- id: msg.id || `msg-${index}`,
60
- data: lightMessage,
61
- timestamp: msg.timestamp ? msg.timestamp.getTime() : Date.now() + index
62
- };
63
- return this.dbManager.put(MESSAGES_STORE, data);
64
- }));
65
- }, 'Failed to save messages to IndexedDB', void 0, this.messagesCleanup);
66
- }
67
- async loadMessages() {
68
- const result = await (0, baseDB_namespaceObject.withErrorHandling)(async ()=>{
69
- const messages = await this.dbManager.getAll(MESSAGES_STORE, true);
70
- if (0 === messages.length) return [];
71
- return Promise.all(messages.map(async (msg)=>{
72
- const item = msg.data;
73
- const restoredItem = {
74
- ...item,
75
- timestamp: new Date(item.timestamp)
76
- };
77
- if ('result' === item.type && item.id) {
78
- const fullResult = await this.loadResult(item.id);
79
- if (fullResult) {
80
- restoredItem.result = fullResult.result;
81
- restoredItem.replayScriptsInfo = fullResult.replayScriptsInfo;
82
- restoredItem.replayCounter = fullResult.replayCounter;
83
- restoredItem.verticalMode = fullResult.verticalMode;
84
- }
85
- }
86
- return restoredItem;
87
- }));
88
- }, 'Failed to load messages from IndexedDB', [], this.messagesCleanup);
89
- return result || [];
90
- }
91
- async clearMessages() {
92
- await (0, baseDB_namespaceObject.withErrorHandling)(async ()=>{
93
- await Promise.all([
94
- this.dbManager.clear(MESSAGES_STORE),
95
- this.dbManager.clear(RESULTS_STORE)
96
- ]);
97
- }, 'Failed to clear messages from IndexedDB');
98
- }
99
- async saveResult(id, result) {
100
- await (0, baseDB_namespaceObject.withErrorHandling)(async ()=>{
101
- const compressedResult = this.compressResultForStorage(result);
102
- const data = {
103
- id,
104
- data: compressedResult,
105
- timestamp: Date.now(),
106
- size: JSON.stringify(compressedResult).length
107
- };
108
- await this.dbManager.put(RESULTS_STORE, data);
109
- }, 'Failed to save result to IndexedDB', void 0, this.resultsCleanup);
110
- }
111
- async loadResult(id) {
112
- const result = await (0, baseDB_namespaceObject.withErrorHandling)(async ()=>{
113
- const data = await this.dbManager.get(RESULTS_STORE, id);
114
- return (null == data ? void 0 : data.data) || null;
115
- }, 'Failed to load result from IndexedDB', null);
116
- return result || null;
117
- }
118
- compressResultForStorage(result) {
119
- var _result_result_dump, _result_result;
120
- if (!(null == (_result_result = result.result) ? void 0 : null == (_result_result_dump = _result_result.dump) ? void 0 : _result_result_dump.executions)) return result;
121
- const compressedExecutions = result.result.dump.executions.map((execution)=>{
122
- var _execution_tasks;
123
- return {
124
- ...execution,
125
- tasks: (null == (_execution_tasks = execution.tasks) ? void 0 : _execution_tasks.map((task)=>{
126
- var _task_recorder;
127
- var _this_compressScreenshotIfNeeded;
128
- return {
129
- ...task,
130
- uiContext: task.uiContext ? {
131
- ...task.uiContext,
132
- screenshotBase64: null != (_this_compressScreenshotIfNeeded = this.compressScreenshotIfNeeded(task.uiContext.screenshotBase64)) ? _this_compressScreenshotIfNeeded : task.uiContext.screenshotBase64
133
- } : task.uiContext,
134
- recorder: null == (_task_recorder = task.recorder) ? void 0 : _task_recorder.map((record)=>({
135
- ...record,
136
- screenshot: this.compressScreenshotIfNeeded(record.screenshot)
137
- }))
138
- };
139
- })) || []
140
- };
141
- });
142
- return {
143
- ...result,
144
- result: {
145
- ...result.result,
146
- dump: {
147
- ...result.result.dump,
148
- executions: compressedExecutions
149
- }
150
- }
151
- };
152
- }
153
- compressScreenshotIfNeeded(screenshot) {
154
- if (!screenshot) return screenshot;
155
- if (screenshot.length > 1048576) {
156
- const sizeKB = Math.round(screenshot.length / 1024);
157
- return `[COMPRESSED: ${sizeKB}KB screenshot removed for storage]`;
158
- }
159
- return screenshot;
160
- }
161
- async getStorageStats() {
162
- const result = await (0, baseDB_namespaceObject.withErrorHandling)(async ()=>{
163
- const [messageCount, resultCount] = await Promise.all([
164
- this.dbManager.count(MESSAGES_STORE),
165
- this.dbManager.count(RESULTS_STORE)
166
- ]);
167
- return {
168
- messageCount,
169
- resultCount
170
- };
171
- }, 'Failed to get storage statistics', {
172
- messageCount: 0,
173
- resultCount: 0
174
- });
175
- return result || {
176
- messageCount: 0,
177
- resultCount: 0
178
- };
179
- }
180
- async cleanup() {
181
- await Promise.all([
182
- this.messagesCleanup(),
183
- this.resultsCleanup()
184
- ]);
185
- }
186
- constructor(namespace = 'playground'){
187
- _define_property(this, "dbManager", void 0);
188
- _define_property(this, "namespace", void 0);
189
- _define_property(this, "messagesCleanup", void 0);
190
- _define_property(this, "resultsCleanup", void 0);
191
- this.namespace = namespace;
192
- this.dbManager = new baseDB_namespaceObject.IndexedDBManager(`${DB_NAME}_${namespace}`, DB_VERSION, [
193
- {
194
- name: MESSAGES_STORE,
195
- keyPath: 'id'
196
- },
197
- {
198
- name: RESULTS_STORE,
199
- keyPath: 'id'
200
- }
201
- ]);
202
- this.messagesCleanup = (0, baseDB_namespaceObject.createCleanupFunction)(this.dbManager, MESSAGES_STORE, MAX_STORED_MESSAGES);
203
- this.resultsCleanup = (0, baseDB_namespaceObject.createCleanupFunction)(this.dbManager, RESULTS_STORE, MAX_STORED_RESULTS);
204
- }
205
- }
206
- class MemoryStorageProvider {
207
- async saveMessages(messages) {
208
- this.messages = [
209
- ...messages
210
- ];
211
- }
212
- async loadMessages() {
213
- return [
214
- ...this.messages
215
- ];
216
- }
217
- async clearMessages() {
218
- this.messages = [];
219
- this.results.clear();
220
- }
221
- async saveResult(id, result) {
222
- this.results.set(id, result);
223
- }
224
- constructor(){
225
- _define_property(this, "messages", []);
226
- _define_property(this, "results", new Map());
227
- }
228
- }
229
- class NoOpStorageProvider {
230
- async saveMessages(_messages) {}
231
- async loadMessages() {
232
- return [];
233
- }
234
- async clearMessages() {}
235
- async saveResult(_id, _result) {}
236
- }
237
- exports.IndexedDBStorageProvider = __webpack_exports__.IndexedDBStorageProvider;
238
- exports.MemoryStorageProvider = __webpack_exports__.MemoryStorageProvider;
239
- exports.NoOpStorageProvider = __webpack_exports__.NoOpStorageProvider;
240
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
241
- "IndexedDBStorageProvider",
242
- "MemoryStorageProvider",
243
- "NoOpStorageProvider"
244
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
245
- Object.defineProperty(exports, '__esModule', {
246
- value: true
247
- });
@@ -1,71 +0,0 @@
1
- import type { InfoListItem, StorageProvider } from '../../../types';
2
- /**
3
- * IndexedDB Storage implementation for playground message persistence
4
- * Provides much larger storage capacity compared to localStorage
5
- */
6
- export declare class IndexedDBStorageProvider implements StorageProvider {
7
- private dbManager;
8
- private namespace;
9
- private messagesCleanup;
10
- private resultsCleanup;
11
- constructor(namespace?: string);
12
- /**
13
- * Save messages to IndexedDB
14
- */
15
- saveMessages(messages: InfoListItem[]): Promise<void>;
16
- /**
17
- * Load messages from IndexedDB
18
- */
19
- loadMessages(): Promise<InfoListItem[]>;
20
- /**
21
- * Clear all messages from IndexedDB
22
- */
23
- clearMessages(): Promise<void>;
24
- /**
25
- * Save a single result to IndexedDB with compression
26
- */
27
- saveResult(id: string, result: InfoListItem): Promise<void>;
28
- /**
29
- * Load a single result from IndexedDB
30
- */
31
- loadResult(id: string): Promise<InfoListItem | null>;
32
- /**
33
- * Compress result data for storage while preserving playback functionality
34
- */
35
- private compressResultForStorage;
36
- /**
37
- * Compress screenshot if it exceeds size threshold
38
- */
39
- private compressScreenshotIfNeeded;
40
- /**
41
- * Get storage statistics
42
- */
43
- getStorageStats(): Promise<{
44
- messageCount: number;
45
- resultCount: number;
46
- }>;
47
- /**
48
- * Manually trigger cleanup
49
- */
50
- cleanup(): Promise<void>;
51
- }
52
- /**
53
- * Memory-based storage provider for IndexedDB fallback
54
- */
55
- export declare class MemoryStorageProvider implements StorageProvider {
56
- private messages;
57
- private results;
58
- saveMessages(messages: InfoListItem[]): Promise<void>;
59
- loadMessages(): Promise<InfoListItem[]>;
60
- clearMessages(): Promise<void>;
61
- saveResult(id: string, result: InfoListItem): Promise<void>;
62
- }
63
- /**
64
- * No-op storage provider for disabled storage
65
- */
66
- export declare class NoOpStorageProvider implements StorageProvider {
67
- saveMessages(_messages: InfoListItem[]): Promise<void>;
68
- loadMessages(): Promise<InfoListItem[]>;
69
- clearMessages(): Promise<void>;
70
- saveResult(_id: string, _result: InfoListItem): Promise<void>;
71
- }