ue-webui-bridge-vite 1.0.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/README.md +99 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# ue-webui-bridge-vite
|
|
2
|
+
|
|
3
|
+
UE WebUI Bridge 的 Vite 插件,用于在构建时自动集成 UE WebUI 桥接功能。
|
|
4
|
+
|
|
5
|
+
## 📦 安装
|
|
6
|
+
|
|
7
|
+
同时安装核心库和 Vite 插件:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install ue-webui-bridge
|
|
11
|
+
npm install ue-webui-bridge-vite -D
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 🚀 快速开始
|
|
15
|
+
|
|
16
|
+
### 1. 配置 Vite 插件
|
|
17
|
+
|
|
18
|
+
在 `vite.config.ts` 中配置插件:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { defineConfig } from 'vite';
|
|
22
|
+
import vue from '@vitejs/plugin-vue';
|
|
23
|
+
import ueWebUiBridge from 'ue-webui-bridge-vite';
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
plugins: [vue(), ueWebUiBridge()],
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. 使用 API
|
|
31
|
+
|
|
32
|
+
配置插件后,可以直接使用 `ue-webui-bridge` 的 API,**无需手动调用 `initUEBridge()`**:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { sendToGame, registerGameInterface } from 'ue-webui-bridge';
|
|
36
|
+
|
|
37
|
+
// 发送消息到 UE
|
|
38
|
+
sendToGame('PlayerAction', { action: 'jump' });
|
|
39
|
+
|
|
40
|
+
// 接收来自 UE 的消息
|
|
41
|
+
registerGameInterface('OnGameEvent', (data) => {
|
|
42
|
+
console.log('收到游戏事件:', data);
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## ✨ 功能特性
|
|
47
|
+
|
|
48
|
+
### 1. 自动初始化
|
|
49
|
+
|
|
50
|
+
插件会自动注入 UE 桥接初始化代码,**无需手动调用 `initUEBridge()`**。
|
|
51
|
+
|
|
52
|
+
### 2. 资源路径优化
|
|
53
|
+
|
|
54
|
+
自动配置资源路径,确保在 UE WebUI 中正确加载所有资源文件。
|
|
55
|
+
|
|
56
|
+
### 3. 兼容性保证
|
|
57
|
+
|
|
58
|
+
确保构建产物能够在 UE 内置浏览器中正常运行,无需额外配置。
|
|
59
|
+
|
|
60
|
+
### 4. 开箱即用
|
|
61
|
+
|
|
62
|
+
零配置,安装即可使用,插件会自动处理所有必要的构建优化。
|
|
63
|
+
|
|
64
|
+
## 📋 配置选项
|
|
65
|
+
|
|
66
|
+
插件采用零配置设计,开箱即用,无需任何额外配置。
|
|
67
|
+
|
|
68
|
+
## 🎯 使用场景
|
|
69
|
+
|
|
70
|
+
此插件适用于以下场景:
|
|
71
|
+
|
|
72
|
+
- 使用 Vite 构建的 Vue/React/Svelte 等项目
|
|
73
|
+
- 需要在 Unreal Engine 的 WebUI 中运行的 Web 应用
|
|
74
|
+
- 需要与 UE 进行双向通信的前端项目
|
|
75
|
+
|
|
76
|
+
## 📦 依赖关系
|
|
77
|
+
|
|
78
|
+
### Dependencies
|
|
79
|
+
|
|
80
|
+
- `@vitejs/plugin-legacy` - 提供旧版浏览器支持
|
|
81
|
+
|
|
82
|
+
### Peer Dependencies
|
|
83
|
+
|
|
84
|
+
- `vite` - 支持版本 ^5.0.0 || ^6.0.0 || ^7.0.0
|
|
85
|
+
|
|
86
|
+
## 🔗 相关项目
|
|
87
|
+
|
|
88
|
+
- [ue-webui-bridge](https://www.npmjs.com/package/ue-webui-bridge) - 核心库,提供运行时 API
|
|
89
|
+
|
|
90
|
+
## 📝 注意事项
|
|
91
|
+
|
|
92
|
+
1. **无需手动初始化**: 使用此插件后,不需要在代码中手动调用 `initUEBridge()`
|
|
93
|
+
2. **自动路径处理**: 插件会自动处理资源路径,确保在 UE 中正确加载
|
|
94
|
+
3. **浏览器兼容**: 构建产物已针对 UE 内置浏览器进行优化
|
|
95
|
+
4. **必须同时安装**: 需要同时安装 `ue-webui-bridge` 核心库和本插件
|
|
96
|
+
|
|
97
|
+
## 📄 许可证
|
|
98
|
+
|
|
99
|
+
GPL-3.0 © kongziming
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var _0x5cd7ba=_0x3f5d;(function(_0x506f0b,_0x13ddd7){var _0x2ee78b=_0x3f5d,_0x466997=_0x506f0b();while(!![]){try{var _0x258441=-parseInt(_0x2ee78b(0x202))/0x1*(parseInt(_0x2ee78b(0x20b))/0x2)+parseInt(_0x2ee78b(0x1f4))/0x3+-parseInt(_0x2ee78b(0x220))/0x4*(parseInt(_0x2ee78b(0x21e))/0x5)+-parseInt(_0x2ee78b(0x208))/0x6+parseInt(_0x2ee78b(0x1f6))/0x7+-parseInt(_0x2ee78b(0x1f5))/0x8*(parseInt(_0x2ee78b(0x200))/0x9)+parseInt(_0x2ee78b(0x219))/0xa;if(_0x258441===_0x13ddd7)break;else _0x466997['push'](_0x466997['shift']());}catch(_0x300f8e){_0x466997['push'](_0x466997['shift']());}}}(_0x6a1a,0x19e3e));function _0x6a1a(){var _0x5290ac=['not\x20IE\x2011','path','__esModule','kOiVa','92304GVTSqh','yzAFR','default','2430TJREia','resolve','IbhgR','defaults','index.html','create','RZEHF','gobGS','replace','<head>\x0a','hasOwnProperty','utf-8','defineProperty','getPrototypeOf','2614620TlxNKT','dist','outDir','XfBSl','error','20435oseuoY','exports','112HOcdUO','xaLZG','function','402954uAYdrX','22744RhIapC','163646qiNlxu','eHXhG','getOwnPropertyNames','\x0a(function()\x20{\x0a\x20\x20if\x20(typeof\x20window.ue\x20!==\x20\x27object\x27)\x20{\x0a\x20\x20\x20\x20window.ue\x20=\x20{\x20interface:\x20{\x20broadcast:\x20()\x20=>\x20{}\x20}\x20};\x0a\x20\x20}\x0a\x0a\x20\x20const\x20originalInterface\x20=\x20window.ue.interface;\x0a\x0a\x20\x20window.ueBridge\x20=\x20function\x20(name,\x20data)\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20name\x20!==\x20\x27string\x27)\x20return;\x0a\x20\x20\x20\x20const\x20dataStr\x20=\x20data\x20!==\x20undefined\x20?\x20JSON.stringify(data)\x20:\x20\x27\x27;\x0a\x20\x20\x20\x20if\x20(typeof\x20originalInterface.broadcast\x20!==\x20\x27function\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20const\x20args\x20=\x20[name,\x20dataStr];\x0a\x20\x20\x20\x20\x20\x20const\x20hash\x20=\x20encodeURIComponent(JSON.stringify(args));\x0a\x20\x20\x20\x20\x20\x20window.location.hash\x20=\x20hash;\x0a\x20\x20\x20\x20\x20\x20window.location.hash\x20=\x20encodeURIComponent(\x27[]\x27);\x0a\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20originalInterface.broadcast(name,\x20dataStr);\x0a\x20\x20\x20\x20}\x0a\x20\x20};\x0a})();\x0a','enumerable','osLzv','message','readFileSync','call','MjDAw','261AIJVoh','出错了:','83sItxaQ','prototype'];_0x6a1a=function(){return _0x5290ac;};return _0x6a1a();}var f=Object[_0x5cd7ba(0x210)],i=Object[_0x5cd7ba(0x217)],u=Object['getOwnPropertyDescriptor'],g=Object[_0x5cd7ba(0x1f8)],p=Object[_0x5cd7ba(0x218)],m=Object[_0x5cd7ba(0x203)][_0x5cd7ba(0x215)],h=(_0x377dc2,_0x17ba4d)=>{var _0x21d462=_0x5cd7ba,_0x3e1c46={'MjDAw':function(_0x536b80,_0x41c17c,_0x388d15,_0x556ddb){return _0x536b80(_0x41c17c,_0x388d15,_0x556ddb);}};for(var _0x50ffbf in _0x17ba4d)_0x3e1c46[_0x21d462(0x1ff)](i,_0x377dc2,_0x50ffbf,{'get':_0x17ba4d[_0x50ffbf],'enumerable':!0x0});},c=(_0x11f018,_0x31af27,_0x5c793f,_0x108222)=>{var _0x2e6239=_0x5cd7ba,_0x2741a0={'gobGS':function(_0x349dec,_0x4ed219){return _0x349dec==_0x4ed219;},'eHXhG':function(_0x12f0b5,_0x1d4514){return _0x12f0b5==_0x1d4514;},'RZEHF':_0x2e6239(0x1f3),'osLzv':function(_0x37585e,_0x57072b){return _0x37585e(_0x57072b);},'SOloe':function(_0xc8b505,_0x47a47f,_0x4431c3,_0x2614d7){return _0xc8b505(_0x47a47f,_0x4431c3,_0x2614d7);},'YQqCz':function(_0x1c4b96,_0xe340c6,_0x40c971){return _0x1c4b96(_0xe340c6,_0x40c971);}};if(_0x31af27&&_0x2741a0[_0x2e6239(0x212)](typeof _0x31af27,'object')||_0x2741a0[_0x2e6239(0x1f7)](typeof _0x31af27,_0x2741a0[_0x2e6239(0x211)])){for(let _0x21eb63 of _0x2741a0[_0x2e6239(0x1fb)](g,_0x31af27))!m[_0x2e6239(0x1fe)](_0x11f018,_0x21eb63)&&_0x21eb63!==_0x5c793f&&_0x2741a0['SOloe'](i,_0x11f018,_0x21eb63,{'get':()=>_0x31af27[_0x21eb63],'enumerable':!(_0x108222=_0x2741a0['YQqCz'](u,_0x31af27,_0x21eb63))||_0x108222[_0x2e6239(0x1fa)]});}return _0x11f018;},w=(_0x30c00d,_0x4a0c89,_0x4c00e6)=>(_0x4c00e6=_0x30c00d!=null?f(p(_0x30c00d)):{},c(_0x4a0c89||!_0x30c00d||!_0x30c00d[_0x5cd7ba(0x206)]?i(_0x4c00e6,_0x5cd7ba(0x20a),{'value':_0x30c00d,'enumerable':!0x0}):_0x4c00e6,_0x30c00d)),y=_0x2aa496=>c(i({},_0x5cd7ba(0x206),{'value':!0x0}),_0x2aa496),S={};function _0x3f5d(_0x1a3a1b,_0x43b83a){_0x1a3a1b=_0x1a3a1b-0x1f3;var _0x6a1ac1=_0x6a1a();var _0x3f5d7a=_0x6a1ac1[_0x1a3a1b];return _0x3f5d7a;}h(S,{'default':()=>l}),module[_0x5cd7ba(0x21f)]=y(S);var s=w(require('@vitejs/plugin-legacy'),0x1),a=require('fs'),d=require(_0x5cd7ba(0x205)),b=_0x5cd7ba(0x1f9);function l(){var _0x524f24=_0x5cd7ba,_0xfcdc1={'XfBSl':_0x524f24(0x20f),'yzAFR':_0x524f24(0x216),'xaLZG':function(_0x2fd5a1,_0x4d5a8a){return _0x2fd5a1 instanceof _0x4d5a8a;},'IbhgR':function(_0x6790fe,_0x451eb2){return _0x6790fe(_0x451eb2);},'FbgTp':_0x524f24(0x21a),'kOiVa':'ue-webui-bridge-plugin','qswYP':_0x524f24(0x20e)};let _0x1ee20c=_0xfcdc1['FbgTp'];return[{'name':_0xfcdc1[_0x524f24(0x207)],'config'(_0x5583cf){return{'base':_0x5583cf['base']??'./'};},'configResolved'(_0x111d72){var _0x5357c2=_0x524f24;_0x1ee20c=_0x111d72['build'][_0x5357c2(0x21b)];},'transformIndexHtml'(_0x472a35){var _0x37da82=_0x524f24;let _0x3e8a42='<script>'+b+'</script>';return _0x472a35[_0x37da82(0x213)](/<head>/,_0x37da82(0x214)+_0x3e8a42);},'closeBundle'(){var _0x1a36de=_0x524f24;let _0x2b31e8=(0x0,d[_0x1a36de(0x20c)])(_0x1ee20c,_0xfcdc1[_0x1a36de(0x21c)]);try{let _0x4032ff=(0x0,a[_0x1a36de(0x1fd)])(_0x2b31e8,_0xfcdc1[_0x1a36de(0x209)]);_0x4032ff=_0x4032ff[_0x1a36de(0x213)](/<script type="module"[^>]*>[\s\S]*?<\/script>/g,''),_0x4032ff=_0x4032ff[_0x1a36de(0x213)](/<script type="module"[^>]*><\/script>/g,''),_0x4032ff=_0x4032ff[_0x1a36de(0x213)](/ nomodule/g,''),_0x4032ff=_0x4032ff['replace'](/ crossorigin/g,''),_0x4032ff=_0x4032ff['replace'](/\n\s*\n\s*\n/g,'\x0a\x0a'),(0x0,a['writeFileSync'])(_0x2b31e8,_0x4032ff);}catch(_0x5551db){let _0x3cebd1=_0xfcdc1[_0x1a36de(0x221)](_0x5551db,Error)?_0x5551db[_0x1a36de(0x1fc)]:_0xfcdc1[_0x1a36de(0x20d)](String,_0x5551db);console[_0x1a36de(0x21d)](_0x1a36de(0x201),_0x3cebd1);}}},...(0x0,s[_0x524f24(0x20a)])({'targets':[_0xfcdc1['qswYP'],_0x524f24(0x204)]})];}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x100032,_0x18fc1a){const _0x1f7a82=_0x4502,_0x13a341=_0x100032();while(!![]){try{const _0x1bc002=-parseInt(_0x1f7a82(0xa1))/0x1*(-parseInt(_0x1f7a82(0x9d))/0x2)+parseInt(_0x1f7a82(0xa0))/0x3*(parseInt(_0x1f7a82(0xa4))/0x4)+-parseInt(_0x1f7a82(0x9f))/0x5*(-parseInt(_0x1f7a82(0x99))/0x6)+parseInt(_0x1f7a82(0xac))/0x7+parseInt(_0x1f7a82(0x9e))/0x8*(parseInt(_0x1f7a82(0xad))/0x9)+parseInt(_0x1f7a82(0x94))/0xa*(parseInt(_0x1f7a82(0x9b))/0xb)+-parseInt(_0x1f7a82(0x90))/0xc;if(_0x1bc002===_0x18fc1a)break;else _0x13a341['push'](_0x13a341['shift']());}catch(_0x1dcd80){_0x13a341['push'](_0x13a341['shift']());}}}(_0x532e,0xe342e));import _0x56de75 from'@vitejs/plugin-legacy';import{readFileSync as _0x4fbd28,writeFileSync as _0x3e549c}from'fs';function _0x4502(_0x5e45de,_0x4d21f7){_0x5e45de=_0x5e45de-0x90;const _0x532e20=_0x532e();let _0x450248=_0x532e20[_0x5e45de];return _0x450248;}import{resolve as _0x54e9b2}from'path';var s='\x0a(function()\x20{\x0a\x20\x20if\x20(typeof\x20window.ue\x20!==\x20\x27object\x27)\x20{\x0a\x20\x20\x20\x20window.ue\x20=\x20{\x20interface:\x20{\x20broadcast:\x20()\x20=>\x20{}\x20}\x20};\x0a\x20\x20}\x0a\x0a\x20\x20const\x20originalInterface\x20=\x20window.ue.interface;\x0a\x0a\x20\x20window.ueBridge\x20=\x20function\x20(name,\x20data)\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20name\x20!==\x20\x27string\x27)\x20return;\x0a\x20\x20\x20\x20const\x20dataStr\x20=\x20data\x20!==\x20undefined\x20?\x20JSON.stringify(data)\x20:\x20\x27\x27;\x0a\x20\x20\x20\x20if\x20(typeof\x20originalInterface.broadcast\x20!==\x20\x27function\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20const\x20args\x20=\x20[name,\x20dataStr];\x0a\x20\x20\x20\x20\x20\x20const\x20hash\x20=\x20encodeURIComponent(JSON.stringify(args));\x0a\x20\x20\x20\x20\x20\x20window.location.hash\x20=\x20hash;\x0a\x20\x20\x20\x20\x20\x20window.location.hash\x20=\x20encodeURIComponent(\x27[]\x27);\x0a\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20originalInterface.broadcast(name,\x20dataStr);\x0a\x20\x20\x20\x20}\x0a\x20\x20};\x0a})();\x0a';function _0x532e(){const _0x308bb=['oMWvw','232PzuZCX','8pjmLZH','827965TZeNrE','27WFbccb','10876xhjEki','ue-webui-bridge-plugin','outDir','771348HHsesi','index.html','wZBPS','nbWAe','PuCQO','tjFzz','<script>','message','1605352CAYrcZ','12151800YoEtgi','71204988sjhlDA','defaults','<head>\x0a','WWgER','670gURQzq','build','rClyw','</script>','replace','24NpuDsi','dist','266882nFHxIG'];_0x532e=function(){return _0x308bb;};return _0x532e();}function d(){const _0x269930=_0x4502,_0xf8becb={'oMWvw':_0x269930(0xa5),'PuCQO':'utf-8','WWgER':function(_0x5dacc3,_0x5dfe42){return _0x5dacc3 instanceof _0x5dfe42;},'hfYTi':function(_0x9ed66c,_0x296184){return _0x9ed66c(_0x296184);},'tjFzz':'出错了:','wZBPS':_0x269930(0x9a),'TmULC':_0x269930(0xa2),'pRIaB':function(_0x18072f,_0x134d8c){return _0x18072f(_0x134d8c);},'rClyw':_0x269930(0x91),'nbWAe':'not\x20IE\x2011'};let _0x384bc6=_0xf8becb[_0x269930(0xa6)];return[{'name':_0xf8becb['TmULC'],'config'(_0x28d6b3){return{'base':_0x28d6b3['base']??'./'};},'configResolved'(_0x32966c){const _0x4b5e68=_0x269930;_0x384bc6=_0x32966c[_0x4b5e68(0x95)][_0x4b5e68(0xa3)];},'transformIndexHtml'(_0x113647){const _0x3b8d12=_0x269930;let _0x618251=_0x3b8d12(0xaa)+s+_0x3b8d12(0x97);return _0x113647[_0x3b8d12(0x98)](/<head>/,_0x3b8d12(0x92)+_0x618251);},'closeBundle'(){const _0x1f7a34=_0x269930;let _0x5bdd73=_0x54e9b2(_0x384bc6,_0xf8becb[_0x1f7a34(0x9c)]);try{let _0x374a6d=_0x4fbd28(_0x5bdd73,_0xf8becb[_0x1f7a34(0xa8)]);_0x374a6d=_0x374a6d[_0x1f7a34(0x98)](/<script type="module"[^>]*>[\s\S]*?<\/script>/g,''),_0x374a6d=_0x374a6d[_0x1f7a34(0x98)](/<script type="module"[^>]*><\/script>/g,''),_0x374a6d=_0x374a6d[_0x1f7a34(0x98)](/ nomodule/g,''),_0x374a6d=_0x374a6d[_0x1f7a34(0x98)](/ crossorigin/g,''),_0x374a6d=_0x374a6d[_0x1f7a34(0x98)](/\n\s*\n\s*\n/g,'\x0a\x0a'),_0x3e549c(_0x5bdd73,_0x374a6d);}catch(_0x14c41){let _0x53a17c=_0xf8becb[_0x1f7a34(0x93)](_0x14c41,Error)?_0x14c41[_0x1f7a34(0xab)]:_0xf8becb['hfYTi'](String,_0x14c41);console['error'](_0xf8becb[_0x1f7a34(0xa9)],_0x53a17c);}}},..._0xf8becb['pRIaB'](_0x56de75,{'targets':[_0xf8becb[_0x269930(0x96)],_0xf8becb[_0x269930(0xa7)]]})];}export{d as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ue-webui-bridge-vite",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vite plugin for UE WebUI Bridge - Automatically integrate UE WebUI bridge functionality at build time",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup && node ../obfuscate.js",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"vite",
|
|
23
|
+
"vite-plugin",
|
|
24
|
+
"unreal-engine",
|
|
25
|
+
"ue",
|
|
26
|
+
"webui"
|
|
27
|
+
],
|
|
28
|
+
"author": "kongziming",
|
|
29
|
+
"license": "GPL-3.0",
|
|
30
|
+
"type": "module",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@vitejs/plugin-legacy": "^7.2.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"tsup": "^8.5.1"
|
|
42
|
+
}
|
|
43
|
+
}
|