@bobfrankston/msger 0.1.74 → 0.1.76

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
package/KNOWN-BUGS.md ADDED
@@ -0,0 +1,121 @@
1
+ # Known Bugs and Limitations
2
+
3
+ ## Critical: Window Manipulation via IPC Crashes (wry 0.47.2 Bug)
4
+
5
+ **Status:** UNFIXED - Library Bug
6
+ **Severity:** Critical
7
+ **Affected Version:** msger using wry 0.47.2
8
+
9
+ ### Description
10
+
11
+ All window manipulation functions called via JavaScript IPC cause immediate crashes with the following error:
12
+
13
+ ```
14
+ thread 'main' panicked at wry-0.47.2\src\webview2\mod.rs:812:58:
15
+ called `Result::unwrap()` on an `Err` value: http::Error(InvalidUri(InvalidFormat))
16
+ ```
17
+
18
+ ### Affected Functions
19
+
20
+ The following `window.msger` API functions are **DISABLED** to prevent crashes:
21
+
22
+ - ❌ `msger.toggleFullscreen()` - Crashes
23
+ - ❌ `msger.setFullscreen(enabled)` - Crashes
24
+ - ❌ `msger.minimize()` - Crashes
25
+ - ❌ `msger.maximize()` - Crashes
26
+ - ❌ `msger.setSize(width, height)` - Crashes
27
+ - ❌ `msger.setPosition(x, y)` - Crashes
28
+ - ❌ `msger.setAlwaysOnTop(enabled)` - Crashes
29
+ - ❌ `msger.setTitle(title)` - Crashes
30
+ - ❌ `msger.close(result)` - Crashes (ALL IPC is broken!)
31
+
32
+ ### Working Functions
33
+
34
+ These functions still work because they don't use IPC:
35
+
36
+ - ✅ `msger.saveData(key, value)` - Uses localStorage only
37
+ - ✅ `msger.loadData(key, defaultValue)` - Uses localStorage only
38
+ - ✅ `msger.removeData(key)` - Uses localStorage only
39
+ - ✅ `msger.clearData()` - Uses localStorage only
40
+ - ✅ `msger.isAvailable()` - Pure JavaScript check
41
+ - ✅ `msger.testHello()` - Pure JavaScript test
42
+
43
+ **Note:** Data saved with `saveData()` **persists across restarts** because it uses localStorage!
44
+
45
+ ### Workarounds
46
+
47
+ #### Window Manipulation
48
+ Use **CLI arguments** when launching msger instead of JavaScript API:
49
+
50
+ ```bash
51
+ # Fullscreen
52
+ node cli.js -url page.html -fullscreen
53
+
54
+ # Window size
55
+ node cli.js -url page.html -size 1024,768
56
+
57
+ # Window position
58
+ node cli.js -url page.html -pos 100,100
59
+
60
+ # Always on top
61
+ node cli.js -url page.html -alwaysOnTop
62
+
63
+ # Window title
64
+ node cli.js -url page.html -title "My App"
65
+ ```
66
+
67
+ #### Fullscreen Toggle
68
+ Use the **F11 keyboard shortcut** instead of JavaScript:
69
+ - Press F11 to enter fullscreen
70
+ - Press F11 again or Esc to exit fullscreen
71
+
72
+ This works because F11 is handled at the native window level, not through IPC.
73
+
74
+ ### Technical Details
75
+
76
+ **Root Cause:**
77
+ The wry 0.47.2 library has a bug where window manipulation operations trigger an internal code path that tries to parse something as an HTTP URI. When this parse fails, it panics in FFI (Foreign Function Interface) code that cannot unwind, causing an immediate abort.
78
+
79
+ **Why catch_unwind Doesn't Work:**
80
+ The panic occurs in `extern "C"` function boundaries (FFI with WebView2 COM interface), which cannot be unwound across. The `std::panic::catch_unwind` wrapper we added catches Rust panics, but not panics in FFI code marked as "cannot unwind".
81
+
82
+ **Crash Location:**
83
+ `C:\Users\Bob\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wry-0.47.2\src\webview2\mod.rs:812:58`
84
+
85
+ ### Potential Solutions
86
+
87
+ 1. **Update wry** - Check if newer versions (0.48+) have fixed this issue
88
+ 2. **Use tauri** - Switch to the full Tauri framework which may have better WebView2 integration
89
+ 3. **Alternative WebView** - Consider using a different WebView library
90
+ 4. **Native UI** - Build a native UI instead of HTML/JavaScript for window controls
91
+
92
+ ### Testing
93
+
94
+ Use the provided test page to verify which functions work:
95
+
96
+ ```bash
97
+ node cli.js -url test-msger-functions.html -size 800,900
98
+ ```
99
+
100
+ All disabled functions will:
101
+ - Return `false`
102
+ - Log an error message to the console
103
+ - NOT crash the application
104
+
105
+ ## Other Known Issues
106
+
107
+ ### F11 Key Sometimes Ignored
108
+
109
+ **Status:** Under Investigation
110
+ **Severity:** Medium
111
+
112
+ F11 keyboard shortcut for fullscreen may be captured by WebView2 before reaching the window event handler.
113
+
114
+ **Workaround:** Launch with `-fullscreen` flag to start in fullscreen mode.
115
+
116
+ ---
117
+
118
+ **Last Updated:** 2025-11-05
119
+ **msger Version:** 0.1.57
120
+ **wry Version:** 0.47.2
121
+ **tao Version:** 0.30
@@ -0,0 +1,162 @@
1
+ # msger JavaScript API - Current State (v0.1.74)
2
+
3
+ ## Summary
4
+
5
+ **The msger JavaScript API is intentionally minimal.** The real value of msger is the CLI tool itself, not a JavaScript library.
6
+
7
+ ## Current API (v0.1.74)
8
+
9
+ ```javascript
10
+ // Only one function:
11
+ msger.isAvailable() // Returns true if running in msger environment
12
+ ```
13
+
14
+ **That's it!** Everything else uses native browser APIs.
15
+
16
+ ## Recommended: Use Native Browser APIs
17
+
18
+ ```javascript
19
+ // Storage - use native localStorage
20
+ localStorage.setItem('key', JSON.stringify(value));
21
+ const value = JSON.parse(localStorage.getItem('key'));
22
+
23
+ // Close window - use native API
24
+ window.close();
25
+
26
+ // File input - use native HTML
27
+ <input type="file" onchange="handleFiles(this.files)">
28
+ ```
29
+
30
+ **Why native APIs?**
31
+ - Works in any browser context, not just msger
32
+ - No dependency on msger-specific code
33
+ - Your app is portable
34
+ - Standard, well-documented APIs
35
+
36
+ ## What msger Actually Provides
37
+
38
+ **msger = Fast CLI wrapper for native windows + HTML + button results**
39
+
40
+ 1. **Create native OS window** (~50-200ms startup)
41
+ 2. **Display HTML/URL content** (uses OS webview)
42
+ 3. **Return button/input results** to parent process (template mode only)
43
+ 4. **Configure everything at launch** via CLI flags
44
+
45
+ ### Example Usage
46
+
47
+ ```bash
48
+ # Simple dialog
49
+ msger -message "Save changes?" -buttons Yes No Cancel
50
+ # Returns: {"button": "Yes"}
51
+
52
+ # HTML with input
53
+ msger -html "<h1>Enter Name</h1><input id='name'>" -buttons OK
54
+ # Returns: {"button": "OK", "value": "John"}
55
+
56
+ # URL viewer
57
+ msger -url "https://example.com" -size 1024,768
58
+ ```
59
+
60
+ ## Future File/Window APIs (Not Yet Implemented)
61
+
62
+ When you have time for debugging, these will be added:
63
+
64
+ ### File System API
65
+ ```javascript
66
+ // File dialogs (always safe)
67
+ await msger.selectFile()
68
+ await msger.selectFiles()
69
+ await msger.saveFileAs(content, name)
70
+ await msger.selectFolder()
71
+
72
+ // Direct path access (requires --allowFs flag)
73
+ await msger.fs.read(path)
74
+ await msger.fs.write(path, content)
75
+ await msger.fs.list(path)
76
+ await msger.fs.exists(path)
77
+ ```
78
+
79
+ ### Window Manipulation API
80
+ ```javascript
81
+ // Runtime window control (template mode only)
82
+ await msger.setSize(width, height)
83
+ await msger.setPosition(x, y)
84
+ await msger.setTitle(title)
85
+ await msger.setAlwaysOnTop(enabled)
86
+ ```
87
+
88
+ **Why not implemented yet?**
89
+ - Requires bidirectional IPC pattern
90
+ - Needs debugging time
91
+ - Works only in template mode (URL mode IPC crashes)
92
+
93
+ See SESSION-NOTES.md for implementation approach.
94
+
95
+ ## Platform App Development
96
+
97
+ **Current approach (without file API):**
98
+ - Use native `<input type="file">` for file selection (gets file content, not path)
99
+ - Use localStorage for persistence
100
+ - Configure window at startup via CLI flags
101
+ - Use template mode for button/input collection
102
+
103
+ **Future approach (with file API):**
104
+ - Native file dialogs for file selection (gets actual paths)
105
+ - Direct file read/write/list operations (with --allowFs flag)
106
+ - Runtime window manipulation
107
+ - Full platform app capabilities
108
+
109
+ ## Technical Details
110
+
111
+ ### IPC Status
112
+ - ✅ **Template mode** (`-message`, `-html`, `-htmlfrom`): IPC works perfectly
113
+ - ❌ **URL mode** (`-url`): IPC crashes (wry 0.47.2 bug)
114
+
115
+ ### What Works Where
116
+
117
+ | Feature | Template Mode | URL Mode |
118
+ |---------|---------------|----------|
119
+ | Native localStorage | ✅ | ✅ |
120
+ | Native window.close() | ✅ | ✅ |
121
+ | Button results via IPC | ✅ | ❌ (crashes) |
122
+ | Future file API | ✅ (when implemented) | ❌ (IPC broken) |
123
+ | Future window API | ✅ (when implemented) | ❌ (IPC broken) |
124
+
125
+ ### Storage Location
126
+ - Windows: `%LOCALAPPDATA%\msger\webview2\`
127
+ - Each app gets isolated storage
128
+ - Each URL origin gets its own partition
129
+
130
+ ## Comparison to Electron
131
+
132
+ | Feature | msger | Electron |
133
+ |---------|-------|----------|
134
+ | Startup time | ~50-200ms | ~2-3s |
135
+ | Binary size | ~2-5MB | ~100MB |
136
+ | Memory usage | ~20-50MB | ~100-200MB |
137
+ | HTML/CSS support | ✅ (OS webview) | ✅ (Chromium) |
138
+ | JavaScript API | Minimal (by design) | Rich |
139
+ | File system access | Future (dialog + path) | Full |
140
+ | Cross-platform | Win/Linux/Pi | Win/Mac/Linux |
141
+
142
+ ## Philosophy
143
+
144
+ **msger is a CLI tool, not a framework.**
145
+
146
+ - Minimal JavaScript API by design
147
+ - Prefer native browser APIs
148
+ - Fast, lightweight, simple
149
+ - Configure via CLI, not runtime APIs
150
+ - Perfect for dialogs, notifications, simple HTML displays
151
+ - Future: Full platform app support with file/window APIs
152
+
153
+ Use Electron/Tauri if you need:
154
+ - Rich JavaScript APIs out of the box
155
+ - Complex desktop app features
156
+ - Native menus, system tray, etc.
157
+
158
+ Use msger if you want:
159
+ - Fast startup and low memory
160
+ - Simple HTML display with button results
161
+ - Minimal dependencies
162
+ - Platform apps (future, with file API)
package/MSGER-API.md ADDED
@@ -0,0 +1,376 @@
1
+ # msger JavaScript API
2
+
3
+ The **msger** JavaScript API provides window control, data persistence, and file system access for applications running inside msger.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Window Control](#window-control)
9
+ - [Data Persistence](#data-persistence)
10
+ - [File System Access](#file-system-access)
11
+ - [Browser Compatibility](#browser-compatibility)
12
+
13
+ ## Installation
14
+
15
+ ### TypeScript Definitions
16
+
17
+ ```bash
18
+ npm install @bobfrankston/msgerdefs
19
+ ```
20
+
21
+ ```typescript
22
+ import type { MsgerAPI } from '@bobfrankston/msgerdefs';
23
+ import { isMsger, getMsgerAPI } from '@bobfrankston/msgerdefs';
24
+ ```
25
+
26
+ ## Window Control
27
+
28
+ Control the msger window from JavaScript.
29
+
30
+ ### toggleFullscreen()
31
+
32
+ Toggle fullscreen mode on/off.
33
+
34
+ ```javascript
35
+ msger.toggleFullscreen();
36
+ ```
37
+
38
+ **Keyboard Shortcuts:**
39
+ - F11: Toggle fullscreen (native window level)
40
+ - Esc: Exit fullscreen or dismiss window
41
+
42
+ ### setFullscreen(enabled)
43
+
44
+ Set fullscreen state explicitly.
45
+
46
+ ```javascript
47
+ msger.setFullscreen(true); // Enter fullscreen
48
+ msger.setFullscreen(false); // Exit fullscreen
49
+ ```
50
+
51
+ ### minimize()
52
+
53
+ Minimize the window to taskbar.
54
+
55
+ ```javascript
56
+ msger.minimize();
57
+ ```
58
+
59
+ ### maximize()
60
+
61
+ Toggle between maximized and restored window state.
62
+
63
+ ```javascript
64
+ msger.maximize(); // Maximize or restore
65
+ ```
66
+
67
+ ### setSize(width, height)
68
+
69
+ Set window dimensions in pixels.
70
+
71
+ ```javascript
72
+ msger.setSize(800, 600);
73
+ msger.setSize(1920, 1080);
74
+ ```
75
+
76
+ ### setPosition(x, y)
77
+
78
+ Move window to specific screen coordinates.
79
+
80
+ ```javascript
81
+ msger.setPosition(100, 100); // Top-left corner
82
+ msger.setPosition(0, 0); // Screen origin
83
+ ```
84
+
85
+ ### setAlwaysOnTop(enabled)
86
+
87
+ Keep window above other windows.
88
+
89
+ ```javascript
90
+ msger.setAlwaysOnTop(true); // Stay on top
91
+ msger.setAlwaysOnTop(false); // Normal behavior
92
+ ```
93
+
94
+ ### setTitle(title)
95
+
96
+ Change window title.
97
+
98
+ ```javascript
99
+ msger.setTitle('My Application');
100
+ msger.setTitle(`Status: ${status}`);
101
+ ```
102
+
103
+ ### close(result?)
104
+
105
+ Close the window with optional result data.
106
+
107
+ ```javascript
108
+ // Close with default dismissed result
109
+ msger.close();
110
+
111
+ // Close with custom result
112
+ msger.close({
113
+ button: 'OK',
114
+ value: 'user input',
115
+ form: { name: 'Bob', email: 'bob@example.com' }
116
+ });
117
+ ```
118
+
119
+ ## Data Persistence
120
+
121
+ Save and load data using localStorage (with `msger_` prefix).
122
+
123
+ ### saveData(key, value)
124
+
125
+ Store data persistently. Value is automatically JSON.stringify'd.
126
+
127
+ ```javascript
128
+ // Save simple values
129
+ msger.saveData('username', 'bob');
130
+ msger.saveData('count', 42);
131
+
132
+ // Save objects
133
+ msger.saveData('userPrefs', {
134
+ theme: 'dark',
135
+ fontSize: 14,
136
+ notifications: true
137
+ });
138
+
139
+ // Save arrays
140
+ msger.saveData('recentFiles', ['/path/to/file1.txt', '/path/to/file2.txt']);
141
+ ```
142
+
143
+ **Returns:** `true` on success, `false` on failure
144
+
145
+ ### loadData(key, defaultValue?)
146
+
147
+ Load data from storage with optional default.
148
+
149
+ ```javascript
150
+ // Load with default
151
+ const username = msger.loadData('username', 'guest');
152
+ const prefs = msger.loadData('userPrefs', {theme: 'light'});
153
+
154
+ // Load without default (returns undefined if not found)
155
+ const data = msger.loadData('optionalData');
156
+ ```
157
+
158
+ **Returns:** Stored value (parsed from JSON) or `defaultValue`
159
+
160
+ ### removeData(key)
161
+
162
+ Delete a specific key from storage.
163
+
164
+ ```javascript
165
+ msger.removeData('tempData');
166
+ msger.removeData('oldSettings');
167
+ ```
168
+
169
+ **Returns:** `true` on success, `false` on failure
170
+
171
+ ### clearData()
172
+
173
+ Clear all msger-prefixed data from localStorage.
174
+
175
+ ```javascript
176
+ msger.clearData(); // Removes all msger_* keys
177
+ ```
178
+
179
+ **Returns:** `true` on success, `false` on failure
180
+
181
+ **Note:** Only removes keys with `msger_` prefix, preserving other localStorage data.
182
+
183
+ ## File System Access
184
+
185
+ **Status:** Coming soon
186
+
187
+ ### File Dialogs (Safe - Always Available)
188
+
189
+ ```javascript
190
+ // Select single file
191
+ const file = await msger.fs.selectFile({
192
+ title: 'Open File',
193
+ filters: [{name: 'Text', extensions: ['txt', 'md']}]
194
+ });
195
+ if (file) {
196
+ console.log(file.name, file.path, file.content);
197
+ }
198
+
199
+ // Select multiple files
200
+ const files = await msger.fs.selectFiles({
201
+ title: 'Open Files'
202
+ });
203
+
204
+ // Save file dialog
205
+ const path = await msger.fs.saveFileAs(
206
+ 'File content here',
207
+ 'default.txt',
208
+ {filters: [{name: 'Text', extensions: ['txt']}]}
209
+ );
210
+
211
+ // Select folder
212
+ const folder = await msger.fs.selectFolder({
213
+ title: 'Select Output Folder'
214
+ });
215
+ ```
216
+
217
+ ### Direct File Access (Requires `allowFs: true`)
218
+
219
+ ```javascript
220
+ // Read file
221
+ const content = await msger.fs.read('/path/to/file.txt');
222
+
223
+ // Write file
224
+ await msger.fs.write('/path/to/file.txt', 'Hello World');
225
+
226
+ // List directory
227
+ const files = await msger.fs.list('/path/to/dir');
228
+ files.forEach(file => {
229
+ console.log(file.name, file.isDir, file.size);
230
+ });
231
+
232
+ // Check existence
233
+ const exists = await msger.fs.exists('/path/to/file.txt');
234
+
235
+ // Delete file
236
+ await msger.fs.delete('/path/to/file.txt');
237
+ ```
238
+
239
+ **Note:** Direct file access requires launching msger with `--allowFs` flag for security.
240
+
241
+ ## Browser Compatibility
242
+
243
+ Use `getMsgerAPI()` for cross-platform code that works in both msger and browsers:
244
+
245
+ ```typescript
246
+ import { getMsgerAPI, isMsger } from '@bobfrankston/msgerdefs';
247
+
248
+ const msger = getMsgerAPI();
249
+
250
+ // Data persistence works in both!
251
+ msger.saveData('userPrefs', {theme: 'dark'});
252
+ const prefs = msger.loadData('userPrefs', {theme: 'light'});
253
+
254
+ // Window control - only works in msger (no-op in browser)
255
+ if (isMsger()) {
256
+ msger.setTitle('My App');
257
+ msger.toggleFullscreen();
258
+ }
259
+
260
+ // File system - only available in msger
261
+ if (msger.fs) {
262
+ const file = await msger.fs.selectFile();
263
+ }
264
+ ```
265
+
266
+ ### Browser Behavior
267
+
268
+ | Feature | msger | Browser |
269
+ |---------|-------|---------|
270
+ | Data persistence | localStorage with `msger_` prefix | localStorage with `msger_` prefix |
271
+ | Window control | Full support | No-op (except `setTitle` → `document.title`) |
272
+ | File system | Full support (with `allowFs` flag) | Not available (`fs` is `undefined`) |
273
+
274
+ ### Detection
275
+
276
+ ```javascript
277
+ import { isMsger } from '@bobfrankston/msgerdefs';
278
+
279
+ if (isMsger()) {
280
+ console.log('Running in msger!');
281
+ // Use msger-specific features
282
+ } else {
283
+ console.log('Running in browser');
284
+ // Use browser fallbacks
285
+ }
286
+ ```
287
+
288
+ ## Examples
289
+
290
+ ### Persistent Settings
291
+
292
+ ```javascript
293
+ // Save user preferences
294
+ function saveSettings(settings) {
295
+ msger.saveData('settings', settings);
296
+ }
297
+
298
+ // Load with defaults
299
+ function loadSettings() {
300
+ return msger.loadData('settings', {
301
+ theme: 'light',
302
+ fontSize: 14,
303
+ autoSave: true
304
+ });
305
+ }
306
+
307
+ // Apply settings on startup
308
+ const settings = loadSettings();
309
+ if (settings.theme === 'dark') {
310
+ document.body.classList.add('dark-theme');
311
+ }
312
+ ```
313
+
314
+ ### Fullscreen Presentation Mode
315
+
316
+ ```javascript
317
+ function enterPresentationMode() {
318
+ msger.setFullscreen(true);
319
+ msger.setAlwaysOnTop(true);
320
+ msger.saveData('wasPresenting', true);
321
+ }
322
+
323
+ function exitPresentationMode() {
324
+ msger.setFullscreen(false);
325
+ msger.setAlwaysOnTop(false);
326
+ msger.removeData('wasPresenting');
327
+ }
328
+
329
+ // Restore presentation mode on reload
330
+ if (msger.loadData('wasPresenting', false)) {
331
+ enterPresentationMode();
332
+ }
333
+ ```
334
+
335
+ ### Window Size Presets
336
+
337
+ ```javascript
338
+ const windowSizes = {
339
+ small: [600, 400],
340
+ medium: [800, 600],
341
+ large: [1200, 800],
342
+ hd: [1920, 1080]
343
+ };
344
+
345
+ function setWindowSize(preset) {
346
+ const [width, height] = windowSizes[preset];
347
+ msger.setSize(width, height);
348
+ msger.saveData('windowSize', preset);
349
+ }
350
+
351
+ // Restore last size on startup
352
+ const lastSize = msger.loadData('windowSize', 'medium');
353
+ setWindowSize(lastSize);
354
+ ```
355
+
356
+ ## Command Line Integration
357
+
358
+ ```bash
359
+ # Launch with fullscreen
360
+ msger -url "file:///app/index.html" --fullscreen
361
+
362
+ # Launch with specific size and position
363
+ msger -url "https://example.com" -size 1024,768 -pos 100,100
364
+
365
+ # Launch always on top
366
+ msger -url "file:///app/monitor.html" --ontop --detach
367
+
368
+ # Launch with file system access (future)
369
+ msger -url "file:///app/editor.html" --allowFs
370
+ ```
371
+
372
+ ## See Also
373
+
374
+ - [README.md](README.md) - Main msger documentation
375
+ - [msgerdefs](msgerdefs/) - TypeScript definitions package
376
+ - [FULLSCREEN-FEATURE.md](FULLSCREEN-FEATURE.md) - Fullscreen implementation details