@orielweb/api 0.5.0 → 0.6.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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 OrielWeb Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OrielWeb Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -55,21 +55,22 @@ npm install @orielweb/api
55
55
  | `menu` | ✅ 菜单树(`Menu` / `MenuItem` / `PredefinedMenuItem` / `Submenu` / `CheckMenuItem` / `IconMenuItem`)+ `popup` / `setAsAppMenu` / `setAsWindowMenu` |
56
56
  | `tray` | ✅ `TrayIcon`(B12,静态 3 + 实例 8),形状与 Tauri 一致 |
57
57
 
58
- ## 关闭接管:语义与 Tauri **相反**
58
+ ## 关闭接管:语义与 Tauri 一致
59
59
 
60
- Tauri 在回调里 `preventDefault()` 阻止关闭;本库是**宿主挂起、页面同意才关**:
60
+ 默认关闭,`preventDefault()` 才留下。handler(含 async)跑完后,没调 `preventDefault()`
61
+ 库会替你调 `destroy()`——迁移代码不用改:
61
62
 
62
63
  ```js
63
64
  const win = getCurrentWindow();
64
- const un = await win.onCloseRequested(async () => {
65
- if (await confirmDiscard()) await win.destroy(); // 同意关闭
66
- // 不同意:什么都不做,窗口留在打开状态
65
+ const un = await win.onCloseRequested(async (event) => {
66
+ if (!(await confirmDiscard())) event.preventDefault(); // 不关
67
+ // 不调:handler 返回后窗口关闭
67
68
  });
68
69
  ```
69
70
 
70
- 传进回调的 `event.preventDefault` 是**空操作**——保留它只是为了让迁移代码不抛 `TypeError`。
71
- 为什么不做成 Tauri 那样:Windows 的 `WM_CLOSE` 是同步消息、页面回执是异步 IPC,
72
- 宿主没法"等你回调跑完再决定"。订阅会自动打开宿主侧的关闭接管开关。
71
+ 宿主侧的形态是"挂起 + 推事件"(Windows 的 `WM_CLOSE` 是同步消息、页面回执是异步 IPC,
72
+ 宿主没法在中途等回调),"关不关"那一半由页面侧的包装层补上,与 Tauri 的实现是同一段逻辑。
73
+ 订阅会自动打开宿主侧的关闭接管开关,退订时关掉。
73
74
 
74
75
  ## `window` 方法的能力要求
75
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orielweb/api",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "OrielWeb 页面侧 API:模块名与 @tauri-apps/api 一一对应,迁移只需替换 import 前缀。",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,7 +25,9 @@
25
25
  "src",
26
26
  "types"
27
27
  ],
28
+ "sideEffects": false,
28
29
  "exports": {
30
+ "./package.json": "./package.json",
29
31
  "./core": {
30
32
  "types": "./types/core.d.ts",
31
33
  "default": "./src/core.js"