@hyext/builder-revues 0.0.1-beta.7 → 0.0.1-beta.9
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/dist/index.js
CHANGED
@@ -3,4 +3,4 @@
|
|
3
3
|
* (c) 2024-2024 Alex
|
4
4
|
* Released under the MIT License.
|
5
5
|
*/
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("fs-extra"),e=require("path"),a=require("@revues/code-compiler"),n=require("os"),o=require("chalk"),i=require("util"),r=require("glob"),u=require("handlebars"),s=require("live-server"),l=require("archiver"),c=require("ramda");function d(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var f,p=d(t),m=d(e),h=d(n),y=d(o),g=d(u),j=d(s),x=d(l),P=d(c);!function(t){t[t.Integration=0]="Integration",t[t.Separate=1]="Separate"}(f||(f={}));const S=m.default.join(h.default.tmpdir(),".revue_cache"),v=f.Integration,w=m.default.resolve(__dirname,"../static"),b="project.config.json";function k(t,e){p.default.copyFileSync(m.default.join(t,b),m.default.join(e,b))}function _(){p.default.existsSync(S)||p.default.mkdirSync(S)}const I=y.default.gray("·");var E=(t=>{t=` ${t}`;return{log(...e){const a=i.format.apply(i.format,e);console.log(y.default.white(t),I,a)},fatal(...e){e[0]instanceof Error&&(e[0]=e[0].message.trim());const a=i.format.apply(i.format,e);console.error(y.default.red(t),I,a),process.exit(1)},success(...e){const a=i.format.apply(i.format,e);console.log(y.default.green(t),I,a)}}})("REVUE");async function U(t,e){_(),await a.compilerManager.init({projectPath:t,outputPath:e,cachePath:S}),await a.compilerManager.compileDev(),k(t,e)}async function T(t,e){_(),function(t){const e=m.default.join(t,"web-adapter.js"),a=require.resolve("@revues/cocos-web-adapter/dist/index.js");p.default.existsSync(e)?p.default.writeFileSync(e,p.default.readFileSync(a)):E.log("The web-adapter.js was not found from project root.")}(t),await a.compilerManager.init({projectPath:t,outputPath:e,cachePath:S}),await a.compilerManager.compileDev(),k(t,e)}const $={test:"//test-extsdk.msstatic.com",prod:"//extsdk-msstatic.cdn.huya.com"};function F(t){return`${$.prod}/sdk/$1/${t.hostId}/${t.extUuid||0}/sdk.js`}function q(t,e,a){const n=p.default.readFileSync(t).toString();p.default.outputFileSync(e,function(t,e,a){return g.default.compile(t,{noEscape:!0})(e,a)}(n,a))}function C(t,e){const n=m.default.join(t,"package"),o=function(t){const e=m.default.join(t,"packageConfig.json");return p.default.readJSONSync(e)}(n),i=o.findIndex((t=>{return(e=t).name===a.pkgFileType.MainPkg&&"."===e.root;var e}));if(-1===i)throw new Error("无法找到主包构建信息");const r=o[i];o.splice(i,1);const u=o;u.length>0&&function(t,e,a,n){const o=m.default.join(t,e.name);a.forEach((e=>{const a=m.default.join(t,e.name),i=m.default.join(a,e.root),r=m.default.join(o,e.root);n&&n(a,o,e),p.default.moveSync(i,r,{overwrite:!0}),p.default.removeSync(m.default.join(t,e.name))}))}(n,r,u,e);const s=m.default.join(w,"framework");if(v===f.Integration){p.default.copySync(s,m.default.join(t,"framework"));const e=m.default.join(t,"sdk");p.default.mkdirSync(e),D(e,"@revues/web-sdk-core"),D(e,"@revues/web-frame")}return{mainPakConf:r,packagePath:n}}function D(t,e){const a=require.resolve(e);let n=m.default.join(a,"../");"dist"===m.default.basename(n)?p.default.copySync(n,t):(n=m.default.resolve(n,"../"),n=m.default.join(n,"dist"),p.default.existsSync(n)?p.default.copySync(n,t):E.log(`Builder can't resolve ${e} entry from ${a}`))}function z(t,e){const{mainPakConf:a,packagePath:n}=C(t),o=m.default.join(w,"template"),i=m.default.join(n,a.name);return function(t){const{mainPath:e,sourcePathPrefix:a,templatePath:n,hyextSDKUrl:o}=t,i={sourcePathPrefix:a,hyextSDKUrl:o},r=[{input:m.default.join(n,"game-frame.hbs"),output:m.default.join(e,"game-frame.html"),data:i},{input:m.default.join(n,"minigame-page-manager.hbs"),output:m.default.join(e,"index.html"),data:i}];r.forEach((t=>{q(t.input,t.output,t.data)}))}({hyextSDKUrl:F({hostId:e.hostId,extUuid:e.extUuid}),sourcePathPrefix:v===f.Integration?m.default.relative(i,t):"",templatePath:o,mainPath:i}),function(t){const e=r.sync("**/**.wasm",{cwd:t,ignore:K,nodir:!0,absolute:!1});console.log("transform wasm to base64 files: \n",e),e.forEach((e=>{const a=m.default.join(t,e),n=p.default.readFileSync(a).toString("base64");p.default.outputFileSync(a+".txt",n)}))}(i),{mainPath:i,main:a,entryPath:"package/"+a.name+"/index.html"}}const K=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];function M(t,e,a){const n=a.name+".js",o=a.name+".js.map",i=m.default.join(t,n),r=m.default.join(t,o);p.default.existsSync(i)&&p.default.outputFileSync(m.default.join(e,n),p.default.readFileSync(i)),p.default.existsSync(r)&&p.default.outputFileSync(m.default.join(e,o),p.default.readFileSync(r))}function N(t,e){const{mainPakConf:a,packagePath:n}=C(t,M),o=function(t){const e=m.default.join(t,"packageExtConfig.json");return p.default.readJSONSync(e)}(n),i=m.default.join(w,"template"),r=m.default.join(n,a.name);return function(t){const{mainPath:e,sourcePathPrefix:a,templatePath:n,hyextSDKUrl:o,packageExtConfig:i}=t,r={sourcePathPrefix:a,hyextSDKUrl:o,packageExtConfig:JSON.stringify(i)},u=[{input:m.default.join(n,"miniapp-page-manager.hbs"),output:m.default.join(e,"index.html"),data:r},{input:m.default.join(n,"service.hbs"),output:m.default.join(e,"service.html"),data:r}];u.forEach((t=>{q(t.input,t.output,t.data)}))}({hyextSDKUrl:F({hostId:e.hostId,extUuid:e.extUuid}),sourcePathPrefix:v===f.Integration?m.default.relative(r,t):"",packageExtConfig:o,templatePath:i,mainPath:r}),{mainPath:r,main:a,entryPath:"package/"+a.name+"/index.html"}}var R={cert:p.default.readFileSync(m.default.join(w,"./certs/cert.pem")),key:p.default.readFileSync(m.default.join(w,"./certs/key.pem")),passphrase:""};async function O(t,e){const{baseURI:a,extTypes:n,entryInfo:o,outputPath:i}=e,r=m.default.join(i,"build-result"),u={},s=n.map((t=>{const e={type:"HTML",content:{pages:[{path:J(t,o)}],baseURI:a}};return u[t]=e,{type:t,buildResult:{[t]:e}}}));if("development"===t){const t=s.map((t=>p.default.outputFile(m.default.join(r,t.type+".json"),JSON.stringify(t.buildResult,null,2))));await Promise.all(t)}return u}function J(t,e){let a=e.entryPath+`?extType=${t}`;return t.endsWith("_h5")&&(a+="&__module_busi__=kiwi-ExtSDK"),a}const L=t=>{const e=(()=>{const t=h.default.networkInterfaces(),e=P.default.flatten(P.default.values(t));return P.default.filter((t=>/(ipv)?4/gi.test(t.family)&&!/^127\./.test(t.address)),e)})();return e&&e.length>1&&(E.log(`检测到本机有多个 ip 地址:\n- ${e.map((t=>t.address)).join("\n- ")}`),E.log("请在 project.config.json 的 host 中指定正确的 ip"),process.exit(1)),e&&e.length<=0&&(E.log("未能找到本机 ip 地址, 本地开发 app 侧将无法加载小程序"),process.exit(1)),e[0]?.address},W=new Set(["web_video_com","app_panel_h5","zs_anchor_panel_h5","pc_anchor_panel","pc_panel"]);function B(t,e){const a={...e};return function(t){let e=[];t&&0!==t.length?t.forEach((t=>{W.has(t)||e.push(t)})):E.fatal("请在project.config.json相应地方填写supportExtTypes."),e.length>0&&E.fatal(`未支持的小程序类型:${e.join("|")}.`)}(e.supportExtTypes),function(t){null==t.hostId&&(t.hostId="huyaext")}(a),"development"===t&&function(t){t.https=!0,null==t.host&&(t.host=L()||""),null==t.port&&(t.port=18080)}(a),a}function H(t){return`${t.https?"https":"http"}://${t.host}:${t.port}/`}function V(t,e,a){E.log("正在合并分包...");const n=("game"==t.compileType?z:N)(e,a);return E.success("合并分包完成"),n}const A=new class{async build(t){const{inputPath:e,outputPath:a,publicPath:n,projectConfig:o,config:i,extUuid:r}=t,u=B("production",i);p.default.existsSync(a)&&p.default.removeSync(a),await p.default.copy(e,a,{overwrite:!0});const s=V(o,a,{hostId:u.hostId,extUuid:r});return await O("production",{entryInfo:s,baseURI:n,extTypes:u.supportExtTypes,outputPath:a})}async start(t){const{inputPath:e,projectConfig:a,outputPath:n,config:o}=t,i=n||m.default.join(__dirname,"../../temp"),r=B("development",o);"game"==a.compileType?await T(e,i):await U(e,i);const u=V(a,i,{hostId:r.hostId,extUuid:void 0});return E.log("启动 live server 服务..."),E.success("本地访问地址:",H(r)+u.entryPath+"?extType=web_video_com"),function(t){var e={port:t.port,host:t.host,root:t.root,open:!1,ignore:t.ignore,file:"index.html",wait:1e3,mount:t.mount,logLevel:1,https:R};j.default.start(e)}({...r,root:i}),await O("development",{entryInfo:u,baseURI:H(r),extTypes:r.supportExtTypes,outputPath:i})}async release(t){const{contextPath:e,releasePath:a,projectConfig:n}=t;p.default.existsSync(a)&&p.default.removeSync(a);const o=n.projectName||n.projectname||"project",i=m.default.join(a,o);"game"==n.compileType?await T(e,i):await U(e,i);const r=m.default.join(a,o);var u;await(u=r,new Promise(((t,e)=>{const a=p.default.createWriteStream(`${u}.zip`),n=x.default("zip",{zlib:{level:9}});a.on("close",(()=>{const e=n.pointer();t({name:`${m.default.basename(u)}.zip`,size:e})})),n.on("warning",(t=>{if("ENOENT"!==t.code)throw t})),n.on("error",(t=>{throw e(t),t})),n.pipe(a),n.directory(`${u}`,!1),n.finalize()})))}config(){}providedProjectConfig(){}};module.exports=A,exports.default=A;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hyext/builder-revues",
|
3
|
-
"version": "0.0.1-beta.
|
3
|
+
"version": "0.0.1-beta.9",
|
4
4
|
"description": "> TODO: description",
|
5
5
|
"author": "diamondloler <857276958@qq.com>",
|
6
6
|
"homepage": "",
|
@@ -22,9 +22,10 @@
|
|
22
22
|
},
|
23
23
|
"scripts": {},
|
24
24
|
"dependencies": {
|
25
|
-
"@revues/cocos-web-adapter": "0.0.1-beta.
|
26
|
-
"@revues/code-compiler": "0.0.1-beta.
|
27
|
-
"@revues/web-
|
25
|
+
"@revues/cocos-web-adapter": "0.0.1-beta.9",
|
26
|
+
"@revues/code-compiler": "0.0.1-beta.9",
|
27
|
+
"@revues/web-frame": "0.0.1-beta.9",
|
28
|
+
"@revues/web-sdk-core": "0.0.1-beta.9",
|
28
29
|
"archiver": "^7.0.1",
|
29
30
|
"chalk": "^2.4.2",
|
30
31
|
"fs-extra": "8.1.0",
|
@@ -39,5 +40,5 @@
|
|
39
40
|
"@types/live-server": "^1.2.3",
|
40
41
|
"@types/ramda": "^0.29.11"
|
41
42
|
},
|
42
|
-
"gitHead": "
|
43
|
+
"gitHead": "9ea152ecbbf8e5a4805f3c5e2054eb3aa7c00e12"
|
43
44
|
}
|
Binary file
|
@@ -3,10 +3,28 @@
|
|
3
3
|
|
4
4
|
<head>
|
5
5
|
<meta charset="UTF-8" />
|
6
|
-
<meta id="viewport" name="viewport"
|
6
|
+
<meta id="viewport" name="viewport"
|
7
|
+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
|
7
8
|
<meta name="content-type" content="text/html; charset=utf-8">
|
8
9
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
9
10
|
<style>
|
11
|
+
html,
|
12
|
+
body {
|
13
|
+
position: relative;
|
14
|
+
width: 100%;
|
15
|
+
height: 100%;
|
16
|
+
}
|
17
|
+
|
18
|
+
.views {
|
19
|
+
display: flex;
|
20
|
+
position: relative;
|
21
|
+
width: 100%;
|
22
|
+
flex-grow: 1;
|
23
|
+
background: #fefefe;
|
24
|
+
flex: 1;
|
25
|
+
z-index: 0;
|
26
|
+
}
|
27
|
+
|
10
28
|
.service,
|
11
29
|
.service-preload,
|
12
30
|
.views>.worker {
|
@@ -17,16 +35,29 @@
|
|
17
35
|
height: 1px;
|
18
36
|
opacity: 0;
|
19
37
|
}
|
38
|
+
|
20
39
|
.views>.webview {
|
21
40
|
position: absolute;
|
22
41
|
width: 100%;
|
23
42
|
height: 100%;
|
24
43
|
}
|
44
|
+
|
45
|
+
body {
|
46
|
+
color: #333;
|
47
|
+
display: flex;
|
48
|
+
overscroll-behavior: none;
|
49
|
+
flex-direction: column;
|
50
|
+
margin: 0;
|
51
|
+
padding: 0;
|
52
|
+
box-sizing: border-box;
|
53
|
+
}
|
25
54
|
</style>
|
55
|
+
<link rel='stylesheet' href='{{sourcePathPrefix}}/sdk/web-frame.css'>
|
26
56
|
<script charset="utf-8">
|
27
|
-
window.
|
57
|
+
window.__packageExtConfig = {{ packageExtConfig }}
|
28
58
|
</script>
|
29
59
|
<script charset="utf-8" src="{{sourcePathPrefix}}/sdk/web-sdk-core.js"></script>
|
60
|
+
<script charset="utf-8" src="{{sourcePathPrefix}}/sdk/web-frame.js"></script>
|
30
61
|
</head>
|
31
62
|
|
32
63
|
<body>
|
@@ -17,24 +17,26 @@
|
|
17
17
|
height: 1px;
|
18
18
|
opacity: 0;
|
19
19
|
}
|
20
|
-
|
21
20
|
.views>.webview {
|
22
21
|
position: absolute;
|
23
22
|
width: 100%;
|
24
23
|
height: 100%;
|
25
24
|
}
|
26
|
-
|
27
25
|
.service.service-view {
|
28
26
|
width: 100%;
|
29
27
|
height: 100%;
|
30
28
|
opacity: 1;
|
31
29
|
z-index: 10;
|
32
30
|
}
|
31
|
+
body {
|
32
|
+
overscroll-behavior: none;
|
33
|
+
}
|
33
34
|
</style>
|
34
35
|
<script charset="utf-8">
|
35
36
|
window.__sdkUrlTemplate = "{{hyextSDKUrl}}"
|
36
37
|
</script>
|
37
38
|
<script charset="utf-8" src="{{sourcePathPrefix}}/sdk/web-sdk-core.js"></script>
|
39
|
+
<script charset="utf-8" src="{{sourcePathPrefix}}/sdk/web-frame.js"></script>
|
38
40
|
</head>
|
39
41
|
|
40
42
|
<body>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta name="content-type" content="text/html; charset=utf-8">
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<script>
|
8
|
+
var __wxAppData = {}
|
9
|
+
var __wxRoute
|
10
|
+
var __wxRouteBegin
|
11
|
+
var __eval = eval
|
12
|
+
var __AppCode__ = {}
|
13
|
+
var global = {}
|
14
|
+
var $gfc
|
15
|
+
</script>
|
16
|
+
<script charset="utf-8" src="{{sourcePathPrefix}}/framework/script/service.js" type="text/javascript"></script>
|
17
|
+
<script charset="utf-8" src="pageframe.js"></script>
|
18
|
+
<script charset="utf-8" src="__APP__.js"></script>
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<script charset="UTF-8">
|
22
|
+
ServiceJSBridge.publish('serviceReady', __wxConfig__, [100000]);
|
23
|
+
</script>
|
24
|
+
</body>
|
25
|
+
|
26
|
+
</html>
|
27
|
+
|
28
|
+
|