Compare commits

...

11 Commits

Author SHA1 Message Date
msojocs
5841b9c128 refactor: 使用napi重写 2025-05-02 13:09:50 +08:00
msojocs
41370c6371 fix: arch linux崩溃 2025-05-02 08:58:59 +08:00
msojocs
5ca14f224f fix: 处理多出的一个括号。(上个版本修改不正确) 2025-02-17 23:09:36 +08:00
msojocs
f31c7dbe8f
fix: wcsc 索引与 一个括号 (#12)
* fix: wine environment

* fix: wine environment

* fix: environment

* perf: remove recommend

* fix: env

* Update release.yml

* fix: permission of wcsc.exe

* fix: 一处越界问题

* fix: pnpm install

* fix: wine prepare

* fix: wine cfg

* feat: error console

* fix: 兼容clang

* perf: 调整位置

* perf: 带入环境

* fix: version

* perf: log

* fix: version check

* fix: version

* fix: wcsc 索引与 一个括号
处理一处索引出现负数的问题;
一处css输出了多余的括号。

* fix: ci
2025-02-16 22:43:43 +08:00
msojocs
754a09886e
chore: 使用新的CI流程 (#11)
* fix: wine environment

* fix: wine environment

* fix: environment

* perf: remove recommend

* fix: env

* Update release.yml

* fix: permission of wcsc.exe

* fix: 一处越界问题

* fix: pnpm install

* fix: wine prepare

* fix: wine cfg

* feat: error console

* fix: 兼容clang

* perf: 调整位置

* perf: 带入环境

* fix: version

* perf: log

* fix: version check

* fix: version
2025-01-22 16:55:30 +08:00
msojocs
002f1b4c33 update: runner version 2025-01-17 22:49:50 +08:00
msojocs
bf19db4f47 update: add new wine version 2025-01-17 22:48:09 +08:00
msojocs
abeecb601c docs: v0.1.1 2024-08-10 10:20:36 +08:00
msojocs
4b0ae120ab fix: ci 2024-08-10 10:10:20 +08:00
msojocs
bb1c888ea9 fix: 标签未闭合会崩溃 2024-08-10 10:01:16 +08:00
msojocs
2c0cb9bdfc feat: support for --wxs 2024-07-13 21:49:54 +08:00
70 changed files with 16261 additions and 14023 deletions

View File

@ -18,7 +18,7 @@ on:
jobs:
build:
name: Build Base Packages
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
@ -58,7 +58,7 @@ jobs:
run: |
export DOCKER_UID=$UID
export DOCKER_GID=$GID
docker-compose up
docker compose up
- name: Upload prepare
run: |
@ -71,7 +71,7 @@ jobs:
ls -l
- name: Upload artifact
uses: actions/upload-artifact@v2.3.1
uses: actions/upload-artifact@v4
with:
# Artifact name
name: wx-compiler-${{ matrix.ARCH }}.build
@ -81,7 +81,7 @@ jobs:
name: Test for spec
needs:
- build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x]
@ -99,40 +99,26 @@ jobs:
node-version: '18.12.0'
check-latest: false
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
- name: Inspect directory after downloading artifacts
run: ls -alFR
- name: Prepare
run: |
set -x -u -o pipefail
source /etc/os-release
# Get rid of packages installed from ppa:ondrej/php so that we will be able to install wine32:i386 without conflicts
# (see issue https://github.com/actions/virtual-environments/issues/4589)
# In detail we:
# 1. Remove all packages that ppa:ondrej/php has but plain Ubuntu doesn't, e.g. everything PHP
# 2. Revert (remaining) packages that ppa:ondrej/php and plain Ubuntu share, back to the plain Ubuntu version
# 3. Assert that no packages from ppa:ondrej/php are left installed
dpkg -l | grep '^ii' | grep -F deb.sury.org | awk '{print $2}' | grep '^php' \
| xargs -r -t sudo apt-get remove --yes libpcre2-posix3 libzip4
dpkg -l | grep '^ii' | grep -F deb.sury.org | awk '{print $2}' | sed "s,\$,/${UBUNTU_CODENAME}," \
| xargs -r -t sudo apt-get install --yes --no-install-recommends --allow-downgrades -V
! dpkg -l | grep '^ii' | grep -F deb.sury.org
set -x
sudo apt update
sudo apt install -y wine64
sudo apt-add-repository universe
sudo apt upgrade -y
sudo dpkg --add-architecture i386
dpkg --print-foreign-architectures
sudo apt update
sudo apt install libwine
echo "install wine32..."
sudo apt install wine32
sudo apt-get install wine-binfmt
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
sudo apt update
sudo apt install winehq-stable -y
sudo apt-get install wine-binfmt wine32 -y
sudo update-binfmts --import /usr/share/binfmts/wine
wine --version
corepack enable
ls -l
@ -144,20 +130,21 @@ jobs:
chmod +x build/*
ls -l build
node -v
pnpm install
pnpm install --no-frozen-lockfile
- name: Test
run: |
ls -l test/wine
# ./test/wine/wcc.exe
sudo apt install -y xvfb curl
pnpm run test-prepare
sudo apt install -y xvfb
ls -l build
ls -l test/runner/nwjs/wcc/build/Release
# fix: 预先运行,做一下配置,不然第一次执行会有问题
./test/wine/wcc.exe || true
./test/wine/wcc.exe -v || true
# 需要wine64
pnpm run test
# - uses: ./.github/actions/test
# with:
# who-to-greet: 'Mona the Octocat'
upload:
name: Create release and upload artifacts
@ -166,7 +153,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
- name: Inspect directory after downloading artifacts
run: ls -alFR
@ -191,7 +178,7 @@ jobs:
sudo apt install -y fuse
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
chmod +x pyuploadtool-x86_64.AppImage
./pyuploadtool-x86_64.AppImage **build/wcc **build/wcsc
./pyuploadtool-x86_64.AppImage **build/wcc **build/wcsc **build/wcc_module.node **build/wcsc_module.node
- name: Release
uses: softprops/action-gh-release@v1

3
.gitignore vendored
View File

@ -8,4 +8,5 @@ node_modules
*err.js
*stderr.json
.cache
*/spec/**/*output.js
*/spec/**/*output.js
tmp

View File

@ -4,7 +4,15 @@ module.exports = {
'ts-node/register'
],
recursive: true,
spec: "./test/spec/**/*.spec.ts",
// spec: "test/spec/wcsc/module/module.spec.ts",
// spec: "./test/spec/**/*.spec.ts",
spec: [
"./test/spec/**/*.spec.ts",
// 'test/spec/wcc/module/module.spec.ts',
// 'test/spec/issue/137/issue137.spec.ts',
// 'test/spec/issue/129/issue129.spec.ts',
// 'test/spec/issue/115/issue115.spec.ts',
// 'test/spec/wcc/module/module.spec.ts',
],
// spec: "test/spec/wcc/wxs/wxs.spec.ts",
timeout: 20000,
}

115
.vscode/launch.json vendored
View File

@ -4,7 +4,118 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Linux module test",
"program": "${workspaceFolder}/cache/nwjs-sdk-v0.55.0-linux-x64/nw",
"args": [
"${workspaceFolder}/test/runner/nwjs/compiler.js",
"wcsc",
"${workspaceFolder}/test/spec/issue/137/data/example.json"
],
"cwd": "${workspaceFolder}"
},
{
"name": "wcc wxs sample2",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/wcc",
"args": [
"--wxs",
"${workspaceRoot}/test/spec/wcc/wxs/sample2.json"
],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"sourceFileMap":{
"${workspaceRoot}": {
"editorPath": "${workspaceRoot}",
"useForBreakpoints": true
}
}
},
{
"name": "wcc wxs sample3",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/wcc",
"args": [
"--wxs",
"${workspaceRoot}/test/spec/wcc/wxs/sample3.json"
],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"sourceFileMap":{
"${workspaceRoot}": {
"editorPath": "${workspaceRoot}",
"useForBreakpoints": true
}
}
},
{
"name": "wcc wxs sample4",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/wcc",
"args": [
"--wxs",
"${workspaceRoot}/test/spec/wcc/wxs/sample4.json"
],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"sourceFileMap":{
"${workspaceRoot}": {
"editorPath": "${workspaceRoot}",
"useForBreakpoints": true
}
}
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
@ -12,10 +123,10 @@
"program": "${workspaceFolder}/build/wcc",
"args": [
"\"--config-path\"",
"\"/home/msojocs/github/wx-compiler/test/spec/issue/102/case1.txt\""
"\"${workspaceRoot}/test/spec/issue/102/case1.txt\""
],
"stopAtEntry": false,
"cwd": "/home/msojocs/github/wx-compiler/test/spec/issue/102/wxapp",
"cwd": "${workspaceRoot}/test/spec/issue/102/wxapp",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",

View File

@ -86,5 +86,6 @@
"--background-index",
"--compile-commands-dir=${workspaceFolder}/build/"
],
"cmake.sourceDirectory": "/home/msojocs/github/wx-compiler"
"cmake.sourceDirectory": "/home/msojocs/github/wx-compiler",
"clangd.path": "clangd-18"
}

View File

@ -3,10 +3,8 @@ project(wx_complier VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)
# message("before: ${CMAKE_CXX_FLAGS_DEBUG}")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1")
# message("after: ${CMAKE_CXX_FLAGS_DEBUG}")
set(TARGET_ARCH x64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_REENTRANT")
add_executable(wcc
src/wcc.cpp

View File

@ -1,3 +1,33 @@
## 🌈 v0.1.4 / 2025-05-01
🐞 Bug Fixes
- `WXSS::CSSTreeLib::CSSSyntaxTree::RenderCode`: Arch linux会崩溃.(数组访问越界)
## 🌈 v0.1.3 / 2025-02-17
🐞 Bug Fixes
- `WXML::Rewrite::RewriteImg`: 输出了多余的右括号。(上个版本修改不正确)
## 🌈 v0.1.2 / 2025-02-16
🐞 Bug Fixes
- `WXML::RPX::accept`: 数组出现负数的问题。
- `WXML::Rewrite::RewriteImg`: 输出了多余的右括号。
## 🌈 v0.1.1 / 2024-08-10
🐞 Bug Fixes
- `WXML::DOMLib::Parser::Error`: 标签未闭合的异常导致崩溃,感谢 [@yutent](https://github.com/yutent) ( [issue ref](https://github.com/msojocs/wechat-web-devtools-linux/issues/115) )
## 🌈 v0.1.0 / 2024-07-13
🚀Features
- 编译器:支持 `--wxs` 参数
## 🌈 v0.0.9 / 2024-07-07
🚀Features

View File

@ -1,4 +1,3 @@
version: "3"
services:
wx_compiler:
image: jiyecafe/wechat-devtools-build:v3

View File

@ -1,5 +1,9 @@
#!/bin/bash
set -ex
npm install -g pnpm@8
pnpm install
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC
echo "----"
strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_

View File

@ -1,4 +1,5 @@
#!/bin/bash
set -ex
gcc --version
g++ --version
# cmake --verion

View File

@ -11,6 +11,17 @@
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bindings": "^1.5.0",
"cmake-js": "^7.3.0",
"node-addon-api": "^7.1.0",
"node-api-headers": "^1.5.0"
},
"binary": {
"napi_versions": [
7
]
},
"devDependencies": {
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.13",
@ -22,5 +33,6 @@
"miniprogram-ci": "^1.9.8",
"mocha": "^10.0.0",
"ts-node": "^10.9.1"
}
},
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
}

7832
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -6,4 +6,5 @@
std::string DictToJsonString(std::map<std::string,std::string> const&);
std::string EscapeToJsonString(std::string const&);
int GetJsonDict(std::string &a1, std::map<std::string, std::string>& a2);
#endif

View File

@ -54,6 +54,7 @@ namespace night
int compile_ns(std::string const&,std::string const&,std::string const&,uint,std::string&,bool);
void compile_ns_with_sourcemap(std::string const&,std::string const&,std::string const&,std::string const&,uint,std::string&,std::string&);
int compile_ns_no_wrapper(std::string const& a1, std::string const& a2, uint a5, std::string& a6, bool a7);
void readfile(char const*, std::string &);
void writefile(char const*, std::string &);
@ -310,7 +311,7 @@ namespace night
std::vector<std::string> * offset_28 = nullptr;
int offset_32 = 0;
std::vector<night::ns_sourcemap> offset_36;
int offset_48;
int offset_48 = 1;
NSCompileJs(/* args */);
~NSCompileJs();
std::string compile(night::ns_node *);

View File

@ -1,10 +1,13 @@
#ifndef __WXML_H_
#define __WXML_H_
#include "define.h"
#include <exception>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <cstring>
#include <memory>
@ -193,13 +196,16 @@ namespace WXML
std::pair<std::string,WXML::DOMLib::Token> const& a1,
std::pair<std::string,WXML::DOMLib::Token> const& a2);
class ParseException
class ParseException: public std::exception
{
private:
/* data */
std::string msg;
public:
ParseException(/* args */);
ParseException(std::string& msg);
~ParseException();
const char* what(/* args */);
};
class Machine
@ -711,6 +717,19 @@ namespace WXML
} // namespace EXPRLib
namespace GlassEaselWxs {
const std::string sWrapper = "function n(nv_require,nv_exports,nv_module){%s}const t={nv_exports:{}};n((function(n){n.startsWith(\"p_\")&&(n=\"/\"+n.slice(2)),n.endsWith(\".wxs\")&&(n=n.slice(0,n.length-4));const t=gdc(require(n),\"nv_\");return function(){return t}}),t.nv_exports,t),Object.assign(module,gdc(t,void 0));";
const std::string sGenFuncDeepCopy = "var gdc=function(){var e=function(){return void 0!==this?this:\"undefined\"!=typeof globalThis?globalThis:\"undefine"
"d\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{}}();return function("
"n,t,o,i=e){if(null==n)return n;if(\"undefined\"!=typeof __wxCodeSpace__&&\"function\"==typeof __wxCodeSpace__.isWxsS"
"tateObject&&__wxCodeSpace__.isWxsStateObject(n))return n;if(\"string\"==typeof n||\"boolean\"==typeof n||\"number\"="
"=typeof n)return n;if(Array.isArray(n)){const e=[];for(let i=0;i<n.length;i++)e.push(gdc(n[i],t,o,n));return e}if(n "
"instanceof Date){const e=new Date;return e.setTime(n.getTime()),e}if(n instanceof RegExp){let e=\"\";return n.global"
"&&(e+=\"g\"),n.ignoreCase&&(e+=\"i\"),n.multiline&&(e+=\"m\"),new RegExp(n.source,e)}if(\"object\"==typeof n){const "
"e={};for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&(void 0===t?e[i.substring(3)]=gdc(n[i],t,o,n):e[t+i]="
"gdc(n[i],t,o,n));return e}return\"function\"==typeof n?1===o?null:function(...e){const o=gdc(e,void 0===t?\"nv_\":vo"
"id 0),r=n.apply(i,o);return gdc(r,t)}:null}}();";
const std::string sWxsEnvInit = aUndefinedTypeo;
};
}
#endif

View File

@ -46,7 +46,7 @@ namespace WXSS
/* data */
public:
using STATE = int;
static int TT[26113];
static int TT[26114];
static bool bInited;
std::string offset_0; // 文件内容
std::string offset_24; // 文件路径

View File

