@bobfrankston/msger 0.1.74 → 0.1.75

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 (134) hide show
  1. package/KNOWN-BUGS.md +121 -0
  2. package/MSGER-API-SUMMARY.md +162 -0
  3. package/MSGER-API.md +376 -0
  4. package/README.md +93 -0
  5. package/SESSION-2025-11-06.md +191 -0
  6. package/SESSION-NOTES.md +678 -0
  7. package/clihandler.d.ts.map +1 -1
  8. package/clihandler.js +62 -2
  9. package/clihandler.js.map +1 -1
  10. package/clihandler.ts +60 -2
  11. package/icon.png +0 -0
  12. package/icon1.png +0 -0
  13. package/msger-native/Cargo.toml +1 -0
  14. package/msger-native/bin/msgernative.exe +0 -0
  15. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Breadcrumbs +12 -118
  16. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/BrowserMetrics/{BrowserMetrics-690552AF-DCD4.pma → BrowserMetrics-690B9AD3-657C.pma} +0 -0
  17. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/BrowserMetrics/{BrowserMetrics-69055373-F88C.pma → BrowserMetrics-690BA05A-501C.pma} +0 -0
  18. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Crashpad/settings.dat +0 -0
  19. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/BrowsingTopicsState +1 -1
  20. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/data_0 +0 -0
  21. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/data_1 +0 -0
  22. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/{BrowserMetrics/BrowserMetrics-69055587-A65C.pma → Default/Cache/Cache_Data/data_2} +0 -0
  23. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/data_3 +0 -0
  24. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/f_000001 +383 -0
  25. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/f_000002 +1091 -0
  26. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/f_000003 +2153 -0
  27. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/f_000004 +0 -0
  28. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/f_000005 +626 -0
  29. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/f_000006 +393 -0
  30. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Cache/Cache_Data/index +0 -0
  31. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/01241693cfdc32b9_0 +0 -0
  32. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/0ba1eea781f3552c_0 +0 -0
  33. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/323aa210eebefe2c_0 +0 -0
  34. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/4608446ac118e77a_0 +0 -0
  35. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/6938205dc2f77841_0 +0 -0
  36. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/6de12299dc89e5f3_0 +0 -0
  37. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/8f403c112eaa455b_0 +0 -0
  38. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/9a3aceb491137f07_0 +0 -0
  39. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/aedb266cbaf9c28f_0 +0 -0
  40. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/ca526fdda86d0b9d_0 +0 -0
  41. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/f5d11d783c9fdf69_0 +0 -0
  42. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Code Cache/js/index-dir/the-real-index +0 -0
  43. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Collections/collectionsSQLite +0 -0
  44. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Collections/collectionsSQLite-journal +0 -0
  45. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/DIPS +0 -0
  46. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/DawnGraphiteCache/data_1 +0 -0
  47. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/DawnGraphiteCache/index +0 -0
  48. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/DawnWebGPUCache/data_1 +0 -0
  49. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/DawnWebGPUCache/index +0 -0
  50. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Extension State/LOG +3 -3
  51. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Extension State/LOG.old +3 -3
  52. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Favicons +0 -0
  53. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/GPUCache/data_0 +0 -0
  54. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/GPUCache/data_1 +0 -0
  55. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/GPUCache/data_2 +0 -0
  56. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/GPUCache/index +0 -0
  57. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/History +0 -0
  58. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Local Storage/leveldb/000003.log +0 -0
  59. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Local Storage/leveldb/LOG +3 -3
  60. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Local Storage/leveldb/LOG.old +3 -3
  61. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/MediaDeviceSalts +0 -0
  62. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/MediaDeviceSalts-journal +0 -0
  63. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Network/Network Persistent State +1 -1
  64. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Network/TransportSecurity +1 -0
  65. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Preferences +1 -1
  66. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/CacheStorage/14e849fa8522d406112ea607cf7fd6342b71b987/249ee9af-c3df-4a86-89a8-2c51f3370ee0/index +0 -0
  67. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/CacheStorage/14e849fa8522d406112ea607cf7fd6342b71b987/249ee9af-c3df-4a86-89a8-2c51f3370ee0/index-dir/the-real-index +0 -0
  68. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/CacheStorage/14e849fa8522d406112ea607cf7fd6342b71b987/index.txt +0 -0
  69. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/000003.log +0 -0
  70. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/CURRENT +1 -0
  71. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/LOCK +0 -0
  72. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/LOG +3 -0
  73. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/LOG.old +3 -0
  74. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/MANIFEST-000001 +0 -0
  75. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/ScriptCache/2cc80dabc69f58b6_0 +0 -0
  76. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/ScriptCache/2cc80dabc69f58b6_1 +0 -0
  77. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/ScriptCache/index +0 -0
  78. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/ScriptCache/index-dir/the-real-index +0 -0
  79. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Session Storage/000003.log +0 -0
  80. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Session Storage/LOG +3 -3
  81. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Session Storage/LOG.old +3 -3
  82. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Site Characteristics Database/000003.log +0 -0
  83. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Site Characteristics Database/LOG +3 -3
  84. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Site Characteristics Database/LOG.old +3 -3
  85. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/LOG +3 -3
  86. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/LOG.old +3 -3
  87. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/WebStorage/QuotaManager +0 -0
  88. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/WebStorage/QuotaManager-journal +0 -0
  89. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/favorites_diagnostic.log +27 -0
  90. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/000003.log +0 -0
  91. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/LOG +3 -3
  92. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/LOG.old +3 -3
  93. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/000003.log +0 -0
  94. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/LOG +3 -3
  95. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/LOG.old +3 -3
  96. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GrShaderCache/data_0 +0 -0
  97. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GrShaderCache/data_1 +0 -0
  98. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GrShaderCache/data_3 +0 -0
  99. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GrShaderCache/f_000003 +0 -0
  100. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GrShaderCache/f_000004 +0 -0
  101. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GrShaderCache/index +0 -0
  102. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GraphiteDawnCache/data_1 +0 -0
  103. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/GraphiteDawnCache/index +0 -0
  104. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Local State +1 -1
  105. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/RevisitationBloomfilter +0 -0
  106. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/ShaderCache/data_1 +0 -0
  107. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/ShaderCache/index +0 -0
  108. package/msger-native/src/main.rs +343 -37
  109. package/msger-native/src/template.html +103 -28
  110. package/msger-storage-demo.html +290 -0
  111. package/msger.code-workspace +3 -0
  112. package/msgerdefs/README.md +122 -0
  113. package/msgerdefs/msgerdefs.d.ts +322 -0
  114. package/msgerdefs/msgerdefs.d.ts.map +1 -0
  115. package/msgerdefs/msgerdefs.js +110 -0
  116. package/msgerdefs/msgerdefs.js.map +1 -0
  117. package/msgerdefs/msgerdefs.ts +427 -0
  118. package/msgerdefs/package.json +38 -0
  119. package/msgerdefs/samples.html +431 -0
  120. package/msgerdefs/test1.cmd +1 -0
  121. package/msgerdefs/tsconfig.json +17 -0
  122. package/msgernative-linux-x64 +0 -0
  123. package/package.json +5 -1
  124. package/shower.d.ts +2 -0
  125. package/shower.d.ts.map +1 -1
  126. package/shower.js +17 -0
  127. package/shower.js.map +1 -1
  128. package/shower.ts +24 -0
  129. package/test-data-persistence.html +315 -0
  130. package/test-htmlfrom.html +29 -0
  131. package/test-ipc-reach.html +113 -0
  132. package/test-msger-api.html +120 -0
  133. package/test-msger-functions.html +325 -0
  134. package/msger-native/bin/msgernative.exe.WebView2/EBWebView/BrowserMetrics/BrowserMetrics-69055419-C8A0.pma +0 -0
