@hicccc77/electron-liquid-glass 0.1.1
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 +21 -0
- package/README.md +155 -0
- package/index.d.ts +91 -0
- package/index.js +77 -0
- package/package.json +53 -0
- package/prebuilds/win32-x64/@hicccc77+electron-liquid-glass.node +0 -0
- package/scripts/install-guard.cjs +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hicccc77
|
|
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
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Electron-Liquid-Glass
|
|
2
|
+
|
|
3
|
+
Windows 全局原生低延迟「液态玻璃」背景面板,for Electron。
|
|
4
|
+
|
|
5
|
+
Low-latency native liquid glass backdrop panels for Electron apps, powered by DXGI Desktop Duplication + D3D11 + DirectComposition.
|
|
6
|
+
|
|
7
|
+
把液态玻璃渲染为一个全局独立的原生窗口,放在你的 Electron 窗口正下方作为实时背景层。
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
> 真实渲染截图(非合成图):通知卡片为 Electron 透明窗口,卡片背后的折射、模糊、色散与驱动文字反色的亮度采样全部来自本模块的原生面板。
|
|
12
|
+
|
|
13
|
+
## 特性
|
|
14
|
+
|
|
15
|
+
- **真折射,非毛玻璃**:圆角矩形 SDF 透镜位移,边缘可见清晰的背景折射与色散,中心通透
|
|
16
|
+
- **6ms 级响应**:DXGI 零拷贝拿 GPU 桌面纹理,D3D11 渲染,DirectComposition 直接上屏,全程不落 CPU
|
|
17
|
+
- **深度节能**:事件驱动——桌面不动不画、脏区不相交不画、无面板自动休眠
|
|
18
|
+
- **自适应反色支持**:内置亮度带采样(均值色 + luma p15/p85),重绘驱动、与画面同帧推送(上限 ~60Hz),驱动上层文字明暗自适应
|
|
19
|
+
- **z 序锚定**:面板自动钉在指定 Electron 窗口正下方,并周期性重申(防其他置顶窗口插队)
|
|
20
|
+
- **防自采集回环**:`WDA_EXCLUDEFROMCAPTURE` 把面板从一切屏幕捕获中排除
|
|
21
|
+
- **零 Electron 侵入**:纯 N-API 原生模块 + 命令队列,跨 Electron 版本 ABI 稳定,任何 Electron 应用可直接接入
|
|
22
|
+
|
|
23
|
+
## 原理
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
DXGI Desktop Duplication(零拷贝 GPU 桌面纹理,仅画面变化时出帧)
|
|
27
|
+
→ D3D11 三趟着色(半分辨率可分离高斯模糊 ×2 → 圆角 SDF 透镜位移 + RGB 色散 + 饱和度 + 圆角 AA)
|
|
28
|
+
→ DirectComposition 预乘 alpha 交换链直接上屏(不经过 DWM 重定向位图)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- 全链路在一个独立工作线程 + GPU 上完成,无像素跨进程/跨线程拷贝
|
|
32
|
+
- 面板窗口 `WS_EX_NOREDIRECTIONBITMAP + WS_EX_TRANSPARENT + WS_EX_NOACTIVATE`(鼠标穿透、不抢焦点、不进任务栏)
|
|
33
|
+
- JS 侧所有调用经命令队列异步投递到工作线程,天然线程安全
|
|
34
|
+
- 分层协作:本面板负责「玻璃背后的世界」(折射/模糊/色散),你的 Electron 透明窗口负责「玻璃表面」(文字、高光、描边、tint)
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
┌─ Electron 透明窗口(内容层:文字 / 高光 / 边框)─┐ ← 你的应用
|
|
38
|
+
│ ┌─ 原生玻璃面板(折射层,钉在正下方)────────┐ │ ← 本模块
|
|
39
|
+
│ │ 实时折射的桌面背景 │ │
|
|
40
|
+
└──┴────────────────────────────────────────────┴──┘
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 系统要求
|
|
44
|
+
|
|
45
|
+
| 平台 | 支持状态 |
|
|
46
|
+
|---|---|
|
|
47
|
+
| Windows 10 2004 (build 19041)+ | 完整支持 |
|
|
48
|
+
| Windows 更旧版本 | `isSupported()` 返回 `false`(缺少 `WDA_EXCLUDEFROMCAPTURE`) |
|
|
49
|
+
| macOS / Linux | 模块可正常安装加载,`isSupported()` 返回 `false`,请回退到你自己的方案(如 Chromium 桌面流 + WebGL);macOS 原生后端(ScreenCaptureKit + Metal)在路线图中 |
|
|
50
|
+
|
|
51
|
+
## 安装
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @hicccc77/electron-liquid-glass
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
npm 包内置 win32-x64 预编译二进制(N-API 8,跨 Electron / Node 版本 ABI 稳定),**安装零编译、无需任何构建工具链**;非 Windows 平台上没有预编译产物时模块自动降级(`isSupported()` 返回 `false`),同样不触发编译。
|
|
58
|
+
|
|
59
|
+
Electron 打包(electron-builder)注意把 `.node` 解包出 asar:
|
|
60
|
+
|
|
61
|
+
```jsonc
|
|
62
|
+
"build": { "asarUnpack": ["node_modules/@hicccc77/electron-liquid-glass/**/*"] }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
从源码构建(仓库检出,Windows):需要 Node.js 18+、VS Build Tools(C++ 桌面工作负载)+ Python,`npm run build` 产出 `build/Release`,`npm run prebuilds` 产出随包分发的 `prebuilds/win32-x64`。
|
|
66
|
+
|
|
67
|
+
## 快速上手(Electron 主进程)
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const { screen } = require('electron')
|
|
71
|
+
const glass = require('@hicccc77/electron-liquid-glass')
|
|
72
|
+
|
|
73
|
+
if (glass.isSupported()) {
|
|
74
|
+
const dpr = screen.getPrimaryDisplay().scaleFactor
|
|
75
|
+
const panel = glass.createPanel({
|
|
76
|
+
// 屏幕物理像素
|
|
77
|
+
x: 1560, y: 40, width: 344, height: 96,
|
|
78
|
+
cornerRadius: 20, blurSigma: 5,
|
|
79
|
+
displacementScale: 70, aberrationIntensity: 2, saturation: 1.4,
|
|
80
|
+
dpr,
|
|
81
|
+
anchorWindow: myToastWindow, // 面板钉在该 BrowserWindow 正下方
|
|
82
|
+
lumaBands: [ // 自适应反色的亮度采样带(面板本地物理像素)
|
|
83
|
+
{ id: 0, x: 0, y: 0, width: 344, height: 48 },
|
|
84
|
+
{ id: 1, x: 0, y: 48, width: 344, height: 48 }
|
|
85
|
+
],
|
|
86
|
+
onLuma: bands => {
|
|
87
|
+
// bands = { '0': { r, g, b, darkTail, lightTail }, '1': ... }
|
|
88
|
+
// 均值 RGB + luma p15/p85(gamma 域 0~255)。重绘驱动:
|
|
89
|
+
// 背景变化的同一帧推送(上限 ~60Hz),桌面静止时不推送
|
|
90
|
+
// 据此切换上层文字的明暗配色
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
panel.show(120) // 淡入 120ms
|
|
95
|
+
panel.setBounds({ x, y, width, height }) // 跟随窗口移动/改尺寸
|
|
96
|
+
panel.hide(240) // 淡出
|
|
97
|
+
panel.destroy()
|
|
98
|
+
} else {
|
|
99
|
+
// 回退:Chromium 桌面流 + WebGL 折射管线,或静态 backdrop-filter
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
上层窗口只需把玻璃区域留透明(Electron `transparent: true` 天然满足),自己绘制文字/描边/高光/tint 等内容层,折射背景由本面板提供。
|
|
104
|
+
|
|
105
|
+
## API
|
|
106
|
+
|
|
107
|
+
完整类型见 [`index.d.ts`](index.d.ts)。所有面板方法线程安全。
|
|
108
|
+
|
|
109
|
+
| 方法 | 说明 |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `isSupported()` | 当前环境是否可用(Windows 10 2004+ 且原生二进制已构建) |
|
|
112
|
+
| `createPanel(options)` | 创建面板,返回句柄;不可用时返回 `null` |
|
|
113
|
+
| `panel.show(fadeMs?)` / `panel.hide(fadeMs?)` | 淡入 / 淡出(`0` = 立即) |
|
|
114
|
+
| `panel.setBounds(bounds)` | 移动 / 改尺寸(物理像素) |
|
|
115
|
+
| `panel.setParams(params)` | 更新视觉参数(圆角、模糊、位移、色散、饱和度) |
|
|
116
|
+
| `panel.anchor(windowOrHwnd)` | 重新钉到某窗口正下方(接受 `BrowserWindow` 或 HWND Buffer) |
|
|
117
|
+
| `panel.setLumaBands(bands)` / `panel.onLuma(cb)` | 更新亮度采样带 / 回调 |
|
|
118
|
+
| `panel.destroy()` | 销毁面板 |
|
|
119
|
+
| `shutdown()` | 停止工作线程并销毁所有面板 |
|
|
120
|
+
|
|
121
|
+
## 实测(1080p,动态背景,Windows 11)
|
|
122
|
+
|
|
123
|
+
| 指标 | Chromium 流方案(getUserMedia + WebGL) | 本模块 |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| 感知位置滞后(中位 / p90) | 77ms / 89ms | **6ms / 6ms** |
|
|
126
|
+
| 满载 CPU 增量(主+GPU+渲染进程合计) | ~1.5% | **~0.3%** |
|
|
127
|
+
| 静止桌面开销 | 持续采集出帧 | **0**(事件驱动) |
|
|
128
|
+
| 首帧启动 | ~80-300ms(getUserMedia 协商) | **<150ms**(面板常驻复用后为 0) |
|
|
129
|
+
| 40 轮通知压测 | — | 面板 1 建 81 复用,内存零增长,零异常 |
|
|
130
|
+
|
|
131
|
+
测量方法:同帧差分法——同一帧屏幕采集内对比玻璃呈现内容与背景真值条纹的计数差,两个时间戳均来自绘制时刻,结果与探针自身延迟无关。
|
|
132
|
+
|
|
133
|
+
## 源码结构
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
src/
|
|
137
|
+
├── addon.cc N-API 绑定层(参数解析、亮度回调线程安全投递)
|
|
138
|
+
├── session.cc/h 调度中枢:独占工作线程跑「采集→渲染→上屏」闭环、命令队列、节能策略
|
|
139
|
+
├── capture.cc/h DXGI Desktop Duplication 采集(零拷贝 GPU 纹理 + 脏区)
|
|
140
|
+
├── renderer.cc/h D3D11 三趟玻璃管线 + 亮度带直方图采样
|
|
141
|
+
├── panel.cc/h DirectComposition 无重定向位图窗口、淡入淡出、z 序锚定、捕获排除
|
|
142
|
+
├── d3d_utils.cc/h 设备创建辅助
|
|
143
|
+
└── addon_stub.cc 非 Windows 桩(isSupported() = false)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 已知限制
|
|
147
|
+
|
|
148
|
+
- 目前仅 Windows 有原生实现(macOS ScreenCaptureKit + Metal 后端在路线图中,API 已按平台后端可插拔设计)
|
|
149
|
+
- 面板排除于截屏/录屏(`WDA_EXCLUDEFROMCAPTURE` 的语义,与内容保护窗口一致)
|
|
150
|
+
- 安全桌面(UAC / 锁屏)期间采集暂停,返回后自动恢复
|
|
151
|
+
- 多显示器:采集会话跟随首个可见面板所在显示器;跨屏移动面板会自动重建会话
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
[MIT](LICENSE)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* electron-liquid-glass
|
|
3
|
+
* Windows 原生低延迟液态玻璃背景面板(DXGI Desktop Duplication + D3D11 + DirectComposition)
|
|
4
|
+
*
|
|
5
|
+
* 所有坐标与尺寸均为屏幕物理像素。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** 玻璃视觉参数(长度单位:物理像素) */
|
|
9
|
+
export interface GlassEffectParams {
|
|
10
|
+
/** 圆角半径,默认 20 */
|
|
11
|
+
cornerRadius?: number
|
|
12
|
+
/** 高斯模糊σ,默认 5 */
|
|
13
|
+
blurSigma?: number
|
|
14
|
+
/** 边缘位移强度(70 = 标准强度),默认 70 */
|
|
15
|
+
displacementScale?: number
|
|
16
|
+
/** RGB 色散强度(0~3),默认 2 */
|
|
17
|
+
aberrationIntensity?: number
|
|
18
|
+
/** 饱和度增益,默认 1.4 */
|
|
19
|
+
saturation?: number
|
|
20
|
+
/**
|
|
21
|
+
* 采样区相对面板的偏移。常规玻璃保持 0;
|
|
22
|
+
* 非 0 时面板折射别处内容(测量/特效场景)
|
|
23
|
+
*/
|
|
24
|
+
sourceOffsetX?: number
|
|
25
|
+
sourceOffsetY?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 亮度采样带(矩形为面板本地物理像素) */
|
|
29
|
+
export interface LumaBand {
|
|
30
|
+
id: number
|
|
31
|
+
x: number
|
|
32
|
+
y: number
|
|
33
|
+
width: number
|
|
34
|
+
height: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 亮度带统计:玻璃模糊层的均值色 + luma p15/p85(0~255) */
|
|
38
|
+
export interface LumaBandStats {
|
|
39
|
+
r: number
|
|
40
|
+
g: number
|
|
41
|
+
b: number
|
|
42
|
+
darkTail: number
|
|
43
|
+
lightTail: number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CreatePanelOptions extends GlassEffectParams {
|
|
47
|
+
x: number
|
|
48
|
+
y: number
|
|
49
|
+
width: number
|
|
50
|
+
height: number
|
|
51
|
+
/** 显示器缩放系数(内部几何常量按此缩放),默认 1 */
|
|
52
|
+
dpr?: number
|
|
53
|
+
/**
|
|
54
|
+
* 从屏幕捕获(截屏/录屏/DDA/WGC)中排除面板,默认 true。
|
|
55
|
+
* 必须保持 true 才能避免自采集反馈回路;仅测试可关。
|
|
56
|
+
*/
|
|
57
|
+
excludeFromCapture?: boolean
|
|
58
|
+
/** 把面板 z 序钉在该窗口正下方(Electron BrowserWindow 或 HWND Buffer) */
|
|
59
|
+
anchorWindow?: unknown
|
|
60
|
+
/** 亮度采样带(配合 onLuma 做自适应文字反色) */
|
|
61
|
+
lumaBands?: LumaBand[]
|
|
62
|
+
/**
|
|
63
|
+
* 亮度回调:bands 为 { [bandId]: LumaBandStats }。
|
|
64
|
+
* 重绘驱动:面板下方内容变化的同一帧推送(上限 ~60Hz),桌面静止时不推送
|
|
65
|
+
*/
|
|
66
|
+
onLuma?: (bands: Record<string, LumaBandStats>) => void
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface GlassPanel {
|
|
70
|
+
readonly id: number
|
|
71
|
+
/** 显示并淡入(默认 120ms) */
|
|
72
|
+
show(fadeMs?: number): void
|
|
73
|
+
/** 淡出并隐藏(默认 100ms;0 = 立即) */
|
|
74
|
+
hide(fadeMs?: number): void
|
|
75
|
+
destroy(): void
|
|
76
|
+
setBounds(bounds: { x: number; y: number; width: number; height: number }): void
|
|
77
|
+
/** 更新视觉参数(传完整参数对象,缺省字段回落默认值) */
|
|
78
|
+
setParams(params: GlassEffectParams): void
|
|
79
|
+
anchor(windowOrHwnd: unknown): void
|
|
80
|
+
setLumaBands(bands: LumaBand[]): void
|
|
81
|
+
onLuma(cb: (bands: Record<string, LumaBandStats>) => void): void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** 当前环境是否支持原生玻璃(Windows 10 2004+ 且原生二进制已构建) */
|
|
85
|
+
export function isSupported(): boolean
|
|
86
|
+
|
|
87
|
+
/** 创建玻璃面板;原生不可用时返回 null(调用方应回退) */
|
|
88
|
+
export function createPanel(options: CreatePanelOptions): GlassPanel | null
|
|
89
|
+
|
|
90
|
+
/** 停止工作线程并销毁所有面板(进程退出前自动调用) */
|
|
91
|
+
export function shutdown(): void
|
package/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// electron-liquid-glass JS 入口:原生模块加载守护 + 面板对象封装。
|
|
2
|
+
// node-gyp-build 依次尝试 prebuilds/<platform>-<arch>(npm 分发的预编译产物,
|
|
3
|
+
// N-API 8,无需使用者本地编译)与 build/Release(仓库内开发构建)。
|
|
4
|
+
// 原生不可用(非 Windows、系统过旧、无预编译产物)时 isSupported() 返回 false,
|
|
5
|
+
// 调用方据此回退自己的方案(如 Chromium 屏幕采集管线)。
|
|
6
|
+
let native = null
|
|
7
|
+
try {
|
|
8
|
+
native = require('node-gyp-build')(__dirname)
|
|
9
|
+
} catch {
|
|
10
|
+
native = null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const panels = new Map()
|
|
14
|
+
let lumaHooked = false
|
|
15
|
+
|
|
16
|
+
function ensureLumaDispatch() {
|
|
17
|
+
if (lumaHooked || !native) return
|
|
18
|
+
lumaHooked = true
|
|
19
|
+
native.setLumaCallback((panelId, bands) => {
|
|
20
|
+
const panel = panels.get(panelId)
|
|
21
|
+
if (panel && panel._onLuma) panel._onLuma(bands)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isSupported() {
|
|
26
|
+
return Boolean(native && native.isSupported())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 创建玻璃面板(所有长度均为物理像素;dpr 用于内部几何常量缩放)。
|
|
31
|
+
* 返回面板句柄对象;原生不可用时返回 null。
|
|
32
|
+
*/
|
|
33
|
+
function createPanel(options) {
|
|
34
|
+
if (!isSupported()) return null
|
|
35
|
+
const { onLuma, lumaBands, anchorWindow, ...config } = options
|
|
36
|
+
if (anchorWindow) config.anchorHwnd = resolveHwnd(anchorWindow)
|
|
37
|
+
|
|
38
|
+
const id = native.createPanel(config)
|
|
39
|
+
const panel = {
|
|
40
|
+
id,
|
|
41
|
+
_onLuma: onLuma ?? null,
|
|
42
|
+
show(fadeMs = 120) { native.showPanel(id, fadeMs) },
|
|
43
|
+
hide(fadeMs = 100) { native.hidePanel(id, fadeMs) },
|
|
44
|
+
destroy() {
|
|
45
|
+
panels.delete(id)
|
|
46
|
+
native.destroyPanel(id)
|
|
47
|
+
},
|
|
48
|
+
setBounds(bounds) { native.setPanelBounds(id, bounds) },
|
|
49
|
+
setParams(params) { native.setPanelParams(id, params) },
|
|
50
|
+
anchor(windowOrHwnd) { native.anchorPanel(id, resolveHwnd(windowOrHwnd)) },
|
|
51
|
+
setLumaBands(bands) { native.setLumaBands(id, bands) },
|
|
52
|
+
onLuma(cb) { panel._onLuma = cb }
|
|
53
|
+
}
|
|
54
|
+
panels.set(id, panel)
|
|
55
|
+
if (lumaBands) native.setLumaBands(id, lumaBands)
|
|
56
|
+
if (onLuma) ensureLumaDispatch()
|
|
57
|
+
return panel
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 接受 Electron BrowserWindow 或 getNativeWindowHandle() 的 Buffer
|
|
61
|
+
function resolveHwnd(windowOrHwnd) {
|
|
62
|
+
if (!windowOrHwnd) return null
|
|
63
|
+
if (Buffer.isBuffer(windowOrHwnd)) return windowOrHwnd
|
|
64
|
+
if (typeof windowOrHwnd.getNativeWindowHandle === 'function') {
|
|
65
|
+
return windowOrHwnd.getNativeWindowHandle()
|
|
66
|
+
}
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function shutdown() {
|
|
71
|
+
// 非 Windows 的桩实现只导出 isSupported/osBuild,其余入口必须判空
|
|
72
|
+
if (native && typeof native.shutdown === 'function') native.shutdown()
|
|
73
|
+
panels.clear()
|
|
74
|
+
lumaHooked = false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { isSupported, createPanel, shutdown, _native: native }
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hicccc77/electron-liquid-glass",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Low-latency native liquid glass backdrop panels for Electron apps (Windows: DXGI Desktop Duplication + D3D11 + DirectComposition)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "hicccc77",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/hicccc77/electron-liquid-glass.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/hicccc77/electron-liquid-glass#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/hicccc77/electron-liquid-glass/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"electron",
|
|
19
|
+
"liquid-glass",
|
|
20
|
+
"glassmorphism",
|
|
21
|
+
"backdrop",
|
|
22
|
+
"blur",
|
|
23
|
+
"native",
|
|
24
|
+
"directcomposition",
|
|
25
|
+
"desktop-duplication",
|
|
26
|
+
"d3d11",
|
|
27
|
+
"windows"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"install": "node scripts/install-guard.cjs",
|
|
31
|
+
"build": "node-gyp rebuild",
|
|
32
|
+
"prebuilds": "prebuildify --napi --strip",
|
|
33
|
+
"prepublishOnly": "node scripts/check-prebuilds.cjs"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"node-addon-api": "^8.5.0",
|
|
37
|
+
"node-gyp-build": "^4.8.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"prebuildify": "^6.0.1"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"index.js",
|
|
47
|
+
"index.d.ts",
|
|
48
|
+
"prebuilds/",
|
|
49
|
+
"scripts/install-guard.cjs",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// 显式 install 脚本:覆盖 npm 对含 binding.gyp 仓库的隐式 "node-gyp rebuild" 注入。
|
|
2
|
+
// npm 分发的 tarball 只带预编译产物(prebuilds/),不含源码与 binding.gyp:
|
|
3
|
+
// - 命中当前平台的 prebuild:直接通过(零编译)
|
|
4
|
+
// - 未命中(如 macOS/Linux):安静降级,运行时 isSupported() 返回 false
|
|
5
|
+
// 任何情况下 exit 0,绝不在使用者的 npm install 阶段失败或触发编译
|
|
6
|
+
try {
|
|
7
|
+
const resolved = require('node-gyp-build').path(require('path').join(__dirname, '..'))
|
|
8
|
+
console.log('[electron-liquid-glass] prebuild ready:', resolved)
|
|
9
|
+
} catch {
|
|
10
|
+
console.log(
|
|
11
|
+
'[electron-liquid-glass] no prebuild for ' + process.platform + '-' + process.arch +
|
|
12
|
+
', isSupported() will return false (see README for fallback guidance)'
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
process.exit(0)
|