@ -3,47 +3,65 @@ message("current dir: ${CMAKE_CURRENT_SOURCE_DIR}")
execute_process(
COMMAND mkdir -p ${CMAKE_CURRENT_SOURCE_DIR}/cache;
)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cache/nw-headers-v${NW_VERSION}.tar.gz")
execute_process(
COMMAND wget -c -O nw-headers-v${NW_VERSION}.tar.gz.tmp https://dl.nwjs.io/v${NW_VERSION}/nw-headers-v${NW_VERSION}.tar.gz;
COMMAND mv nw-headers-v${NW_VERSION}.tar.gz.tmp nw-headers-v${NW_VERSION}.tar.gz;
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cache
OUTPUT_VARIABLE CMAKE_JS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
execute_process(COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/node WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/node")
execute_process(COMMAND tar -zxf nw-headers-v${NW_VERSION}.tar.gz -C ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cache)
endif()
# if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/node-v${NW_VERSION}.lib")
# execute_process(
# COMMAND wget -c -O node-v${NW_VERSION}.lib.tmp https://dl.nwjs.io/v${NW_VERSION}/node.lib;
# COMMAND mv node-v${NW_VERSION}.lib.tmp node-v${NW_VERSION}.lib;
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib
# OUTPUT_VARIABLE CMAKE_JS_VERSION
# OUTPUT_STRIP_TRAILING_WHITESPACE
# )
# endif()
# if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/nw-v${NW_VERSION}.lib")
# execute_process(
# COMMAND wget -c -O nw-v${NW_VERSION}.lib.tmp https://dl.nwjs.io/v${NW_VERSION}/nw.lib;
# COMMAND mv nw-v${NW_VERSION}.lib.tmp nw-v${NW_VERSION}.lib;
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib
# OUTPUT_VARIABLE CMAKE_JS_VERSION
# OUTPUT_STRIP_TRAILING_WHITESPACE
# )
# endif()
include_directories(node/src)
include_directories(node/include/node)
include_directories(node/deps/v8/include)
include_directories(node/deps/uv/include)
find_program(PNPM_EXECUTABLE pnpm)
if(NOT PNPM_EXECUTABLE)
message(FATAL_ERROR "pnpm not found!")
endif()
if(WIN32)
set(PNPM_EXECUTABLE "${PNPM_EXECUTABLE}.CMD")
endif()
message("CMAKE_CXX_FLAGS:${CMAKE_CXX_FLAGS}")
message("获取 cmake-js 配置")
message(${PROJECT_SOURCE_DIR})
execute_process(COMMAND
${PNPM_EXECUTABLE} --silent cmake-js --version
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE CMAKE_JS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND
${PNPM_EXECUTABLE} cmake-js print-cmakejs-src --arch ${TARGET_ARCH} --silent -l error
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE CMAKE_JS_SRC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message("获取 CMAKE_JS_SRC 配置: ${CMAKE_JS_SRC}")
message("PNPM_EXECUTABLE: " ${PNPM_EXECUTABLE})
execute_process(COMMAND
${PNPM_EXECUTABLE} cmake-js print-cmakejs-include --silent -l error
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE CMAKE_JS_INC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message("CMAKE_JS_INC:" ${CMAKE_JS_INC})
foreach(item IN LISTS CMAKE_JS_INC)
message("include: ${item}")
include_directories(${item})
endforeach()
message("获取 node-addon-api 配置")
execute_process(COMMAND
node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message("node-addon-api 路径:${NODE_ADDON_API_DIR}")
message("CMAKE_JS_INC: " ${CMAKE_JS_INC})
message("CMAKE_JS_SRC: " ${CMAKE_JS_SRC})
message("CMAKE_JS_LIB: " ${CMAKE_JS_LIB})
include_directories(${CMAKE_JS_SRC})
include_directories(${NODE_ADDON_API_DIR})
add_library(wcc_module
SHARED
./wcc.cpp
./include/wcc.hh
./config/wcc.hh
./config/wcc.cc
../include/wxml.h
../include/night.h
@ -85,11 +103,10 @@ add_library(wcc_module
../utils/json.cpp
../utils/string_utils.cpp
../utils/file.cpp
${CMAKE_JS_SRC}
)
target_link_libraries(wcc_module PRIVATE rt pthread)
set_target_properties(wcc_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# DV8_COMPRESS_POINTERS: IsString
target_compile_options(wcc_module PRIVATE "-DNODE_GYP_MODULE_NAME=binding" "-DUSING_UV_SHARED=1" "-DUSING_V8_SHARED=1" "-DV8_DEPRECATION_WARNINGS=1" "-DV8_DEPRECATION_WARNINGS" "-DV8_REVERSE_JSARGS" "-D_GLIBCXX_USE_CXX11_ABI=1" "-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64" "-DV8_COMPRESS_POINTERS" "-DV8_31BIT_SMIS_ON_64BIT_ARCH" "-D__STDC_FORMAT_MACROS" "-DOPENSSL_NO_PINSHARED" "-DOPENSSL_THREADS" "-DOPENSSL_NO_ASM" "-DBUILDING_NODE_EXTENSION")
set_target_properties(wcc_module PROPERTIES PREFIX "" SUFFIX ".node")
# target_link_libraries(wcc_module ${CMAKE_CURRENT_SOURCE_DIR}/lib/nw-v${NW_VERSION}.lib)
# target_link_libraries(wcc_module ${CMAKE_CURRENT_SOURCE_DIR}/lib/node-v${NW_VERSION}.lib)
@ -98,6 +115,7 @@ set_target_properties(wcc_module PROPERTIES PREFIX "" SUFFIX ".node")
add_library(wcsc_module
SHARED
./wcsc.cpp
./config/wcsc.hh
./config/wcsc.cc
../wcsc/usage.cpp
../wxa/wxa.cpp
@ -119,8 +137,8 @@ add_library(wcsc_module
../utils/json.cpp
../utils/string_utils.cpp
../utils/file.cpp
${CMAKE_JS_SRC}
)
target_link_libraries(wcsc_module PRIVATE rt pthread)
set_target_properties(wcsc_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# DV8_COMPRESS_POINTERS: IsString
target_compile_options(wcsc_module PRIVATE "-DNODE_GYP_MODULE_NAME=binding" "-DUSING_UV_SHARED=1" "-DUSING_V8_SHARED=1" "-DV8_DEPRECATION_WARNINGS=1" "-DV8_DEPRECATION_WARNINGS" "-DV8_REVERSE_JSARGS" "-D_GLIBCXX_USE_CXX11_ABI=1" "-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64" "-DV8_COMPRESS_POINTERS" "-DV8_31BIT_SMIS_ON_64BIT_ARCH" "-D__STDC_FORMAT_MACROS" "-DOPENSSL_NO_PINSHARED" "-DOPENSSL_THREADS" "-DOPENSSL_NO_ASM" "-DBUILDING_NODE_EXTENSION")
set_target_properties(wcsc_module PROPERTIES PREFIX "" SUFFIX ".node")

View File

@ -1,172 +1,145 @@
#include "../include/wcc.hh"
#include "./wcc.hh"
#include "napi.h"
namespace wcc_options
{
using v8::Local;
using v8::String;
using v8::Value;
bool get_boolean_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, bool &out_value)
bool parse_wcc_options(Napi::Env &env, Napi::Object &src, WCCOptions *result)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (src.Get("verbose").IsBoolean())
{
result->verbose = src.Get("verbose").As<Napi::Boolean>().Value();
}
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("debug").IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->debug = src.Get("debug").As<Napi::Boolean>().Value();
}
if (value->IsUndefined())
{
out_value = false;
return true;
}
if (!value->IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a boolean").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
out_value = value->BooleanValue(isolate);
return true;
}
bool get_string_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, std::string &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (src.Get("debugWXS").IsBoolean())
{
result->debugWXS = src.Get("debugWXS").As<Napi::Boolean>().Value();
}
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("showNewTree").IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->showNewTree = src.Get("showNewTree").As<Napi::Boolean>().Value();
}
if (!value->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
v8::String::Utf8Value utf8Value(isolate, value);
std::string str(*utf8Value, utf8Value.length());
out_value = str;
return true;
}
bool get_vector_string_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, std::vector<std::string> &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (src.Get("isPlugin").IsBoolean())
{
result->isPlugin = src.Get("isPlugin").As<Napi::Boolean>().Value();
}
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("addTestAttre").IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->addTestAttre = src.Get("addTestAttre").As<Napi::Boolean>().Value();
}
if (!value->IsArray())
if (src.Get("independent").IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a array").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->independent = src.Get("independent").As<Napi::Boolean>().Value();
}
auto arr = value.As<v8::Array>();
for (int i=0; i < arr->Length(); i++)
if (src.Get("isCut").IsBoolean())
{
v8::Local<v8::Value> v;
if (!arr->Get(context, i).ToLocal(&v))
result->isCut = src.Get("isCut").As<Napi::Boolean>().Value();
}
if (src.Get("lazyload").IsBoolean())
{
result->lazyload = src.Get("lazyload").As<Napi::Boolean>().Value();
}
if (src.Get("genfuncname").IsString())
{
result->genfuncname = src.Get("genfuncname").As<Napi::String>().Utf8Value();
}
if (src.Get("cwd").IsString())
{
result->cwd = src.Get("cwd").As<Napi::String>().Utf8Value();
}
if (src.Get("wxmlCompileConfig").IsString())
{
result->wxmlCompileConfig = src.Get("wxmlCompileConfig").As<Napi::String>().Utf8Value();
}
if (src.Get("wxmlCompileConfigSplit").IsString())
{
result->wxmlCompileConfigSplit = src.Get("wxmlCompileConfigSplit").As<Napi::String>().Utf8Value();
}
if (src.Get("lazyloadConfig").IsString())
{
result->lazyloadConfig = src.Get("lazyloadConfig").As<Napi::String>().Utf8Value();
}
if (src.Get("files").IsArray())
{
Napi::Array arr = src.Get("files").As<Napi::Array>();
for (size_t i = 0; i < arr.Length(); i++)
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
Napi::Value value = arr[i];
if (value.IsString())
{
result->files.push_back(value.As<Napi::String>().Utf8Value());
}
else
{
throw Napi::Error::New(env, "files must be an array of strings");
}
}
if (!v->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + std::string("[") + std::to_string(i) +"]' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
v8::String::Utf8Value utf8Value(isolate, v);
std::string str(*utf8Value, utf8Value.length());
out_value.emplace_back(str);
}
return true;
}
bool get_map_string_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, std::map<std::string, std::string> &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("contents").IsArray())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
Napi::Array arr = src.Get("contents").As<Napi::Array>();
for (size_t i = 0; i < arr.Length(); i++)
{
Napi::Value value = arr[i];
if (value.IsString())
{
result->contents.push_back(value.As<Napi::String>().Utf8Value());
}
else
{
throw Napi::Error::New(env, "contents must be an array of strings");
}
}
}
if (!value->IsObject())
if (src.Get("replaceContent").IsObject())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a object").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
auto obj = value.As<v8::Object>();
auto keys = obj->GetPropertyNames(context).ToLocalChecked();
for (int i = 0; i < keys->Length(); i++)
{
// key
v8::Local<v8::Value> k;
if (!keys->Get(context, i).ToLocal(&k))
Napi::Object obj = src.Get("replaceContent").As<Napi::Object>();
Napi::Array keys = obj.GetPropertyNames();
for (size_t i = 0; i < keys.Length(); i++)
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
Napi::Value key = keys[i];
if (key.IsString())
{
std::string keyStr = key.As<Napi::String>().Utf8Value();
Napi::Value value = obj.Get(key);
if (value.IsString())
{
result->replaceContent[keyStr] = value.As<Napi::String>().Utf8Value();
}
else
{
throw Napi::Error::New(env, "replaceContent must be a map of strings");
}
}
else
{
throw Napi::Error::New(env, "replaceContent must be a map of strings");
}
}
if (!k->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + std::string("[") + std::to_string(i) +"]' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
// value
v8::Local<v8::Value> v;
if (!obj->Get(context, k).ToLocal(&v))
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
if (!v->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + std::string("[") + std::to_string(i) +"]' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
v8::String::Utf8Value utf8Value(isolate, k);
std::string kr(*utf8Value, utf8Value.length());
v8::String::Utf8Value utf8Value2(isolate, v);
std::string vr(*utf8Value2, utf8Value2.length());
out_value.emplace(kr, vr);
}
return true;
}
bool parse_wcc_options(v8::Isolate *isolate, v8::Local<v8::Object> &src, WCCOptions *result)
{
Local<v8::Context> context = isolate->GetCurrentContext();
bool ret = get_boolean_property(isolate, src, "verbose", result->verbose) &&
get_boolean_property(isolate, src, "debug", result->debug) &&
get_boolean_property(isolate, src, "debugWXS", result->debugWXS) &&
get_boolean_property(isolate, src, "showNewTree", result->showNewTree) &&
get_boolean_property(isolate, src, "isPlugin", result->isPlugin) &&
get_boolean_property(isolate, src, "addTestAttre", result->addTestAttre) &&
get_boolean_property(isolate, src, "independent", result->independent) &&
get_boolean_property(isolate, src, "isCut", result->isCut) &&
get_boolean_property(isolate, src, "lazyload", result->lazyload) &&
get_string_property(isolate, src, "genfuncname", result->genfuncname) &&
get_string_property(isolate, src, "cwd", result->cwd) &&
get_string_property(isolate, src, "wxmlCompileConfig", result->wxmlCompileConfig) &&
get_string_property(isolate, src, "wxmlCompileConfigSplit", result->wxmlCompileConfigSplit) &&
get_string_property(isolate, src, "lazyloadConfig", result->lazyloadConfig) &&
get_vector_string_property(isolate, src, "files", result->files) &&
get_vector_string_property(isolate, src, "contents", result->contents) &&
get_map_string_property(isolate, src, "replaceContent", result->replaceContent);
return ret;
}
}

View File

@ -3,7 +3,7 @@
#include <vector>
#include <string>
#include <map>
#include <node.h>
#include <napi.h>
struct WCCOptions
{
@ -18,7 +18,7 @@ struct WCCOptions
bool addTestAttre = false;
bool independent = false;
std::string genfuncname;
bool isCut;
bool isCut = false;
std::string cwd;
bool lazyload = false;
std::string wxmlCompileConfig;
@ -28,6 +28,6 @@ struct WCCOptions
namespace wcc_options
{
bool parse_wcc_options(v8::Isolate *isolate, v8::Local<v8::Object> &src, WCCOptions *result);
bool parse_wcc_options(Napi::Env &env, Napi::Object &src, WCCOptions *result);
}
#endif

View File

@ -1,179 +1,108 @@
#include "../include/wcsc.hh"
#include "v8.h"
#include "./wcsc.hh"
#include "napi.h"
namespace wcsc_options
{
using v8::Local;
using v8::String;
using v8::Value;
bool get_boolean_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, bool &out_value)
bool parse_wcsc_options(Napi::Env &env, Napi::Object &src, WCSCOptions *result)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (src.Get("debug").IsBoolean())
{
result->debug = src.Get("debug").As<Napi::Boolean>().Value();
}
else {
throw Napi::Error::New(env, "debug must be a boolean");
}
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("lazyload").IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->lazyload = src.Get("lazyload").As<Napi::Boolean>().Value();
}
if (!value->IsBoolean())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a boolean").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
else {
throw Napi::Error::New(env, "lazyload must be a boolean");
}
out_value = value->BooleanValue(isolate);
return true;
}
bool get_string_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, std::string &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (src.Get("cwd").IsString())
{
result->cwd = src.Get("cwd").As<Napi::String>().Utf8Value();
}
else {
throw Napi::Error::New(env, "cwd must be a string");
}
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("classPrefix").IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->classPrefix = src.Get("classPrefix").As<Napi::String>().Utf8Value();
}
if (!value->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
else {
throw Napi::Error::New(env, "classPrefix must be a string");
}
v8::String::Utf8Value utf8Value(isolate, value);
std::string str(*utf8Value, utf8Value.length());
out_value = str;
return true;
}
bool get_integer_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, int &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("pageCount").IsNumber())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
result->pageCount = src.Get("pageCount").As<Napi::Number>().Int32Value();
}
if (!value->IsInt32())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a int32").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
else {
throw Napi::Error::New(env, "pageCount must be a number");
}
out_value = value->Int32Value(isolate->GetCurrentContext()).ToChecked();
return true;
}
bool get_vector_string_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, std::vector<std::string> &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (!src->Get(context, key).ToLocal(&value))
if (src.Get("files").IsArray())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
if (!value->IsArray())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a array").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
auto arr = value.As<v8::Array>();
for (int i=0; i < arr->Length(); i++)
{
v8::Local<v8::Value> v;
if (!arr->Get(context, i).ToLocal(&v))
Napi::Array arr = src.Get("files").As<Napi::Array>();
for (size_t i = 0; i < arr.Length(); i++)
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
Napi::Value value = arr[i];
if (value.IsString())
{
result->files.push_back(value.As<Napi::String>().Utf8Value());
}
else {
throw Napi::Error::New(env, "files must be an array of strings");
}
}
if (!v->IsString())
}
else {
throw Napi::Error::New(env, "files must be an array");
}
if (src.Get("contents").IsArray())
{
Napi::Array arr = src.Get("contents").As<Napi::Array>();
for (size_t i = 0; i < arr.Length(); i++)
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + std::string("[") + std::to_string(i) +"]' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
Napi::Value value = arr[i];
if (value.IsString())
{
result->contents.push_back(value.As<Napi::String>().Utf8Value());
}
else {
throw Napi::Error::New(env, "contents must be an array of strings");
}
}
v8::String::Utf8Value utf8Value(isolate, v);
std::string str(*utf8Value, utf8Value.length());
out_value.emplace_back(str);
}
else {
throw Napi::Error::New(env, "contents must be an array");
}
if (src.Get("replaceContent").IsObject())
{
Napi::Object obj = src.Get("replaceContent").As<Napi::Object>();
Napi::Array keys = obj.GetPropertyNames();
for (size_t i = 0; i < keys.Length(); i++)
{
Napi::Value k = keys[i];
std::string key = k.As<Napi::String>().Utf8Value();
if (obj.Get(key).IsString())
{
result->replaceContent[key] = obj.Get(key).As<Napi::String>().Utf8Value();
}
else {
throw Napi::Error::New(env, "replaceContent must be an object of strings");
}
}
}
else {
throw Napi::Error::New(env, "replaceContent must be an object");
}
return true;
}
bool get_map_string_property(v8::Isolate *isolate, v8::Local<v8::Object> &src, const char *property_name, std::map<std::string, std::string> &out_value)
{
v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, property_name, v8::NewStringType::kNormal).ToLocalChecked();
v8::Local<v8::Value> value;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (!src->Get(context, key).ToLocal(&value))
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
if (!value->IsObject())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + "' property must be a object").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
auto obj = value.As<v8::Object>();
auto keys = obj->GetPropertyNames(context).ToLocalChecked();
for (int i = 0; i < keys->Length(); i++)
{
// key
v8::Local<v8::Value> k;
if (!keys->Get(context, i).ToLocal(&k))
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
if (!k->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + std::string("[") + std::to_string(i) +"]' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
// value
v8::Local<v8::Value> v;
if (!obj->Get(context, k).ToLocal(&v))
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("Failed to get '" + std::string(property_name) + "' property").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
if (!v->IsString())
{
isolate->ThrowException(v8::String::NewFromUtf8(isolate, ("The '" + std::string(property_name) + std::string("[") + std::to_string(i) +"]' property must be a string").c_str(), v8::NewStringType::kNormal).ToLocalChecked());
return false;
}
v8::String::Utf8Value utf8Value(isolate, k);
std::string kr(*utf8Value, utf8Value.length());
v8::String::Utf8Value utf8Value2(isolate, v);
std::string vr(*utf8Value2, utf8Value2.length());
out_value.emplace(kr, vr);
}
return true;
}
bool parse_wcsc_options(v8::Isolate *isolate, v8::Local<v8::Object> &src, WCSCOptions *result)
{
Local<v8::Context> context = isolate->GetCurrentContext();
bool ret = get_boolean_property(isolate, src, "debug", result->debug) &&
get_boolean_property(isolate, src, "lazyload", result->lazyload) &&
get_string_property(isolate, src, "cwd", result->cwd) &&
get_string_property(isolate, src, "classPrefix", result->classPrefix) &&
get_integer_property(isolate, src, "pageCount", result->pageCount) &&
get_vector_string_property(isolate, src, "files", result->files) &&
get_vector_string_property(isolate, src, "contents", result->contents) &&
get_map_string_property(isolate, src, "replaceContent", result->replaceContent);
return ret;
}
}

View File

@ -3,7 +3,7 @@
#include <vector>
#include <string>
#include <map>
#include <node.h>
#include <napi.h>
struct WCSCOptions
{
@ -14,11 +14,11 @@ struct WCSCOptions
std::string cwd;
bool debug = false;
std::string classPrefix;
bool lazyload;
bool lazyload = false;
};
namespace wcsc_options
{
bool parse_wcsc_options(v8::Isolate *isolate, v8::Local<v8::Object> &src, WCSCOptions *result);
bool parse_wcsc_options(Napi::Env &env, Napi::Object &src, WCSCOptions *result);
}
#endif

View File