@@ -0,0 +1,427 @@
1
+ /**
2
+ * TypeScript definitions for the msger JavaScript API
3
+ *
4
+ * This module provides type-safe access to msger's window control,
5
+ * data persistence, and file system features.
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import type { MsgerAPI } from '@bobfrankston/msgerdefs';
10
+ *
11
+ * declare global {
12
+ * interface Window {
13
+ * msger?: MsgerAPI;
14
+ * }
15
+ * }
16
+ *
17
+ * // Check if running in msger
18
+ * if (window.msger) {
19
+ * window.msger.setTitle('My App');
20
+ * }
21
+ * ```
22
+ */
23
+
24
+ /**
25
+ * Result object returned when the window closes
26
+ */
27
+ export interface MsgerResult {
28
+ /** Button that was clicked */
29
+ button: string;
30
+ /** Optional input field value */
31
+ value?: string;
32
+ /** Optional form data */
33
+ form?: Record<string, any>;
34
+ /** True if window was closed via close button */
35
+ closed?: boolean;
36
+ /** True if window was dismissed via Escape key */
37
+ dismissed?: boolean;
38
+ /** True if window was closed due to timeout */
39
+ timeout?: boolean;
40
+ }
41
+
42
+ /**
43
+ * File information returned by file system operations
44
+ */
45
+ export interface FileInfo {
46
+ /** File name */
47
+ name: string;
48
+ /** Full file path */
49
+ path: string;
50
+ /** True if this is a directory */
51
+ isDir: boolean;
52
+ /** File size in bytes (0 for directories) */
53
+ size: number;
54
+ /** Last modified timestamp (ISO 8601 string) */
55
+ modified?: string;
56
+ }
57
+
58
+ /**
59
+ * Options for file selection dialogs
60
+ */
61
+ export interface FileDialogOptions {
62
+ /** Dialog title */
63
+ title?: string;
64
+ /** Default filename for save dialogs */
65
+ defaultFilename?: string;
66
+ /** File filters (e.g., [{name: "Text", extensions: ["txt", "md"]}]) */
67
+ filters?: Array<{name: string; extensions: string[]}>;
68
+ /** Default directory to open */
69
+ defaultPath?: string;
70
+ }
71
+
72
+ /**
73
+ * Selected file with content
74
+ */
75
+ export interface SelectedFile {
76
+ /** File name */
77
+ name: string;
78
+ /** Full file path */
79
+ path: string;
80
+ /** File content as string */
81
+ content: string;
82
+ }
83
+
84
+ /**
85
+ * msger JavaScript API
86
+ *
87
+ * Available when running inside msger via window.msger
88
+ */
89
+ export interface MsgerAPI {
90
+ // ========================================
91
+ // Window Control
92
+ // ========================================
93
+
94
+ /**
95
+ * Toggle fullscreen mode on/off
96
+ * @example
97
+ * msger.toggleFullscreen();
98
+ */
99
+ toggleFullscreen(): void;
100
+
101
+ /**
102
+ * Set fullscreen mode
103
+ * @param enabled - true to enter fullscreen, false to exit
104
+ * @example
105
+ * msger.setFullscreen(true);
106
+ */
107
+ setFullscreen(enabled: boolean): void;
108
+
109
+ /**
110
+ * Minimize the window
111
+ * @example
112
+ * msger.minimize();
113
+ */
114
+ minimize(): void;
115
+
116
+ /**
117
+ * Toggle maximize/restore window
118
+ * @example
119
+ * msger.maximize();
120
+ */
121
+ maximize(): void;
122
+
123
+ /**
124
+ * Set window size
125
+ * @param width - Window width in pixels
126
+ * @param height - Window height in pixels
127
+ * @example
128
+ * msger.setSize(800, 600);
129
+ */
130
+ setSize(width: number, height: number): void;
131
+
132
+ /**
133
+ * Set window position
134
+ * @param x - X coordinate in pixels
135
+ * @param y - Y coordinate in pixels
136
+ * @example
137
+ * msger.setPosition(100, 100);
138
+ */
139
+ setPosition(x: number, y: number): void;
140
+
141
+ /**
142
+ * Set always-on-top behavior
143
+ * @param enabled - true to keep window on top
144
+ * @example
145
+ * msger.setAlwaysOnTop(true);
146
+ */
147
+ setAlwaysOnTop(enabled: boolean): void;
148
+
149
+ /**
150
+ * Set window title
151
+ * @param title - New window title
152
+ * @example
153
+ * msger.setTitle("My Application");
154
+ */
155
+ setTitle(title: string): void;
156
+
157
+ /**
158
+ * Close the window
159
+ * @param result - Optional result to return to parent process
160
+ * @example
161
+ * // Close with default dismissed result
162
+ * msger.close();
163
+ *
164
+ * // Close with custom result
165
+ * msger.close({button: 'OK', value: 'user data'});
166
+ */
167
+ close(result?: Partial<MsgerResult>): void;
168
+
169
+ /**
170
+ * Send result and close window (legacy compatibility)
171
+ * @param result - Result to return to parent process
172
+ * @example
173
+ * msger.sendResult({button: 'Submit', value: 'form data'});
174
+ */
175
+ sendResult(result: Partial<MsgerResult>): void;
176
+
177
+ // ========================================
178
+ // Data Persistence (localStorage wrapper)
179
+ // ========================================
180
+
181
+ /**
182
+ * Save data to persistent storage
183
+ * Data is stored with 'msger_' prefix in localStorage
184
+ * @param key - Storage key
185
+ * @param value - Value to store (will be JSON.stringify'd)
186
+ * @returns true on success, false on failure
187
+ * @example
188
+ * msger.saveData('userPrefs', {theme: 'dark', fontSize: 14});
189
+ */
190
+ saveData(key: string, value: any): boolean;
191
+
192
+ /**
193
+ * Load data from persistent storage
194
+ * @param key - Storage key
195
+ * @param defaultValue - Default value if key not found
196
+ * @returns Stored value or defaultValue
197
+ * @example
198
+ * const prefs = msger.loadData('userPrefs', {theme: 'light'});
199
+ */
200
+ loadData<T = any>(key: string, defaultValue?: T): T;
201
+
202
+ /**
203
+ * Remove data from persistent storage
204
+ * @param key - Storage key to remove
205
+ * @returns true on success, false on failure
206
+ * @example
207
+ * msger.removeData('tempData');
208
+ */
209
+ removeData(key: string): boolean;
210
+
211
+ /**
212
+ * Clear all msger data from persistent storage
213
+ * Only removes items with 'msger_' prefix
214
+ * @returns true on success, false on failure
215
+ * @example
216
+ * msger.clearData();
217
+ */
218
+ clearData(): boolean;
219
+
220
+ // ========================================
221
+ // File System Access (to be implemented)
222
+ // ========================================
223
+
224
+ /**
225
+ * File system operations namespace
226
+ */
227
+ fs?: {
228
+ /**
229
+ * Select a file using native file picker
230
+ * @param options - File dialog options
231
+ * @returns Selected file with content, or null if cancelled
232
+ * @example
233
+ * const file = await msger.fs.selectFile({
234
+ * title: 'Open File',
235
+ * filters: [{name: 'Text', extensions: ['txt', 'md']}]
236
+ * });
237
+ * if (file) {
238
+ * console.log(file.content);
239
+ * }
240
+ */
241
+ selectFile(options?: FileDialogOptions): Promise<SelectedFile | null>;
242
+
243
+ /**
244
+ * Select multiple files using native file picker
245
+ * @param options - File dialog options
246
+ * @returns Array of selected files with content
247
+ * @example
248
+ * const files = await msger.fs.selectFiles({
249
+ * title: 'Open Files'
250
+ * });
251
+ */
252
+ selectFiles(options?: FileDialogOptions): Promise<SelectedFile[]>;
253
+
254
+ /**
255
+ * Save file using native save dialog
256
+ * @param content - File content to save
257
+ * @param defaultFilename - Default filename
258
+ * @param options - Additional dialog options
259
+ * @returns Path where file was saved, or null if cancelled
260
+ * @example
261
+ * const path = await msger.fs.saveFileAs('Hello World', 'greeting.txt');
262
+ */
263
+ saveFileAs(
264
+ content: string,
265
+ defaultFilename?: string,
266
+ options?: FileDialogOptions
267
+ ): Promise<string | null>;
268
+
269
+ /**
270
+ * Select a directory using native folder picker
271
+ * @param options - Dialog options
272
+ * @returns Selected directory path, or null if cancelled
273
+ * @example
274
+ * const dir = await msger.fs.selectFolder({
275
+ * title: 'Select Output Folder'
276
+ * });
277
+ */
278
+ selectFolder(options?: FileDialogOptions): Promise<string | null>;
279
+
280
+ /**
281
+ * Read file contents
282
+ * Note: Requires allowFs: true flag when launching msger
283
+ * @param path - File path to read
284
+ * @returns File content as string
285
+ * @example
286
+ * const content = await msger.fs.read('/path/to/file.txt');
287
+ */
288
+ read(path: string): Promise<string>;
289
+
290
+ /**
291
+ * Write file contents
292
+ * Note: Requires allowFs: true flag when launching msger
293
+ * @param path - File path to write
294
+ * @param content - Content to write
295
+ * @example
296
+ * await msger.fs.write('/path/to/file.txt', 'Hello World');
297
+ */
298
+ write(path: string, content: string): Promise<void>;
299
+
300
+ /**
301
+ * List directory contents
302
+ * Note: Requires allowFs: true flag when launching msger
303
+ * @param path - Directory path to list
304
+ * @returns Array of file information
305
+ * @example
306
+ * const files = await msger.fs.list('/path/to/dir');
307
+ */
308
+ list(path: string): Promise<FileInfo[]>;
309
+
310
+ /**
311
+ * Check if file or directory exists
312
+ * Note: Requires allowFs: true flag when launching msger
313
+ * @param path - Path to check
314
+ * @returns true if exists
315
+ * @example
316
+ * const exists = await msger.fs.exists('/path/to/file.txt');
317
+ */
318
+ exists(path: string): Promise<boolean>;
319
+
320
+ /**
321
+ * Delete file or directory
322
+ * Note: Requires allowFs: true flag when launching msger
323
+ * @param path - Path to delete
324
+ * @example
325
+ * await msger.fs.delete('/path/to/file.txt');
326
+ */
327
+ delete(path: string): Promise<void>;
328
+ };
329
+ }
330
+
331
+ /**
332
+ * Helper to check if code is running in msger
333
+ * @returns true if running in msger environment
334
+ * @example
335
+ * if (isMsger()) {
336
+ * msger.setTitle('Running in msger!');
337
+ * } else {
338
+ * console.log('Running in browser');
339
+ * }
340
+ */
341
+ export function isMsger(): boolean {
342
+ return typeof window !== 'undefined' && typeof window.msger !== 'undefined';
343
+ }
344
+
345
+ /**
346
+ * Get msger API with fallback for browser compatibility
347
+ * @returns msger API if available, or stub implementation for browser
348
+ * @example
349
+ * const api = getMsgerAPI();
350
+ * api.saveData('key', 'value'); // Works in both msger and browser
351
+ */
352
+ export function getMsgerAPI(): MsgerAPI {
353
+ if (isMsger()) {
354
+ return window.msger!;
355
+ }
356
+
357
+ // Return browser-compatible stub
358
+ return {
359
+ // Window control - no-op in browser
360
+ toggleFullscreen: () => {},
361
+ setFullscreen: () => {},
362
+ minimize: () => {},
363
+ maximize: () => {},
364
+ setSize: () => {},
365
+ setPosition: () => {},
366
+ setAlwaysOnTop: () => {},
367
+ setTitle: (title: string) => { document.title = title; },
368
+ close: () => { window.close(); },
369
+ sendResult: () => { window.close(); },
370
+
371
+ // Data persistence - use localStorage in browser
372
+ saveData: (key: string, value: any): boolean => {
373
+ try {
374
+ localStorage.setItem('msger_' + key, JSON.stringify(value));
375
+ return true;
376
+ } catch {
377
+ return false;
378
+ }
379
+ },
380
+ loadData: <T = any>(key: string, defaultValue?: T): T => {
381
+ try {
382
+ const item = localStorage.getItem('msger_' + key);
383
+ return item ? JSON.parse(item) : (defaultValue as T);
384
+ } catch {
385
+ return defaultValue as T;
386
+ }
387
+ },
388
+ removeData: (key: string): boolean => {
389
+ try {
390
+ localStorage.removeItem('msger_' + key);
391
+ return true;
392
+ } catch {
393
+ return false;
394
+ }
395
+ },
396
+ clearData: (): boolean => {
397
+ try {
398
+ const keys = Object.keys(localStorage);
399
+ for (const key of keys) {
400
+ if (key.startsWith('msger_')) {
401
+ localStorage.removeItem(key);
402
+ }
403
+ }
404
+ return true;
405
+ } catch {
406
+ return false;
407
+ }
408
+ },
409
+
410
+ // File system - not available in browser
411
+ fs: undefined
412
+ };
413
+ }
414
+
415
+ /**
416
+ * Declare global window.msger
417
+ */
418
+ declare global {
419
+ interface Window {
420
+ msger?: MsgerAPI;
421
+ }
422
+ }
423
+
424
+ export default {
425
+ isMsger,
426
+ getMsgerAPI
427
+ };
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@bobfrankston/msgerdefs",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript definitions for msger JavaScript API",
5
+ "type": "module",
6
+ "main": "./msgerdefs.js",
7
+ "types": "./msgerdefs.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./msgerdefs.js",
11
+ "types": "./msgerdefs.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "msgerdefs.js",
16
+ "msgerdefs.d.ts",
17
+ "msgerdefs.ts",
18
+ "README.md",
19
+ "samples.html"
20
+ ],
21
+ "keywords": [
22
+ "msger",
23
+ "typescript",
24
+ "definitions",
25
+ "types",
26
+ "webview"
27
+ ],
28
+ "author": "Bob Frankston",
29
+ "license": "ISC",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/BobFrankston/msger.git",
33
+ "directory": "msgerdefs"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }