nexfep 0.1.0 → 0.1.2
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 +20 -20
- package/README-CN.md +2 -2
- package/README.md +2 -2
- package/index.js +121 -121
- package/package.json +4 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 zhuxiaojt
|
|
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
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zhuxiaojt
|
|
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
21
|
SOFTWARE.
|
package/README-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nexfep
|
|
2
2
|
|
|
3
|
-
语言: [English](https://github.com/
|
|
3
|
+
语言: [English](https://github.com/nexfteam/Nexfep/blob/main/README.md) | 简体中文(当前)
|
|
4
4
|
|
|
5
5
|
基于 @webviewjs/webview 的桌面应用框架
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
## 简介
|
|
14
14
|
|
|
15
|
-
Nexfep 是一个基于 [@webviewjs/webview](https://github.com/
|
|
15
|
+
Nexfep 是一个基于 [@webviewjs/webview](https://github.com/webviewjs/webview) 构建的桌面应用框架,使用 TypeScript 编写。它旨在为开发者提供一套简洁、高效的工具链,用于构建跨平台桌面应用。
|
|
16
16
|
|
|
17
17
|
框架采用窗口池管理机制,支持多窗口应用场景,如代码编辑器、聊天工具、仪表盘等。
|
|
18
18
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nexfep
|
|
2
2
|
|
|
3
|
-
Language: English(now) | [简体中文](https://github.com/
|
|
3
|
+
Language: English(now) | [简体中文](https://github.com/nexfteam/Nexfep/blob/main/README-CN.md)
|
|
4
4
|
|
|
5
5
|
A desktop application framework based on @webviewjs/webview
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ This project is currently in early development, with many core capabilities for
|
|
|
12
12
|
|
|
13
13
|
## Introduction
|
|
14
14
|
|
|
15
|
-
Nexfep is a desktop application framework built on [@webviewjs/webview](https://github.com/
|
|
15
|
+
Nexfep is a desktop application framework built on [@webviewjs/webview](https://github.com/webviewjs/webview), written in TypeScript. It aims to provide developers with a concise and efficient toolchain for building cross-platform desktop applications.
|
|
16
16
|
|
|
17
17
|
The framework uses a window pool management mechanism, supporting multi-window application scenarios such as code editors, chat tools, dashboards, etc.
|
|
18
18
|
|
package/index.js
CHANGED
|
@@ -102,118 +102,118 @@ class WindowPool {
|
|
|
102
102
|
}
|
|
103
103
|
async __injectControlFunctions(windowObj) {
|
|
104
104
|
console.log("Create INJECT_CODE");
|
|
105
|
-
const INJECT_CSS = `
|
|
106
|
-
[nexfep-area-drag],
|
|
107
|
-
[nexfep-area-drag] * {
|
|
108
|
-
-webkit-app-region: drag;
|
|
109
|
-
app-region: drag;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
[nexfep-element-drag] {
|
|
113
|
-
-webkit-app-region: drag;
|
|
114
|
-
app-region: drag;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
[nexfep-no-drag],
|
|
118
|
-
[nexfep-no-drag] * {
|
|
119
|
-
-webkit-app-region: no-drag !important;
|
|
120
|
-
app-region: no-drag !important;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
[nexfep-auto-drag],
|
|
124
|
-
[nexfep-auto-drag] * {
|
|
125
|
-
-webkit-app-region: drag;
|
|
126
|
-
app-region: drag;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
[nexfep-auto-drag] button,
|
|
130
|
-
[nexfep-auto-drag] input,
|
|
131
|
-
[nexfep-auto-drag] select,
|
|
132
|
-
[nexfep-auto-drag] textarea,
|
|
133
|
-
[nexfep-auto-drag] a {
|
|
134
|
-
-webkit-app-region: no-drag;
|
|
135
|
-
app-region: no-drag;
|
|
136
|
-
}
|
|
105
|
+
const INJECT_CSS = `
|
|
106
|
+
[nexfep-area-drag],
|
|
107
|
+
[nexfep-area-drag] * {
|
|
108
|
+
-webkit-app-region: drag;
|
|
109
|
+
app-region: drag;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
[nexfep-element-drag] {
|
|
113
|
+
-webkit-app-region: drag;
|
|
114
|
+
app-region: drag;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
[nexfep-no-drag],
|
|
118
|
+
[nexfep-no-drag] * {
|
|
119
|
+
-webkit-app-region: no-drag !important;
|
|
120
|
+
app-region: no-drag !important;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
[nexfep-auto-drag],
|
|
124
|
+
[nexfep-auto-drag] * {
|
|
125
|
+
-webkit-app-region: drag;
|
|
126
|
+
app-region: drag;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[nexfep-auto-drag] button,
|
|
130
|
+
[nexfep-auto-drag] input,
|
|
131
|
+
[nexfep-auto-drag] select,
|
|
132
|
+
[nexfep-auto-drag] textarea,
|
|
133
|
+
[nexfep-auto-drag] a {
|
|
134
|
+
-webkit-app-region: no-drag;
|
|
135
|
+
app-region: no-drag;
|
|
136
|
+
}
|
|
137
137
|
`;
|
|
138
|
-
const INJECT_CODE = `
|
|
139
|
-
// 事件监听
|
|
140
|
-
window.addEventListener("beforeunload", () => {
|
|
141
|
-
const MessageBody = { type: 'NexfepBeforeUnload' }
|
|
142
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// 窗口控制函数
|
|
146
|
-
window.close = () => {
|
|
147
|
-
const MessageBody = { type: 'NexfepCloseWindow' }
|
|
148
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
window.minimize = () => {
|
|
152
|
-
const MessageBody = { type: 'NexfepMinimizeWindow' }
|
|
153
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
window.unminimize = () => {
|
|
157
|
-
const MessageBody = { type: 'NexfepUnMinimizeWindow' }
|
|
158
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
window.maximize = () => {
|
|
162
|
-
const MessageBody = { type: 'NexfepMaximizeWindow' }
|
|
163
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
window.unmaximize = () => {
|
|
167
|
-
const MessageBody = { type: 'NexfepUnMaximizeWindow' }
|
|
168
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
169
|
-
};
|
|
170
|
-
window.setTitle = (title) => {
|
|
171
|
-
const MessageBody = { type: 'NexfepSetTitle', title: title }
|
|
172
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
window.openDevTools = () => {
|
|
176
|
-
const MessageBody = { type: 'NexfepOpenDevTools' }
|
|
177
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
window.closeDevTools = () => {
|
|
181
|
-
const MessageBody = { type: 'NexfepCloseDevTools' }
|
|
182
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
window.postMessage = (data) => {
|
|
186
|
-
const MessageBody = { type: 'CustomMessage', data: data }
|
|
187
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
window.eventCount = 0;
|
|
191
|
-
|
|
192
|
-
window.invoke = async (event, data) => {
|
|
193
|
-
const MessageBody = { type: 'NexfepInvoke', eventId: [${this.injectCount}, ++window.eventCount], event: event, data: data }
|
|
194
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
195
|
-
return new Promise((resolve, reject) => {
|
|
196
|
-
window.addEventListener("nexfep-invoke-result-"+${this.injectCount}+"-"+window.eventCount, (event) => {
|
|
197
|
-
window.removeEventListener("nexfep-invoke-result-"+${this.injectCount}+"-"+window.eventCount, event);
|
|
198
|
-
if(event.detail){
|
|
199
|
-
resolve(event.detail);
|
|
200
|
-
}else{
|
|
201
|
-
resolve();
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// 注入 CSS 样式
|
|
208
|
-
const style = document.createElement('style');
|
|
209
|
-
style.textContent = \`${INJECT_CSS}\`;
|
|
210
|
-
document.head.appendChild(style);
|
|
211
|
-
|
|
212
|
-
// 标记加载完成
|
|
213
|
-
window.isNexfepLoadDone = true;
|
|
214
|
-
|
|
215
|
-
// 触发加载完成事件
|
|
216
|
-
window.dispatchEvent(new Event('nexfep-load-done'));
|
|
138
|
+
const INJECT_CODE = `
|
|
139
|
+
// 事件监听
|
|
140
|
+
window.addEventListener("beforeunload", () => {
|
|
141
|
+
const MessageBody = { type: 'NexfepBeforeUnload' }
|
|
142
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// 窗口控制函数
|
|
146
|
+
window.close = () => {
|
|
147
|
+
const MessageBody = { type: 'NexfepCloseWindow' }
|
|
148
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
window.minimize = () => {
|
|
152
|
+
const MessageBody = { type: 'NexfepMinimizeWindow' }
|
|
153
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
window.unminimize = () => {
|
|
157
|
+
const MessageBody = { type: 'NexfepUnMinimizeWindow' }
|
|
158
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
window.maximize = () => {
|
|
162
|
+
const MessageBody = { type: 'NexfepMaximizeWindow' }
|
|
163
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
window.unmaximize = () => {
|
|
167
|
+
const MessageBody = { type: 'NexfepUnMaximizeWindow' }
|
|
168
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
169
|
+
};
|
|
170
|
+
window.setTitle = (title) => {
|
|
171
|
+
const MessageBody = { type: 'NexfepSetTitle', title: title }
|
|
172
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
window.openDevTools = () => {
|
|
176
|
+
const MessageBody = { type: 'NexfepOpenDevTools' }
|
|
177
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
window.closeDevTools = () => {
|
|
181
|
+
const MessageBody = { type: 'NexfepCloseDevTools' }
|
|
182
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
window.postMessage = (data) => {
|
|
186
|
+
const MessageBody = { type: 'CustomMessage', data: data }
|
|
187
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
window.eventCount = 0;
|
|
191
|
+
|
|
192
|
+
window.invoke = async (event, data) => {
|
|
193
|
+
const MessageBody = { type: 'NexfepInvoke', eventId: [${this.injectCount}, ++window.eventCount], event: event, data: data }
|
|
194
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
195
|
+
return new Promise((resolve, reject) => {
|
|
196
|
+
window.addEventListener("nexfep-invoke-result-"+${this.injectCount}+"-"+window.eventCount, (event) => {
|
|
197
|
+
window.removeEventListener("nexfep-invoke-result-"+${this.injectCount}+"-"+window.eventCount, event);
|
|
198
|
+
if(event.detail){
|
|
199
|
+
resolve(event.detail);
|
|
200
|
+
}else{
|
|
201
|
+
resolve();
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 注入 CSS 样式
|
|
208
|
+
const style = document.createElement('style');
|
|
209
|
+
style.textContent = \`${INJECT_CSS}\`;
|
|
210
|
+
document.head.appendChild(style);
|
|
211
|
+
|
|
212
|
+
// 标记加载完成
|
|
213
|
+
window.isNexfepLoadDone = true;
|
|
214
|
+
|
|
215
|
+
// 触发加载完成事件
|
|
216
|
+
window.dispatchEvent(new Event('nexfep-load-done'));
|
|
217
217
|
`;
|
|
218
218
|
console.log("Before inject code INJECT_CODE");
|
|
219
219
|
await this.__injectCode(windowObj, INJECT_CODE);
|
|
@@ -230,12 +230,12 @@ class WindowPool {
|
|
|
230
230
|
const dataText = data.body.toString();
|
|
231
231
|
const dataObj = JSON.parse(dataText);
|
|
232
232
|
if (dataObj.type == 'NexfepBeforeUnload') {
|
|
233
|
-
webview.evaluateScript(`if(window?.isNexfepLoadDone){
|
|
234
|
-
const MessageBody = { type: 'NexfepBeforeUnload' }
|
|
235
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
236
|
-
}else{
|
|
237
|
-
const MessageBody = { type: 'NexfepLoadFalse' }
|
|
238
|
-
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
233
|
+
webview.evaluateScript(`if(window?.isNexfepLoadDone){
|
|
234
|
+
const MessageBody = { type: 'NexfepBeforeUnload' }
|
|
235
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
236
|
+
}else{
|
|
237
|
+
const MessageBody = { type: 'NexfepLoadFalse' }
|
|
238
|
+
window.ipc.postMessage(JSON.stringify(MessageBody));
|
|
239
239
|
}`);
|
|
240
240
|
}
|
|
241
241
|
else if (dataObj.type == 'NexfepLoadFalse') {
|
|
@@ -273,13 +273,13 @@ class WindowPool {
|
|
|
273
273
|
handlers.forEach(async (handler) => {
|
|
274
274
|
const result = await handler(dataObj.data);
|
|
275
275
|
if (result) {
|
|
276
|
-
webview.evaluateScript(`
|
|
277
|
-
window.dispatchEvent(new Event('nexfep-invoke-result-${dataObj.eventId[0]}-${dataObj.eventId[1]}', { detail: ${JSON.stringify(result)} }));
|
|
276
|
+
webview.evaluateScript(`
|
|
277
|
+
window.dispatchEvent(new Event('nexfep-invoke-result-${dataObj.eventId[0]}-${dataObj.eventId[1]}', { detail: ${JSON.stringify(result)} }));
|
|
278
278
|
`);
|
|
279
279
|
}
|
|
280
280
|
else {
|
|
281
|
-
webview.evaluateScript(`
|
|
282
|
-
window.dispatchEvent(new Event('nexfep-invoke-result-${dataObj.eventId[0]}-${dataObj.eventId[1]}', { detail: undefined }));
|
|
281
|
+
webview.evaluateScript(`
|
|
282
|
+
window.dispatchEvent(new Event('nexfep-invoke-result-${dataObj.eventId[0]}-${dataObj.eventId[1]}', { detail: undefined }));
|
|
283
283
|
`);
|
|
284
284
|
}
|
|
285
285
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexfep",
|
|
3
3
|
"description": "A desktop application framework based on @webviewjs/webview",
|
|
4
|
-
"repository": "https://github.com/
|
|
5
|
-
"homepage": "https://github.com/
|
|
4
|
+
"repository": "https://github.com/nexfteam/Nexfep",
|
|
5
|
+
"homepage": "https://github.com/nexfteam/Nexfep#readme",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/nexfteam/Nexfep/issues"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"desktop",
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
"webview",
|
|
15
15
|
"typescript"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.1.
|
|
17
|
+
"version": "0.1.2",
|
|
18
18
|
"type": "module",
|
|
19
|
-
"packageManager": "pnpm@9.15.9",
|
|
20
19
|
"main": "./index.js",
|
|
21
20
|
"scripts": {
|
|
22
21
|
"compile": "tsc"
|