@ -1,323 +1,294 @@
// hello.cc
#include "./include/wcc.hh"
#include "./config/wcc.hh"
#include "../include/file.h"
#include "../include/night.h"
#include "../include/string_utils.h"
#include "../include/wxml.h"
#include "v8.h"
#include <node.h>
#include <string>
#include "napi.h"
#include <algorithm>
#include <cstdio>
#include <exception>
#include <string>
namespace wx_compiler {
using v8::Function;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::Isolate;
using v8::Local;
using v8::NewStringType;
using v8::Object;
using v8::String;
using v8::Value;
using std::map;
using std::string;
using std::vector;
int compile(Isolate *isolate, WCCOptions &options, Local<Value> &result,
std::string &errMsg) {
int mark = 0;
if (options.debug) {
mark |= 2u;
}
if (options.debugWXS) {
mark |= 4u;
}
std::map<std::string, std::string> fileContentMap;
for (int i = 0; i < options.files.size(); i++) {
fileContentMap[options.files[i]] = options.contents[i];
}
map<string, vector<string>> componentListMap;
std::string xc_Or_completeCode_Param = options.wxmlCompileConfig;
if (!xc_Or_completeCode_Param.empty())
{
Napi::Value compile(Napi::Env &env, WCCOptions &options) {
int mark = 0;
if (options.debug) {
mark |= 2u;
}
if (options.debugWXS) {
mark |= 4u;
}
std::map<std::string, std::string> fileContentMap;
std::map<std::string, std::string> wxsMap;
for (int i = 0; i < options.files.size(); i++) {
auto file = options.files[i];
fileContentMap[file] = options.contents[i];
if (file.find(".wxs") != std::string::npos) {
wxsMap[file] = options.contents[i];
}
}
map<string, vector<string>> componentListMap;
std::string xc_Or_completeCode_Param = options.wxmlCompileConfig;
if (!xc_Or_completeCode_Param.empty()) {
string data;
vector<string> allComponentList;
data = getNextArg(xc_Or_completeCode_Param, options.wxmlCompileConfigSplit);
data =
getNextArg(xc_Or_completeCode_Param, options.wxmlCompileConfigSplit);
unsigned long long count = strtoull(&data[0], 0, 10);
for (unsigned long long i = 0; i < count; i++)
{
vector<string> componentList;
string arg1 = getNextArg(xc_Or_completeCode_Param, options.wxmlCompileConfigSplit);
data = getNextArg(xc_Or_completeCode_Param, options.wxmlCompileConfigSplit);
unsigned long long jCount = strtoull(&data[0], 0, 10);
for (unsigned long long i = 0; i < jCount; i++)
{
string componentName = getNextArg(xc_Or_completeCode_Param, options.wxmlCompileConfigSplit);
componentList.push_back(componentName);
auto it = std::find(allComponentList.begin(), allComponentList.end(), componentName);
if (it == allComponentList.end())
{
allComponentList.push_back(componentName);
}
}
auto it = componentListMap.lower_bound(arg1);
if (it == componentListMap.end() || arg1 < it->first)
{
componentListMap.emplace(arg1, componentList);
for (unsigned long long i = 0; i < count; i++) {
vector<string> componentList;
string arg1 = getNextArg(xc_Or_completeCode_Param,
options.wxmlCompileConfigSplit);
data = getNextArg(xc_Or_completeCode_Param,
options.wxmlCompileConfigSplit);
unsigned long long jCount = strtoull(&data[0], 0, 10);
for (unsigned long long i = 0; i < jCount; i++) {
string componentName = getNextArg(xc_Or_completeCode_Param,
options.wxmlCompileConfigSplit);
componentList.push_back(componentName);
auto it = std::find(allComponentList.begin(), allComponentList.end(),
componentName);
if (it == allComponentList.end()) {
allComponentList.push_back(componentName);
}
}
auto it = componentListMap.lower_bound(arg1);
if (it == componentListMap.end() || arg1 < it->first) {
componentListMap.emplace(arg1, componentList);
}
}
componentListMap["ALL"] = allComponentList;
}
if (options.lazyload) {
// 懒加载
std::vector<std::string> splitedData;
split(splitedData, options.lazyloadConfig, options.wxmlCompileConfigSplit);
// 处理文件路径
for (int i = 0; i < splitedData.size(); i++) {
string path = splitedData[i];
if (path[0] == '.' && path[1] == '/') {
// 以"./"开头,去掉前两个字符
splitedData[i] = path.substr(2);
}
}
int compilerResult = 0;
if (wxsMap.size())
{
std::string wxs;
std::map<std::string, std::string> outputContentMap;
map<string, string> outputFuncMap;
map<string, vector<string>> dependencyListMap;
map<string, string> mapData1;
const char off_5403C3[] = {'s', '\0', 'e', '\0'};
compilerResult = WXML::Compiler::CompileLazy(
fileContentMap, errMsg, outputContentMap,
outputFuncMap, // map<string, string>
dependencyListMap, // std::map<std::string,std::vector<std::string>>
componentListMap, // componentListMap
splitedData, mapData1,
options.isCut, // isLLA,
options.genfuncname, mark, 10, &off_5403C3[2], off_5403C3, "gg", "e_",
"d_", "p_", "\0", "boxofchocolate", "$gdwx", "f_");
if (outputContentMap.count("__COMMON__") == 0) {
string helperCode;
WXML::Compiler::WXMLHelperCode(helperCode);
string data =
"var __wxAppData=__wxAppData||{};var "
"__wxAppCode__=__wxAppCode__||{};var global=global||{};var "
"__WXML_GLOBAL__="
"__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_"
"init:undefined,total_ops:0};var Component=Comp"
"onent||function(){};var definePlugin=definePlugin||function(){};var "
"requirePlugin=requirePlugin||function(){};"
"var Behavior=Behavior||function(){};var "
"__vd_version_info__=__vd_version_info__||{};var "
"__GWX_GLOBAL__=__GWX_G"
"LOBAL__||{};var __globalThis=(typeof "
"__vd_version_info__!=='undefined'&&typeof "
"__vd_version_info__.globalThis!"
"=='undefined')?__vd_version_info__.globalThis:(typeof "
"window!=='undefined'?window:globalThis);";
data = data + helperCode;
outputContentMap["__COMMON__"] = data;
} else {
string helperCode;
WXML::Compiler::WXMLHelperCode(helperCode);
string commonData =
"var __wxAppData=__wxAppData||{};var "
"__wxAppCode__=__wxAppCode__||{};var global=global||{};var "
"__WXML_GLOBAL__="
"__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_"
"init:undefined,total_ops:0};var Component=Comp"
"onent||function(){};var definePlugin=definePlugin||function(){};var "
"requirePlugin=requirePlugin||function(){};"
"var Behavior=Behavior||function(){};var "
"__vd_version_info__=__vd_version_info__||{};var "
"__GWX_GLOBAL__=__GWX_G"
"LOBAL__||{};var __globalThis=(typeof "
"__vd_version_info__!=='undefined'&&typeof "
"__vd_version_info__.globalThis!"
"=='undefined')?__vd_version_info__.globalThis:(typeof "
"window!=='undefined'?window:globalThis);";
commonData = commonData + helperCode;
commonData = commonData.append(outputContentMap["__COMMON__"]);
outputContentMap["__COMMON__"] = commonData;
}
std::stringstream dep;
dep << ";var __WXML_DEP__=__WXML_DEP__||{};";
// dependencyListMap v121
for (auto j = dependencyListMap.begin(); j != dependencyListMap.end();
j++) {
if (j->second.begin() != j->second.end()) {
dep << "__WXML_DEP__[\"";
dep << j->first;
dep << "\"]=[";
auto list = j->second;
for (auto k = list.begin(); k != list.end(); k++) {
dep << "\"";
dep << WXML::Rewrite::ToStringCode(*k);
dep << "\",";
for (auto m=wxsMap.begin(); m != wxsMap.end(); m++) {
auto v152 = m->first;
auto v156 = m->second;
std::string v146;
if ( night::compile_ns_no_wrapper(v152, v156, 1, v146, 0) )
{
throw Napi::Error::New(env, "Error: " + v146 + "\n");
}
auto v31 = snprintf(0, 0, WXML::GlassEaselWxs::sWrapper.c_str(),
v146.c_str()) + 1; char *v32 = (char *)operator new[](v31);
snprintf(v32, v31, WXML::GlassEaselWxs::sWrapper.c_str(),
v146.c_str()); wxsMap[v152] = v32; delete[] v32;
}
dep << "];";
}
}
std::string v140 = dep.str();
outputContentMap["__COMMON__"].append(v140);
if (!compilerResult) {
if (options.lazyload) {
v8::Local<v8::Object> funcContent = v8::Object::New(isolate);
// 懒加载
std::vector<std::string> splitedData;
split(splitedData, options.lazyloadConfig,
options.wxmlCompileConfigSplit);
// 处理文件路径
for (int i = 0; i < splitedData.size(); i++) {
string path = splitedData[i];
if (path[0] == '.' && path[1] == '/') {
// 以"./"开头,去掉前两个字符
splitedData[i] = path.substr(2);
}
}
int compilerResult = 0;
std::map<std::string, std::string> outputContentMap;
map<string, string> outputFuncMap;
map<string, vector<string>> dependencyListMap;
map<string, string> mapData1;
const char off_5403C3[] = {'s', '\0', 'e', '\0'};
std::string errMsg;
compilerResult = WXML::Compiler::CompileLazy(
fileContentMap, errMsg, outputContentMap,
outputFuncMap, // map<string, string>
dependencyListMap, // std::map<std::string,std::vector<std::string>>
componentListMap, // componentListMap
splitedData, mapData1,
options.isCut, // isLLA,
options.genfuncname, mark, 10, &off_5403C3[2], off_5403C3, "gg", "e_",
"d_", "p_", "\0", "boxofchocolate", "$gdwx", "f_");
if (outputContentMap.count("__COMMON__") == 0) {
string helperCode;
WXML::Compiler::WXMLHelperCode(helperCode);
string data =
"var __wxAppData=__wxAppData||{};var "
"__wxAppCode__=__wxAppCode__||{};var global=global||{};var "
"__WXML_GLOBAL__="
"__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_"
"init:undefined,total_ops:0};var Component=Comp"
"onent||function(){};var "
"definePlugin=definePlugin||function(){};var "
"requirePlugin=requirePlugin||function(){};"
"var Behavior=Behavior||function(){};var "
"__vd_version_info__=__vd_version_info__||{};var "
"__GWX_GLOBAL__=__GWX_G"
"LOBAL__||{};var __globalThis=(typeof "
"__vd_version_info__!=='undefined'&&typeof "
"__vd_version_info__.globalThis!"
"=='undefined')?__vd_version_info__.globalThis:(typeof "
"window!=='undefined'?window:globalThis);";
data = data + helperCode;
outputContentMap["__COMMON__"] = data;
} else {
string helperCode;
WXML::Compiler::WXMLHelperCode(helperCode);
string commonData =
"var __wxAppData=__wxAppData||{};var "
"__wxAppCode__=__wxAppCode__||{};var global=global||{};var "
"__WXML_GLOBAL__="
"__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_"
"init:undefined,total_ops:0};var Component=Comp"
"onent||function(){};var "
"definePlugin=definePlugin||function(){};var "
"requirePlugin=requirePlugin||function(){};"
"var Behavior=Behavior||function(){};var "
"__vd_version_info__=__vd_version_info__||{};var "
"__GWX_GLOBAL__=__GWX_G"
"LOBAL__||{};var __globalThis=(typeof "
"__vd_version_info__!=='undefined'&&typeof "
"__vd_version_info__.globalThis!"
"=='undefined')?__vd_version_info__.globalThis:(typeof "
"window!=='undefined'?window:globalThis);";
commonData = commonData + helperCode;
commonData = commonData.append(outputContentMap["__COMMON__"]);
outputContentMap["__COMMON__"] = commonData;
}
std::stringstream dep;
dep << ";var __WXML_DEP__=__WXML_DEP__||{};";
// dependencyListMap v121
for (auto j = dependencyListMap.begin(); j != dependencyListMap.end();
j++) {
if (j->second.begin() != j->second.end()) {
dep << "__WXML_DEP__[\"";
dep << j->first;
dep << "\"]=[";
auto list = j->second;
for (auto k = list.begin(); k != list.end(); k++) {
dep << "\"";
dep << WXML::Rewrite::ToStringCode(*k);
dep << "\",";
}
dep << "];";
}
}
std::string v140 = dep.str();
outputContentMap["__COMMON__"].append(v140);
if (compilerResult) {
throw Napi::Error::New(env, "Error: " + errMsg + "\n");
}
// Create return objects using proper N-API object creation
auto result = Napi::Object::New(env);
auto funcContent = Napi::Object::New(env);
for (auto content : outputContentMap) {
funcContent
->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, content.first.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked(),
String::NewFromUtf8(isolate, content.second.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked())
.Check();
funcContent.Set(Napi::String::New(env, content.first),
Napi::String::New(env, content.second));
}
v8::Local<v8::Object> funcName = v8::Object::New(isolate);
auto funcName = Napi::Object::New(env);
for (auto func : outputFuncMap) {
funcName
->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, func.first.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked(),
String::NewFromUtf8(isolate, func.second.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked())
.Check();
funcName.Set(Napi::String::New(env, func.first),
Napi::String::New(env, func.second));
}
// 你可以在这里设置对象的属性和方法
// Set properties on the result object
result.Set("generateFunctionName", funcName);
result.Set("generateFunctionContent", funcContent);
// 创建一个实例
v8::Local<v8::Object> object_instance = v8::Object::New(isolate);
auto _ = object_instance->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, "generateFunctionName",
v8::NewStringType::kNormal)
.ToLocalChecked(),
funcName);
_ = object_instance->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate,
"generateFunctionContent",
v8::NewStringType::kNormal)
.ToLocalChecked(),
funcContent);
return result;
} else {
// 普通
result = object_instance;
std::map<std::string, std::string> v105;
map<string, vector<string>> componentListMap;
std::string r;
std::string errMsg;
int compilerResult =
WXML::Compiler::Compile(fileContentMap, // a2
errMsg, // a3
r, // a4
componentListMap, // a5
v105, // a6
false, // a7
options.genfuncname, // a8
mark, // a9
'\n', //
"e", // off_5403C3[2]
"s", // off_5403C3
"gg", // "gg" a13
"e_", // "e_"
"d_", // "d_"
"p_", // "p_"
"", // '\0'
"boxofchocolate", // "boxofchocolate"
"$gdwx", // "$gdwx"
"f_"); // "f_"
if (compilerResult) {
// error
throw Napi::Error::New(env, "Error: " + errMsg + "\n");
}
return Napi::String::New(env, r);
}
return compilerResult;
} else {
// 普通
int compilerResult = 0;
std::map<std::string, std::string> v105;
map<string, vector<string>> componentListMap;
std::string r;
compilerResult =
WXML::Compiler::Compile(fileContentMap, // a2
errMsg, // a3
r, // a4
componentListMap, // a5
v105, // a6
false, // a7
options.genfuncname, // a8
mark, // a9
'\n', //
"e", // off_5403C3[2]
"s", // off_5403C3
"gg", // "gg" a13
"e_", // "e_"
"d_", // "d_"
"p_", // "p_"
"", // '\0'
"boxofchocolate", // "boxofchocolate"
"$gdwx", // "$gdwx"
"f_"); // "f_"
result = String::NewFromUtf8(isolate, r.c_str(), NewStringType::kNormal)
.ToLocalChecked();
return compilerResult;
}
return 0;
}
void wcc(const FunctionCallbackInfo<Value> &args) {
Isolate *isolate = args.GetIsolate();
v8::HandleScope scope(isolate); // Ensure we have a proper handle scope.
Napi::Value wcc(const Napi::CallbackInfo &info) {
auto env = info.Env();
// Check if the first argument is an object.
if (args.Length() < 1 || !args[0]->IsObject()) {
isolate->ThrowException(String::NewFromUtf8(isolate,
"Argument must be an object",
NewStringType::kNormal)
.ToLocalChecked());
return;
if (info.Length() < 1 || !info[0].IsObject()) {
throw Napi::Error::New(env, "Argument must be an object");
}
// Cast the first argument to an Object.
Local<v8::Context> context = isolate->GetCurrentContext();
Local<Object> obj = args[0]->ToObject(context).ToLocalChecked();
Napi::Object obj = info[0].As<Napi::Object>();
WCCOptions options;
if (!wcc_options::parse_wcc_options(isolate, obj, &options)) {
// 选项解析失败
return;
wcc_options::parse_wcc_options(env, obj, &options);
try {
auto result = Napi::Object::New(env);
return compile(env, options);
} catch (std::string& err) {
fprintf(stderr, "Error: %s", err.c_str());
throw Napi::Error::New(env, err);
} catch (WXML::DOMLib::ParseException& err) {
fprintf(stderr, "Error: %s", err.what());
throw Napi::Error::New(env, err.what());
} catch (std::exception& err) {
fprintf(stderr, "Error: %s", err.what());
throw Napi::Error::New(env, err.what());
}
Local<Value> result;
std::string errMsg;
int code = compile(isolate, options, result, errMsg);
// Convert the "msg" property to a C++ string and return it.
if (code) {
// error
args.GetReturnValue().Set(
String::NewFromUtf8(isolate, errMsg.c_str(), NewStringType::kNormal)
.ToLocalChecked());
} else {
// ok
args.GetReturnValue().Set(result);
catch (...) {
fprintf(stderr, "Error: Unknown error");
throw Napi::Error::New(env, "Unknown error");
}
}
void Initialize(Local<Object> exports, Local<Object> module) {
Isolate *isolate = exports->GetIsolate();
auto context = isolate->GetCurrentContext();
static Napi::Object Initialize(Napi::Env env, Napi::Object exports) {
std::string versionInfo;
WXML::Compiler::GetVersionInfo(versionInfo, "global");
// Set the module.exports to be a function
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, wcc);
Local<Function> fn = tpl->GetFunction(context).ToLocalChecked();
auto func = Napi::Function::New(env, wcc);
// Set the 'version' property on the function
fn->Set(context,
String::NewFromUtf8(isolate, "version", NewStringType::kNormal)
.ToLocalChecked(),
String::NewFromUtf8(isolate, versionInfo.c_str(),
NewStringType::kNormal)
.ToLocalChecked())
.Check();
exports.Set("version", Napi::String::New(env, versionInfo));
module
->Set(context,
String::NewFromUtf8(isolate, "exports", NewStringType::kNormal)
.ToLocalChecked(),
fn)
.Check();
return func;
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
NODE_API_MODULE(WCC_MODULE, Initialize)
} // namespace wx_compiler

View File

@ -1,36 +1,25 @@
// hello.cc
#include "./include/wcsc.hh"
#include "./config/wcsc.hh"
#include "../include/file.h"
#include "../include/string_utils.h"
#include "../include/wxss.h"
#include "../include/wxml.h"
#include "v8.h"
#include "napi.h"
#include <algorithm>
#include <node.h>
#include <cstdio>
#include <stdexcept>
#include <string>
#include <vector>
namespace wx_compiler {
using v8::Function;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::Isolate;
using v8::Local;
using v8::NewStringType;
using v8::Object;
using v8::String;
using v8::Value;
using std::map;
using std::string;
using std::vector;
int compile(Isolate *isolate, WCSCOptions &options, Local<Value> &result,
std::string &errMsg) {
Napi::Value compile(const Napi::Env &env, WCSCOptions &options) {
/**
* map filename -> fileContent
*/
* map filename -> fileContent
*/
std::map<std::string, std::string> v77;
for (int i=0; i<options.files.size(); i++) {
v77[options.files[i]] = options.contents[i];
@ -41,7 +30,7 @@ int compile(Isolate *isolate, WCSCOptions &options, Local<Value> &result,
for (int i=0; i<options.pageCount; i++) {
v72.push_back(options.files[i]);
}
std::string errMsg;
if (options.lazyload) {
// 懒加载
@ -58,6 +47,7 @@ int compile(Isolate *isolate, WCSCOptions &options, Local<Value> &result,
int ret = lt.GetCommHead(v72, v94, true, v76);
if (ret) {
fprintf(stderr, "ERR: GetCommHead ret %d", ret);
throw Napi::Error::New(env, "ERR: GetCommHead ret " + std::to_string(ret));
}
for (int i = 0; i < v72.size(); i++) {
std::string v98;
@ -69,131 +59,88 @@ int compile(Isolate *isolate, WCSCOptions &options, Local<Value> &result,
}
v92.emplace(cur, v98);
}
v8::Local<v8::Object> pageWxss = v8::Object::New(isolate);
for (auto func : v92) {
pageWxss
->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, func.first.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked(),
String::NewFromUtf8(isolate, func.second.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked())
.Check();
// Create stable N-API objects for return
auto result = Napi::Object::New(env);
auto pageWxss = Napi::Object::New(env);
// Add properties to the pageWxss object
for (auto const& pair : v92) {
pageWxss.Set(
Napi::String::New(env, pair.first),
Napi::String::New(env, pair.second)
);
}
v8::Local<v8::Object> object_instance = v8::Object::New(isolate);
auto _ = object_instance->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate, "common",
v8::NewStringType::kNormal)
.ToLocalChecked(),
String::NewFromUtf8(isolate, v94.c_str(),
v8::NewStringType::kNormal).ToLocalChecked());
_ = object_instance->Set(isolate->GetCurrentContext(),
String::NewFromUtf8(isolate,
"pageWxss",
v8::NewStringType::kNormal)
.ToLocalChecked(),
pageWxss);
result = object_instance;
// Set the common and pageWxss properties on the result object
result.Set("common", Napi::String::New(env, v94));
result.Set("pageWxss", pageWxss);
if (ret) {
fprintf(stderr, "ERR: %s\nerror file count: %d\n", "", 0);
return 1;
throw Napi::Error::New(env, "ERR: \nerror file count: " + std::to_string(0));
}
// main - 25 - 9
return 0;
return result;
}
std::string ret = "ERR: wxss GetCompiledResult: " + v96 + ", error file count: " + std::to_string(lt.offset_4) + ", ret " + std::to_string(lt.offset_0);
auto r = String::NewFromUtf8(isolate, ret.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked();
fprintf(stderr,
"ERR: wxss GetCompiledResult: %s, error file count: %d, ret %d",
v96.data(), lt.offset_4, lt.offset_0);
return 1;
throw Napi::Error::New(env, ret);
} else {
// 普通
std::string v88;
int ret = WXSS::NewLintAndParseCSSList(v77, v72, v88, errMsg, 0, options.debug, v75, v76);
if (ret)
{
return 1;
if (ret) {
throw Napi::Error::New(env, "ERR: wxss GetCompiledResult: " + errMsg + ", error file count: " + std::to_string(ret));
}
result = String::NewFromUtf8(isolate, v88.c_str(), NewStringType::kNormal).ToLocalChecked();
// Create a String object with proper lifetime
return Napi::String::New(env, v88);
}
return 0;
}
void wcc(const FunctionCallbackInfo<Value> &args) {
Isolate *isolate = args.GetIsolate();
v8::HandleScope scope(isolate); // Ensure we have a proper handle scope.
Napi::Value wcsc(const Napi::CallbackInfo &info) {
auto env = info.Env();
// Check if the first argument is an object.
if (args.Length() < 1 || !args[0]->IsObject()) {
isolate->ThrowException(String::NewFromUtf8(isolate,
"Argument must be an object",
NewStringType::kNormal)
.ToLocalChecked());
return;
if (info.Length() < 1 || !info[0].IsObject()) {
throw Napi::Error::New(env, Napi::String::New(env, "Argument must be an object"));
}
// Cast the first argument to an Object.
Local<v8::Context> context = isolate->GetCurrentContext();
Local<Object> obj = args[0]->ToObject(context).ToLocalChecked();
auto obj = info[0].As<Napi::Object>();
WCSCOptions options;
if (!wcsc_options::parse_wcsc_options(isolate, obj, &options)) {
// 选项解析失败
return;
try {
wcsc_options::parse_wcsc_options(env, obj, &options);
Napi::Object result;
std::string errMsg;
return compile(env, options);
}
catch (std::string& err) {
fprintf(stderr, "Error: %s", err.c_str());
throw Napi::Error::New(env, err);
}catch (std::runtime_error &err) {
fprintf(stderr, "Runtime error: %s",err.what());
throw Napi::Error::New(env, err.what());
} catch (std::exception& err) {
fprintf(stderr, "Exception: %s", err.what());
throw Napi::Error::New(env, err.what());
}
catch (...) {
fprintf(stderr, "Error: Unknown error");
throw Napi::Error::New(env, "Unknown error");
}
Local<Value> result;
std::string errMsg;
int code = compile(isolate, options, result, errMsg);
// Convert the "msg" property to a C++ string and return it.
if (code) {
// error
args.GetReturnValue().Set(
String::NewFromUtf8(isolate, errMsg.c_str(), NewStringType::kNormal)
.ToLocalChecked());
} else {
// ok
args.GetReturnValue().Set(result);
}
}
void Initialize(Local<Object> exports, Local<Object> module) {
static Napi::Object Initialize(Napi::Env env, Napi::Object exports) {
Isolate *isolate = exports->GetIsolate();
auto context = isolate->GetCurrentContext();
std::string versionInfo;
// TODO
// WXML::Compiler::GetVersionInfo(versionInfo, "global");
// Set the module.exports to be a function
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, wcc);
Local<Function> fn = tpl->GetFunction(context).ToLocalChecked();
// Set the 'version' property on the function
fn->Set(context,
String::NewFromUtf8(isolate, "version", NewStringType::kNormal)
.ToLocalChecked(),
String::NewFromUtf8(isolate, versionInfo.c_str(),
NewStringType::kNormal)
.ToLocalChecked())
.Check();
module
->Set(context,
String::NewFromUtf8(isolate, "exports", NewStringType::kNormal)
.ToLocalChecked(),
fn)
.Check();
return Napi::Function::New(env, wcsc);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
NODE_API_MODULE(WCSC_MODULE, Initialize)
} // namespace wx_compiler

View File

@ -1,4 +1,5 @@
#include "../include/night.h"
#include <vector>
namespace night
{
@ -156,6 +157,42 @@ namespace night
throw "not implement";
}
int compile_ns_no_wrapper(
std::string const& a1,
std::string const& a2,
uint a3,
std::string& a4,
bool a5
)
{
const char off_51B9E4[] = { '\0', '%', 'u', '\0' }; // idb
a4 = off_51B9E4;
// a4 = "";
night::NSStream v22(a1, a2, a3);
night::NSGod v8;
night::NSToken v11;
v11.offset_0 = &v8;
v11.offset_4 = &v22;
std::string v13 = a1;
night::NSASTParse v23(v13, &v11, &v8);
v13 = "";
night::NSCompileJs compile;
compile.offset_24 = &v23;
std::vector<std::string> v9;
std::string v10 = compile.compile_once(a4, &v9, a5);
v8.hamlet();
int v5 =0;
if(v10.length())
{
a4 = v10;
v5 = 121;
}
return v5;
}
/**
*
*

View File

@ -1,4 +1,6 @@
#include "../include/night.h"
#include <cstdio>
#include <exception>
namespace night
{
@ -694,14 +696,22 @@ namespace night
int inner_compile_once_i = compile_once_i;
this->offset_28 = a4;
a3 = "";
night::ns_node* v5 = this->offset_24->top_down();
if (a5)
{
std::string ret = v5->debug_no_space();
printf("ast :%s\n", ret.data());
try {
night::ns_node* v5 = this->offset_24->top_down();
if (a5)
{
std::string ret = v5->debug_no_space();
printf("ast :%s\n", ret.data());
}
std::string v9 = this->compile(v5);
a3.assign(v9);
}
catch(const std::exception& err)
{
// printf("%s\n", err.what());
std::string ret(err.what());
return ret;
}
std::string v9 = this->compile(v5);
a3.assign(v9);
return this->offset_0;
}

View File

@ -31,11 +31,11 @@ namespace night
{
if (this->offset_24.length())
{
sprintf(str, "(%d,%d)type[%s] value[%s]", this->offset_48, this->offset_52, this->offset_0, this->offset_60);
sprintf(str, "(%d,%d)type[%s] value[%s]", this->offset_48, this->offset_52, this->offset_0.c_str(), this->offset_60.c_str());
}
else
{
sprintf(str, "type[%s] value[%s]", this->offset_0, this->offset_60);
sprintf(str, "type[%s] value[%s]", this->offset_0.c_str(), this->offset_60.c_str());
}
}
if (
@ -49,22 +49,22 @@ namespace night
{
if (this->offset_24.length())
{
sprintf(str, "(%d,%d)type[%s] value[%s]", this->offset_48, this->offset_52, this->offset_0, this->offset_60);
sprintf(str, "(%d,%d)type[%s] value[%s]", this->offset_48, this->offset_52, this->offset_0.c_str(), this->offset_60.c_str());
}
else
{
sprintf(str, "type[%s] value[%s]", this->offset_0, this->offset_60);
sprintf(str, "type[%s] value[%s]", this->offset_0.c_str(), this->offset_60.c_str());
}
}
if ("var" == this->offset_0)
{
if (this->offset_24.length())
{
sprintf(str, "(%d,%d)type[%s] value[%s] flag[%d]", this->offset_48, this->offset_52, this->offset_0, this->offset_60, this->offset_56);
sprintf(str, "(%d,%d)type[%s] value[%s] flag[%d]", this->offset_48, this->offset_52, this->offset_0.c_str(), this->offset_60.c_str(), this->offset_56);
}
else
{
sprintf(str, "type[%s] value[%s] flag[%d]", this->offset_0, this->offset_60, this->offset_56);
sprintf(str, "type[%s] value[%s] flag[%d]", this->offset_0.c_str(), this->offset_60.c_str(), this->offset_56);
}
}
// debug_no_space - 5

View File

@ -1,4 +1,6 @@
#include "../include/night.h"
#include <exception>
#include <stdexcept>
namespace night
{
@ -128,7 +130,8 @@ namespace night
v12.append(":");
v10 += v12;
v10 += a2;
throw v10;
throw std::runtime_error(v10.c_str());
}
}

View File

@ -320,12 +320,12 @@ namespace night
bool NSToken::tk_is_whitespace(char ch, void *)
{
auto v1 = night::NS_BUILTIN_SPACE.find(ch, 0);
int v1 = night::NS_BUILTIN_SPACE.find(ch, 0);
return v1 != -1;
}
bool NSToken::tk_is_not_line_break(char ch, void *)
{
return ch != 10;
return ch != 10; // \n
}
bool NSToken::tk_is_valid_op_str(char ch, void *t)
{

View File

@ -1,7 +1,9 @@
#include <cstdint>
#include <iostream>
#include <map>
#include <iomanip>
#include <sstream>
#include <string>
std::string EscapeToJsonString(std::string const& a2)
{
@ -48,3 +50,233 @@ std::string DictToJsonString(std::map<std::string, std::string> const& a2)
ret << "}";
return ret.str();
}
int HexDigit(char a1, int a2)
{
int v2; // eax
if ( (uint8_t)(a1 - 48) > 9u )
{
if ( (uint8_t)(a1 - 97) > 5u )
{
v2 = 0;
if ( (uint8_t)(a1 - 65) <= 5u )
v2 = a1 - 55;
}
else
{
v2 = a1 - 87;
}
}
else
{
v2 = a1 - 48;
}
return v2 << a2;
}
int GetUnicodeNum(std::string &a1, int a2)
{
int v3; // ebx
int v4; // ebx
int v5; // ebx
v3 = HexDigit(a1[a2 + 2], 12);
v4 = HexDigit(a1[a2 + 3], 8) + v3;
v5 = HexDigit(a1[a2 + 4], 4) + v4;
return v5 + HexDigit(a1[a2 + 5], 0);
}
void GetUnicode(std::string& a1, unsigned int a2)
{
char v2; // bl
unsigned int v3; // eax
unsigned int v4; // eax
v2 = a2;
if ( a2 > 0x7F )
{
if ( a2 > 0x7FF )
{
if ( a2 > 0xFFFF )
{
a1.push_back((a2 >> 18) | 0xF0);
v4 = (a2 >> 12) & 0x3F | 0xFFFFFF80;
}
else
{
v4 = (a2 >> 12) | 0xFFFFFFE0;
}
a1.push_back(v4);
v3 = (a2 >> 6) & 0x3F | 0xFFFFFF80;
}
else
{
v3 = (a2 >> 6) | 0xFFFFFFC0;
}
a1.push_back(v3);
v2 = a2 & 0x3F | 0x80;
}
a1.push_back(v2);
}
int GetJsonString(std::string &a1, int *a2, std::string& a3)
{
std::ostringstream v17;
int v3 = *a2;
if ( a1[*a2] != '"' )
{
LABEL_41:
int v9 = ~v3;
return v9;
}
std::string v16;
for ( *a2 = v3 + 1; ; ++*a2 )
{
v3 = *a2;
char v12;
int v6;
int v14 = a1.length();
if ( *a2 >= v14 )
return ~v3;
char v5 = a1[v3];
if ( v5 == '"' )
break;
if ( v5 == '\\' )
{
if ( v3 + 1 >= v14 )
{
v6 = -2;
LABEL_31:
return v6 - v3;
}
char v7 = a1[v3 + 1];
if ( v7 == 'n' )
{
v12 = 10;
goto LABEL_26;
}
if ( v7 <= 'n' )
{
if ( v7 == 'b' )
{
v12 = 8;
goto LABEL_26;
}
if ( v7 <= 'b' )
{
if ( v7 != '/' && v7 != '\\' && v7 != '"' )
goto LABEL_41;
v17 << a1[v3 + 1];
goto LABEL_27;
}
if ( v7 != 'f' )
goto LABEL_41;
v12 = 12;
LABEL_26:
v17 << v12;
LABEL_27:
++*a2;
continue;
}
if ( v7 == 't' )
{
int v12 = 9;
goto LABEL_26;
}
if ( v7 != 'u' )
{
if ( v7 != 'r' )
goto LABEL_41;
int v12 = 13;
goto LABEL_26;
}
int UnicodeNum = GetUnicodeNum(a1, v3);
if ( (unsigned int)(UnicodeNum - 55296) > 0x3FF )
{
*a2 = v3 + 5;
}
else
{
if ( v3 + 11 >= v14 || a1[v3 + 6] != '\\' )
{
v6 = -7;
goto LABEL_31;
}
if ( a1[v3 + 7] != 'u' )
{
v6 = -8;
goto LABEL_31;
}
int v10 = GetUnicodeNum(a1, v3 + 6);
*a2 = v3 + 11;
UnicodeNum = (v10 & 0x3FF | (UnicodeNum << 10) & 0xFFC00) + 0x10000;
}
GetUnicode(v16, UnicodeNum);
v17 << v16;
}
else
{
v17 << a1[v3];
}
}
*a2 = v3 + 1;
a3 = v17.str();
return 0;
}
int GetJsonDict(std::string &a1, std::map<std::string, std::string>& a2)
{
if ( a1[0] != '{' )
return -1;
int v10 = 1;
while ( 1 )
{
int v3 = a1.length();
if ( v10 >= v3 )
return 0;
std::string v11;
std::string v13;
while ( v10 < v3 )
{
if ( a1[v10] == '"' )
goto LABEL_9;
++v10;
}
if ( v10 == v3 )
return 0;
LABEL_9:
int JsonString = GetJsonString(a1, &v10, v11);
if ( JsonString )
return JsonString;
int v5 = a1.length();
while ( v10 < v5 )
{
if ( a1[v10] == ':' )
goto LABEL_18;
++v10;
}
if ( v10 == v5 )
{
LABEL_26:
return 0;
}
LABEL_18:
while ( v10 < v5 )
{
if (a1[v10] == '"' )
goto LABEL_20;
++v10;
}
if ( v10 == v5 )
return 0;
LABEL_20:
JsonString = GetJsonString(a1, &v10, v13);
if ( JsonString )
{
LABEL_27:
return JsonString;
}
a2[v11] = v13;
int v7 = a1.length();
while ( v10 < v7 && a1[v10] != ',' )
++v10;
}
}

View File

@ -1,4 +1,6 @@
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
@ -7,6 +9,7 @@
#include "include/string_utils.h"
#include "include/wxml.h"
#include "include/json.h"
#include "include/night.h"
using namespace std;
@ -64,6 +67,9 @@ int main(int argc, const char **argv)
bool version = false;
bool isLLA = false;
bool hasLL = false;
bool isWxs = false;
bool isGDC = false;
bool isWxsEnv = false;
string xc_Or_completeCode_Param;
string outputFileName;
vector<string> fileList;
@ -218,17 +224,18 @@ int main(int argc, const char **argv)
mapData1["life_cycle_callback_content"] = callbackData;
}
}
else if (!param.compare("--pm"))
{
// 参数是--pm
if (i + 1 < paramList.size())
{
mapData1["plain_text_marker"] = paramList[i + 1];
continue;
}
}
else
{
if (!param.compare("--pm"))
{
// 参数是--pm
if (i + 1 < paramList.size())
{
mapData1["plain_text_marker"] = paramList[i + 1];
continue;
}
}
if (param[1] == 'l' && param[2] == 'l')
{
// -ll
@ -259,6 +266,19 @@ int main(int argc, const char **argv)
i++;
hasLL = true;
}
else if (!param.compare("--wxs"))
{
isWxs = true;
}
else if (!param.compare("--gdc"))
{
isGDC = true;
}
else if (!param.compare("--wxs-env"))
{
isWxsEnv = true;
}
}
}
@ -280,6 +300,74 @@ int main(int argc, const char **argv)
fclose(f);
}
if (isWxs)
{
std::string wxs;
if (fileList.size() == 0)
{
fprintf(stderr, "WXS file is needed\n");
return -1;
}
if ( readFile(fileList[0].c_str(), wxs))
{
fprintf(stderr, "Failed to read input from %s\n", fileList[0].c_str());
return -1;
}
std::map<std::string, std::string> cfg;
int ret = GetJsonDict(wxs, cfg);
if (ret)
{
fprintf(stderr, "Failed to read JSON at position %d (%c)", ret, wxs[ret]);
return -2;
}
for (auto m=cfg.begin(); m != cfg.end(); m++) {
auto v152 = m->first;
auto v156 = m->second;
std::string v146;
if ( night::compile_ns_no_wrapper(v152, v156, 1, v146, 0) )
{
fprintf(stderr, "Error in file %s: %s\n", v152.c_str(), v146.c_str());
return -2;
}
auto v31 = snprintf(0, 0, WXML::GlassEaselWxs::sWrapper.c_str(), v146.c_str()) + 1;
char *v32 = (char *)operator new[](v31);
snprintf(v32, v31, WXML::GlassEaselWxs::sWrapper.c_str(), v146.c_str());
cfg[v152] = v32;
delete[] v32;
}
std::string v136 = DictToJsonString(cfg);
FILE *f = stdout;
if (!outputFileName.empty())
f = fopen(outputFileName.c_str(), "w");
fprintf(f, "%s\n", v136.data());
if (f != stdout)
return fclose(f);
return 0;
}
if (isGDC)
{
std::string v136 = WXML::GlassEaselWxs::sGenFuncDeepCopy.c_str();
FILE *f = stdout;
if (!outputFileName.empty())
f = fopen(outputFileName.c_str(), "w");
fprintf(f, "%s\n", v136.data());
if (f != stdout)
return fclose(f);
return 0;
}
if (isWxsEnv)
{
std::string v136 = WXML::GlassEaselWxs::sWxsEnvInit.c_str();
FILE *f = stdout;
if (!outputFileName.empty())
f = fopen(outputFileName.c_str(), "w");
fprintf(f, "%s\n", v136.data());
if (f != stdout)
return fclose(f);
return 0;
}
// main - 30
if (fileList.empty())
{
@ -498,7 +586,8 @@ int main(int argc, const char **argv)
f = fopen(outputFileName.data(), "w");
}
fprintf(f, "%s\n", v113.data());
fclose(f);
if (f != stdout)
fclose(f);
}
}
// main - 55

View File

@ -10,9 +10,18 @@ namespace WXML
{
}
ParseException::ParseException(std::string& msg)
{
this->msg = msg;
}
ParseException::~ParseException()
{
}
const char * ParseException::what()
{
return this->msg.c_str();
}
}
}

View File

@ -1,5 +1,7 @@
#include "../../include/wxml.h"
#include <cstdio>
#include <cstring>
#include <sstream>
namespace WXML
{
@ -168,7 +170,7 @@ namespace WXML
if (!v47.IsMatch(&v40[0]))
{
std::string msg = "expect end-tag `" + v40;
msg += v40 + "`.";
msg += "`.";
auto err = this->Error(&msg[0], 0);
throw err;
}
@ -232,9 +234,51 @@ namespace WXML
return this->offset_104;
}
WXML::DOMLib::ParseException Parser::Error(char const*, WXML::DOMLib::Token *)
WXML::DOMLib::ParseException Parser::Error(char const* msg, WXML::DOMLib::Token *token)
{
return WXML::DOMLib::ParseException();
// printf("error: %s\n", msg);
std::stringstream ss;
auto t = this->Peek();
if (t.offset_24 == 4)
{
if (!token)
{
token = &this->tokenList[this->peekIndex - 1];
}
msg = "end tag missing";
}
ss << this->filePath.c_str();
ss << ":";
ss << t.offset_8;
ss << ":";
ss << t.offset_12;
ss << ": " << msg << ", near `";
for (int v12 = 0; t.offset_20 > v12; v12++) {
if (v12 == 7)
{
if (t.offset_20 > 7)
{
ss << "...";
}
break;
}
char v13 = t.offset_0[t.offset_16 + v12];
if (v13 == '\r')
{
ss << "\\r";
}
else if (v13 == '\n')
{
ss << "\\n";
}
else {
ss << v13;
}
}
ss << "`";
std::string v18 = ss.str();
// printf("-->%s\n", v18.c_str());
return WXML::DOMLib::ParseException(v18);
}
void Parser::DOMS()
{

View File

@ -1300,7 +1300,7 @@ namespace WXML {
/* code */
if (j->second.offset_56 == -3)
{
if (a14 & 1 == 0)
if ((a14 & 1) == 0)
{
auto err = this->Error(a2, j->second, j->first, j->second.offset_60);
throw "RenderException" + err;

View File

@ -1,5 +1,6 @@
#include "../include/wxml.h"
#include <cstdio>
namespace WXML {
@ -306,7 +307,7 @@ namespace WXML {
a2 += v26;
result = 1;
}
if (++i == v21.size() - 1)
if (++i == v21.size())
{
v17 = 0;
}

View File

@ -33,7 +33,7 @@ namespace WXML
for (i = a3; i > 0; i--)
{
v7 = v4;
v4 = a1[266 * v4 + *a4]; // 266 * 4 = 0x428
v4 = a1[266 * v4 + (uint8_t)*a4]; // 266 * 4 = 0x428
if (v4 == -1)
{
break;

View File

@ -38,7 +38,7 @@ namespace WXSS
if (
i
&& cur->offset_164 > this->offset_120[i - 1]->offset_168
&& a2[a2.length() - 1] != '\n'
&& (a2.length() == 0 || a2[a2.length() - 1] != '\n')
)
{
a2 += " ";

View File

@ -21,7 +21,7 @@ namespace WXSS
}
const char *DIRECTIVES[] = {"@import", "@charset", "@media", "@keyframes", "@-webkit-keyframes", "@supports", "nth-child", "nth-last-child", "nth-of-type", "nth-last-of-type"};
int Tokenizer::TT[26113] = {0};
int Tokenizer::TT[26114] = {0};
bool Tokenizer::bInited = false;
void Tokenizer::InitTransitTable(/* args */)
{

919
test/main.cpp Normal file
View File

@ -0,0 +1,919 @@
//----- (00500ED0) --------------------------------------------------------
int main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
char **v4; // edi
int v5; // eax
bool v6; // dl
int v7; // edi
int v8; // ebx
void **v9; // eax
_BYTE *v10; // edx
char v11; // al
char v12; // al
void **v13; // eax
void **v14; // eax
bool v15; // si
_BYTE *v16; // edx
char *v17; // eax
_DWORD *v18; // eax
const char **v19; // ecx
_BYTE *v20; // eax
void **v21; // esi
_DWORD *v22; // eax
char v23; // dl
void **v24; // ebx
char *v25; // ecx
int v26; // edx
int v27; // edx
FILE *v28; // ebx
int JsonDict; // eax
char **m; // ebx
int v31; // edi
char *v32; // esi
_DWORD *v33; // eax
const char **v34; // edx
unsigned int v35; // ebx
_DWORD *v36; // eax
_DWORD *v37; // eax
int v38; // esi
int v39; // edi
int v40; // esi
int *inserted; // ebx
char *v42; // eax
void **v43; // edi
char *v44; // esi
int insert_hint_unique_pos; // eax
_DWORD *v46; // edx
int v47; // edx
_DWORD *v48; // eax
int v49; // edx
FILE *v50; // ebx
int v51; // edi
void **j; // ebx
int *v53; // eax
int *v54; // esi
_DWORD *v55; // ebx
_DWORD *v56; // eax
_DWORD *v57; // eax
void **v58; // ecx
_DWORD *v59; // eax
int *k; // edi
std::ostream::sentry *v61; // esi
std::ostream::sentry *v62; // eax
int *v63; // ebx
std::ostream::sentry *v64; // eax
_DWORD *v65; // eax
FILE *v66; // ebx
int v67; // edx
int v68; // edx
int v69; // edx
void (__cdecl *v71)(void *); // [esp-6Ch] [ebp-414h]
char v72; // [esp+6h] [ebp-3A2h]
char v73; // [esp+7h] [ebp-3A1h]
char v74; // [esp+8h] [ebp-3A0h]
char v75; // [esp+9h] [ebp-39Fh]
char v76; // [esp+Ah] [ebp-39Eh]
char v77; // [esp+Bh] [ebp-39Dh]
const char **v78; // [esp+Ch] [ebp-39Ch]
char **v79; // [esp+Ch] [ebp-39Ch]
int v80; // [esp+10h] [ebp-398h]
int v81; // [esp+10h] [ebp-398h]
char v82; // [esp+14h] [ebp-394h]
int *v83; // [esp+14h] [ebp-394h]
int v84; // [esp+18h] [ebp-390h]
std::ostream::sentry *i; // [esp+18h] [ebp-390h]
std::ostream::sentry *v86; // [esp+18h] [ebp-390h]
bool excb; // [esp+1Ch] [ebp-38Ch]
int exc; // [esp+1Ch] [ebp-38Ch]
int exca; // [esp+1Ch] [ebp-38Ch]
char *FileName; // [esp+28h] [ebp-380h] BYREF
const char **v91; // [esp+2Ch] [ebp-37Ch] BYREF
void **v92; // [esp+30h] [ebp-378h]
int v93; // [esp+34h] [ebp-374h]
void **v94; // [esp+38h] [ebp-370h] BYREF
int v95; // [esp+3Ch] [ebp-36Ch]
int v96; // [esp+40h] [ebp-368h]
void **v97; // [esp+44h] [ebp-364h] BYREF
int v98; // [esp+48h] [ebp-360h]
int v99; // [esp+4Ch] [ebp-35Ch]
char *v100; // [esp+50h] [ebp-358h] BYREF
int v101; // [esp+54h] [ebp-354h]
char v102; // [esp+58h] [ebp-350h] BYREF
char *v103; // [esp+68h] [ebp-340h] BYREF
int v104; // [esp+6Ch] [ebp-33Ch]
char v105; // [esp+70h] [ebp-338h] BYREF
int v106; // [esp+80h] [ebp-328h] BYREF
int v107[5]; // [esp+84h] [ebp-324h] BYREF
int v108[6]; // [esp+98h] [ebp-310h] BYREF
void *v109[6]; // [esp+B0h] [ebp-2F8h] BYREF
int v110; // [esp+C8h] [ebp-2E0h] BYREF
int v111[5]; // [esp+CCh] [ebp-2DCh] BYREF
int v112; // [esp+E0h] [ebp-2C8h] BYREF
int v113[5]; // [esp+E4h] [ebp-2C4h] BYREF
int v114; // [esp+F8h] [ebp-2B0h] BYREF
int v115[5]; // [esp+FCh] [ebp-2ACh] BYREF
int v116[2]; // [esp+110h] [ebp-298h] BYREF
char v117; // [esp+118h] [ebp-290h] BYREF
void *v118[2]; // [esp+128h] [ebp-280h] BYREF
char v119; // [esp+130h] [ebp-278h] BYREF
int v120; // [esp+140h] [ebp-268h] BYREF
int v121[5]; // [esp+144h] [ebp-264h] BYREF
int v122; // [esp+158h] [ebp-250h] BYREF
int v123[5]; // [esp+15Ch] [ebp-24Ch] BYREF
int v124; // [esp+170h] [ebp-238h] BYREF
int v125[5]; // [esp+174h] [ebp-234h] BYREF
int v126; // [esp+188h] [ebp-220h] BYREF
int v127[5]; // [esp+18Ch] [ebp-21Ch] BYREF
int v128[6]; // [esp+1A0h] [ebp-208h] BYREF
int v129[6]; // [esp+1B8h] [ebp-1F0h] BYREF
int v130[6]; // [esp+1D0h] [ebp-1D8h] BYREF
int v131[6]; // [esp+1E8h] [ebp-1C0h] BYREF
int v132[6]; // [esp+200h] [ebp-1A8h] BYREF
int v133; // [esp+218h] [ebp-190h] BYREF
int v134; // [esp+21Ch] [ebp-18Ch]
int v135; // [esp+220h] [ebp-188h]
int v136; // [esp+230h] [ebp-178h] BYREF
int v137; // [esp+234h] [ebp-174h]
int v138; // [esp+238h] [ebp-170h]
char *String; // [esp+248h] [ebp-160h] BYREF
int v140; // [esp+24Ch] [ebp-15Ch]
int v141; // [esp+250h] [ebp-158h] BYREF
int v142; // [esp+260h] [ebp-148h] BYREF
char *v143[5]; // [esp+264h] [ebp-144h] BYREF
char *v144; // [esp+278h] [ebp-130h] BYREF
int v145[5]; // [esp+27Ch] [ebp-12Ch] BYREF
int v146; // [esp+290h] [ebp-118h] BYREF
int v147; // [esp+294h] [ebp-114h]
char v148[16]; // [esp+298h] [ebp-110h] BYREF
char *Format; // [esp+2A8h] [ebp-100h] BYREF
int v150; // [esp+2ACh] [ebp-FCh]
int v151[4]; // [esp+2B0h] [ebp-F8h] BYREF
int v152; // [esp+2C0h] [ebp-E8h] BYREF
int v153; // [esp+2C4h] [ebp-E4h]
char v154[4]; // [esp+2C8h] [ebp-E0h] BYREF
int v155[3]; // [esp+2CCh] [ebp-DCh] BYREF
char v156[192]; // [esp+2D8h] [ebp-D0h] BYREF
int *p_argc; // [esp+398h] [ebp-10h]
p_argc = &argc;
v80 = argc;
v78 = argv;
__main();
FileName = 0;
v100 = &v102;
v91 = 0;
v92 = 0;
v93 = 0;
v101 = 0;
v102 = 0;
v103 = &v105;
v104 = 0;
v105 = 0;
v94 = 0;
v95 = 0;
v96 = 0;
v97 = 0;
v98 = 0;
v99 = 0;
std::_Rb_tree_header::_Rb_tree_header(v107);
std::string::basic_string((void **)v108, "$gwx");
std::string::basic_string(v109, " ");
v3 = 1;
std::_Rb_tree_header::_Rb_tree_header(v111);
while ( v3 < v80 )
{
std::string::basic_string((void **)&v152, "--config-path");
v4 = (char **)&v78[v3];
v5 = std::string::compare((int)&v152, *v4);
v6 = 0;
if ( !v5 )
v6 = v3 + 1 < v80;
excb = v6;
std::string::_M_dispose((void **)&v152);
if ( excb )
{
std::string::operator=((unsigned int *)&v103, (char *)v78[++v3]);
}
else
{
std::string::basic_string((void **)&v152, *v4);
std::vector<std::string>::emplace_back<std::string>(&v94, &v152);
std::string::_M_dispose((void **)&v152);
}
++v3;
}
if ( v104 )
{
v147 = 0;
v146 = (int)v148;
v148[0] = 0;
ReadFile(v103, (unsigned int *)&v146);
while ( v147 )
{
std::string::basic_string((void **)&Format, "\n");
GetNextArg(&v152, &v146, (int)&Format);
std::vector<std::string>::emplace_back<std::string>(&v94, &v152);
std::string::_M_dispose((void **)&v152);
std::string::_M_dispose((void **)&Format);
}
std::string::_M_dispose((void **)&v146);
}
v7 = 0;
exc = 0;
v72 = 0;
v73 = 0;
v74 = 0;
v75 = 0;
v84 = -1431655765 * ((v95 - (int)v94) >> 3);
v76 = 0;
v82 = 0;
v77 = 0;
while ( v7 < v84 )
{
v8 = 6 * v7;
v9 = &v94[6 * v7];
v10 = *v9;
if ( *(_BYTE *)*v9 != 45 )
{
std::vector<std::string>::push_back(&v91, (int)v9);
goto LABEL_90;
}
v11 = v10[1];
switch ( v11 )
{
case 'd':
v12 = v10[2];
if ( !v12 )
{
exc |= 2u;
goto LABEL_90;
}
if ( v12 == 115 )
{
exc |= 4u;
goto LABEL_90;
}
break;
case 's':
if ( v10[2] == 116 )
{
exc |= 8u;
goto LABEL_90;
}
if ( v7 + 1 < v84 )
{
v77 = 1;
std::vector<std::string>::push_back(&v91, (int)&v94[v8 + 6]);
goto LABEL_90;
}
break;
case 'v':
if ( v10[2] == 98 )
exc |= 0x10u;
else
v76 = 1;
goto LABEL_90;
case 'x':
if ( v10[2] == 99 && v7 + 1 < v84 )
{
v13 = &v94[v8 + 6];
v82 = 1;
if ( *(_BYTE *)*v13 != 45 )
{
std::string::_M_assign((int)&v100, (int)v13);
v82 = 1;
++v7;
}
goto LABEL_90;
}
break;
case 'c':
if ( v10[2] == 99 && v7 + 1 < v84 )
{
v14 = &v94[v8 + 6];
v82 = 0;
if ( *(_BYTE *)*v14 != 45 )
{
std::string::_M_assign((int)&v100, (int)v14);
v82 = 0;
++v7;
}
goto LABEL_90;
}
break;
case 'o':
if ( v7 + 1 < v84 )
{
++v7;
FileName = (char *)v94[v8 + 6];
goto LABEL_90;
}
break;
case 'g':
if ( v10[2] == 110 && v7 + 1 < v84 )
{
std::string::_M_assign((int)v108, (int)&v94[v8 + 6]);
++v7;
goto LABEL_90;
}
break;
case 'p':
exc |= 0x20u;
goto LABEL_90;
case 't':
exc |= 1u;
goto LABEL_90;
case 'i':
exc |= 0x40u;
goto LABEL_90;
}
std::string::basic_string((void **)&v152, "--split");
v15 = std::operator==<char>((int)&v94[v8], (int)&v152);
if ( v15 )
v15 = v7 + 1 < v84;
std::string::_M_dispose((void **)&v152);
if ( v15 )
{
++v7;
std::string::_M_assign((int)v109, (int)&v94[v8 + 6]);
}
else
{
v16 = v94[6 * v7];
if ( v16[1] == 99 && v16[2] == 98 )
{
++v7;
LOBYTE(v151[0]) = 0;
Format = (char *)v151;
v17 = (char *)v94[v8 + 6];
exc |= 0x80u;
v150 = 0;
ReadFile(v17, (unsigned int *)&Format);
if ( v150 )
{
std::string::basic_string((void **)&v152, "life_cycle_callback_content");
v18 = std::map<std::string,std::string>::operator[](&v110, &v152);
std::string::_M_assign((int)v18, (int)&Format);
std::string::_M_dispose((void **)&v152);
}
std::string::_M_dispose((void **)&Format);
}
else if ( !std::string::compare((int)&v94[v8], "--pm") && v7 + 1 < v84 )
{
v21 = &v94[v8 + 6];
std::string::basic_string((void **)&v152, "plain_text_marker");
v22 = std::map<std::string,std::string>::operator[](&v110, &v152);
std::string::_M_assign((int)v22, (int)v21);
std::string::_M_dispose((void **)&v152);
++v7;
}
else
{
v19 = (const char **)&v94[v8];
v20 = v94[v8];
if ( v20[1] == 108/*l*/ && v20[2] == 108/*l*/ )
{
v23 = v20[3];
if ( v23 != 119 )
{
if ( v23 != 97 )
{
fprintf(&__iob[2], "Error: expected -llw or -lla, but got %s", *v19);
exca = -1;
goto LABEL_177;
}
v15 = 1;
}
if ( !std::string::compare((int)v109, " ") )
std::string::basic_string((void **)&v152, ",");
else
std::string::basic_string(&v152, (int)v109);
++v7;
Split((int)&v133, (int *)&v94[v8 + 6], (int)&v152);
v24 = (void **)v133;
v25 = (char *)v97;
v133 = 0;
v26 = v98;
v97 = v24;
Format = v25;
v98 = v134;
v151[0] = v99;
v150 = v26;
v99 = v135;
v134 = 0;
v135 = 0;
std::vector<std::string>::~vector((void ***)&Format, v26);
std::vector<std::string>::~vector((void ***)&v133, v27);
std::string::_M_dispose((void **)&v152);
v75 = 1;
v82 = v15;
}
else if ( !std::string::compare((int)v19, "--wxs") )
{
v74 = 1;
}
else if ( !std::string::compare((int)&v94[v8], "--gdc") )
{
v73 = 1;
}
else if ( !std::string::compare((int)&v94[v8], "--wxs-env") )
{
v72 = 1;
}
}
}
LABEL_90:
++v7;
}
// version
if ( v76 )
{
std::string::basic_string((void **)&v152, "global");
WXML::Compiler::GetVersionInfo((int)&Format, &v152);
std::string::_M_dispose((void **)&v152);
if ( FileName && *FileName )
v28 = fopen(FileName, "w");
else
v28 = &__iob[1];
fprintf(v28, "%s\n", Format);
fclose(v28);
std::string::_M_dispose((void **)&Format);
}
// not wxs
if ( !v74 )
{
v34 = (const char **)&WXML::GlassEaselWxs::sGenFuncDeepCopy;
// not gdc
if ( !v73 )
{
// not wxs env
if ( !v72 )
{
// empty
if ( v91 == (const char **)v92 )
{
exca = Usage(v80, v78);
}
else
{
v35 = 0;
std::_Rb_tree_header::_Rb_tree_header(v113);
std::_Rb_tree_header::_Rb_tree_header(v115);
if ( v77 )
{
v152 = (int)v154;
v153 = 0;
v154[0] = 0;
ReadFile(0, (unsigned int *)&v152);
v36 = std::map<std::string,std::string>::operator[](&v112, (int)v91);
std::string::_M_assign((int)v36, (int)&v152);
std::string::_M_dispose((void **)&v152);
}
else
{
while ( v35 < -1431655765 * (((char *)v92 - (char *)v91) >> 3) )
{
v154[0] = 0;
v152 = (int)v154;
v153 = 0;
ReadFile((char *)v91[6 * v35], (unsigned int *)&v152);
v37 = std::map<std::string,std::string>::operator[](&v112, (int)&v91[6 * v35]);
std::string::_M_assign((int)v37, (int)&v152);
++v35;
std::string::_M_dispose((void **)&v152);
}
}
if ( v101 )
{
GetNextArg(&String, (int *)&v100, (int)v109);
v81 = strtoull(String, 0, 10);
std::string::_M_dispose((void **)&String);
v136 = 0;
v137 = 0;
v138 = 0;
for ( i = 0; (int)i < v81; i = (std::ostream::sentry *)((char *)i + 1) )
{
v150 = 0;
Format = (char *)v151;
LOBYTE(v151[0]) = 0;
String = 0;
v140 = 0;
v141 = 0;
GetNextArg(&v142, (int *)&v100, (int)v109);
std::string::operator=(&Format, &v142);
std::string::_M_dispose((void **)&v142);
std::__find_if<__gnu_cxx::__normal_iterator<std::string *,std::vector<std::string>>,__gnu_cxx::__ops::_Iter_equals_val<std::string const>>(
(int)v91,
(int)v92,
(int)&Format);
GetNextArg(&v144, (int *)&v100, (int)v109);
v38 = 0;
v79 = (char **)strtoull(v144, 0, 10);
std::string::_M_dispose((void **)&v144);
while ( v38 < (int)v79 )
{
v153 = 0;
v152 = (int)v154;
v154[0] = 0;
GetNextArg(&v146, (int *)&v100, (int)v109);
std::string::operator=(&v152, &v146);
std::string::_M_dispose((void **)&v146);
std::vector<std::string>::push_back(&String, (int)&v152);
v39 = v137;
if ( v39 == std::__find_if<__gnu_cxx::__normal_iterator<std::string *,std::vector<std::string>>,__gnu_cxx::__ops::_Iter_equals_val<std::string const>>(
v136,
v137,
(int)&v152) )
std::vector<std::string>::push_back(&v136, (int)&v152);
++v38;
std::string::_M_dispose((void **)&v152);
}
v40 = v115[1];
inserted = v115;
while ( v40 )
{
if ( (unsigned __int8)std::operator<<char>(v40 + 16, (int)&Format) )
{
v40 = *(_DWORD *)(v40 + 12);
}
else
{
inserted = (int *)v40;
v40 = *(_DWORD *)(v40 + 8);
}
}
if ( inserted == v115 || (unsigned __int8)std::operator<<char>((int)&Format, (int)(inserted + 4)) )
{
v42 = (char *)operator new((struct type_info *)0x34, v71);
v43 = (void **)(v42 + 16);
v44 = v42;
std::string::basic_string((_DWORD *)v42 + 4, (int)&Format);
*((_DWORD *)v44 + 10) = 0;
*((_DWORD *)v44 + 11) = 0;
*((_DWORD *)v44 + 12) = 0;
insert_hint_unique_pos = std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::_M_get_insert_hint_unique_pos(
&v114,
inserted,
(int)v43);
inserted = (int *)insert_hint_unique_pos;
if ( v46 )
{
inserted = std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::_M_insert_node(
&v114,
insert_hint_unique_pos,
v46,
v44);
}
else
{
std::vector<std::string>::~vector((void ***)v44 + 10, 0);
std::string::_M_dispose(v43);
operator delete(v44);
}
}
std::vector<std::string>::operator=((int)(inserted + 10), (int *)&String);
std::vector<std::string>::~vector((void ***)&String, v47);
std::string::_M_dispose((void **)&Format);
}
std::string::basic_string((void **)&v152, "ALL");
v48 = std::map<std::string,std::vector<std::string>>::operator[](&v114, &v152);
std::vector<std::string>::operator=((int)v48, &v136);
std::string::_M_dispose((void **)&v152);
std::vector<std::string>::~vector((void ***)&v136, v49);
}
v116[1] = 0;
v116[0] = (int)&v117;
v117 = 0;
v118[0] = &v119;
v118[1] = 0;
v119 = 0;
std::_Rb_tree_header::_Rb_tree_header(v121);
if ( v75 )
{
v51 = v98;
for ( j = v97; (void **)v51 != j; j += 6 )
{
if ( *(_BYTE *)*j == 46 && *((_BYTE *)*j + 1) == 47 )
{
std::string::substr((void **)&v152, j, 2u, 0xFFFFFFFF);
std::string::operator=(j, &v152);
std::string::_M_dispose((void **)&v152);
}
}
std::_Rb_tree_header::_Rb_tree_header(v123);
std::_Rb_tree_header::_Rb_tree_header(v125);
std::_Rb_tree_header::_Rb_tree_header(v127);
std::string::basic_string((void **)&v152, "l_");
std::string::basic_string((void **)&Format, "f_");
std::string::basic_string((void **)&v146, "$gdwx");
std::string::basic_string((void **)&v144, "boxofchocolate");
std::string::basic_string((void **)&v142, (char *)&byte_5173B0);
std::string::basic_string((void **)&String, "p_");
std::string::basic_string((void **)&v136, "d_");
std::string::basic_string((void **)&v133, "e_");
std::string::basic_string((void **)v132, "gg");
std::string::basic_string((void **)v131, (char *)&off_5174F9);
std::string::basic_string((void **)v130, (_BYTE *)&off_5174F9 + 2);
std::string::basic_string((void **)v129, (char *)&byte_5173B0);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::_Rb_tree(
v128,
(int)&v114);
exca = WXML::Compiler::CompileLazy(
(std::_Rb_tree_header *)&v112,
(unsigned int *)v116,
&v120,
&v106,
&v122,
(int)&v124,
(int)v128,
(std::_Rb_tree_header *)&v97,
0,
v129,
(int)&v126,
&v110,
v82,
(int)v108,
exc,
10,
v130,
v131,
v132,
&v133,
&v136,
(int *)&String,
(int)&v142,
(int)&v144,
(int)&v146,
(int *)&Format);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)v128);
std::string::_M_dispose((void **)v129);
std::string::_M_dispose((void **)v130);
std::string::_M_dispose((void **)v131);
std::string::_M_dispose((void **)v132);
std::string::_M_dispose((void **)&v133);
std::string::_M_dispose((void **)&v136);
std::string::_M_dispose((void **)&String);
std::string::_M_dispose((void **)&v142);
std::string::_M_dispose((void **)&v144);
std::string::_M_dispose((void **)&v146);
std::string::_M_dispose((void **)&Format);
std::string::_M_dispose((void **)&v152);
std::string::basic_string((void **)&Format, "__COMMON__");
v53 = (int *)std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::_M_lower_bound(
v121[1],
(int)v121,
(int)&Format);
v54 = v53;
if ( v53 != v121 && (unsigned __int8)std::operator<<char>((int)&Format, (int)(v53 + 4)) )
v54 = v121;
std::string::_M_dispose((void **)&Format);
if ( v54 == v121 )
{
WXML::Compiler::WXMLHelperCode[abi:cxx11]((void **)&Format);
std::string::basic_string(
(void **)&v146,
"var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLO"
"BAL__=__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0};var Co"
"mponent=Component||function(){};var definePlugin=definePlugin||function(){};var requirePlugin=requirePlu"
"gin||function(){};var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};va"
"r __GWX_GLOBAL__=__GWX_GLOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof _"
"_vd_version_info__.globalThis!=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'"
"?window:globalThis);");
std::operator+<char>(&v152, &v146, (unsigned int *)&Format);
std::string::basic_string((void **)&v144, "__COMMON__");
v59 = std::map<std::string,std::string>::operator[](&v120, &v144);
std::string::operator=(v59, &v152);
std::string::_M_dispose((void **)&v144);
std::string::_M_dispose((void **)&v152);
v58 = (void **)&v146;
}
else
{
std::string::basic_string((void **)&Format, "__COMMON__");
v55 = std::map<std::string,std::string>::operator[](&v120, &Format);
WXML::Compiler::WXMLHelperCode[abi:cxx11]((void **)&v144);
std::string::basic_string(
(void **)&v142,
"var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLO"
"BAL__=__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0};var Co"
"mponent=Component||function(){};var definePlugin=definePlugin||function(){};var requirePlugin=requirePlu"
"gin||function(){};var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};va"
"r __GWX_GLOBAL__=__GWX_GLOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof _"
"_vd_version_info__.globalThis!=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'"
"?window:globalThis);");
std::operator+<char>(&v146, &v142, (unsigned int *)&v144);
v56 = std::string::append(&v146, (int)v55);
std::string::basic_string(&v152, v56);
std::string::basic_string((void **)&String, "__COMMON__");
v57 = std::map<std::string,std::string>::operator[](&v120, &String);
std::string::operator=(v57, &v152);
std::string::_M_dispose((void **)&String);
std::string::_M_dispose((void **)&v152);
std::string::_M_dispose((void **)&v146);
std::string::_M_dispose((void **)&v142);
v58 = (void **)&v144;
}
std::string::_M_dispose(v58);
std::string::_M_dispose((void **)&Format);
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)&v152);
std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v154, ";var __WXML_DEP__=__WXML_DEP__||{};");
for ( k = (int *)v123[2]; k != v123; k = (int *)std::_Rb_tree_increment((int)k) )
{
if ( k[11] != k[10] )
{
v61 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v154, "__WXML_DEP__[\"");
WXML::Rewrite::ToStringCode((int)&Format, k + 4);
v62 = std::operator<<<char>(v61, (int *)&Format);
std::operator<<<std::char_traits<char>>(v62, "\"]=[");
std::string::_M_dispose((void **)&Format);
v63 = (int *)k[10];
v83 = (int *)k[11];
while ( v83 != v63 )
{
v86 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v154, "\"");
WXML::Rewrite::ToStringCode((int)&Format, v63);
v64 = std::operator<<<char>(v86, (int *)&Format);
std::operator<<<std::char_traits<char>>(v64, "\",");
v63 += 6;
std::string::_M_dispose((void **)&Format);
}
std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v154, "];");
}
}
std::stringbuf::str((int)&Format, v155);
std::string::basic_string((void **)&v146, "__COMMON__");
v65 = std::map<std::string,std::string>::operator[](&v120, &v146);
std::string::operator+=(v65, (int)&Format);
std::string::_M_dispose((void **)&v146);
std::string::_M_dispose((void **)&Format);
if ( exca )
{
fprintf(&__iob[2], "Error %d: %s\n", exca, (const char *)v116[0]);
}
else
{
if ( FileName && *FileName )
v66 = fopen(FileName, "w");
else
v66 = &__iob[1];
DictToJsonString((int)&v144, (int)&v120);
DictToJsonString((int)&v146, (int)&v106);
std::string::basic_string(
(void **)&Format,
" {\"generateFunctionContent\":%s,\"generateFunctionName\":%s} ");
fprintf(v66, Format, v144, v146);
fclose(v66);
std::string::_M_dispose((void **)&Format);
std::string::_M_dispose((void **)&v146);
std::string::_M_dispose((void **)&v144);
}
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::~basic_stringstream((int)&v152);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)&v126);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)&v124);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)&v122);
}
else
{
std::string::basic_string((void **)&v152, "l_");
std::string::basic_string((void **)&Format, "f_");
std::string::basic_string((void **)&v146, "$gdwx");
std::string::basic_string((void **)&v144, "boxofchocolate");
std::string::basic_string((void **)&v142, (char *)&byte_5173B0);
std::string::basic_string((void **)&String, "p_");
std::string::basic_string((void **)&v136, "d_");
std::string::basic_string((void **)&v133, "e_");
std::string::basic_string((void **)v132, "gg");
std::string::basic_string((void **)v131, (char *)&off_5174F9);
std::string::basic_string((void **)v130, (_BYTE *)&off_5174F9 + 2);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::_Rb_tree(
v129,
(int)&v114);
exca = WXML::Compiler::Compile(
&v112,
(unsigned int *)v116,
v118,
v129,
&v110,
v82,
v108,
exc,
10,
v130,
v131,
v132,
&v133,
&v136,
(int *)&String,
(int)&v142,
(int)&v144,
(int)&v146,
(int *)&Format);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)v129);
std::string::_M_dispose((void **)v130);
std::string::_M_dispose((void **)v131);
std::string::_M_dispose((void **)v132);
std::string::_M_dispose((void **)&v133);
std::string::_M_dispose((void **)&v136);
std::string::_M_dispose((void **)&String);
std::string::_M_dispose((void **)&v142);
std::string::_M_dispose((void **)&v144);
std::string::_M_dispose((void **)&v146);
std::string::_M_dispose((void **)&Format);
std::string::_M_dispose((void **)&v152);
if ( exca )
{
fprintf(&__iob[2], "%s\n", (const char *)v116[0]);
}
else
{
if ( FileName && *FileName )
v50 = fopen(FileName, "w");
else
v50 = &__iob[1];
fprintf(v50, "%s\n", (const char *)v118[0]);
fclose(v50);
}
}
std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::~_Rb_tree((int)&v120);
std::string::_M_dispose(v118);
std::string::_M_dispose((void **)v116);
std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)&v114);
std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::~_Rb_tree((int)&v112);
}
goto LABEL_177; // 清理数据
}
v34 = (const char **)&WXML::GlassEaselWxs::sWxsEnvInit;
}
main::{lambda(std::string const&)#1}::operator()((const char **)&FileName, v34);
exca = 0;
goto LABEL_177; // 清理数据
}
v140 = 0;
String = (char *)&v141;
LOBYTE(v141) = 0;
std::_Rb_tree_header::_Rb_tree_header(v143);
std::_Rb_tree_header::_Rb_tree_header(v145);
if ( ReadFile((char *)*v91, (unsigned int *)&String) )
{
fprintf(&__iob[2], "Failed to read input from %s", *v91);
exca = -1;
}
else
{
JsonDict = GetJsonDict((int *)&String, (int)&v142);
exca = JsonDict;
if ( JsonDict )
{
fprintf(&__iob[2], "Failed to read JSON at position %d (%c)", ~JsonDict, String[~JsonDict]);
LABEL_106:
exca = -2;
}
else
{
for ( m = (char **)v143[2]; m != v143; m = (char **)std::_Rb_tree_increment((int)m) )
{
std::string::basic_string(&v152, (int)(m + 4));
std::string::basic_string(v156, (int)(m + 10));
v146 = (int)v148;
v147 = 0;
v148[0] = 0;
if ( night::compile_ns_no_wrapper((int)&v152, (int)v156, 1, (unsigned int *)&v146, 0) )
{
fprintf(&__iob[2], "Error in file %s: %s\n", (const char *)v152, (const char *)v146);
std::string::_M_dispose((void **)&v146);
std::pair<std::string const,std::string>::~pair((void **)&v152);
goto LABEL_106;
}
v31 = snprintf(0, 0, WXML::GlassEaselWxs::sWrapper, v146) + 1;
v32 = (char *)operator new[](v31);
snprintf(v32, v31, WXML::GlassEaselWxs::sWrapper, v146);
std::string::basic_string((void **)&Format, v32);
v33 = std::map<std::string,std::string>::operator[](&v144, (int)&v152);
std::string::operator=(v33, &Format);
std::string::_M_dispose((void **)&Format);
operator delete[](v32);
std::string::_M_dispose((void **)&v146);
std::pair<std::string const,std::string>::~pair((void **)&v152);
}
DictToJsonString((int)&v136, (int)&v144);
main::{lambda(std::string const&)#1}::operator()((const char **)&FileName, (const char **)&v136);
std::string::_M_dispose((void **)&v136);
}
}
std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::~_Rb_tree((int)&v144);
std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::~_Rb_tree((int)&v142);
std::string::_M_dispose((void **)&String);
LABEL_177:
std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::~_Rb_tree((int)&v110);
std::string::_M_dispose(v109);
std::string::_M_dispose((void **)v108);
std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::~_Rb_tree((int)&v106);
std::vector<std::string>::~vector(&v97, v67);
std::vector<std::string>::~vector(&v94, v68);
std::string::_M_dispose((void **)&v103);
std::string::_M_dispose((void **)&v100);
std::vector<std::string>::~vector((void ***)&v91, v69);
return exca;
}

View File

@ -49,6 +49,7 @@ const wcc = (args: string[], projectPath: string): Promise<string> => {
args,
{
cwd: projectPath,
env: process.env,
}
);
const spwanData: any[] = [],
@ -69,11 +70,19 @@ const wcc = (args: string[], projectPath: string): Promise<string> => {
resolve(result);
} else {
process.stderr.write(
"wine error:" +
"wine error:\n" +
Buffer.concat(errData).toString()
);
process.stderr.write(
"stdout:\n" +
Buffer.concat(spwanData).toString()
);
// process.stderr.write(Buffer.concat(spwanData).toString());
reject(n);
reject({
code: n,
stdout: Buffer.concat(spwanData).toString(),
stderr: Buffer.concat(errData).toString(),
});
}
});
});

View File

@ -1,10 +1,11 @@
import { spawn } from "child_process";
import path from "path";
import * as fs from 'fs'
import { CompilerResult } from "./types";
const NW_VERSION = '0.55.0'
const wcscNative = (optionsPath: string, projectPath: string, outputPath: string | undefined = undefined): Promise<string> => {
const wcscNative = (optionsPath: string, projectPath: string, outputPath: string | undefined = undefined): Promise<CompilerResult> => {
const nodeExec = spawn(
path.resolve(__dirname, `../../cache/nwjs-sdk-v${NW_VERSION}-linux-x64/nw`),
@ -35,18 +36,31 @@ const wcscNative = (optionsPath: string, projectPath: string, outputPath: string
let result = Buffer.concat(spwanData).toString();
result = result.split('---------------result------------------\n')[1]
const options = JSON.parse(fs.readFileSync(optionsPath).toString())
const r: CompilerResult = {
success: true,
type: "string",
data: result
}
if (options.lazyloadConfig || options.lazyload)
result = JSON.parse(result);
resolve(result);
{
r.type = 'object'
r.data = JSON.parse(result);
}
resolve(r);
} else {
// process.stderr.write(Buffer.concat(errData).toString());
// process.stderr.write(Buffer.concat(spwanData).toString());
reject(n);
const err = Buffer.concat(errData).toString()
process.stderr.write(err);
const r: CompilerResult = {
success: false,
type: "string",
data: err
}
resolve(r)
}
});
});
};
const wccNative = (optionsPath: string, outputPath: string | undefined = undefined): Promise<string | Record<string, any>> => {
const wccNative = (optionsPath: string, outputPath: string | undefined = undefined): Promise<CompilerResult> => {
const nodeExec = spawn(
path.resolve(__dirname, `../../cache/nwjs-sdk-v${NW_VERSION}-linux-x64/nw`),
@ -72,17 +86,34 @@ const wccNative = (optionsPath: string, outputPath: string | undefined = undefin
nodeExec.on("close", (n) => {
// console.log("node n: ", n);
outputPath && require('fs').writeFileSync(`${outputPath}/linux_err.js`, Buffer.concat(errData).toString())
if (0 === n) {
if (0 === n && errData.length == 0) {
let result = Buffer.concat(spwanData).toString();
result = result.split('---------------result------------------\n')[1]
// process.stdout.write(result);
if (result[0] === '{')
result = JSON.parse(result);
resolve(result);
const split = '---------------result------------------\n'
if (result.includes(split))
result = result.split(split)[1]
const r: CompilerResult = {
success: true,
type: "string",
data: result
}
if (result?.[0] === '{')
{
r.type = 'object'
r.data = JSON.parse(result);
}
resolve(r);
} else {
process.stderr.write(Buffer.concat(errData).toString());
const err = Buffer.concat(errData).toString()
// process.stderr.write(err);
// process.stderr.write(Buffer.concat(spwanData).toString());
reject(n);
const r: CompilerResult = {
success: false,
type: "string",
data: err
}
resolve(r);
}
});
});

View File

@ -1,12 +1,12 @@
import * as fs from 'fs'
import { request } from "http";
import { CompilerOptions } from './types';
import { CompilerOptions, CompilerResult, RequestResult } from './types';
import path from 'path'
import { execFileSync } from 'child_process';
// 预先启动wine focker环境再使用HTTP协议最后销毁容器
const HTTP = {
POST: (type: 'wcc' | 'wcsc', compilerOptions: CompilerOptions): Promise<string | Record<string, any>> => {
POST: (type: 'wcc' | 'wcsc', compilerOptions: CompilerOptions): Promise<RequestResult> => {
return new Promise((resolve, reject) => {
compilerOptions.cwd = compilerOptions.cwd.replace(path.resolve(__dirname, '../../'), '/wrokspace')
@ -35,17 +35,20 @@ const HTTP = {
});
res.on('end', () => {
// console.log('No more data in response.');
if (ret?.startsWith('server error'))
if (res.statusCode != 200)
{
console.log('error:', ret)
}
if (compilerOptions.lazyloadConfig || compilerOptions.lazyload)
{
resolve(JSON.parse(ret))
// console.log('response error:\n', ret)
resolve({
success: false,
data: ret
})
}
else
{
resolve(ret)
resolve({
success: true,
data: ret
})
}
});
});
@ -62,13 +65,37 @@ const HTTP = {
}
}
const wcscNative = async (optionsPath: string) => {
const wcscNative = async (optionsPath: string): Promise<CompilerResult> => {
const options = JSON.parse(fs.readFileSync(optionsPath).toString())
return await HTTP.POST('wcsc', options)
const result = await HTTP.POST('wcsc', options)
const r: CompilerResult = {
success: result.success,
type: 'string',
data: result.data
}
if (!result.success) return r;
if (options.lazyloadConfig || options.lazyload)
{
r.type = 'object'
r.data = JSON.parse(result.data)
}
return r
};
const wccNative = async (optionsPath: string) => {
const options = JSON.parse(fs.readFileSync(optionsPath).toString())
return await HTTP.POST('wcc', options)
const wccNative = async (optionsPath: string): Promise<CompilerResult> => {
const options = JSON.parse(fs.readFileSync(optionsPath).toString()) as CompilerOptions
const result = await HTTP.POST('wcc', options)
const r: CompilerResult = {
success: result.success,
type: 'string',
data: result.data
}
if (!result.success) return r;
if (options.lazyloadConfig || options.lazyload)
{
r.type = 'object'
r.data = JSON.parse(result.data)
}
return r
};
export default {

View File

@ -8,11 +8,17 @@ const optionsData = fs.readFileSync(p).toString();
const options = JSON.parse(optionsData);
(async () => {
const result = await compiler[type](options);
console.log('---------------result------------------')
if (typeof result === "string") {
process.stdout.write(result);
} else {
process.stdout.write(JSON.stringify(result));
try {
const result = await compiler[type](options);
console.log('---------------result------------------')
if (typeof result === "string") {
process.stdout.write(result);
process.exitCode = 1
process.exit(1)
} else {
process.stdout.write(JSON.stringify(result));
}
}catch (err) {
// console.error('conpile.js error ->' + err)
}
})();

View File

@ -2,7 +2,7 @@
Xvfb :98 & # Start xvfb on display :98
export DISPLAY=:98
set -x
set -ex
root_dir=$(cd `dirname $0`/../../.. && pwd -P)
cur_dir=$(cd `dirname $0` && pwd -P)
@ -46,7 +46,7 @@ docker_start(){
--env=TZ=Asia/Shanghai\
--volume=winehome:/home/wineuser\
-p 8083:8083\
scottyhardy/docker-wine:latest\
scottyhardy/docker-wine\
wine /workspace/cache/nwjs-sdk-v$nw_version-win-x64/nw.exe
i=0

View File

@ -1,7 +1,9 @@
// initialize your app
// and ...
console.log("main.js");
console.log("====================================================================");
console.log("==============================main.js===============================");
console.log("====================================================================");
const fs = require("fs");
console.log("fs:", fs);
const wcc = require("./wcc");
@ -10,7 +12,7 @@ console.log("wcc:", wcc);
const { createServer } = require("http");
const HOST = "0.0.0.0";
const PORT = "8083";
const PORT = 8083;
const Handle = {
/**
@ -71,9 +73,9 @@ const server = createServer(async (req, resp) => {
}
} catch (e) {
console.error('server error:', e)
// console.error('server error:', e)
resp.writeHead(500, { "Content-Type": "text/plain" });
resp.end("server error:" + e);
resp.end(`${e}`);
}
});

View File

@ -1,5 +1,5 @@
{
"name": "helloworld",
"main": "main.js",
"show": "false"
"show": false
}

View File

@ -10,4 +10,14 @@ export interface CompilerOptions {
cwd: string
lazyload: boolean
lazyloadConfig: string
}
export interface RequestResult {
success: boolean
data: string
}
export interface CompilerResult {
success: boolean
type: 'string' | 'object'
data: any
}

1
test/spec/issue/115/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
sample

View File

@ -0,0 +1,16 @@
{
"files": [
"./pages/index/index.wxml"
],
"debugWXS": false,
"debug": true,
"genfuncname": "$gwx",
"wxmlCompileConfig": "1>_<7122./pages/index/index.wxml>_<71220",
"wxmlCompileConfigSplit": ">_<7122",
"replaceContent": {
"pages/index/index.wxml": "<!--index.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <view class=\"container\">\n <view class=\"usermotto\">\n <view class=\"user-motto\">test\n </view>\n </view>\n</scroll-view>\n",
"./pages/index/index.wxml": "<!--index.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <view class=\"container\">\n <view class=\"usermotto\">\n <view class=\"user-motto\">test\n </view>\n </view>\n</scroll-view>\n"
},
"cwd": "/home/msojocs/WeChatProjects/miniprogram-3",
"lazyloadConfig": "./pages/index/index"
}

View File

@ -0,0 +1,38 @@
import assert from "assert"
import path from "path"
import { describe } from "mocha";
import linux from '../../../runner/module-linux'
import windows from '../../../runner/module-windows'
import * as fs from 'fs'
describe("issue - 115", function () {
describe("issue: linux output should equal with wine", function () {
it("标签没合闭", async function () {
const p = path.resolve(__dirname, './data/example.json')
const storagePath = path.resolve(
__dirname,
`issue-115/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
const w = await windows.wcc(p);
const n = await linux.wcc(p, '');
// console.log('windows:', typeof w)
// console.log('linux:', typeof n)
assert.equal(typeof n, typeof w);
assert.equal(w.success, false)
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
});
});
});

5
test/spec/issue/115/prepare.sh Executable file
View File

@ -0,0 +1,5 @@
#! /bin/bash
dir=$(cd `dirname $0` && pwd -P)
tar -zxf $dir/sample.tar.gz -C $dir

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
import assert from "assert"
import path from "path"
import { describe } from "mocha";
import linux from '../../../runner/module-linux'
import windows from '../../../runner/module-windows'
import * as fs from 'fs'
describe("issue - 129", function () {
describe("issue: linux output should equal with wine", function () {
it("crash", async function () {
const p = path.resolve(__dirname, './data/example.json')
const storagePath = path.resolve(
__dirname,
`issue-129/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
const w = await windows.wcsc(p);
const n = await linux.wcsc(p, '', storagePath);
// console.log('windows:', typeof w)
// console.log('linux:', typeof n)
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.equal(typeof n, typeof w);
assert.equal(w.success, true)
assert.deepEqual(n, w);
});
});
});

4
test/spec/issue/129/prepare.sh Executable file
View File

@ -0,0 +1,4 @@
#! /bin/bash
dir=$(cd `dirname $0` && pwd -P)

View File

@ -0,0 +1,29 @@
{
"files": [
"./pages/index/index.wxss",
"./pages/logs/logs.wxss",
"./components/navigation-bar/navigation-bar.wxss",
"./app.wxss"
],
"contents": [
"/**index.wxss**/\n:root\npage {\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n\n.scrollarea {\n flex: 1;\n overflow-y: hidden;\n}\n\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n width: 80%;\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}\n\n.avatar-wrapper {\n padding: 0;\n width: 56px !important;\n border-radius: 8px;\n margin-top: 40px;\n margin-bottom: 40px;\n}\n\n.avatar {\n display: block;\n width: 56px;\n height: 56px;\n}\n\n.nickname-wrapper {\n display: flex;\n width: 100%;\n padding: 16px;\n box-sizing: border-box;\n border-top: .5px solid rgba(0, 0, 0, 0.1);\n border-bottom: .5px solid rgba(0, 0, 0, 0.1);\n color: black;\n}\n\n.nickname-label {\n width: 105px;\n}\n\n.nickname-input {\n flex: 1;\n}\n",
"page {\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n.scrollarea {\n flex: 1;\n overflow-y: hidden;\n}\n.log-item {\n margin-top: 20rpx;\n text-align: center;\n}\n.log-item:last-child {\n padding-bottom: env(safe-area-inset-bottom);\n}\n",
".weui-navigation-bar {\n --weui-FG-0:rgba(0,0,0,.9);\n --height: 44px;\n --left: 16px;\n}\n.weui-navigation-bar .android {\n --height: 48px;\n}\n\n.weui-navigation-bar {\n overflow: hidden;\n color: var(--weui-FG-0);\n flex: none;\n}\n\n.weui-navigation-bar__inner {\n position: relative;\n top: 0;\n left: 0;\n height: calc(var(--height) + env(safe-area-inset-top));\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n padding-top: env(safe-area-inset-top);\n width: 100%;\n box-sizing: border-box;\n}\n\n.weui-navigation-bar__left {\n position: relative;\n padding-left: var(--left);\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n height: 100%;\n box-sizing: border-box;\n}\n\n.weui-navigation-bar__btn_goback_wrapper {\n padding: 11px 18px 11px 16px;\n margin: -11px -18px -11px -16px;\n}\n\n.weui-navigation-bar__btn_goback_wrapper.weui-active {\n opacity: 0.5;\n}\n\n.weui-navigation-bar__btn_goback {\n font-size: 12px;\n width: 12px;\n height: 24px;\n -webkit-mask: url(\"data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E\") no-repeat 50% 50%;\n mask: url(\"data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E\") no-repeat 50% 50%;\n -webkit-mask-size: cover;\n mask-size: cover;\n background-color: var(--weui-FG-0);\n}\n\n.weui-navigation-bar__center {\n font-size: 17px;\n text-align: center;\n position: relative;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n font-weight: bold;\n flex: 1;\n height: 100%;\n}\n\n.weui-navigation-bar__loading {\n margin-right: 4px;\n align-items: center;\n}\n\n.weui-loading {\n font-size: 16px;\n width: 16px;\n height: 16px;\n display: block;\n background: transparent url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient x1='94.0869141%25' y1='0%25' x2='94.0869141%25' y2='90.559082%25' id='linearGradient-1'%3E%3Cstop stop-color='%23606060' stop-opacity='0' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient x1='100%25' y1='8.67370605%25' x2='100%25' y2='90.6286621%25' id='linearGradient-2'%3E%3Cstop stop-color='%23606060' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='url(%23linearGradient-1)'%3E%3C/path%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='url(%23linearGradient-2)'%3E%3C/path%3E%3Ccircle id='Oval' fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\") no-repeat;\n background-size: 100%;\n margin-left: 0;\n animation: loading linear infinite 1s;\n}\n\n@keyframes loading {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(360deg);\n }\n}\n",
":root\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": 3,
"cwd": "/home/msojocs/WeChatProjects/miniprogram-2",
"replaceContent": {
"app.wxss": ":root\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",
"./app.wxss": ":root\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",
"components/navigation-bar/navigation-bar.wxss": ".weui-navigation-bar {\n --weui-FG-0:rgba(0,0,0,.9);\n --height: 44px;\n --left: 16px;\n}\n.weui-navigation-bar .android {\n --height: 48px;\n}\n\n.weui-navigation-bar {\n overflow: hidden;\n color: var(--weui-FG-0);\n flex: none;\n}\n\n.weui-navigation-bar__inner {\n position: relative;\n top: 0;\n left: 0;\n height: calc(var(--height) + env(safe-area-inset-top));\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n padding-top: env(safe-area-inset-top);\n width: 100%;\n box-sizing: border-box;\n}\n\n.weui-navigation-bar__left {\n position: relative;\n padding-left: var(--left);\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n height: 100%;\n box-sizing: border-box;\n}\n\n.weui-navigation-bar__btn_goback_wrapper {\n padding: 11px 18px 11px 16px;\n margin: -11px -18px -11px -16px;\n}\n\n.weui-navigation-bar__btn_goback_wrapper.weui-active {\n opacity: 0.5;\n}\n\n.weui-navigation-bar__btn_goback {\n font-size: 12px;\n width: 12px;\n height: 24px;\n -webkit-mask: url(\"data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E\") no-repeat 50% 50%;\n mask: url(\"data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E\") no-repeat 50% 50%;\n -webkit-mask-size: cover;\n mask-size: cover;\n background-color: var(--weui-FG-0);\n}\n\n.weui-navigation-bar__center {\n font-size: 17px;\n text-align: center;\n position: relative;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n font-weight: bold;\n flex: 1;\n height: 100%;\n}\n\n.weui-navigation-bar__loading {\n margin-right: 4px;\n align-items: center;\n}\n\n.weui-loading {\n font-size: 16px;\n width: 16px;\n height: 16px;\n display: block;\n background: transparent url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient x1='94.0869141%25' y1='0%25' x2='94.0869141%25' y2='90.559082%25' id='linearGradient-1'%3E%3Cstop stop-color='%23606060' stop-opacity='0' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient x1='100%25' y1='8.67370605%25' x2='100%25' y2='90.6286621%25' id='linearGradient-2'%3E%3Cstop stop-color='%23606060' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='url(%23linearGradient-1)'%3E%3C/path%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='url(%23linearGradient-2)'%3E%3C/path%3E%3Ccircle id='Oval' fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\") no-repeat;\n background-size: 100%;\n margin-left: 0;\n animation: loading linear infinite 1s;\n}\n\n@keyframes loading {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(360deg);\n }\n}\n",
"./components/navigation-bar/navigation-bar.wxss": ".weui-navigation-bar {\n --weui-FG-0:rgba(0,0,0,.9);\n --height: 44px;\n --left: 16px;\n}\n.weui-navigation-bar .android {\n --height: 48px;\n}\n\n.weui-navigation-bar {\n overflow: hidden;\n color: var(--weui-FG-0);\n flex: none;\n}\n\n.weui-navigation-bar__inner {\n position: relative;\n top: 0;\n left: 0;\n height: calc(var(--height) + env(safe-area-inset-top));\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n padding-top: env(safe-area-inset-top);\n width: 100%;\n box-sizing: border-box;\n}\n\n.weui-navigation-bar__left {\n position: relative;\n padding-left: var(--left);\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n height: 100%;\n box-sizing: border-box;\n}\n\n.weui-navigation-bar__btn_goback_wrapper {\n padding: 11px 18px 11px 16px;\n margin: -11px -18px -11px -16px;\n}\n\n.weui-navigation-bar__btn_goback_wrapper.weui-active {\n opacity: 0.5;\n}\n\n.weui-navigation-bar__btn_goback {\n font-size: 12px;\n width: 12px;\n height: 24px;\n -webkit-mask: url(\"data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E\") no-repeat 50% 50%;\n mask: url(\"data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E\") no-repeat 50% 50%;\n -webkit-mask-size: cover;\n mask-size: cover;\n background-color: var(--weui-FG-0);\n}\n\n.weui-navigation-bar__center {\n font-size: 17px;\n text-align: center;\n position: relative;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n font-weight: bold;\n flex: 1;\n height: 100%;\n}\n\n.weui-navigation-bar__loading {\n margin-right: 4px;\n align-items: center;\n}\n\n.weui-loading {\n font-size: 16px;\n width: 16px;\n height: 16px;\n display: block;\n background: transparent url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient x1='94.0869141%25' y1='0%25' x2='94.0869141%25' y2='90.559082%25' id='linearGradient-1'%3E%3Cstop stop-color='%23606060' stop-opacity='0' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient x1='100%25' y1='8.67370605%25' x2='100%25' y2='90.6286621%25' id='linearGradient-2'%3E%3Cstop stop-color='%23606060' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='url(%23linearGradient-1)'%3E%3C/path%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='url(%23linearGradient-2)'%3E%3C/path%3E%3Ccircle id='Oval' fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\") no-repeat;\n background-size: 100%;\n margin-left: 0;\n animation: loading linear infinite 1s;\n}\n\n@keyframes loading {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(360deg);\n }\n}\n",
"pages/index/index.wxss": "/**index.wxss**/\n:root\npage {\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n\n.scrollarea {\n flex: 1;\n overflow-y: hidden;\n}\n\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n width: 80%;\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}\n\n.avatar-wrapper {\n padding: 0;\n width: 56px !important;\n border-radius: 8px;\n margin-top: 40px;\n margin-bottom: 40px;\n}\n\n.avatar {\n display: block;\n width: 56px;\n height: 56px;\n}\n\n.nickname-wrapper {\n display: flex;\n width: 100%;\n padding: 16px;\n box-sizing: border-box;\n border-top: .5px solid rgba(0, 0, 0, 0.1);\n border-bottom: .5px solid rgba(0, 0, 0, 0.1);\n color: black;\n}\n\n.nickname-label {\n width: 105px;\n}\n\n.nickname-input {\n flex: 1;\n}\n",
"./pages/index/index.wxss": "/**index.wxss**/\n:root\npage {\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n\n.scrollarea {\n flex: 1;\n overflow-y: hidden;\n}\n\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n width: 80%;\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}\n\n.avatar-wrapper {\n padding: 0;\n width: 56px !important;\n border-radius: 8px;\n margin-top: 40px;\n margin-bottom: 40px;\n}\n\n.avatar {\n display: block;\n width: 56px;\n height: 56px;\n}\n\n.nickname-wrapper {\n display: flex;\n width: 100%;\n padding: 16px;\n box-sizing: border-box;\n border-top: .5px solid rgba(0, 0, 0, 0.1);\n border-bottom: .5px solid rgba(0, 0, 0, 0.1);\n color: black;\n}\n\n.nickname-label {\n width: 105px;\n}\n\n.nickname-input {\n flex: 1;\n}\n",
"pages/logs/logs.wxss": "page {\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n.scrollarea {\n flex: 1;\n overflow-y: hidden;\n}\n.log-item {\n margin-top: 20rpx;\n text-align: center;\n}\n.log-item:last-child {\n padding-bottom: env(safe-area-inset-bottom);\n}\n",
"./pages/logs/logs.wxss": "page {\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n.scrollarea {\n flex: 1;\n overflow-y: hidden;\n}\n.log-item {\n margin-top: 20rpx;\n text-align: center;\n}\n.log-item:last-child {\n padding-bottom: env(safe-area-inset-bottom);\n}\n"
},
"debug": true,
"classPrefix": "",
"lazyload": true
}

View File

@ -0,0 +1,38 @@
import assert from "assert"
import path from "path"
import { describe } from "mocha";
import linux from '../../../runner/module-linux'
import windows from '../../../runner/module-windows'
import * as fs from 'fs'
describe("issue - 137", function () {
describe("issue: linux output should equal with wine", function () {
it("Arch linux crash", async function () {
const p = path.resolve(__dirname, './data/example.json')
const storagePath = path.resolve(
__dirname,
`output/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
const w = await windows.wcsc(p);
const n = await linux.wcsc(p, '', storagePath);
// console.log('windows:', typeof w)
// console.log('linux:', typeof n)
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.equal(typeof n, typeof w);
assert.equal(w.success, true)
assert.deepEqual(n, w);
});
});
});

View File

@ -16,7 +16,11 @@ describe("wcc - empty", function () {
try
{
w = (await windows.wcc(args, projectPath)).replace(/\r\n/g, '\n')
}catch{}
}
catch(err: any){
console.error('error:', err)
w = err.stdout.replace(/\r\n/g, '\n')
}
const n = await linux.wcc(args, projectPath);
const storagePath = path.resolve(
__dirname,
@ -28,7 +32,7 @@ describe("wcc - empty", function () {
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
fs.writeFileSync(`${storagePath}/node-output.js`, n);
assert.equal(w, n);
assert.equal(n, w, `wine: ${w}\n\nlinux: ${n}`);
});
});
});

View File

@ -0,0 +1,28 @@
{
"files": [
"./pages/index/index.wxml",
"./pages/logs/logs.wxml"
],
"contents": [
"<!--index.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <view class=\"container\">\n <view class=\"userinfo\">\n <block wx:if=\"{{canIUseNicknameComp && !hasUserInfo}}\">\n <button class=\"avatar-wrapper\" open-type=\"chooseAvatar\" bind:chooseavatar=\"onChooseAvatar\">\n <image class=\"avatar\" src=\"{{userInfo.avatarUrl}}\"></image>\n </button>\n <view class=\"nickname-wrapper\">\n <text class=\"nickname-label\">昵称</text>\n <input type=\"nickname\" class=\"nickname-input\" placeholder=\"请输入昵称\" bind:change=\"onInputChange\" />\n </view>\n </block>\n <block wx:elif=\"{{!hasUserInfo}}\">\n <button wx:if=\"{{canIUseGetUserProfile}}\" bindtap=\"getUserProfile\"> 获取头像昵称 </button>\n <view wx:else> 请使用2.10.4及以上版本基础库 </view>\n </block>\n <block wx:else>\n <image bindtap=\"bindViewTap\" class=\"userinfo-avatar\" src=\"{{userInfo.avatarUrl}}\" mode=\"cover\"></image>\n <text class=\"userinfo-nickname\">{{userInfo.nickName}}</text>\n </block>\n </view>\n <view class=\"usermotto\">\n <text class=\"user-motto\" style=\"color:var(--primary);\">{{motto}}</text>\n </view>\n </view>\n</scroll-view>\n",
"<!--logs.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <block wx:for=\"{{logs}}\" wx:key=\"timeStamp\" wx:for-item=\"log\">\n <view class=\"log-item\">{{index + 1}}. {{log.date}}</view>\n </block>\n</scroll-view>\n"
],
"replaceContent": {
"pages/index/index.wxml": "<!--index.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <view class=\"container\">\n <view class=\"userinfo\">\n <block wx:if=\"{{canIUseNicknameComp && !hasUserInfo}}\">\n <button class=\"avatar-wrapper\" open-type=\"chooseAvatar\" bind:chooseavatar=\"onChooseAvatar\">\n <image class=\"avatar\" src=\"{{userInfo.avatarUrl}}\"></image>\n </button>\n <view class=\"nickname-wrapper\">\n <text class=\"nickname-label\">昵称</text>\n <input type=\"nickname\" class=\"nickname-input\" placeholder=\"请输入昵称\" bind:change=\"onInputChange\" />\n </view>\n </block>\n <block wx:elif=\"{{!hasUserInfo}}\">\n <button wx:if=\"{{canIUseGetUserProfile}}\" bindtap=\"getUserProfile\"> 获取头像昵称 </button>\n <view wx:else> 请使用2.10.4及以上版本基础库 </view>\n </block>\n <block wx:else>\n <image bindtap=\"bindViewTap\" class=\"userinfo-avatar\" src=\"{{userInfo.avatarUrl}}\" mode=\"cover\"></image>\n <text class=\"userinfo-nickname\">{{userInfo.nickName}}</text>\n </block>\n </view>\n <view class=\"usermotto\">\n <text class=\"user-motto\" style=\"color:var(--primary);\">{{motto}}</text>\n </view>\n </view>\n</scroll-view>\n",
"./pages/index/index.wxml": "<!--index.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <view class=\"container\">\n <view class=\"userinfo\">\n <block wx:if=\"{{canIUseNicknameComp && !hasUserInfo}}\">\n <button class=\"avatar-wrapper\" open-type=\"chooseAvatar\" bind:chooseavatar=\"onChooseAvatar\">\n <image class=\"avatar\" src=\"{{userInfo.avatarUrl}}\"></image>\n </button>\n <view class=\"nickname-wrapper\">\n <text class=\"nickname-label\">昵称</text>\n <input type=\"nickname\" class=\"nickname-input\" placeholder=\"请输入昵称\" bind:change=\"onInputChange\" />\n </view>\n </block>\n <block wx:elif=\"{{!hasUserInfo}}\">\n <button wx:if=\"{{canIUseGetUserProfile}}\" bindtap=\"getUserProfile\"> 获取头像昵称 </button>\n <view wx:else> 请使用2.10.4及以上版本基础库 </view>\n </block>\n <block wx:else>\n <image bindtap=\"bindViewTap\" class=\"userinfo-avatar\" src=\"{{userInfo.avatarUrl}}\" mode=\"cover\"></image>\n <text class=\"userinfo-nickname\">{{userInfo.nickName}}</text>\n </block>\n </view>\n <view class=\"usermotto\">\n <text class=\"user-motto\" style=\"color:var(--primary);\">{{motto}}</text>\n </view>\n </view>\n</scroll-view>\n",
"pages/logs/logs.wxml": "<!--logs.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <block wx:for=\"{{logs}}\" wx:key=\"timeStamp\" wx:for-item=\"log\">\n <view class=\"log-item\">{{index + 1}}. {{log.date}}</view>\n </block>\n</scroll-view>\n",
"./pages/logs/logs.wxml": "<!--logs.wxml-->\n<scroll-view class=\"scrollarea\" scroll-y type=\"list\">\n <block wx:for=\"{{logs}}\" wx:key=\"timeStamp\" wx:for-item=\"log\">\n <view class=\"log-item\">{{index + 1}}. {{log.date}}</view>\n </block>\n</scroll-view>\n"
},
"verbose": false,
"debug": true,
"debugWXS": false,
"showNewTree": false,
"addTestAttre": false,
"independent": false,
"genfuncname": "$gwx",
"cwd": "/home/msojocs/WeChatProjects/miniprogram-2",
"lazyload": true,
"lazyloadConfig": "./pages/index/index>_<2413./pages/logs/logs",
"wxmlCompileConfig": "2>_<2413./pages/index/index.wxml>_<24130>_<2413./pages/logs/logs.wxml>_<24130",
"wxmlCompileConfigSplit": ">_<2413"
}

View File

@ -26,33 +26,18 @@ describe("wcc - module", function () {
const w = await windows.wcc(p);
const n = await linux.wcc(p, '');
// console.log('windows:', typeof w)
// console.log('linux:', typeof n)
// console.log('linux:', n)
assert.equal(typeof n, typeof w);
if (typeof w == 'string')
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
w
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
n as string
);
assert.equal(n, w);
}
else
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
}
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
});
it("初次加载2", async function () {
const p = path.resolve(__dirname, './data/options-1719836863260.json')
@ -66,34 +51,45 @@ describe("wcc - module", function () {
const w = await windows.wcc(p);
const n = await linux.wcc(p, '');
console.log('windows:', typeof w)
console.log('linux:', typeof n)
// console.log('windows:', typeof w)
// console.log('linux:', typeof n)
assert.equal(typeof n, typeof w);
if (typeof w == 'string')
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
w
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
n as string
);
assert.equal(n, w);
}
else
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
}
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
});
it("初次加载3 - 1", async function () {
const p = path.resolve(__dirname, './data/options-202505012307.json')
const storagePath = path.resolve(
__dirname,
`miniprogram-demo/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
const w = await windows.wcc(p);
const n = await linux.wcc(p, '');
// console.log('windows:', typeof w)
// console.log('linux:', typeof n)
assert.equal(typeof n, typeof w);
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
});
});
});

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{"compile_placeholder.wxs":"/* compile_placeholder */"}

View File

@ -0,0 +1,3 @@
{
"pages/comm": "// /pages/comm.wxs\n\nvar foo = \"'hello world' from comm.wxs\";\nvar bar = function(d) {\n return d;\n}\nmodule.exports = {\n foo: foo,\n bar: bar\n};"
}

View File

@ -0,0 +1,93 @@
import assert from 'assert';
import path from 'path';
import linux from '../../../runner/binary-linux'
import windows from '../../../runner/binary-windows'
import * as fs from 'fs'
import { describe } from "mocha";
describe("wcc - wxs", function () {
describe("wxs: node output should equal with wine", function () {
// afterEach(function(){
// if(this.currentTest.state === 'failed'){
// console.error('failed', this.currentTest)
// }
// })
it("sample1", async function () {
const projectPath = path.resolve(
__dirname,
"../../../projects/miniprogram-demo/miniprogram"
);
const p = path.resolve(__dirname, './sample1.json')
const args = [
"--wxs",
p
];
const w = (await windows.wcc(args, projectPath)).replace(/\r\n/g, '\n')
const n = await linux.wcc(args, projectPath);
const storagePath = path.resolve(
__dirname,
`miniprogram-demo/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
assert.equal(typeof w, typeof n);
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
fs.writeFileSync(`${storagePath}/node-output.js`, n);
assert.equal(w, n);
});
it("sample2", async function () {
const projectPath = path.resolve(
__dirname,
"../../../projects/miniprogram-demo/miniprogram"
);
const p = path.resolve(__dirname, './sample2.json')
const args = [
"--wxs",
p
];
const w = (await windows.wcc(args, projectPath)).replace(/\r\n/g, '\n')
const n = await linux.wcc(args, projectPath);
const storagePath = path.resolve(
__dirname,
`miniprogram-demo/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
assert.equal(typeof w, typeof n);
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
fs.writeFileSync(`${storagePath}/node-output.js`, n);
assert.equal(w, n);
});
it("sample3", async function () {
const projectPath = path.resolve(
__dirname,
"../../../projects/miniprogram-demo/miniprogram"
);
const p = path.resolve(__dirname, './sample3.json')
const args = [
"--wxs",
p
];
const w = (await windows.wcc(args, projectPath)).replace(/\r\n/g, '\n')
const n = await linux.wcc(args, projectPath);
const storagePath = path.resolve(
__dirname,
`miniprogram-demo/${this.test?.title}`
);
try {
fs.mkdirSync(storagePath, { recursive: true });
} catch (error) {}
assert.equal(typeof w, typeof n);
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
fs.writeFileSync(`${storagePath}/node-output.js`, n);
assert.equal(w, n);
});
});
});

View File

@ -28,30 +28,15 @@ describe("wcsc - module", function () {
const n = await linux.wcsc(p, storagePath);
// console.log('linux:', typeof n)
assert.equal(typeof n, typeof w);
if (typeof w == 'string')
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
w
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
n as string
);
assert.equal(n, w);
}
else
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
}
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
});
it("初次加载2", async function () {
const p = path.resolve(__dirname, './data/1720337273873-wcsc-options.json')
@ -69,30 +54,15 @@ describe("wcsc - module", function () {
// console.log('linux:', typeof n)
assert.equal(typeof n, typeof w);
if (typeof w == 'string')
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
w
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
n as string
);
assert.equal(n, w);
}
else
{
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
}
fs.writeFileSync(
`${storagePath}/wine-output.json`,
JSON.stringify(w, null, 4)
);
fs.writeFileSync(
`${storagePath}/node-output.json`,
JSON.stringify(n, null, 4)
);
assert.deepEqual(n, w);
});
});
});

3
test/test-linux-module.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
/home/msojocs/github/wx-compiler/cache/nwjs-sdk-v0.55.0-linux-x64/nw /home/msojocs/github/wx-compiler/test/runner/nwjs/compiler.js wcsc /home/msojocs/github/wx-compiler/test/spec/issue/129/data/example.json

File diff suppressed because it is too large Load Diff

6
test/wcsc_module.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
root_dir=$(cd `dirname $0`/.. && pwd -P)
echo "linux:"
$root_dir/cache/nwjs-sdk-v0.55.0-linux-x64/nw $root_dir/test/runner/nwjs/compiler.js wcsc $root_dir/test/spec/issue/137/data/example.json

View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo apt-get install -y libxdamage1 libxcomposite-dev libxkbcommon-x11-0 libcups2 libnss3-dev libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2 libatspi2.0-0

View File

@ -0,0 +1,5 @@
#!/bin/bash
root_dir=$(cd `dirname $0`/.. && pwd -P)