fix: 可视化设计, 可视化wcc、wcsc #16

This commit is contained in:
msojocs 2022-02-24 21:14:30 +08:00
parent c29f28ffd6
commit f0d100c761
16 changed files with 1737 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -104,14 +104,14 @@ function wxmlToJS(rootPath, files, { cut } = {}, options={}) {
// @TODO如果遇到参数过长被操作系统干掉的情况可以使用 --config-path FILE 配置,参数空格换成空行 // @TODO如果遇到参数过长被操作系统干掉的情况可以使用 --config-path FILE 配置,参数空格换成空行
// const componentArgs = getComponentArgs(files), componentArgs.join(' ') // const componentArgs = getComponentArgs(files), componentArgs.join(' ')
const args = ['-d', '--split', options.wxmlCompileConfigSplit, type, options.wxmlCompileConfig] let args = ['-d', '--split', options.wxmlCompileConfigSplit, type, options.wxmlCompileConfig]
.concat(files) .concat(files)
.concat(['-gn', '$gwx']) .concat(['-gn', '$gwx'])
// wxs调试 // wxs调试
if(options.debugWXS)args.unshift('-ds') if(options.debugWXS)args.unshift('-ds')
// 懒加载 // 懒加载
if(options.lazyload)args=args.concat(['-ll', options.lazyloadConfig]) // if(options.lazyload)args=args.concat(['-ll', options.lazyloadConfig])
// wxmlParserPath 二进制可执行文件路径 // wxmlParserPath 二进制可执行文件路径
const wxmlParserPath = getWXMLParsePath() const wxmlParserPath = getWXMLParsePath()

View File

@ -56,15 +56,28 @@ exports = async function (options) {
options.contents = await Promise.all(tasks) || [] options.contents = await Promise.all(tasks) || []
} }
let wccResult let wcscResult
try { try {
console.warn('wcsc options', options) console.warn('wcsc options', options)
wccResult = wcsc(options.cwd, options.files, options) wcscResult = wcsc(options.cwd, options.files, options)
if(options.lazyload){
const t = wcscResult
wcscResult = {
common: t.comm,
pageWxss: {}
}
for(let key in t){
console.log(key)
if(key.endsWith('.wxss')){
wcscResult.pageWxss[key] = t[key]
}
}
}
} catch (errmsg) { } catch (errmsg) {
throw new Error(errmsg) throw new Error(errmsg)
} }
const result = options.lazyload ? wccResult : tranWcscResultToObject(wccResult) const result = options.lazyload ? wcscResult : tranWcscResultToObject(wcscResult)
if (options.output) { if (options.output) {
const output = path.resolve(options.cwd, options.output) const output = path.resolve(options.cwd, options.output)

View File

@ -58,19 +58,29 @@ function getAllFiles(rootPath, files) {
* 编译 wxss js * 编译 wxss js
*/ */
function wxssToJS(rootPath, files, options) { function wxssToJS(rootPath, files, options) {
files = getAllFiles(rootPath, files) // files = getAllFiles(rootPath, files)
const args = ['-db', '-pc', String(files.compWxssNum)].concat(files.list) const args = ['-db', '-pc', String(options.pageCount)].concat(files)
const wxssParserPath = getWXSSParsePath() const wxssParserPath = getWXSSParsePath()
console.warn('wcsc args: ', args) console.warn('wcsc args: ', args)
const wcsc = spawnSync(wxssParserPath, args, { cwd: rootPath }) const wcsc = spawnSync(wxssParserPath, args, { cwd: rootPath })
if (wcsc.status === 0) { if (wcsc.status === 0) {
const res = wcsc.stdout.toString().split('=') let res = wcsc.stdout.toString();
res = res.split('=')
const funcList = {} const funcList = {}
for (let i = 0, len = res.length; i < len && res[i + 1]; i += 2) { for (let i = 0, len = res.length; i < len && res[i + 1]; i += 2) {
funcList[res[i]] = res[i + 1] funcList[res[i]] = res[i + 1].replace(
/((\\x[\da-f]{2}|\\u[\da-f]{4})){1,}/gi,
function ($0, $1, $2) {
return eval('"' + $0 + '"');
}
).replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) {
// console.log($0, $1)
const c = $0 === "\\n" ? "\n" : $0[1];
return c
})
} }
return funcList return funcList
} else { } else {

View File

@ -0,0 +1,186 @@
$gwx_XC_0=function(_,_v,_n,_p,_s,_wp,_wl,$gwn,$gwl,$gwh,wh,$gstack,$gwrt,gra,grb,TestTest,wfor,_ca,_da,_r,_rz,_o,_oz,_1,_1z,_2,_2z,_m,_mz,nv_getDate,nv_getRegExp,nv_console,nv_parseInt,nv_parseFloat,nv_isNaN,nv_isFinite,nv_decodeURI,nv_decodeURIComponent,nv_encodeURI,nv_encodeURIComponent,$gdc,nv_JSON,_af,_gv,_ai,_grp,_gd,_gapi,$ixc,_ic,_w,_ev,_tsd){return function(path,global){
if(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}
if(typeof __WXML_GLOBAL__ === 'undefined') {
__WXML_GLOBAL__={};
}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};
var e_={}
if(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;
var d_={}
if(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;
var f_={}
if(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};
var p_={}
var cs
__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}
__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};
__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};
var z=__WXML_GLOBAL__.ops_set.$gwx_XC_0 || [];
function gz$gwx_XC_0_1(){
if( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1
__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[];
(function(z){var a=11;function Z(ops){z.push(ops)}
Z([3,'container'])
Z([3,'0'])
Z([3,'userinfo'])
Z([3,'1'])
Z([3,'2'])
Z([[7],[3,'canIUseOpenData']])
Z([3,'bindViewTap'])
Z([3,'userinfo-avatar'])
Z([3,'3'])
Z([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box'])
Z([3,'4'])
Z([3,'userAvatarUrl'])
Z([3,'5'])
Z([3,'userNickName'])
Z([3,'6'])
Z([[2,'!'],[[7],[3,'hasUserInfo']]])
Z([[7],[3,'canIUseGetUserProfile']])
Z([3,'getUserProfile'])
Z([3,'7'])
Z([3,' 获取头像昵称 '])
Z([[7],[3,'canIUse']])
Z([3,'getUserInfo'])
Z([3,'8'])
Z(z[21])
Z(z[19])
Z([3,'9'])
Z([3,' 请使用1.4.4及以上版本基础库 '])
Z([3,'10'])
Z(z[6])
Z(z[7])
Z([3,'11'])
Z([3,'cover'])
Z([[6],[[7],[3,'userInfo']],[3,'avatarUrl']])
Z([3,'userinfo-nickname'])
Z([3,'12'])
Z([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]])
Z([3,'usermotto'])
Z([3,'13'])
Z([3,'user-motto'])
Z([3,'14'])
Z([a,[[7],[3,'motto']]])
})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1
}
__WXML_GLOBAL__.ops_set.$gwx_XC_0=z;
__WXML_GLOBAL__.ops_init.$gwx_XC_0=true;
var x=['./pages/index/index.wxml'];d_[x[0]]={}
var m0=function(e,s,r,gg){
var z=gz$gwx_XC_0_1()
cs.push("./pages/index/index.wxml:view:2:2")
var oB=_mz(z,'view',['class',0,'data-ib-structured-id',1],[],e,s,gg)
cs.push("./pages/index/index.wxml:view:3:4")
var xC=_mz(z,'view',['class',2,'data-ib-structured-id',1],[],e,s,gg)
var oD=_v()
_(xC,oD)
if(_oz(z,5,e,s,gg)){oD.wxVkey=1
cs.push("./pages/index/index.wxml:block:4:6")
cs.push("./pages/index/index.wxml:view:5:8")
var fE=_mz(z,'view',['bindtap',6,'class',1,'data-ib-structured-id',2,'style',3],[],e,s,gg)
cs.push("./pages/index/index.wxml:open-data:6:10")
var cF=_mz(z,'open-data',['data-ib-structured-id',10,'type',1],[],e,s,gg)
cs.pop()
_(fE,cF)
cs.pop()
_(oD,fE)
cs.push("./pages/index/index.wxml:open-data:8:8")
var hG=_mz(z,'open-data',['data-ib-structured-id',12,'type',1],[],e,s,gg)
cs.pop()
_(oD,hG)
cs.pop()
}
else if(_oz(z,15,e,s,gg)){oD.wxVkey=2
cs.push("./pages/index/index.wxml:block:10:6")
var oH=_v()
_(oD,oH)
if(_oz(z,16,e,s,gg)){oH.wxVkey=1
cs.push("./pages/index/index.wxml:button:11:8")
cs.push("./pages/index/index.wxml:button:11:8")
var cI=_mz(z,'button',['bindtap',17,'data-ib-structured-id',1],[],e,s,gg)
var oJ=_oz(z,19,e,s,gg)
_(cI,oJ)
cs.pop()
_(oH,cI)
cs.pop()
}
else if(_oz(z,20,e,s,gg)){oH.wxVkey=2
cs.push("./pages/index/index.wxml:button:12:8")
cs.push("./pages/index/index.wxml:button:12:8")
var lK=_mz(z,'button',['bindgetuserinfo',21,'data-ib-structured-id',1,'openType',2],[],e,s,gg)
var aL=_oz(z,24,e,s,gg)
_(lK,aL)
cs.pop()
_(oH,lK)
cs.pop()
}
else{oH.wxVkey=3
cs.push("./pages/index/index.wxml:view:13:8")
cs.push("./pages/index/index.wxml:view:13:8")
var tM=_n('view')
_rz(z,tM,'data-ib-structured-id',25,e,s,gg)
var eN=_oz(z,26,e,s,gg)
_(tM,eN)
cs.pop()
_(oH,tM)
cs.pop()
}
oH.wxXCkey=1
cs.pop()
}
else{oD.wxVkey=3
cs.push("./pages/index/index.wxml:block:15:6")
cs.push("./pages/index/index.wxml:image:16:8")
var bO=_mz(z,'image',['bindtap',28,'class',1,'data-ib-structured-id',2,'mode',3,'src',4],[],e,s,gg)
cs.pop()
_(oD,bO)
cs.push("./pages/index/index.wxml:text:17:8")
var oP=_mz(z,'text',['class',33,'data-ib-structured-id',1],[],e,s,gg)
var xQ=_oz(z,35,e,s,gg)
_(oP,xQ)
cs.pop()
_(oD,oP)
cs.pop()
}
oD.wxXCkey=1
cs.pop()
_(oB,xC)
cs.push("./pages/index/index.wxml:view:20:4")
var oR=_mz(z,'view',['class',36,'data-ib-structured-id',1],[],e,s,gg)
cs.push("./pages/index/index.wxml:text:21:6")
var fS=_mz(z,'text',['class',38,'data-ib-structured-id',1],[],e,s,gg)
var cT=_oz(z,40,e,s,gg)
_(fS,cT)
cs.pop()
_(oR,fS)
cs.pop()
_(oB,oR)
cs.pop()
_(r,oB)
return r
}
e_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}
if(path&&e_[path]){
window.__wxml_comp_version__=0.02
return function(env,dd,global){$gwxc=0;var root={"tag":"wx-page"};root.children=[]
;g="$gwx_XC_0";var main=e_[path].f
cs=[]
if (typeof global==="undefined")global={};global.f=$gdc(f_[path],"",1);
if(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)
{
env=window.__mergeData__(env,dd);
}
try{
main(env,{},root,global);
_tsd(root)
if(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}
}catch(err){
console.log(cs, env);
console.log(err)
throw err
}
;g="";
return root;
}
}
}
}(__g.a,__g.b,__g.c,__g.d,__g.e,__g.f,__g.g,__g.h,__g.i,__g.j,__g.k,__g.l,__g.m,__g.n,__g.o,__g.p,__g.q,__g.r,__g.s,__g.t,__g.u,__g.v,__g.w,__g.x,__g.y,__g.z,__g.A,__g.B,__g.C,__g.D,__g.E,__g.F,__g.G,__g.H,__g.I,__g.J,__g.K,__g.L,__g.M,__g.N,__g.O,__g.P,__g.Q,__g.R,__g.S,__g.T,__g.U,__g.V,__g.W,__g.X,__g.Y,__g.Z,__g.aa);if(__vd_version_info__.delayedGwx||false)$gwx_XC_0();

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

19
test/wcc/viewedit/ll.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
root_dir=$(cd `dirname $0`/../../.. && pwd -P)
# pkg_dir="/mnt/disk1/Project/WeCuit-Project/WeCuit-Mini-uni-test_uni_vue-cli/dist/build/mp-weixin"
pkg_dir="/home/msojocs/Documents/we1"
store_dir="$root_dir/test/wcc/ll/1"
# cd "$pkg_dir" && \
# wine "$root_dir/package.nw/js/vendor/wcc.exe" "-d" \
# "--split" ">_<6427" \
# "-xc" "2>_<6427./pages/index/index.wxml>_<64270>_<6427./pages/logs/logs.wxml>_<64270" "./pages/index/index.wxml" "./pages/logs/logs.wxml" \
# "-gn" "\$gwx" \
# "-ll" "./pages/index/index>_<6427./pages/logs/logs"
cd "$pkg_dir" && \
/mnt/disk1/GitHub/wechat-devtools-linux/compiler/wcc "-d" \
"--split" ">_<6427" \
"-xc" "2>_<6427./pages/index/index.wxml>_<64270>_<6427./pages/logs/logs.wxml>_<64270" "./pages/index/index.wxml" "./pages/logs/logs.wxml" \
"-gn" "\$gwx" \
"-ll" "./pages/index/index>_<6427./pages/logs/logs"

18
test/wcc/viewedit/ll1.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# 本脚本用于测试wcc编译器带ll参数时的编译结果
root_dir=$(cd `dirname $0`/../../.. && pwd -P)
# pkg_dir="/mnt/disk1/Project/WeCuit-Project/WeCuit-Mini-uni-test_uni_vue-cli/dist/build/mp-weixin"
pkg_dir="/home/msojocs/Documents/we1"
store_dir="$root_dir/test/wcc/ll/1"
cd "$pkg_dir" && \
"$root_dir/compiler/nodejs/wcc" "-d" "--split" ">_<9657" "-cc" "2>_<9657./pages/index/index.wxml>_<96570>_<9657./pages/logs/logs.wxml>_<96570" "./pages/index/index>_<9657./pages/logs/logs" "./pages/index/index.wxml" "./pages/logs/logs.wxml" "-gn" "\$gwx" \
"-ll" "./pages/index/index>_<7055./pages/logs/logs" \
> "$store_dir/nodejs.json"
diff "$store_dir/wine.json" "$store_dir/nodejs.json" >/dev/null
if [ "$?" == "0" ];then
echo "the file or dir is same!"
else
echo "the file or dir is different!"
fi

File diff suppressed because one or more lines are too long

21
test/wcc/viewedit/wcc.js Normal file
View File

@ -0,0 +1,21 @@
const wcc = require('../../../package.nw/node_modules/wcc')
const fs = require('fs')
const options = {
"files": ["./pages/index/index.wxml", "./pages/logs/logs.wxml"],
"debugWXS": false,
"debug": true,
"genfuncname": "$gwx",
"wxmlCompileConfig": "2>_<7055./pages/index/index.wxml>_<70550>_<7055./pages/logs/logs.wxml>_<70550",
"wxmlCompileConfigSplit": ">_<7055",
"replaceContent": {
"./pages/index/index.wxml": "<!--index.wxml-->\n<view class=\"container\" data-ib-structured-id=\"0\">\n <view class=\"userinfo\" data-ib-structured-id=\"1\">\n <block wx:if=\"{{canIUseOpenData}}\" data-ib-structured-id=\"2\">\n <view class=\"userinfo-avatar\" bindtap=\"bindViewTap\" style=\"width: 183rpx; height: 148rpx; display: block; box-sizing: border-box\" data-ib-structured-id=\"3\">\n <open-data type=\"userAvatarUrl\" data-ib-structured-id=\"4\"></open-data>\n </view>\n <open-data type=\"userNickName\" data-ib-structured-id=\"5\"></open-data>\n </block>\n <block wx:elif=\"{{!hasUserInfo}}\" data-ib-structured-id=\"6\">\n <button wx:if=\"{{canIUseGetUserProfile}}\" bindtap=\"getUserProfile\" data-ib-structured-id=\"7\"> 获取头像昵称 </button>\n <button wx:elif=\"{{canIUse}}\" open-type=\"getUserInfo\" bindgetuserinfo=\"getUserInfo\" data-ib-structured-id=\"8\"> 获取头像昵称 </button>\n <view wx:else data-ib-structured-id=\"9\"> 请使用1.4.4及以上版本基础库 </view>\n </block>\n <block wx:else data-ib-structured-id=\"10\">\n <image bindtap=\"bindViewTap\" class=\"userinfo-avatar\" src=\"{{userInfo.avatarUrl}}\" mode=\"cover\" data-ib-structured-id=\"11\"></image>\n <text class=\"userinfo-nickname\" data-ib-structured-id=\"12\">{{userInfo.nickName}}</text>\n </block>\n </view>\n <view class=\"usermotto\" data-ib-structured-id=\"13\">\n <text class=\"user-motto\" data-ib-structured-id=\"14\">{{motto}}</text>\n </view>\n</view>\n"
},
"cwd": "/home/msojocs/Documents/we1",
"lazyloadConfig": "./pages/index/index>_<7055./pages/logs/logs"
}
wcc(options)
.then(res=>{
console.log(res)
fs.writeFileSync('test/wcc/viewedit/1/node.json', res)
})

View File

@ -0,0 +1,8 @@
{
"common": "var BASE_DEVICE_WIDTH = 750;\nvar isIOS=navigator.userAgent.match(\"iPhone\");\nvar deviceWidth = window.screen.width || 375;\nvar deviceDPR = window.devicePixelRatio || 2;\nvar checkDeviceWidth = window.__checkDeviceWidth__ || function() {\nvar newDeviceWidth = window.screen.width || 375\nvar newDeviceDPR = window.devicePixelRatio || 2\nvar newDeviceHeight = window.screen.height || 375\nif (window.screen.orientation && /^landscape/.test(window.screen.orientation.type || '')) newDeviceWidth = newDeviceHeight\nif (newDeviceWidth !== deviceWidth || newDeviceDPR !== deviceDPR) {\ndeviceWidth = newDeviceWidth\ndeviceDPR = newDeviceDPR\n}\n}\ncheckDeviceWidth()\nvar eps = 1e-4;\nvar transformRPX = window.__transformRpx__ || function(number, newDeviceWidth) {\nif ( number === 0 ) return 0;\nnumber = number / BASE_DEVICE_WIDTH * ( newDeviceWidth || deviceWidth );\nnumber = Math.floor(number + eps);\nif (number === 0) {\nif (deviceDPR === 1 || !isIOS) {\nreturn 1;\n} else {\nreturn 0.5;\n}\n}\nreturn number;\n}\nwindow.__rpxRecalculatingFuncs__ = window.__rpxRecalculatingFuncs__ || [];\nvar __COMMON_STYLESHEETS__ = __COMMON_STYLESHEETS__||{}\n\nvar setCssToHead = function(file, _xcInvalid, info) {\nvar Ca = {};\nvar css_id;\nvar info = info || {};\nvar _C = __COMMON_STYLESHEETS__\nfunction makeup(file, opt) {\nvar _n = typeof(file) === \"string\";\nif ( _n && Ca.hasOwnProperty(file)) return \"\";\nif ( _n ) Ca[file] = 1;\nvar ex = _n ? _C[file] : file;\nvar res=\"\";\nfor (var i = ex.length - 1; i >= 0; i--) {\nvar content = ex[i];\nif (typeof(content) === \"object\")\n{\nvar op = content[0];\nif ( op == 0 )\nres = transformRPX(content[1], opt.deviceWidth) + \"px\" + res;\nelse if ( op == 1)\nres = opt.suffix + res;\nelse if ( op == 2 )\nres = makeup(content[1], opt) + res;\n}\nelse\nres = content + res\n}\nreturn res;\n}\nvar styleSheetManager = window.__styleSheetManager2__\nvar rewritor = function(suffix, opt, style){\nopt = opt || {};\nsuffix = suffix || \"\";\nopt.suffix = suffix;\nif ( opt.allowIllegalSelector != undefined && _xcInvalid != undefined )\n{\nif ( opt.allowIllegalSelector )\nconsole.warn( \"For developer:\" + _xcInvalid );\nelse\n{\nconsole.error( _xcInvalid );\n}\n}\nCa={};\ncss = makeup(file, opt);\nif (styleSheetManager) {\nvar key = (info.path || Math.random()) + ':' + suffix\nif (!style) {\nstyleSheetManager.addItem(key, info.path);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, true);\n});\n}\nstyleSheetManager.setCss(key, css);\nreturn;\n}\nif ( !style )\n{\nvar head = document.head || document.getElementsByTagName('head')[0];\nstyle = document.createElement('style');\nstyle.type = 'text/css';\nstyle.setAttribute( \"wxss:path\", info.path );\nhead.appendChild(style);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, style);\n});\n}\nif (style.styleSheet) {\nstyle.styleSheet.cssText = css;\n} else {\nif ( style.childNodes.length == 0 )\nstyle.appendChild(document.createTextNode(css));\nelse\nstyle.childNodes[0].nodeValue = css;\n}\n}\nreturn rewritor;\n}\nsetCssToHead([])();setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})();",
"pageWxss": {
"./app.wxss": "setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})",
"./pages/index/index.wxss": "setCssToHead([\".\",[1],\"userinfo { display: flex; flex-direction: column; align-items: center; color: #aaa; ;wxcs_originclass: .userinfo;;wxcs_fileinfo: ./pages/index/index.wxss 2 1; }\\n.\",[1],\"userinfo-avatar { overflow: hidden; width: \",[0,128],\"; ;wxcs_style_width : 128rpx; height: \",[0,128],\"; ;wxcs_style_height : 128rpx; margin: \",[0,20],\"; ;wxcs_style_margin : 20rpx; border-radius: 50%; ;wxcs_originclass: .userinfo-avatar;;wxcs_fileinfo: ./pages/index/index.wxss 9 1; }\\n.\",[1],\"usermotto { margin-top: 200px; ;wxcs_originclass: .usermotto;;wxcs_fileinfo: ./pages/index/index.wxss 17 1; }\\n\",],undefined,{path:\"./pages/index/index.wxss\"})",
"./pages/logs/logs.wxss": "setCssToHead([\".\",[1],\"log-list { display: flex; flex-direction: column; padding: \",[0,40],\"; ;wxcs_style_padding : 40rpx; ;wxcs_originclass: .log-list;;wxcs_fileinfo: ./pages/logs/logs.wxss 1 1; }\\n.\",[1],\"log-item { margin: \",[0,10],\"; ;wxcs_style_margin : 10rpx; ;wxcs_originclass: .log-item;;wxcs_fileinfo: ./pages/logs/logs.wxss 6 1; }\\n\",],undefined,{path:\"./pages/logs/logs.wxss\"})"
}
}

View File

@ -0,0 +1,8 @@
{
"common": "var BASE_DEVICE_WIDTH = 750;\nvar isIOS=navigator.userAgent.match(\"iPhone\");\nvar deviceWidth = window.screen.width || 375;\nvar deviceDPR = window.devicePixelRatio || 2;\nvar checkDeviceWidth = window.__checkDeviceWidth__ || function() {\nvar newDeviceWidth = window.screen.width || 375\nvar newDeviceDPR = window.devicePixelRatio || 2\nvar newDeviceHeight = window.screen.height || 375\nif (window.screen.orientation && /^landscape/.test(window.screen.orientation.type || '')) newDeviceWidth = newDeviceHeight\nif (newDeviceWidth !== deviceWidth || newDeviceDPR !== deviceDPR) {\ndeviceWidth = newDeviceWidth\ndeviceDPR = newDeviceDPR\n}\n}\ncheckDeviceWidth()\nvar eps = 1e-4;\nvar transformRPX = window.__transformRpx__ || function(number, newDeviceWidth) {\nif ( number === 0 ) return 0;\nnumber = number / BASE_DEVICE_WIDTH * ( newDeviceWidth || deviceWidth );\nnumber = Math.floor(number + eps);\nif (number === 0) {\nif (deviceDPR === 1 || !isIOS) {\nreturn 1;\n} else {\nreturn 0.5;\n}\n}\nreturn number;\n}\nwindow.__rpxRecalculatingFuncs__ = window.__rpxRecalculatingFuncs__ || [];\nvar __COMMON_STYLESHEETS__ = __COMMON_STYLESHEETS__||{}\n\nvar setCssToHead = function(file, _xcInvalid, info) {\nvar Ca = {};\nvar css_id;\nvar info = info || {};\nvar _C = __COMMON_STYLESHEETS__\nfunction makeup(file, opt) {\nvar _n = typeof(file) === \"string\";\nif ( _n && Ca.hasOwnProperty(file)) return \"\";\nif ( _n ) Ca[file] = 1;\nvar ex = _n ? _C[file] : file;\nvar res=\"\";\nfor (var i = ex.length - 1; i >= 0; i--) {\nvar content = ex[i];\nif (typeof(content) === \"object\")\n{\nvar op = content[0];\nif ( op == 0 )\nres = transformRPX(content[1], opt.deviceWidth) + \"px\" + res;\nelse if ( op == 1)\nres = opt.suffix + res;\nelse if ( op == 2 )\nres = makeup(content[1], opt) + res;\n}\nelse\nres = content + res\n}\nreturn res;\n}\nvar styleSheetManager = window.__styleSheetManager2__\nvar rewritor = function(suffix, opt, style){\nopt = opt || {};\nsuffix = suffix || \"\";\nopt.suffix = suffix;\nif ( opt.allowIllegalSelector != undefined && _xcInvalid != undefined )\n{\nif ( opt.allowIllegalSelector )\nconsole.warn( \"For developer:\" + _xcInvalid );\nelse\n{\nconsole.error( _xcInvalid );\n}\n}\nCa={};\ncss = makeup(file, opt);\nif (styleSheetManager) {\nvar key = (info.path || Math.random()) + ':' + suffix\nif (!style) {\nstyleSheetManager.addItem(key, info.path);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, true);\n});\n}\nstyleSheetManager.setCss(key, css);\nreturn;\n}\nif ( !style )\n{\nvar head = document.head || document.getElementsByTagName('head')[0];\nstyle = document.createElement('style');\nstyle.type = 'text/css';\nstyle.setAttribute( \"wxss:path\", info.path );\nhead.appendChild(style);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, style);\n});\n}\nif (style.styleSheet) {\nstyle.styleSheet.cssText = css;\n} else {\nif ( style.childNodes.length == 0 )\nstyle.appendChild(document.createTextNode(css));\nelse\nstyle.childNodes[0].nodeValue = css;\n}\n}\nreturn rewritor;\n}\nsetCssToHead([])();setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})();",
"pageWxss": {
"./app.wxss": "setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})",
"./pages/index/index.wxss": "setCssToHead([\".\",[1],\"userinfo { display: flex; flex-direction: column; align-items: center; color: #aaa; ;wxcs_originclass: .userinfo;;wxcs_fileinfo: ./pages/index/index.wxss 2 1; }\\n.\",[1],\"userinfo-avatar { overflow: hidden; width: \",[0,128],\"; ;wxcs_style_width : 128rpx; height: \",[0,128],\"; ;wxcs_style_height : 128rpx; margin: \",[0,20],\"; ;wxcs_style_margin : 20rpx; border-radius: 50%; ;wxcs_originclass: .userinfo-avatar;;wxcs_fileinfo: ./pages/index/index.wxss 9 1; }\\n.\",[1],\"usermotto { margin-top: 200px; ;wxcs_originclass: .usermotto;;wxcs_fileinfo: ./pages/index/index.wxss 17 1; }\\n\",],undefined,{path:\"./pages/index/index.wxss\"})",
"./pages/logs/logs.wxss": "setCssToHead([\".\",[1],\"log-list { display: flex; flex-direction: column; padding: \",[0,40],\"; ;wxcs_style_padding : 40rpx; ;wxcs_originclass: .log-list;;wxcs_fileinfo: ./pages/logs/logs.wxss 1 1; }\\n.\",[1],\"log-item { margin: \",[0,10],\"; ;wxcs_style_margin : 10rpx; ;wxcs_originclass: .log-item;;wxcs_fileinfo: ./pages/logs/logs.wxss 6 1; }\\n\",],undefined,{path:\"./pages/logs/logs.wxss\"})"
}
}

View File

@ -0,0 +1,25 @@
const wcsc = require('../../../package.nw/node_modules/wcsc')
const fs = require('fs')
const options = {
"files": [
"./pages/index/index.wxss",
"./pages/logs/logs.wxss",
"./app.wxss"],
"contents": [
"/**index.wxss**/\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n}\n\n.userinfo-avatar {\n overflow: hidden;\n width: 128rpx;\n height: 128rpx;\n margin: 20rpx;\n border-radius: 50%;\n}\n\n.usermotto {\n margin-top: 200px;\n}", ".log-list {\n display: flex;\n flex-direction: column;\n padding: 40rpx;\n}\n.log-item {\n margin: 10rpx;\n}\n", "/**app.wxss**/\n.container {\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: space-between;\n padding: 200rpx 0;\n box-sizing: border-box;\n} \n"
],
"pageCount": 2,
"cwd": "/home/msojocs/Documents/we1",
"replaceContent": {
"./pages/index/index.wxss": "/**index.wxss**/\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n}\n\n.userinfo-avatar {\n overflow: hidden;\n width: 128rpx;\n height: 128rpx;\n margin: 20rpx;\n border-radius: 50%;\n}\n\n.usermotto {\n margin-top: 200px;\n}"
},
"debug": true,
"classPrefix": "",
"lazyload": true
}
wcsc(options)
.then(res=>{
console.log(res)
fs.writeFileSync('test/wcsc/viewedit/1/node.json', JSON.stringify(res, null, 2))
})