mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
Compare commits
No commits in common. "master" and "v0.0.7" have entirely different histories.
27
.github/actions/test/action.yml
vendored
27
.github/actions/test/action.yml
vendored
@ -1,27 +0,0 @@
|
|||||||
name: 'Hello World'
|
|
||||||
description: 'Greet someone'
|
|
||||||
inputs:
|
|
||||||
who-to-greet: # id of input
|
|
||||||
description: 'Who to greet'
|
|
||||||
required: true
|
|
||||||
default: 'World'
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Run Nginx server
|
|
||||||
run: |
|
|
||||||
docker run -d -p 8080:80 nginx
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Wait for Nginx to be up
|
|
||||||
run: |
|
|
||||||
until $(curl --output /dev/null --silent --head --fail http://127.0.0.1:8080); do
|
|
||||||
printf '.'
|
|
||||||
curl http://127.0.0.1:8080
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- run: pnpm run test
|
|
||||||
shell: bash
|
|
68
.github/workflows/release.yml
vendored
68
.github/workflows/release.yml
vendored
@ -9,7 +9,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
branches: [ master, dev, ci, module]
|
branches: [ master, dev, ci]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
# # Allows you to run this workflow manually from the Actions tab
|
# # Allows you to run this workflow manually from the Actions tab
|
||||||
@ -18,10 +18,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Base Packages
|
name: Build Base Packages
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
node-version: [16.x]
|
||||||
ARCH: ['x86_64']
|
ARCH: ['x86_64']
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
export DOCKER_UID=$UID
|
export DOCKER_UID=$UID
|
||||||
export DOCKER_GID=$GID
|
export DOCKER_GID=$GID
|
||||||
docker compose up
|
docker-compose up
|
||||||
|
|
||||||
- name: Upload prepare
|
- name: Upload prepare
|
||||||
run: |
|
run: |
|
||||||
@ -66,12 +67,12 @@ jobs:
|
|||||||
echo "------------------------"
|
echo "------------------------"
|
||||||
ls -l build
|
ls -l build
|
||||||
mkdir -p tmp/build
|
mkdir -p tmp/build
|
||||||
mv build/{wcc,wcsc,wcc_module.node,wcsc_module.node} tmp/build
|
mv build/{wcc,wcsc} tmp/build
|
||||||
cd tmp/build
|
cd tmp/build
|
||||||
ls -l
|
ls -l
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v2.3.1
|
||||||
with:
|
with:
|
||||||
# Artifact name
|
# Artifact name
|
||||||
name: wx-compiler-${{ matrix.ARCH }}.build
|
name: wx-compiler-${{ matrix.ARCH }}.build
|
||||||
@ -81,10 +82,10 @@ jobs:
|
|||||||
name: Test for spec
|
name: Test for spec
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [18.x]
|
node-version: [16.x]
|
||||||
ARCH: ['x86_64']
|
ARCH: ['x86_64']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -96,54 +97,59 @@ jobs:
|
|||||||
# Version Spec of the version to use in SemVer notation.
|
# Version Spec of the version to use in SemVer notation.
|
||||||
# It also emits such aliases as lts, latest, nightly and canary builds
|
# It also emits such aliases as lts, latest, nightly and canary builds
|
||||||
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
||||||
node-version: '18.12.0'
|
node-version: '16.20.2'
|
||||||
check-latest: false
|
check-latest: false
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v2
|
||||||
|
|
||||||
- name: Inspect directory after downloading artifacts
|
- name: Inspect directory after downloading artifacts
|
||||||
run: ls -alFR
|
run: ls -alFR
|
||||||
|
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
set -x
|
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
|
||||||
|
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt upgrade -y
|
sudo apt install -y wine64
|
||||||
|
sudo apt-add-repository universe
|
||||||
sudo dpkg --add-architecture i386
|
sudo dpkg --add-architecture i386
|
||||||
sudo mkdir -pm755 /etc/apt/keyrings
|
dpkg --print-foreign-architectures
|
||||||
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 update
|
sudo apt install libwine
|
||||||
sudo apt install winehq-stable -y
|
echo "install wine32..."
|
||||||
sudo apt-get install wine-binfmt wine32 -y
|
sudo apt install wine32
|
||||||
|
sudo apt-get install wine-binfmt
|
||||||
sudo update-binfmts --import /usr/share/binfmts/wine
|
sudo update-binfmts --import /usr/share/binfmts/wine
|
||||||
wine --version
|
|
||||||
|
|
||||||
corepack enable
|
corepack enable
|
||||||
ls -l
|
ls -l
|
||||||
mkdir build
|
mkdir build
|
||||||
cp **build/wcc build
|
cp **build/wcc build
|
||||||
cp **build/wcsc build
|
cp **build/wcsc build
|
||||||
cp **build/wcc_module.node build
|
|
||||||
cp **build/wcsc_module.node build
|
|
||||||
chmod +x build/*
|
chmod +x build/*
|
||||||
ls -l build
|
ls -l build
|
||||||
node -v
|
node -v
|
||||||
pnpm install --no-frozen-lockfile
|
pnpm install
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
ls -l test/wine
|
ls -l test/wine
|
||||||
# ./test/wine/wcc.exe
|
# ./test/wine/wcc.exe
|
||||||
sudo apt install -y xvfb curl
|
|
||||||
pnpm run test-prepare
|
pnpm run test-prepare
|
||||||
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
|
pnpm run test
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
@ -153,7 +159,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v2
|
||||||
- name: Inspect directory after downloading artifacts
|
- name: Inspect directory after downloading artifacts
|
||||||
run: ls -alFR
|
run: ls -alFR
|
||||||
|
|
||||||
@ -178,7 +184,7 @@ jobs:
|
|||||||
sudo apt install -y fuse
|
sudo apt install -y fuse
|
||||||
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
|
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
|
||||||
chmod +x pyuploadtool-x86_64.AppImage
|
chmod +x pyuploadtool-x86_64.AppImage
|
||||||
./pyuploadtool-x86_64.AppImage **build/wcc **build/wcsc **build/wcc_module.node **build/wcsc_module.node
|
./pyuploadtool-x86_64.AppImage **build/wcc **build/wcsc
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
@ -191,5 +197,3 @@ jobs:
|
|||||||
files: |
|
files: |
|
||||||
**build/wcc
|
**build/wcc
|
||||||
**build/wcsc
|
**build/wcsc
|
||||||
**build/wcc_module.node
|
|
||||||
**build/wcsc_module.node
|
|
||||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
/build
|
build
|
||||||
cache
|
|
||||||
test/*.json
|
test/*.json
|
||||||
wcc.exe.c
|
wcc.exe.c
|
||||||
|
|
||||||
@ -8,5 +7,4 @@ node_modules
|
|||||||
*err.js
|
*err.js
|
||||||
*stderr.json
|
*stderr.json
|
||||||
.cache
|
.cache
|
||||||
*/spec/**/*output.js
|
*/spec/**/*output.js
|
||||||
tmp
|
|
11
.mocharc.js
11
.mocharc.js
@ -4,15 +4,6 @@ module.exports = {
|
|||||||
'ts-node/register'
|
'ts-node/register'
|
||||||
],
|
],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
// spec: "./test/spec/**/*.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,
|
timeout: 20000,
|
||||||
}
|
}
|
115
.vscode/launch.json
vendored
115
.vscode/launch.json
vendored
@ -4,118 +4,7 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"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",
|
"name": "(gdb) Launch",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
@ -123,10 +12,10 @@
|
|||||||
"program": "${workspaceFolder}/build/wcc",
|
"program": "${workspaceFolder}/build/wcc",
|
||||||
"args": [
|
"args": [
|
||||||
"\"--config-path\"",
|
"\"--config-path\"",
|
||||||
"\"${workspaceRoot}/test/spec/issue/102/case1.txt\""
|
"\"/home/msojocs/github/wx-compiler/test/spec/issue/102/case1.txt\""
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceRoot}/test/spec/issue/102/wxapp",
|
"cwd": "/home/msojocs/github/wx-compiler/test/spec/issue/102/wxapp",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"MIMode": "gdb",
|
"MIMode": "gdb",
|
||||||
|
21
.vscode/settings.json
vendored
21
.vscode/settings.json
vendored
@ -54,23 +54,7 @@
|
|||||||
"ratio": "cpp",
|
"ratio": "cpp",
|
||||||
"mutex": "cpp",
|
"mutex": "cpp",
|
||||||
"thread": "cpp",
|
"thread": "cpp",
|
||||||
"variant": "cpp",
|
"variant": "cpp"
|
||||||
"hash_map": "cpp",
|
|
||||||
"hash_set": "cpp",
|
|
||||||
"bitset": "cpp",
|
|
||||||
"charconv": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"compare": "cpp",
|
|
||||||
"concepts": "cpp",
|
|
||||||
"forward_list": "cpp",
|
|
||||||
"list": "cpp",
|
|
||||||
"unordered_set": "cpp",
|
|
||||||
"ranges": "cpp",
|
|
||||||
"shared_mutex": "cpp",
|
|
||||||
"span": "cpp",
|
|
||||||
"stop_token": "cpp",
|
|
||||||
"cfenv": "cpp",
|
|
||||||
"typeindex": "cpp"
|
|
||||||
},
|
},
|
||||||
"cmake.debugConfig": {
|
"cmake.debugConfig": {
|
||||||
"cwd": "/home/msojocs/github/wx-compiler/test/spec/issue/102/wxapp",
|
"cwd": "/home/msojocs/github/wx-compiler/test/spec/issue/102/wxapp",
|
||||||
@ -86,6 +70,5 @@
|
|||||||
"--background-index",
|
"--background-index",
|
||||||
"--compile-commands-dir=${workspaceFolder}/build/"
|
"--compile-commands-dir=${workspaceFolder}/build/"
|
||||||
],
|
],
|
||||||
"cmake.sourceDirectory": "/home/msojocs/github/wx-compiler",
|
"cmake.sourceDirectory": "/home/msojocs/github/wx-compiler"
|
||||||
"clangd.path": "clangd-18"
|
|
||||||
}
|
}
|
@ -1,10 +1,16 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.0)
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
project(wx_complier VERSION 0.1.0 LANGUAGES C CXX)
|
project(wx_complier VERSION 0.1.0 LANGUAGES C CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(TARGET_ARCH x64)
|
# set (CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_REENTRANT")
|
# 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}")
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
add_executable(wcc
|
add_executable(wcc
|
||||||
src/wcc.cpp
|
src/wcc.cpp
|
||||||
@ -93,13 +99,9 @@ add_executable(test1
|
|||||||
# src/wxml/expr_lib/transit_table.cpp
|
# src/wxml/expr_lib/transit_table.cpp
|
||||||
# )
|
# )
|
||||||
|
|
||||||
include(CTest)
|
|
||||||
enable_testing()
|
|
||||||
add_test(transit_table_test
|
add_test(transit_table_test
|
||||||
$<TARGET_FILE:transit_table>
|
$<TARGET_FILE:transit_table>
|
||||||
)
|
)
|
||||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
||||||
add_subdirectory(./src/module)
|
|
60
CMakeLists1.txt
Normal file
60
CMakeLists1.txt
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
project(mylrc VERSION 0.1.0)
|
||||||
|
|
||||||
|
find_package(cJSON REQUIRED)
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
include_directories(./src/include)
|
||||||
|
add_executable(
|
||||||
|
mylrc
|
||||||
|
main.cpp
|
||||||
|
src/common.cpp
|
||||||
|
src/tmc.cpp
|
||||||
|
src/ae.cpp
|
||||||
|
src/ae/keyExpansion.cpp
|
||||||
|
src/ae/storeStateArray.cpp
|
||||||
|
src/ae/shiftRows.cpp
|
||||||
|
src/ae/loadStateArray.cpp
|
||||||
|
src/ae/mixColumns.cpp
|
||||||
|
src/ae/subBytes.cpp
|
||||||
|
src/ae/addRoundKey.cpp
|
||||||
|
src/ka.cpp
|
||||||
|
src/kq.cpp
|
||||||
|
src/print_hex.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
mylrc
|
||||||
|
PRIVATE cjson
|
||||||
|
OpenSSL::SSL
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(mylrc_test test/test.cpp)
|
||||||
|
add_executable(
|
||||||
|
storeStateArray_test
|
||||||
|
test/storeStateArray_test.cpp
|
||||||
|
src/common.cpp
|
||||||
|
src/ae/storeStateArray.cpp
|
||||||
|
)
|
||||||
|
add_executable(
|
||||||
|
printHex_test
|
||||||
|
test/printHex_test.cpp
|
||||||
|
src/print_hex.cpp
|
||||||
|
)
|
||||||
|
add_executable(
|
||||||
|
md5_test
|
||||||
|
test/md5_test.cpp
|
||||||
|
src/kq.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(md5_test OpenSSL::SSL)
|
||||||
|
# add_subdirectory(src)
|
||||||
|
add_test(
|
||||||
|
mylrc_test
|
||||||
|
$<TARGET_FILE:mylrc_test>#
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
|
include(CPack)
|
43
changelog.md
43
changelog.md
@ -1,45 +1,3 @@
|
|||||||
## 🌈 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
|
|
||||||
|
|
||||||
- 编译器:新增nwjs的模块编译器
|
|
||||||
|
|
||||||
## 🌈 v0.0.8 / 2024-06-30
|
|
||||||
|
|
||||||
🚀Features
|
|
||||||
|
|
||||||
- 版本:更新至 -> 3c3eb3ac0ec1f85e5a72a9e7608a770a wcc.exe, 472fef6c6e0f6b3217e3d3dfa85188b2 wcsc.exe
|
|
||||||
|
|
||||||
## 🌈 v0.0.5 / 2023-09-23
|
## 🌈 v0.0.5 / 2023-09-23
|
||||||
|
|
||||||
🐞 Bug Fixes
|
🐞 Bug Fixes
|
||||||
@ -54,7 +12,6 @@
|
|||||||
- `WXSS::CSSTreeLib::RewriteSelectorRule::MarkGood`: 比较字符串错误
|
- `WXSS::CSSTreeLib::RewriteSelectorRule::MarkGood`: 比较字符串错误
|
||||||
|
|
||||||
🚀Features
|
🚀Features
|
||||||
|
|
||||||
- feat: 添加新的`wcsc`的测试用例
|
- feat: 添加新的`wcsc`的测试用例
|
||||||
|
|
||||||
## 🌈 v0.0.3 / 2023-08-31
|
## 🌈 v0.0.3 / 2023-08-31
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
version: "3"
|
||||||
services:
|
services:
|
||||||
wx_compiler:
|
wx_compiler:
|
||||||
image: jiyecafe/wechat-devtools-build:v3
|
image: jiyecafe/wechat-devtools-build:v3
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
npm install -g pnpm@8
|
|
||||||
pnpm install
|
|
||||||
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC
|
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC
|
||||||
echo "----"
|
echo "----"
|
||||||
strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_
|
strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -ex
|
|
||||||
gcc --version
|
gcc --version
|
||||||
g++ --version
|
g++ --version
|
||||||
# cmake --verion
|
# cmake --verion
|
||||||
@ -10,9 +9,5 @@ cd build
|
|||||||
cmake ..
|
cmake ..
|
||||||
cmake --build . --config Release --target wcc
|
cmake --build . --config Release --target wcc
|
||||||
cmake --build . --config Release --target wcsc
|
cmake --build . --config Release --target wcsc
|
||||||
cmake --build . --config Release --target wcc_module
|
|
||||||
cmake --build . --config Release --target wcsc_module
|
|
||||||
readelf -s ./wcc | grep -oP "GLIBC.*" | sort | uniq
|
readelf -s ./wcc | grep -oP "GLIBC.*" | sort | uniq
|
||||||
readelf -s ./wcsc | grep -oP "GLIBC.*" | sort | uniq
|
readelf -s ./wcsc | grep -oP "GLIBC.*" | sort | uniq
|
||||||
readelf -s ./wcc_module.node | grep -oP "GLIBC.*" | sort | uniq
|
|
||||||
readelf -s ./wcsc_module.node | grep -oP "GLIBC.*" | sort | uniq
|
|
5
node/.babelrc.json
Normal file
5
node/.babelrc.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
"@babel/preset-env"
|
||||||
|
]
|
||||||
|
}
|
113
node/.github/workflows/release.yml
vendored
Normal file
113
node/.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||||
|
|
||||||
|
name: Build Packages
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
branches: [ master, dev, 45-snap-version]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
# # Allows you to run this workflow manually from the Actions tab
|
||||||
|
# workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build Base Packages
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [16.x]
|
||||||
|
ARCH: ['x86_64']
|
||||||
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
cd compiler && npm install
|
||||||
|
echo "$UID, $GID"
|
||||||
|
|
||||||
|
- name: Generate TAG
|
||||||
|
id: Tag
|
||||||
|
run: |
|
||||||
|
tag='continuous'
|
||||||
|
name='Continuous Build'
|
||||||
|
if [ 'true' == ${{ startsWith(github.ref, 'refs/tags/') }} ];then
|
||||||
|
tag='${{ github.ref_name }}'
|
||||||
|
name='${{ github.ref_name }}'
|
||||||
|
fi
|
||||||
|
echo "tag result: $tag - $name"
|
||||||
|
echo "::set-output name=tag::$tag"
|
||||||
|
echo "::set-output name=name::$name"
|
||||||
|
|
||||||
|
- name: Compress
|
||||||
|
run: |
|
||||||
|
ls -l
|
||||||
|
mkdir -p tmp/build
|
||||||
|
sudo rm -rf test
|
||||||
|
tar -zcf compiler.tar.gz *
|
||||||
|
mv compiler.tar.gz tmp/build
|
||||||
|
cd tmp/build
|
||||||
|
ls -l
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v2.3.1
|
||||||
|
with:
|
||||||
|
# Artifact name
|
||||||
|
name: wechat-devtools-${{ matrix.ARCH }}.build
|
||||||
|
path: tmp/build
|
||||||
|
|
||||||
|
upload:
|
||||||
|
name: Create release and upload artifacts
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
- name: Inspect directory after downloading artifacts
|
||||||
|
run: ls -alFR
|
||||||
|
|
||||||
|
- name: Generate TAG
|
||||||
|
id: Tag
|
||||||
|
run: |
|
||||||
|
tag='continuous'
|
||||||
|
name='Continuous Build'
|
||||||
|
if [ 'true' == ${{ startsWith(github.ref, 'refs/tags/') }} ];then
|
||||||
|
tag='${{ github.ref_name }}'
|
||||||
|
name='${{ github.ref_name }}'
|
||||||
|
fi
|
||||||
|
echo "tag result: $tag - $name"
|
||||||
|
echo "::set-output name=tag::$tag"
|
||||||
|
echo "::set-output name=name::$name"
|
||||||
|
|
||||||
|
- name: Create release and upload artifacts
|
||||||
|
if: startsWith(github.ref, 'refs/heads/')
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
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/*.tar.gz
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
# note you'll typically need to create a personal access token
|
||||||
|
# with permissions to create releases in the other repo
|
||||||
|
name: ${{ steps.tag.outputs.name }}
|
||||||
|
tag_name: ${{ steps.tag.outputs.tag }}
|
||||||
|
files: |
|
||||||
|
**build/*.tar.gz
|
12
node/.gitignore
vendored
Normal file
12
node/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
node_modules
|
||||||
|
test/wcc/**/*-output.json
|
||||||
|
test/wcsc/**/*-output.json
|
||||||
|
test/wcc/**/*-output.js
|
||||||
|
test/wcsc/**/*-output.js
|
||||||
|
test/wcc/**/*_output.json
|
||||||
|
test/wcsc/**/*_output.json
|
||||||
|
test/wcc/**/*_stderr.json
|
||||||
|
test/wcsc/**/*_stderr.json
|
||||||
|
test/wcc/**/linux_err.js
|
||||||
|
test/wcsc/**/linux_err.js
|
||||||
|
nwjs
|
3
node/.gitmodules
vendored
Normal file
3
node/.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "test/examples/miniprogram-demo"]
|
||||||
|
path = test/examples/miniprogram-demo
|
||||||
|
url = https://github.com/wechat-miniprogram/miniprogram-demo.git
|
6
node/.mocharc.js
Normal file
6
node/.mocharc.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
require: ["@babel/register"],
|
||||||
|
recursive: true,
|
||||||
|
spec: "test/**/*.test.js",
|
||||||
|
timeout: 20000,
|
||||||
|
}
|
85
node/generatemd5.js
Normal file
85
node/generatemd5.js
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const fs = require('fs')
|
||||||
|
const crypto = require('crypto')
|
||||||
|
const os = require('os')
|
||||||
|
const child_process = require('child_process')
|
||||||
|
let platform = process.argv[2]
|
||||||
|
|
||||||
|
let exeList = []
|
||||||
|
const macExeList = [
|
||||||
|
'wcc',
|
||||||
|
'wcsc',
|
||||||
|
'wcc.bin',
|
||||||
|
'wcsc.bin'
|
||||||
|
]
|
||||||
|
const winExeList = [
|
||||||
|
'wcc.exe',
|
||||||
|
'wcsc.exe'
|
||||||
|
]
|
||||||
|
if(platform === 'darwin') {
|
||||||
|
exeList = macExeList;
|
||||||
|
} else if(platform === 'win32') {
|
||||||
|
exeList= winExeList;
|
||||||
|
} else {
|
||||||
|
exeList = macExeList.concat(winExeList)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function generate(vendorPath) {
|
||||||
|
let dirList = fs.readdirSync(vendorPath)
|
||||||
|
|
||||||
|
let libs = {}
|
||||||
|
dirList.forEach((item) => {
|
||||||
|
if (item == 'dev' || item == 'quickstart' || item == 'beta') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let itemPath = path.join(vendorPath, item)
|
||||||
|
let stat = fs.statSync(itemPath)
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
let fileList = fs.readdirSync(itemPath)
|
||||||
|
|
||||||
|
let md5Info = {}
|
||||||
|
fileList.forEach((file) => {
|
||||||
|
if (fs.statSync(path.join(itemPath, file)).isFile()) {
|
||||||
|
let fileData = fs.readFileSync(path.join(itemPath, file))
|
||||||
|
let md5sum = crypto.createHash('md5')
|
||||||
|
md5sum.update(fileData)
|
||||||
|
md5Info[file] = md5sum.digest('hex')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
libs[item] = md5Info
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let oldConfig = JSON.parse(fs.readFileSync(path.join(vendorPath, 'config.json'), 'utf8'))
|
||||||
|
for (var key in oldConfig.libs) {
|
||||||
|
// libs[key] = Object.assign({}, oldConfig.libs[key], libs[key])
|
||||||
|
oldConfig.libs[key] = Object.assign({}, oldConfig.libs[key], libs[key])
|
||||||
|
}
|
||||||
|
|
||||||
|
// let newLib = {}
|
||||||
|
// let keys = Object.keys(libs)
|
||||||
|
// keys.sort()
|
||||||
|
// for (var i = 0; i < keys.length; i++) {
|
||||||
|
// let key = keys[i]
|
||||||
|
// newLib[key] = libs[key]
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 更新
|
||||||
|
oldConfig.configVersion = Date.now()
|
||||||
|
|
||||||
|
for (let key in exeList) {
|
||||||
|
let file = exeList[key]
|
||||||
|
let fileData = fs.readFileSync(path.join(vendorPath, file))
|
||||||
|
let md5sum = crypto.createHash('md5')
|
||||||
|
md5sum.update(fileData)
|
||||||
|
oldConfig[file] = md5sum.digest('hex')
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(path.join(vendorPath, 'config.json'), JSON.stringify(oldConfig, null, '\t'))
|
||||||
|
}
|
||||||
|
|
||||||
|
generate(__dirname)
|
675
node/nodejs/wcc
Executable file
675
node/nodejs/wcc
Executable file
File diff suppressed because one or more lines are too long
1
node/nodejs/wcc.bin
Symbolic link
1
node/nodejs/wcc.bin
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../node_modules/miniprogram-compiler/bin/linux/wcc
|
90
node/nodejs/wcsc
Executable file
90
node/nodejs/wcsc
Executable file
@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// wcsc.exe md5 = "d45f45f109afa238cd83c8ad1d0e2a5e"
|
||||||
|
const version = "20220908";
|
||||||
|
const { spawn } = require("child_process");
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const wcscPath = path.resolve(__dirname, "./wcsc.bin");
|
||||||
|
const DEBUG_OUTPUT = process.env["WX_DEBUG_COMPILER_OUTPUT"];
|
||||||
|
|
||||||
|
// 向错误输出流写入信息
|
||||||
|
process.stderr.write(`环境及执行信息:
|
||||||
|
编译器版本: ${version}
|
||||||
|
node版本: ${process.version}
|
||||||
|
参数: ${args.join(' ')}
|
||||||
|
|
||||||
|
具体报错:
|
||||||
|
`);
|
||||||
|
|
||||||
|
function encode1(s) {
|
||||||
|
return encodeURI(s).replace(
|
||||||
|
/%(u[0-9A-F]{4})|(%[0-9A-F]{2})/gm,
|
||||||
|
function ($0, $1, $2) {
|
||||||
|
return ($1 && "\\" + $1.toLowerCase()) || decodeURI($2);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (args.includes("-ll")) {
|
||||||
|
const wcsc = spawn(wcscPath, args, {
|
||||||
|
cwd: process.cwd(),
|
||||||
|
});
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wcsc.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wcsc.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
wcsc.on("close", (n) => {
|
||||||
|
if (0 === n) {
|
||||||
|
let str = Buffer.concat(spwanData).toString();
|
||||||
|
DEBUG_OUTPUT &&
|
||||||
|
fs.writeFileSync(`${DEBUG_OUTPUT}/linux_output.js`, str);
|
||||||
|
const resultSplit = str.split("=");
|
||||||
|
const tempObj = {};
|
||||||
|
for (
|
||||||
|
let i = 0, total = resultSplit.length;
|
||||||
|
i < total && resultSplit[i + 1];
|
||||||
|
i += 2
|
||||||
|
) {
|
||||||
|
// a=b ---> a: b
|
||||||
|
const key = resultSplit[i];
|
||||||
|
if (key === "version") continue;
|
||||||
|
tempObj[key] = resultSplit[i + 1].replace(
|
||||||
|
/[^\\]((\\x[\da-f]{2}|\\u[\da-f]{4})){1,}/g,
|
||||||
|
function ($0, $1, $2) {
|
||||||
|
return eval('"' + $0 + '"');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const resultObj = {
|
||||||
|
common: tempObj.comm,
|
||||||
|
pageWxss: {},
|
||||||
|
};
|
||||||
|
for (const key in tempObj) {
|
||||||
|
if (key.endsWith(".wxss")) {
|
||||||
|
resultObj.pageWxss[key] = tempObj[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let result = JSON.stringify(resultObj);
|
||||||
|
result = result.replace(/\\\\/g, "\\");
|
||||||
|
process.stdout.write(result);
|
||||||
|
} else {
|
||||||
|
const err = Buffer.concat(errData).toString();
|
||||||
|
DEBUG_OUTPUT &&
|
||||||
|
fs.writeFileSync(`${DEBUG_OUTPUT}/linux_err.js`, err);
|
||||||
|
process.stderr.write(err);
|
||||||
|
process.exitCode = n;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const wcsc = spawn(wcscPath, args, {
|
||||||
|
cwd: process.cwd(),
|
||||||
|
stdio: "inherit",
|
||||||
|
});
|
||||||
|
wcsc.on("close", (code) => {
|
||||||
|
process.exitCode = code;
|
||||||
|
});
|
||||||
|
}
|
1
node/nodejs/wcsc.bin
Symbolic link
1
node/nodejs/wcsc.bin
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../node_modules/miniprogram-compiler/bin/linux/wcsc
|
93
node/old/wcc_node_old/index.js
Normal file
93
node/old/wcc_node_old/index.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
const util = require('./util')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
let wcc
|
||||||
|
try {
|
||||||
|
wcc = require('./src/wcc')
|
||||||
|
} catch (err) {
|
||||||
|
console.error('wcc', err)
|
||||||
|
// wcc = require('./build/Release/wcc.node')
|
||||||
|
}
|
||||||
|
|
||||||
|
const fs = util.fs
|
||||||
|
|
||||||
|
exports = async function (options) {
|
||||||
|
if (!options) throw Error('options is required')
|
||||||
|
|
||||||
|
const lazyload = !!options.lazyloadConfig
|
||||||
|
|
||||||
|
options = Object.assign(
|
||||||
|
{
|
||||||
|
files: [], // FILES
|
||||||
|
contents: [],
|
||||||
|
replaceContent: {},
|
||||||
|
verbose: false,
|
||||||
|
debug: false, // -d
|
||||||
|
debugWXS: false, // -ds
|
||||||
|
showNewTree: false,
|
||||||
|
isPlugin: false,
|
||||||
|
addTestAttre: false,
|
||||||
|
independent: false,
|
||||||
|
genfuncname: '$gwx', // -gn
|
||||||
|
isCut: false, // --split
|
||||||
|
cwd: process.cwd,
|
||||||
|
debug: false,
|
||||||
|
lazyload, // -ll
|
||||||
|
lazyloadConfig: '',
|
||||||
|
},
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
let st = Date.now()
|
||||||
|
|
||||||
|
// 获取文件内容
|
||||||
|
if (!options.contents.length) {
|
||||||
|
const tasks = options.files.map((file) => {
|
||||||
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
|
return options.replaceContent[file]
|
||||||
|
}
|
||||||
|
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
||||||
|
})
|
||||||
|
options.contents = await Promise.all(tasks) || []
|
||||||
|
}
|
||||||
|
// console.warn('wcc get files', Date.now() - st, options.contents)
|
||||||
|
let result
|
||||||
|
try {
|
||||||
|
// console.warn('final options:', options);
|
||||||
|
result = wcc(options)
|
||||||
|
// console.warn('wcc result', result)
|
||||||
|
} catch(errmsg) {
|
||||||
|
reject(new Error(errmsg))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('wcc get compile', Date.now() - st)
|
||||||
|
if (options.output) {
|
||||||
|
const output = path.resolve(options.cwd, options.output)
|
||||||
|
const dir = path.dirname(output)
|
||||||
|
if (lazyload) {
|
||||||
|
// lazyload 为 true时,wcc 返回值是个对象, 需要序列化一下
|
||||||
|
result = JSON.stringify(result)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await fs.stat(dir)
|
||||||
|
} catch (e) {
|
||||||
|
await fs.mkdir(dir, {
|
||||||
|
recursive: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await fs.writeFile(output, result, 'utf8')
|
||||||
|
}
|
||||||
|
console.warn('wcc get output', Date.now() - st)
|
||||||
|
resolve(result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'version', {
|
||||||
|
get() {
|
||||||
|
return wcc.version
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = exports
|
25
node/old/wcc_node_old/package.json
Normal file
25
node/old/wcc_node_old/package.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "miniprogram-wcc",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "WCC node C++ addon",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"install": "node-gyp-build",
|
||||||
|
"rebuild": "node-gyp rebuild",
|
||||||
|
"build:dist": "node scripts/build",
|
||||||
|
"build": "node-gyp build",
|
||||||
|
"test": "node ./test/index",
|
||||||
|
"format": "prettier *.js test/*.js scripts/*.js --write"
|
||||||
|
},
|
||||||
|
"author": "coverguo",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"node-gyp-build": "^4.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eustia-module": "^1.21.2",
|
||||||
|
"licia": "^1.21.2",
|
||||||
|
"ncp": "^2.0.0",
|
||||||
|
"node-gyp": "^7.0.0"
|
||||||
|
}
|
||||||
|
}
|
30
node/old/wcc_node_old/src/index.js
Normal file
30
node/old/wcc_node_old/src/index.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const vm = require('vm')
|
||||||
|
const glob = require('glob')
|
||||||
|
const unescapeJs = require('unescape-js')
|
||||||
|
|
||||||
|
const wcc = require('./wcc')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
wxmlToJs(rootPath) {
|
||||||
|
// wcc 编译器需要完整的 wxml 文件列表
|
||||||
|
const files = glob.sync('**/*.wxml', {
|
||||||
|
cwd: rootPath,
|
||||||
|
nodir: true,
|
||||||
|
dot: true,
|
||||||
|
ignore: ['node_modules/**/*.wxml'],
|
||||||
|
})
|
||||||
|
const wxsFiles = glob.sync('**/*.wxs', {
|
||||||
|
cwd: rootPath,
|
||||||
|
nodir: true,
|
||||||
|
dot: true,
|
||||||
|
ignore: ['node_modules/**/*.wxs'],
|
||||||
|
})
|
||||||
|
const compileResult = wcc(rootPath, files.map(file => file.substring(0, file.length - 5)), wxsFiles)
|
||||||
|
|
||||||
|
return `
|
||||||
|
${compileResult};
|
||||||
|
return $gwx;
|
||||||
|
`
|
||||||
|
},
|
||||||
|
}
|
438
node/old/wcc_node_old/src/wcc.js
Normal file
438
node/old/wcc_node_old/src/wcc.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
91
node/old/wcsc_node_old/index.js
Normal file
91
node/old/wcsc_node_old/index.js
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
const util = require('./util')
|
||||||
|
const path = require('path')
|
||||||
|
const fs = util.fs
|
||||||
|
|
||||||
|
let wcsc
|
||||||
|
try {
|
||||||
|
wcsc = require('./src/wcsc')
|
||||||
|
} catch (err) {
|
||||||
|
console.error('wcsc', err)
|
||||||
|
// wcsc = require('./build/Release/wcsc.node')
|
||||||
|
}
|
||||||
|
|
||||||
|
function tranWcscResultToObject(resultStr) {
|
||||||
|
const resultArr = resultStr.split('=')
|
||||||
|
const result = {}
|
||||||
|
for (let i = 0, len = resultArr.length; i < len && resultArr[i + 1]; i += 2) {
|
||||||
|
result[resultArr[i]] = resultArr[i + 1]
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
exports = async function (options) {
|
||||||
|
if (!options) throw Error('options is required')
|
||||||
|
|
||||||
|
// avoid undefined or null
|
||||||
|
if (typeof options.subPackage !== 'string') {
|
||||||
|
delete options.subPackage
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof options.lazyload !== 'boolean') {
|
||||||
|
delete options.lazyload
|
||||||
|
}
|
||||||
|
|
||||||
|
options = Object.assign(
|
||||||
|
{
|
||||||
|
files: [],
|
||||||
|
contents: [],
|
||||||
|
pageCount: 0,
|
||||||
|
cwd: process.cwd,
|
||||||
|
replaceContent: {},
|
||||||
|
debug: false,
|
||||||
|
classPrefix: '',
|
||||||
|
lazyload: false,
|
||||||
|
},
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!options.contents.length) {
|
||||||
|
const tasks = options.files.map((file) => {
|
||||||
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
|
return options.replaceContent[file]
|
||||||
|
}
|
||||||
|
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
||||||
|
})
|
||||||
|
options.contents = await Promise.all(tasks) || []
|
||||||
|
}
|
||||||
|
|
||||||
|
let wcscResult
|
||||||
|
try {
|
||||||
|
console.warn('wcsc options', options)
|
||||||
|
wcscResult = await wcsc(options)
|
||||||
|
console.warn('wcsc ok')
|
||||||
|
} catch (errmsg) {
|
||||||
|
throw new Error(errmsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = options.lazyload ? wcscResult : tranWcscResultToObject(wcscResult)
|
||||||
|
|
||||||
|
if (options.output) {
|
||||||
|
const output = path.resolve(options.cwd, options.output)
|
||||||
|
const dir = path.dirname(output)
|
||||||
|
try {
|
||||||
|
await fs.stat(dir)
|
||||||
|
} catch (e) {
|
||||||
|
await fs.mkdir(dir, {
|
||||||
|
recursive: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await fs.writeFile(output, JSON.stringify(result, null, 2), 'utf8')
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'version', {
|
||||||
|
get() {
|
||||||
|
return wcsc.version
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = exports
|
30
node/old/wcsc_node_old/package.json
Normal file
30
node/old/wcsc_node_old/package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "miniprogram-wcsc",
|
||||||
|
"version": "0.0.2",
|
||||||
|
"description": "WXSS node C++ addon",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"install": "node-gyp-build",
|
||||||
|
"rebuild": "node-gyp rebuild",
|
||||||
|
"build:dist": "node scripts/build",
|
||||||
|
"build": "node-gyp build",
|
||||||
|
"test": "node ./test/index",
|
||||||
|
"format": "prettier *.js test/*.js scripts/*.js --write"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@git.code.oa.com:redhoodsu/wxss.git"
|
||||||
|
},
|
||||||
|
"author": "redhoodsu",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"node-gyp-build": "^4.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eustia-module": "^1.21.2",
|
||||||
|
"licia": "^1.21.2",
|
||||||
|
"ncp": "^2.0.0",
|
||||||
|
"node-gyp": "^7.0.0",
|
||||||
|
"prettier": "^2.3.1"
|
||||||
|
}
|
||||||
|
}
|
58
node/old/wcsc_node_old/src/index.js
Normal file
58
node/old/wcsc_node_old/src/index.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const vm = require('vm')
|
||||||
|
const glob = require('glob')
|
||||||
|
const unescapeJs = require('unescape-js')
|
||||||
|
|
||||||
|
const wcc = require('./wcc')
|
||||||
|
const wcsc = require('./wcsc')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
wxmlToJs(rootPath) {
|
||||||
|
// wcc 编译器需要完整的 wxml 文件列表
|
||||||
|
const files = glob.sync('**/*.wxml', {
|
||||||
|
cwd: rootPath,
|
||||||
|
nodir: true,
|
||||||
|
dot: true,
|
||||||
|
ignore: ['node_modules/**/*.wxml'],
|
||||||
|
})
|
||||||
|
const wxsFiles = glob.sync('**/*.wxs', {
|
||||||
|
cwd: rootPath,
|
||||||
|
nodir: true,
|
||||||
|
dot: true,
|
||||||
|
ignore: ['node_modules/**/*.wxs'],
|
||||||
|
})
|
||||||
|
const compileResult = wcc(rootPath, files.map(file => file.substr(0, file.length - 5)), wxsFiles)
|
||||||
|
|
||||||
|
return `
|
||||||
|
${compileResult};
|
||||||
|
return $gwx;
|
||||||
|
`
|
||||||
|
},
|
||||||
|
|
||||||
|
wxssToJs(rootPath) {
|
||||||
|
// wcsc 编译器需要完整的 wxss 文件列表
|
||||||
|
const files = glob.sync('**/*.wxss', {
|
||||||
|
cwd: rootPath,
|
||||||
|
nodir: true,
|
||||||
|
dot: true,
|
||||||
|
ignore: ['node_modules/**/*.wxss'],
|
||||||
|
})
|
||||||
|
const compileResult = wcsc(rootPath, files.map(file => file.substr(0, file.length - 5)))
|
||||||
|
|
||||||
|
// 拼装 wxss map 字符串
|
||||||
|
let wxssMap = ''
|
||||||
|
Object.keys(compileResult).forEach(key => {
|
||||||
|
if (path.extname(key) === '.wxss') {
|
||||||
|
wxssMap += `'${key}': ${unescapeJs(compileResult[key])},`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return `
|
||||||
|
${unescapeJs(compileResult.comm)};
|
||||||
|
var wxssMap = { ${wxssMap} };
|
||||||
|
return function (filePath) {
|
||||||
|
return wxssMap[filePath];
|
||||||
|
};
|
||||||
|
`
|
||||||
|
},
|
||||||
|
}
|
143
node/old/wcsc_node_old/src/wcsc.js
Normal file
143
node/old/wcsc_node_old/src/wcsc.js
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
const { spawn, spawnSync } = require('child_process')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const os = require('os')
|
||||||
|
const { throws } = require('assert')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 wxss 编译器路径
|
||||||
|
*/
|
||||||
|
let wxssParserPath = ''
|
||||||
|
function getWXSSParsePath() {
|
||||||
|
if (wxssParserPath) return wxssParserPath
|
||||||
|
|
||||||
|
const fileName = process.platform === 'darwin' ? '../bin/mac/wcsc' : process.platform === 'linux' ? '../bin/linux/wcsc' : '../bin/windows/wcsc.exe'
|
||||||
|
wxssParserPath = path.join(__dirname, fileName)
|
||||||
|
|
||||||
|
// 尝试修改权限
|
||||||
|
try {
|
||||||
|
fs.chmodSync(wxssParserPath, 0o777)
|
||||||
|
} catch (err) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxssParserPath
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取完整文件列表
|
||||||
|
*/
|
||||||
|
function getAllFiles(rootPath, files) {
|
||||||
|
const ret = []
|
||||||
|
let compWxssNum = 0
|
||||||
|
|
||||||
|
for (let i = 0, len = files.length; i < len; i++) {
|
||||||
|
const file = files[i]
|
||||||
|
|
||||||
|
let fileJson = null
|
||||||
|
try {
|
||||||
|
fileJson = require(path.join(rootPath, `${file}.json`))
|
||||||
|
} catch(err) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileJson) {
|
||||||
|
// 组件 wxss
|
||||||
|
compWxssNum++
|
||||||
|
ret.unshift(`${file}.wxss`)
|
||||||
|
} else {
|
||||||
|
ret.push(`${file}.wxss`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
list: ret,
|
||||||
|
compWxssNum,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编译 wxss 到 js
|
||||||
|
*/
|
||||||
|
async function wxssToJS(options) {
|
||||||
|
// 创建临时目录
|
||||||
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'wcsc_'))
|
||||||
|
// 判断是否replace,是写入replace,否则拷贝文件到临时目录
|
||||||
|
for(let file of options.files){
|
||||||
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
|
// 写入替换内容
|
||||||
|
fs.mkdirSync(path.dirname(path.resolve(tmp, file)), {recursive:true})
|
||||||
|
fs.writeFileSync(path.resolve(tmp, file), options.replaceContent[file])
|
||||||
|
}else{
|
||||||
|
// 复制原文件
|
||||||
|
fs.mkdirSync(path.dirname(path.resolve(tmp, file)), {recursive:true})
|
||||||
|
fs.copyFileSync(path.resolve(options.cwd, file), path.resolve(tmp, file))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 使用临时目录执行wcc
|
||||||
|
options.cwd = tmp
|
||||||
|
|
||||||
|
let rootPath = options.cwd, files=options.files
|
||||||
|
// files = getAllFiles(rootPath, files)
|
||||||
|
|
||||||
|
const args = ['-db', '-pc', String(options.pageCount)].concat(files)
|
||||||
|
options.subPackage && (args.push("--subpackage"), args.push(options.subPackage.replace(/\/$/, "")));
|
||||||
|
const wxssParserPath = getWXSSParsePath()
|
||||||
|
// console.warn('wcsc args: ', args)
|
||||||
|
// const wcsc = spawnSync(wxssParserPath, args, { cwd: rootPath })
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
|
||||||
|
const wcsc = spawn(wxssParserPath, args, {
|
||||||
|
cwd: rootPath,
|
||||||
|
});
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wcsc.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wcsc.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
wcsc.on("close", (code) => {
|
||||||
|
console.warn('close', new Date().getTime()/1000)
|
||||||
|
if (code === 0) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
if(options.lazyload){
|
||||||
|
result = result.split('=')
|
||||||
|
let funcList = {}
|
||||||
|
for (let i = 0, len = result.length; i < len && result[i + 1]; i += 2) {
|
||||||
|
funcList[result[i]] = result[i + 1]
|
||||||
|
.replace(
|
||||||
|
/[^\\]((\\x[\da-f]{2}|\\u[\da-f]{4})){1,}/gi,
|
||||||
|
function ($0, $1, $2) {
|
||||||
|
return eval('"' + $0 + '"');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) {
|
||||||
|
// console.log($0, $1)
|
||||||
|
const c = $0 === "\\n" ? "\n" : $0[1];
|
||||||
|
return c
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const t = funcList
|
||||||
|
funcList = {
|
||||||
|
common: t.comm,
|
||||||
|
pageWxss: {}
|
||||||
|
}
|
||||||
|
for(let key in t){
|
||||||
|
if(key.endsWith('.wxss')){
|
||||||
|
funcList.pageWxss[key] = t[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = funcList
|
||||||
|
}
|
||||||
|
resolve(result)
|
||||||
|
} else {
|
||||||
|
throw new Error(`编译 .wxss 文件错误(${wcsc.status}):${wcsc.stderr.toString()}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = wxssToJS
|
File diff suppressed because it is too large
Load Diff
5816
node/package-lock.json
generated
Normal file
5816
node/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
27
node/package.json
Normal file
27
node/package.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"forceVendor": true,
|
||||||
|
"name": "wx_compiler",
|
||||||
|
"main": "test/node-modules/index.html",
|
||||||
|
"productName": "wx_compiler",
|
||||||
|
"appname": "wx_compiler",
|
||||||
|
"version": "1.0",
|
||||||
|
"chromium-args": "--mixed-context",
|
||||||
|
"window": {
|
||||||
|
"frame": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha --reporter-option maxDiffSize=1e9",
|
||||||
|
"start": "nw ./test/node-modules"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"miniprogram-compiler": "^0.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.18.10",
|
||||||
|
"@babel/core": "^7.18.13",
|
||||||
|
"@babel/preset-env": "^7.18.10",
|
||||||
|
"@babel/register": "^7.18.9",
|
||||||
|
"mocha": "^10.0.0"
|
||||||
|
}
|
||||||
|
}
|
3
node/test/.gitignore
vendored
Normal file
3
node/test/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node-output.js
|
||||||
|
linux_output.js
|
||||||
|
node-output.json
|
8
node/test/demo.test.js
Normal file
8
node/test/demo.test.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const assert = require('assert');
|
||||||
|
describe('Demo', function() {
|
||||||
|
describe('#indexOf()', function() {
|
||||||
|
it('should return -1 when the value is not present', function() {
|
||||||
|
assert.equal(-1, [1,2,3].indexOf(4));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
18
node/test/node-modules/.vscode/launch.json
vendored
Normal file
18
node/test/node-modules/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "nwjs",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch NWjs",
|
||||||
|
"nwjsVersion": "any",
|
||||||
|
"webRoot": "${workspaceFolder}",
|
||||||
|
"reloadAfterAttached": true,
|
||||||
|
"userDataDir": "${workspaceFolder}/data",
|
||||||
|
"runtimeExecutable": "/mnt/disk2/wechat-web-devtools-linux/cache/wechat_devtools_1.05.2204180_x64/wechatdevtools.exe"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
13
node/test/node-modules/README.MD
Normal file
13
node/test/node-modules/README.MD
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# NODE模块的编译器测试目录
|
||||||
|
|
||||||
|
## 代码存放位置
|
||||||
|
|
||||||
|
wine版存放于 `node_modules/wcc_wine`
|
||||||
|
linux版存放于 `node_modules/wcc_linux`
|
||||||
|
|
||||||
|
|
||||||
|
## 生成代码
|
||||||
|
|
||||||
|
wine版按 `./vscode/launch.json` 配置执行nwjs生成 `wine.txt` 结尾的文件
|
||||||
|
linux版执行 `wcc_test.js` `wcsc_test.js` 生成 `linux.txt` 结尾的文件
|
||||||
|
|
30
node/test/node-modules/cases/wcc/lazyload/case1/config.json
Normal file
30
node/test/node-modules/cases/wcc/lazyload/case1/config.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"wxmlCompileConfig": "12>_<7800./component/navigation-bar/navigation-bar.wxml>_<78001>_<7800mp-navigation-bar>_<7800./components/navigation-bar/index.wxml>_<78001>_<7800mp-navigation-bar>_<7800./components/page-scroll/index.wxml>_<78001>_<7800mp-navigation-bar>_<7800./miniprogram_npm/miniprogram-barrage/index.wxml>_<78000>_<7800./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<78000>_<7800./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<78000>_<7800./miniprogram_npm/wxml-to-canvas/index.wxml>_<78000>_<7800./page/API/index.wxml>_<78002>_<7800set-tab-bar>_<7800mp-navigation-bar>_<7800./page/API/components/set-tab-bar/set-tab-bar.wxml>_<78001>_<7800mp-navigation-bar>_<7800./page/cloud/index.wxml>_<78001>_<7800mp-navigation-bar>_<7800./page/component/index.wxml>_<78001>_<7800mp-navigation-bar>_<7800./page/extend/index.wxml>_<78001>_<7800mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<7800",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": "./component/navigation-bar/navigation-bar>_<7800./components/navigation-bar/index>_<7800./components/page-scroll/index>_<7800./miniprogram_npm/miniprogram-barrage/index>_<7800./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<7800./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<7800./miniprogram_npm/wxml-to-canvas/index>_<7800./page/API/index>_<7800./page/API/components/set-tab-bar/set-tab-bar>_<7800./page/cloud/index>_<7800./page/component/index>_<7800./page/extend/index"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
30
node/test/node-modules/cases/wcc/lazyload/case2/config.json
Normal file
30
node/test/node-modules/cases/wcc/lazyload/case2/config.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"wxmlCompileConfig": "12>_<6365./component/navigation-bar/navigation-bar.wxml>_<63651>_<6365mp-navigation-bar>_<6365./components/navigation-bar/index.wxml>_<63651>_<6365mp-navigation-bar>_<6365./components/page-scroll/index.wxml>_<63651>_<6365mp-navigation-bar>_<6365./miniprogram_npm/miniprogram-barrage/index.wxml>_<63650>_<6365./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<63650>_<6365./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<63650>_<6365./miniprogram_npm/wxml-to-canvas/index.wxml>_<63650>_<6365./page/API/index.wxml>_<63652>_<6365set-tab-bar>_<6365mp-navigation-bar>_<6365./page/API/components/set-tab-bar/set-tab-bar.wxml>_<63651>_<6365mp-navigation-bar>_<6365./page/cloud/index.wxml>_<63651>_<6365mp-navigation-bar>_<6365./page/component/index.wxml>_<63651>_<6365mp-navigation-bar>_<6365./page/extend/index.wxml>_<63651>_<6365mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<6365",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": "./component/navigation-bar/navigation-bar>_<6365./components/navigation-bar/index>_<6365./components/page-scroll/index>_<6365./miniprogram_npm/miniprogram-barrage/index>_<6365./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<6365./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<6365./miniprogram_npm/wxml-to-canvas/index>_<6365./page/API/index>_<6365./page/API/components/set-tab-bar/set-tab-bar>_<6365./page/cloud/index>_<6365./page/component/index>_<6365./page/extend/index"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
30
node/test/node-modules/cases/wcc/lazyload/case3/config.json
Normal file
30
node/test/node-modules/cases/wcc/lazyload/case3/config.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"wxmlCompileConfig": "12>_<5318./component/navigation-bar/navigation-bar.wxml>_<53181>_<5318mp-navigation-bar>_<5318./components/navigation-bar/index.wxml>_<53181>_<5318mp-navigation-bar>_<5318./components/page-scroll/index.wxml>_<53181>_<5318mp-navigation-bar>_<5318./miniprogram_npm/miniprogram-barrage/index.wxml>_<53180>_<5318./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<53180>_<5318./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<53180>_<5318./miniprogram_npm/wxml-to-canvas/index.wxml>_<53180>_<5318./page/API/index.wxml>_<53182>_<5318set-tab-bar>_<5318mp-navigation-bar>_<5318./page/API/components/set-tab-bar/set-tab-bar.wxml>_<53181>_<5318mp-navigation-bar>_<5318./page/cloud/index.wxml>_<53181>_<5318mp-navigation-bar>_<5318./page/component/index.wxml>_<53181>_<5318mp-navigation-bar>_<5318./page/extend/index.wxml>_<53181>_<5318mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<5318",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": "./component/navigation-bar/navigation-bar>_<5318./components/navigation-bar/index>_<5318./components/page-scroll/index>_<5318./miniprogram_npm/miniprogram-barrage/index>_<5318./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<5318./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<5318./miniprogram_npm/wxml-to-canvas/index>_<5318./page/API/index>_<5318./page/API/components/set-tab-bar/set-tab-bar>_<5318./page/cloud/index>_<5318./page/component/index>_<5318./page/extend/index"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
31
node/test/node-modules/cases/wcc/lazyload/case4/config.json
Normal file
31
node/test/node-modules/cases/wcc/lazyload/case4/config.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"isCut": true,
|
||||||
|
"wxmlCompileConfig": "12>_<9307./component/navigation-bar/navigation-bar.wxml>_<93071>_<9307mp-navigation-bar>_<9307./components/navigation-bar/index.wxml>_<93071>_<9307mp-navigation-bar>_<9307./components/page-scroll/index.wxml>_<93071>_<9307mp-navigation-bar>_<9307./miniprogram_npm/miniprogram-barrage/index.wxml>_<93070>_<9307./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<93070>_<9307./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<93070>_<9307./miniprogram_npm/wxml-to-canvas/index.wxml>_<93070>_<9307./page/API/index.wxml>_<93072>_<9307set-tab-bar>_<9307mp-navigation-bar>_<9307./page/API/components/set-tab-bar/set-tab-bar.wxml>_<93071>_<9307mp-navigation-bar>_<9307./page/cloud/index.wxml>_<93071>_<9307mp-navigation-bar>_<9307./page/component/index.wxml>_<93071>_<9307mp-navigation-bar>_<9307./page/extend/index.wxml>_<93071>_<9307mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<9307",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": "./component/navigation-bar/navigation-bar>_<9307./components/navigation-bar/index>_<9307./components/page-scroll/index>_<9307./miniprogram_npm/miniprogram-barrage/index>_<9307./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<9307./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<9307./miniprogram_npm/wxml-to-canvas/index>_<9307./page/API/index>_<9307./page/API/components/set-tab-bar/set-tab-bar>_<9307./page/cloud/index>_<9307./page/component/index>_<9307./page/extend/index"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
31
node/test/node-modules/cases/wcc/lazyload/case5/config.json
Normal file
31
node/test/node-modules/cases/wcc/lazyload/case5/config.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"isCut": true,
|
||||||
|
"wxmlCompileConfig": "12>_<2998./component/navigation-bar/navigation-bar.wxml>_<29981>_<2998mp-navigation-bar>_<2998./components/navigation-bar/index.wxml>_<29981>_<2998mp-navigation-bar>_<2998./components/page-scroll/index.wxml>_<29981>_<2998mp-navigation-bar>_<2998./miniprogram_npm/miniprogram-barrage/index.wxml>_<29980>_<2998./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<29980>_<2998./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<29980>_<2998./miniprogram_npm/wxml-to-canvas/index.wxml>_<29980>_<2998./page/API/index.wxml>_<29982>_<2998set-tab-bar>_<2998mp-navigation-bar>_<2998./page/API/components/set-tab-bar/set-tab-bar.wxml>_<29981>_<2998mp-navigation-bar>_<2998./page/cloud/index.wxml>_<29981>_<2998mp-navigation-bar>_<2998./page/component/index.wxml>_<29981>_<2998mp-navigation-bar>_<2998./page/extend/index.wxml>_<29981>_<2998mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<2998",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": "./component/navigation-bar/navigation-bar>_<2998./components/navigation-bar/index>_<2998./components/page-scroll/index>_<2998./miniprogram_npm/miniprogram-barrage/index>_<2998./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<2998./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<2998./miniprogram_npm/wxml-to-canvas/index>_<2998./page/API/index>_<2998./page/API/components/set-tab-bar/set-tab-bar>_<2998./page/cloud/index>_<2998./page/component/index>_<2998./page/extend/index"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
31
node/test/node-modules/cases/wcc/lazyload/case6/config.json
Normal file
31
node/test/node-modules/cases/wcc/lazyload/case6/config.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"isCut": true,
|
||||||
|
"wxmlCompileConfig": "12>_<6832./component/navigation-bar/navigation-bar.wxml>_<68321>_<6832mp-navigation-bar>_<6832./components/navigation-bar/index.wxml>_<68321>_<6832mp-navigation-bar>_<6832./components/page-scroll/index.wxml>_<68321>_<6832mp-navigation-bar>_<6832./miniprogram_npm/miniprogram-barrage/index.wxml>_<68320>_<6832./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<68320>_<6832./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<68320>_<6832./miniprogram_npm/wxml-to-canvas/index.wxml>_<68320>_<6832./page/API/index.wxml>_<68322>_<6832set-tab-bar>_<6832mp-navigation-bar>_<6832./page/API/components/set-tab-bar/set-tab-bar.wxml>_<68321>_<6832mp-navigation-bar>_<6832./page/cloud/index.wxml>_<68321>_<6832mp-navigation-bar>_<6832./page/component/index.wxml>_<68321>_<6832mp-navigation-bar>_<6832./page/extend/index.wxml>_<68321>_<6832mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<6832",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": "./component/navigation-bar/navigation-bar>_<6832./components/navigation-bar/index>_<6832./components/page-scroll/index>_<6832./miniprogram_npm/miniprogram-barrage/index>_<6832./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<6832./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<6832./miniprogram_npm/wxml-to-canvas/index>_<6832./page/API/index>_<6832./page/API/components/set-tab-bar/set-tab-bar>_<6832./page/cloud/index>_<6832./page/component/index>_<6832./page/extend/index"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
14
node/test/node-modules/cases/wcc/raw/case1/config.json
Normal file
14
node/test/node-modules/cases/wcc/raw/case1/config.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"files": ["./miniprogram_npm/miniprogram-barrage/index.wxml", "./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml", "./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml", "./miniprogram_npm/wxml-to-canvas/index.wxml", "./page/API/index.wxml", "./page/API/components/set-tab-bar/set-tab-bar.wxml", "./page/cloud/index.wxml", "./page/common/foot.wxml", "./page/common/head.wxml", "./page/component/index.wxml", "./page/extend/index.wxml"],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"isCut": true,
|
||||||
|
"wxmlCompileConfig": "9>_<1027./miniprogram_npm/miniprogram-barrage/index.wxml>_<10270>_<1027./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<10270>_<1027./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<10270>_<1027./miniprogram_npm/wxml-to-canvas/index.wxml>_<10270>_<1027./page/API/index.wxml>_<10271>_<1027set-tab-bar>_<1027./page/API/components/set-tab-bar/set-tab-bar.wxml>_<10270>_<1027./page/cloud/index.wxml>_<10270>_<1027./page/component/index.wxml>_<10270>_<1027./page/extend/index.wxml>_<10270",
|
||||||
|
"wxmlCompileConfigSplit": ">_<1027",
|
||||||
|
"replaceContent": {
|
||||||
|
"./packageComponent/pages/camera-scan-code/camera-scan-code.wxml": "<import data-ib-structured-id=\"0\" src=\"../../../common/head.wxml\" />\n<import data-ib-structured-id=\"1\" src=\"../../../common/foot.wxml\" />\n\n<view class=\"container page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <template data-ib-structured-id=\"3\" is=\"head\" data=\"{{title: 'camera'}}\"/>\n\n <view class=\"page-body\" data-ib-structured-id=\"4\">\n <view class=\"page-body-wrapper\" data-ib-structured-id=\"5\">\n <camera\n mode=\"scanCode\"\n flash=\"off\"\n bindscancode=\"scanCode\"\n binderror=\"error\"\n data-ib-structured-id=\"6\">\n </camera>\n <view class=\"btn-area\" data-ib-structured-id=\"7\">\n <button type=\"primary\" bindtap=\"navigateBack\" data-ib-structured-id=\"8\">\n 返回正常模式\n </button>\n </view>\n <form data-ib-structured-id=\"9\">\n <view class=\"page-section\" data-ib-structured-id=\"10\">\n <view class=\"weui-cells weui-cells_after-title\" data-ib-structured-id=\"11\">\n <view class=\"weui-cell weui-cell_input\" data-ib-structured-id=\"12\">\n <view class=\"weui-cell__hd\" data-ib-structured-id=\"13\">\n <view class=\"weui-label\" data-ib-structured-id=\"14\">类型</view>\n </view>\n <view class=\"weui-cell__bd\" data-ib-structured-id=\"15\">\n {{ result.type }}\n </view>\n </view>\n <view class=\"weui-cell weui-cell_input\" data-ib-structured-id=\"16\">\n <view class=\"weui-cell__hd\" data-ib-structured-id=\"17\">\n <view class=\"weui-label\" data-ib-structured-id=\"18\">结果</view>\n </view>\n <view class=\"weui-cell__bd\" data-ib-structured-id=\"19\">\n {{ result.result }}\n </view>\n </view>\n </view>\n </view>\n </form>\n </view>\n </view>\n\n <template data-ib-structured-id=\"20\" is=\"foot\" />\n</view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": ""
|
||||||
|
}
|
1421
node/test/node-modules/cases/wcc/raw/case1/output/wine-output.js
Normal file
1421
node/test/node-modules/cases/wcc/raw/case1/output/wine-output.js
Normal file
File diff suppressed because it is too large
Load Diff
31
node/test/node-modules/cases/wcc/raw/case2/config.json
Normal file
31
node/test/node-modules/cases/wcc/raw/case2/config.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$gwx",
|
||||||
|
"isCut": true,
|
||||||
|
"wxmlCompileConfig": "12>_<5704./component/navigation-bar/navigation-bar.wxml>_<57041>_<5704mp-navigation-bar>_<5704./components/navigation-bar/index.wxml>_<57041>_<5704mp-navigation-bar>_<5704./components/page-scroll/index.wxml>_<57041>_<5704mp-navigation-bar>_<5704./miniprogram_npm/miniprogram-barrage/index.wxml>_<57040>_<5704./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<57040>_<5704./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<57040>_<5704./miniprogram_npm/wxml-to-canvas/index.wxml>_<57040>_<5704./page/API/index.wxml>_<57042>_<5704set-tab-bar>_<5704mp-navigation-bar>_<5704./page/API/components/set-tab-bar/set-tab-bar.wxml>_<57041>_<5704mp-navigation-bar>_<5704./page/cloud/index.wxml>_<57041>_<5704mp-navigation-bar>_<5704./page/component/index.wxml>_<57041>_<5704mp-navigation-bar>_<5704./page/extend/index.wxml>_<57041>_<5704mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<5704",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": ""
|
||||||
|
}
|
1705
node/test/node-modules/cases/wcc/raw/case2/output/wine-output.js
Normal file
1705
node/test/node-modules/cases/wcc/raw/case2/output/wine-output.js
Normal file
File diff suppressed because it is too large
Load Diff
38
node/test/node-modules/cases/wcc/raw/case3/config.json
Normal file
38
node/test/node-modules/cases/wcc/raw/case3/config.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"./packageSkyline/pages/flutter/half-page/index.wxml",
|
||||||
|
"./packageSkyline/pages/flutter/scale-page/index.wxml",
|
||||||
|
"./packageSkyline/pages/share-element/card/index.wxml",
|
||||||
|
"./packageSkyline/pages/share-element/list/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/animation/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/bottom-sheet/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/gesture/index.wxml"
|
||||||
|
],
|
||||||
|
"debugWXS": false,
|
||||||
|
"debug": true,
|
||||||
|
"genfuncname": "$7061636b616765536b796c696e652f",
|
||||||
|
"isCut": true,
|
||||||
|
"wxmlCompileConfig": "7>_<344./packageSkyline/pages/flutter/half-page/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar>_<344./packageSkyline/pages/flutter/scale-page/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar>_<344./packageSkyline/pages/share-element/card/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar>_<344./packageSkyline/pages/share-element/list/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar>_<344./packageSkyline/pages/worklet/animation/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar>_<344./packageSkyline/pages/worklet/bottom-sheet/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar>_<344./packageSkyline/pages/worklet/gesture/index.wxml>_<3443>_<344navigation-bar>_<344page-scroll>_<344mp-navigation-bar",
|
||||||
|
"wxmlCompileConfigSplit": ">_<344",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxml": "<mp-navigation-bar title=\"小程序官方组件展示\" back=\"{{false}}\" data-ib-structured-id=\"0\"></mp-navigation-bar>\n<scroll-view class=\"page-scroll-view\" scroll-y type=\"list\" data-ib-structured-id=\"1\">\n<view class=\"page\" data-weui-theme=\"{{theme}}\" data-ib-structured-id=\"2\">\n <view class=\"index\" data-ib-structured-id=\"3\">\n <view class=\"index-hd\" data-ib-structured-id=\"4\">\n <image class=\"index-logo\" src=\"resources/kind/logo.png\" data-ib-structured-id=\"5\"></image>\n <text class=\"index-desc\" data-ib-structured-id=\"6\">以下将展示小程序官方组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见 <text class=\"weui-agree__link\" bindtap=\"navToDoc\" data-ib-structured-id=\"7\">小程序开发文档</text>。</text>\n </view>\n <view class=\"index-bd\" data-ib-structured-id=\"8\">\n <view class=\"kind-list\" data-ib-structured-id=\"9\">\n <block wx:for-items=\"{{list}}\" wx:key=\"{{item.id}}\" data-ib-structured-id=\"10\">\n <view class=\"kind-list-item\" data-ib-structured-id=\"11\">\n <view id=\"{{item.id}}\" class=\"kind-list-item-hd {{item.open ? 'kind-list-item-hd-show' : ''}}\" bindtap=\"kindToggle\" data-ib-structured-id=\"12\">\n <view class=\"kind-list-text\" data-ib-structured-id=\"13\">{{item.name}}</view>\n <image wx:if=\"{{theme === 'dark'}}\" class=\"kind-list-img\" src=\"resources/kind/{{item.id}}_dark.png\" data-ib-structured-id=\"14\"></image>\n <image wx:else class=\"kind-list-img\" src=\"resources/kind/{{item.id}}.png\" data-ib-structured-id=\"15\"></image>\n </view>\n <view class=\"kind-list-item-bd {{item.open ? 'kind-list-item-bd-show' : ''}}\" data-ib-structured-id=\"16\">\n <view class=\"navigator-box {{item.open ? 'navigator-box-show' : ''}}\" data-ib-structured-id=\"17\">\n <block wx:for-items=\"{{item.pages}}\" wx:for-item=\"page\" wx:key=\"*item\" data-ib-structured-id=\"18\">\n <view wx:if=\"{{page.appid}}\" data-ib-structured-id=\"19\">\n <navigator target=\"miniProgram\" open-type=\"navigate\" app-id=\"{{page.appid}}\" path=\"\" extra-data=\"\" version=\"release\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"20\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"21\"></view>\n </view>\n <!-- custom-route,自定义路由暂时不能用 navigator -->\n <view wx:elif=\"{{page.key == 'custom-route'}}\" data-ib-structured-id=\"22\">\n <view bindtap=\"goToCustomRoute\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"23\">{{page.name}}</view>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"24\"></view>\n </view>\n <!-- skyline -->\n <view wx:elif=\"{{item.id == 'Skyline'}}\" data-ib-structured-id=\"25\">\n <navigator url=\"/packageSkyline/pages/{{page.url}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"26\">{{page.name}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"27\"></view>\n </view>\n <view wx:else data-ib-structured-id=\"28\">\n <navigator url=\"/packageComponent/pages/{{item.id}}/{{page}}/{{page}}\" class=\"navigator {{index + 1 === item.pages.length ? '' : 'navigator-bottom-line'}}\" data-ib-structured-id=\"29\">{{page}}</navigator>\n <view class=\"navigator-arrow\" data-ib-structured-id=\"30\"></view>\n </view>\n </block>\n </view>\n </view>\n </view>\n </block>\n </view>\n </view>\n </view>\n</view>\n</scroll-view>\n"
|
||||||
|
},
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyloadConfig": ""
|
||||||
|
}
|
1805
node/test/node-modules/cases/wcc/raw/case3/output/wine-output.js
Normal file
1805
node/test/node-modules/cases/wcc/raw/case3/output/wine-output.js
Normal file
File diff suppressed because it is too large
Load Diff
59
node/test/node-modules/cases/wcc/wcc.test.js
Normal file
59
node/test/node-modules/cases/wcc/wcc.test.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const ASTHelper = require("../../../runner/ast-helper");
|
||||||
|
const path = require("path");
|
||||||
|
const scan = require("../../utils/scan");
|
||||||
|
const fs = require("fs");
|
||||||
|
const COMPILER = require("../../../../wcc_node/lib/index");
|
||||||
|
|
||||||
|
assert.deepEqual2 = function () {
|
||||||
|
// console.log(arguments[0])
|
||||||
|
try {
|
||||||
|
assert.deepEqual.apply(this, arguments);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("\t默认deepEqual检测失败,尝试检测语法");
|
||||||
|
const dw = ASTHelper.code2ast(JSON.stringify(arguments[0]));
|
||||||
|
const dn = ASTHelper.code2ast(JSON.stringify(arguments[1]));
|
||||||
|
assert.deepEqual(dw, dn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("module wcc", function () {
|
||||||
|
const configPaths = scan.scanFiles(__dirname);
|
||||||
|
for (const configPath of configPaths) {
|
||||||
|
const casePath = path.dirname(configPath);
|
||||||
|
const caseName = path.basename(casePath);
|
||||||
|
const type = path.basename(path.dirname(casePath));
|
||||||
|
const config = JSON.parse(fs.readFileSync(configPath).toString());
|
||||||
|
describe(`${type}: node output should deep equal or equal with wine`, function () {
|
||||||
|
it(`${type} - ${caseName}`, async function () {
|
||||||
|
// const projectPath = path.join(casePath, config.cwd);
|
||||||
|
const storagePath = path.join(casePath, `output`);
|
||||||
|
config.cwd = path.join(configPath, config.cwd);
|
||||||
|
if(!fs.existsSync(config.cwd)){
|
||||||
|
throw new Error('cwd not exists!')
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
let nodeResult = await COMPILER.wcc(config);
|
||||||
|
|
||||||
|
if(!!config.lazyloadConfig){
|
||||||
|
const wineResult = JSON.parse(fs.readFileSync(
|
||||||
|
`${casePath}/output/wine-output.json`
|
||||||
|
).toString());
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.json`, JSON.stringify(nodeResult, null, 4));
|
||||||
|
assert.deepEqual2(wineResult, nodeResult);
|
||||||
|
}else{
|
||||||
|
nodeResult = nodeResult.substring(0, nodeResult.length - 1);
|
||||||
|
const wineResult = fs.readFileSync(
|
||||||
|
`${casePath}/output/wine-output.js`
|
||||||
|
).toString();
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.js`, nodeResult);
|
||||||
|
assert.equal(wineResult, nodeResult);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
28
node/test/node-modules/cases/wcsc/lazyload/case1/config.json
Normal file
28
node/test/node-modules/cases/wcsc/lazyload/case1/config.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"pageCount": 12,
|
||||||
|
"files": [
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxss",
|
||||||
|
"./components/navigation-bar/index.wxss",
|
||||||
|
"./components/page-scroll/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/common-skyline.wxss",
|
||||||
|
"./common/reset.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./page/common/index-skyline.wxss"
|
||||||
|
],
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyload": true,
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxss": "@import \"../../common/reset.wxss\";\r\n@import \"../common/index-skyline.wxss\";\r\n\r\n.weui-agree__link {\r\n display: inline;\r\n color: #576b95;\r\n}\r\n\r\n[data-weui-theme=dark] .weui-agree__link {\r\n color: #7d90a9;\r\n}\r\n"
|
||||||
|
},
|
||||||
|
"debug": true
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
28
node/test/node-modules/cases/wcsc/lazyload/case2/config.json
Normal file
28
node/test/node-modules/cases/wcsc/lazyload/case2/config.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"pageCount": 12,
|
||||||
|
"files": [
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxss",
|
||||||
|
"./components/navigation-bar/index.wxss",
|
||||||
|
"./components/page-scroll/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/common-skyline.wxss",
|
||||||
|
"./common/reset.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./page/common/index-skyline.wxss"
|
||||||
|
],
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"lazyload": true,
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxss": "@import \"../../common/reset.wxss\";\n@import \"../common/index-skyline.wxss\";\n\n.weui-agree__link {\n display: inline;\n color: #576b95;\n}\n\n[data-weui-theme=dark] .weui-agree__link {\n color: #7d90a9;\n}\n"
|
||||||
|
},
|
||||||
|
"debug": true
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
27
node/test/node-modules/cases/wcsc/raw/case1/config.json
Normal file
27
node/test/node-modules/cases/wcsc/raw/case1/config.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"pageCount": 12,
|
||||||
|
"files": [
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxss",
|
||||||
|
"./components/navigation-bar/index.wxss",
|
||||||
|
"./components/page-scroll/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/common-skyline.wxss",
|
||||||
|
"./common/reset.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./page/common/index-skyline.wxss"
|
||||||
|
],
|
||||||
|
"cwd": "../../../../../../examples/miniprogram-demo/miniprogram/",
|
||||||
|
"replaceContent": {
|
||||||
|
"./page/component/index.wxss": "@import \"../../common/reset.wxss\";\n@import \"../common/index-skyline.wxss\";\n\n.weui-agree__link {\n display: inline;\n color: #576b95;\n}\n\n[data-weui-theme=dark] .weui-agree__link {\n color: #7d90a9;\n}\n"
|
||||||
|
},
|
||||||
|
"debug": true
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
50
node/test/node-modules/cases/wcsc/wcsc.test.js
Normal file
50
node/test/node-modules/cases/wcsc/wcsc.test.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const ASTHelper = require("../../../runner/ast-helper");
|
||||||
|
const path = require("path");
|
||||||
|
const scan = require("../../utils/scan");
|
||||||
|
const fs = require("fs");
|
||||||
|
const COMPILER = require("../../../../wcc_node/lib/index");
|
||||||
|
|
||||||
|
assert.deepEqual2 = function () {
|
||||||
|
// console.log(arguments[0])
|
||||||
|
try {
|
||||||
|
assert.deepEqual.apply(this, arguments);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("\t默认deepEqual检测失败,尝试检测语法");
|
||||||
|
const dw = ASTHelper.code2ast(JSON.stringify(arguments[0]));
|
||||||
|
const dn = ASTHelper.code2ast(JSON.stringify(arguments[1]));
|
||||||
|
assert.deepEqual(dw, dn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("module wcsc", function () {
|
||||||
|
const configPaths = scan.scanFiles(__dirname);
|
||||||
|
for (const configPath of configPaths) {
|
||||||
|
const casePath = path.dirname(configPath);
|
||||||
|
const caseName = path.basename(casePath);
|
||||||
|
const type = path.basename(path.dirname(casePath));
|
||||||
|
const config = JSON.parse(fs.readFileSync(configPath).toString());
|
||||||
|
describe(`${type}: node output should deep equal or equal with wine`, function () {
|
||||||
|
it(`${type} - ${caseName}`, async function () {
|
||||||
|
// const projectPath = path.join(casePath, config.cwd);
|
||||||
|
const storagePath = path.join(casePath, `output`);
|
||||||
|
config.cwd = path.join(configPath, config.cwd);
|
||||||
|
if(!fs.existsSync(config.cwd)){
|
||||||
|
throw new Error('cwd not exists!')
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
let nodeResult = await COMPILER.wcsc(config);
|
||||||
|
|
||||||
|
const wineResult = JSON.parse(fs.readFileSync(
|
||||||
|
`${casePath}/output/wine-output.json`
|
||||||
|
).toString());
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.json`, JSON.stringify(nodeResult, null, 4));
|
||||||
|
assert.deepEqual2(wineResult, nodeResult);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
16
node/test/node-modules/index.html
Normal file
16
node/test/node-modules/index.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>node test</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button onclick="location.reload();">刷新</button>
|
||||||
|
<pre id="result">
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<!-- <script src="index.js" ></script> -->
|
||||||
|
<script>
|
||||||
|
require('./index')
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
41
node/test/node-modules/index.js
Normal file
41
node/test/node-modules/index.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
console.log("---index.js----")
|
||||||
|
|
||||||
|
const WCC = require('./wcc_test')
|
||||||
|
WCC.init();
|
||||||
|
const WCSC = require('./wcsc_test')
|
||||||
|
WCSC.init();
|
||||||
|
|
||||||
|
// const WCSC = require('./wcsc_test')
|
||||||
|
const scanFiles = function(dir) {
|
||||||
|
var results = []
|
||||||
|
var list = fs.readdirSync(dir)
|
||||||
|
list.forEach(function(file) {
|
||||||
|
// 排除static静态目录(可按你需求进行新增)
|
||||||
|
// if (file === 'config.json') {
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
|
const filePath = dir + '/' + file
|
||||||
|
var stat = fs.statSync(filePath)
|
||||||
|
if (stat && stat.isDirectory()) {
|
||||||
|
results = results.concat(scanFiles(filePath))
|
||||||
|
} else {
|
||||||
|
// 过滤后缀名(可按你需求进行新增)
|
||||||
|
// if (path.extname(filePath) === '.json') {
|
||||||
|
// results.push(path.resolve(__dirname, filePath))
|
||||||
|
// }
|
||||||
|
if (file === 'config.json') {
|
||||||
|
results.push(path.resolve(__dirname, filePath))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
const init = ()=>{
|
||||||
|
console.log(__dirname)
|
||||||
|
const files = scanFiles(__dirname)
|
||||||
|
console.log(files)
|
||||||
|
}
|
||||||
|
init()
|
30
node/test/node-modules/utils/scan.js
Normal file
30
node/test/node-modules/utils/scan.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
const scanFiles = function(dir) {
|
||||||
|
var results = []
|
||||||
|
var list = fs.readdirSync(dir)
|
||||||
|
list.forEach(function(file) {
|
||||||
|
// 排除static静态目录(可按你需求进行新增)
|
||||||
|
// if (file === 'config.json') {
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
|
const filePath = dir + '/' + file
|
||||||
|
var stat = fs.statSync(filePath)
|
||||||
|
if (stat && stat.isDirectory()) {
|
||||||
|
results = results.concat(scanFiles(filePath))
|
||||||
|
} else {
|
||||||
|
// 过滤后缀名(可按你需求进行新增)
|
||||||
|
// if (path.extname(filePath) === '.json') {
|
||||||
|
// results.push(path.resolve(__dirname, filePath))
|
||||||
|
// }
|
||||||
|
if (file === 'config.json') {
|
||||||
|
results.push(path.resolve(__dirname, filePath))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
scanFiles
|
||||||
|
}
|
1
node/test/node-modules/wcc_node
Symbolic link
1
node/test/node-modules/wcc_node
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../wcc_node
|
40
node/test/node-modules/wcc_test.js
Executable file
40
node/test/node-modules/wcc_test.js
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const scan = require('./utils/scan')
|
||||||
|
const MODE = typeof nw === 'object' ? 'wine' : 'linux'
|
||||||
|
const COMPILER = require(`./wcc_${MODE}/lib`)
|
||||||
|
|
||||||
|
|
||||||
|
const init = async()=>{
|
||||||
|
const configPaths = scan.scanFiles(`${__dirname}/cases/wcc`);
|
||||||
|
for (const configPath of configPaths) {
|
||||||
|
const casePath = path.dirname(configPath);
|
||||||
|
const caseName = path.basename(casePath);
|
||||||
|
const type = path.basename(path.dirname(casePath));
|
||||||
|
const config = JSON.parse(fs.readFileSync(configPath).toString());
|
||||||
|
// const projectPath = path.join(casePath, config.cwd);
|
||||||
|
const storagePath = path.join(casePath, `output`);
|
||||||
|
config.cwd = path.join(configPath, config.cwd);
|
||||||
|
if(!fs.existsSync(config.cwd)){
|
||||||
|
throw new Error('cwd not exists!')
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
let nodeResult = await COMPILER.wcc(config);
|
||||||
|
|
||||||
|
if(!!config.lazyloadConfig){
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.json`, JSON.stringify(nodeResult, null, 4));
|
||||||
|
}else{
|
||||||
|
// nodeResult = nodeResult.substring(0, nodeResult.length - 1);
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.js`, nodeResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
init
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
wcc: require('./wcc'),
|
wcc: require('./wcc'),
|
||||||
wcsc: require('./wcsc')
|
wcsc: require('./wcsc')
|
||||||
}
|
}
|
1134
node/test/node-modules/wcc_wine/lib/util.js
Normal file
1134
node/test/node-modules/wcc_wine/lib/util.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,94 +1,94 @@
|
|||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
let wcc
|
let wcc
|
||||||
|
|
||||||
function loadWccAddon() {
|
function loadWccAddon() {
|
||||||
if (wcc) return
|
if (wcc) return
|
||||||
wcc = require('../build/Release/wcc.node')
|
wcc = require('../build/Release/wcc.node')
|
||||||
}
|
}
|
||||||
|
|
||||||
const fs = util.fs
|
const fs = util.fs
|
||||||
|
|
||||||
exports = async function (options) {
|
exports = async function (options) {
|
||||||
|
|
||||||
loadWccAddon()
|
loadWccAddon()
|
||||||
|
|
||||||
if (!options) throw Error('options is required')
|
if (!options) throw Error('options is required')
|
||||||
|
|
||||||
const lazyload = !!options.lazyloadConfig
|
const lazyload = !!options.lazyloadConfig
|
||||||
|
|
||||||
options = Object.assign(
|
options = Object.assign(
|
||||||
{
|
{
|
||||||
files: [],
|
files: [],
|
||||||
contents: [],
|
contents: [],
|
||||||
replaceContent: {},
|
replaceContent: {},
|
||||||
verbose: false,
|
verbose: false,
|
||||||
debug: false,
|
debug: false,
|
||||||
debugWXS: false,
|
debugWXS: false,
|
||||||
showNewTree: false,
|
showNewTree: false,
|
||||||
isPlugin: false,
|
isPlugin: false,
|
||||||
addTestAttre: false,
|
addTestAttre: false,
|
||||||
independent: false,
|
independent: false,
|
||||||
genfuncname: '$gwx',
|
genfuncname: '$gwx',
|
||||||
isCut: false,
|
isCut: false,
|
||||||
cwd: process.cwd,
|
cwd: process.cwd,
|
||||||
debug: false,
|
debug: false,
|
||||||
lazyload,
|
lazyload,
|
||||||
lazyloadConfig: '',
|
lazyloadConfig: '',
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let st = Date.now()
|
let st = Date.now()
|
||||||
|
|
||||||
// 获取文件内容
|
// 获取文件内容
|
||||||
if (!options.contents.length) {
|
if (!options.contents.length) {
|
||||||
const tasks = options.files.map((file) => {
|
const tasks = options.files.map((file) => {
|
||||||
if (typeof options.replaceContent[file] === 'string') {
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
return options.replaceContent[file]
|
return options.replaceContent[file]
|
||||||
}
|
}
|
||||||
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
||||||
})
|
})
|
||||||
options.contents = await Promise.all(tasks) || []
|
options.contents = await Promise.all(tasks) || []
|
||||||
}
|
}
|
||||||
// console.log('wcc get files', Date.now() - st, options.contents)
|
// console.log('wcc get files', Date.now() - st, options.contents)
|
||||||
let result
|
let result
|
||||||
try {
|
try {
|
||||||
result = wcc(options)
|
result = wcc(options)
|
||||||
} catch(errmsg) {
|
} catch(errmsg) {
|
||||||
reject(new Error(errmsg))
|
reject(new Error(errmsg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('wcc get compile', Date.now() - st)
|
console.log('wcc get compile', Date.now() - st)
|
||||||
if (options.output) {
|
if (options.output) {
|
||||||
const output = path.resolve(options.cwd, options.output)
|
const output = path.resolve(options.cwd, options.output)
|
||||||
const dir = path.dirname(output)
|
const dir = path.dirname(output)
|
||||||
if (lazyload) {
|
if (lazyload) {
|
||||||
// lazyload 为 true时,wcc 返回值是个对象, 需要序列化一下
|
// lazyload 为 true时,wcc 返回值是个对象, 需要序列化一下
|
||||||
result = JSON.stringify(result)
|
result = JSON.stringify(result)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await fs.stat(dir)
|
await fs.stat(dir)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await fs.mkdir(dir, {
|
await fs.mkdir(dir, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
await fs.writeFile(output, result, 'utf8')
|
await fs.writeFile(output, result, 'utf8')
|
||||||
}
|
}
|
||||||
console.log('wcc get output', Date.now() - st)
|
console.log('wcc get output', Date.now() - st)
|
||||||
resolve(result)
|
resolve(result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(exports, 'version', {
|
Object.defineProperty(exports, 'version', {
|
||||||
get() {
|
get() {
|
||||||
loadWccAddon()
|
loadWccAddon()
|
||||||
return wcc.version
|
return wcc.version
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = exports
|
module.exports = exports
|
@ -1,92 +1,92 @@
|
|||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = util.fs
|
const fs = util.fs
|
||||||
|
|
||||||
let wcsc
|
let wcsc
|
||||||
|
|
||||||
function loadWcscAddon() {
|
function loadWcscAddon() {
|
||||||
if (wcsc) return
|
if (wcsc) return
|
||||||
wcsc = require('../build/Release/wcsc.node')
|
wcsc = require('../build/Release/wcsc.node')
|
||||||
}
|
}
|
||||||
|
|
||||||
function tranWcscResultToObject(resultStr) {
|
function tranWcscResultToObject(resultStr) {
|
||||||
const resultArr = resultStr.split('=')
|
const resultArr = resultStr.split('=')
|
||||||
const result = {}
|
const result = {}
|
||||||
for (let i = 0, len = resultArr.length; i < len && resultArr[i + 1]; i += 2) {
|
for (let i = 0, len = resultArr.length; i < len && resultArr[i + 1]; i += 2) {
|
||||||
result[resultArr[i]] = resultArr[i + 1]
|
result[resultArr[i]] = resultArr[i + 1]
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
exports = async function (options) {
|
exports = async function (options) {
|
||||||
|
|
||||||
loadWcscAddon()
|
loadWcscAddon()
|
||||||
|
|
||||||
if (!options) throw Error('options is required')
|
if (!options) throw Error('options is required')
|
||||||
|
|
||||||
// avoid undefined or null
|
// avoid undefined or null
|
||||||
if (typeof options.subPackage !== 'string') {
|
if (typeof options.subPackage !== 'string') {
|
||||||
delete options.subPackage
|
delete options.subPackage
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options.lazyload !== 'boolean') {
|
if (typeof options.lazyload !== 'boolean') {
|
||||||
delete options.lazyload
|
delete options.lazyload
|
||||||
}
|
}
|
||||||
|
|
||||||
options = Object.assign(
|
options = Object.assign(
|
||||||
{
|
{
|
||||||
files: [],
|
files: [],
|
||||||
contents: [],
|
contents: [],
|
||||||
pageCount: 0,
|
pageCount: 0,
|
||||||
cwd: process.cwd,
|
cwd: process.cwd,
|
||||||
replaceContent: {},
|
replaceContent: {},
|
||||||
debug: false,
|
debug: false,
|
||||||
classPrefix: '',
|
classPrefix: '',
|
||||||
lazyload: false,
|
lazyload: false,
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!options.contents.length) {
|
if (!options.contents.length) {
|
||||||
const tasks = options.files.map((file) => {
|
const tasks = options.files.map((file) => {
|
||||||
if (typeof options.replaceContent[file] === 'string') {
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
return options.replaceContent[file]
|
return options.replaceContent[file]
|
||||||
}
|
}
|
||||||
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
||||||
})
|
})
|
||||||
options.contents = await Promise.all(tasks) || []
|
options.contents = await Promise.all(tasks) || []
|
||||||
}
|
}
|
||||||
|
|
||||||
let wccResult
|
let wccResult
|
||||||
try {
|
try {
|
||||||
wccResult = wcsc(options)
|
wccResult = wcsc(options)
|
||||||
} catch (errmsg) {
|
} catch (errmsg) {
|
||||||
throw new Error(errmsg)
|
throw new Error(errmsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = options.lazyload ? wccResult : tranWcscResultToObject(wccResult)
|
const result = options.lazyload ? wccResult : tranWcscResultToObject(wccResult)
|
||||||
|
|
||||||
if (options.output) {
|
if (options.output) {
|
||||||
const output = path.resolve(options.cwd, options.output)
|
const output = path.resolve(options.cwd, options.output)
|
||||||
const dir = path.dirname(output)
|
const dir = path.dirname(output)
|
||||||
try {
|
try {
|
||||||
await fs.stat(dir)
|
await fs.stat(dir)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await fs.mkdir(dir, {
|
await fs.mkdir(dir, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
await fs.writeFile(output, JSON.stringify(result, null, 2), 'utf8')
|
await fs.writeFile(output, JSON.stringify(result, null, 2), 'utf8')
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(exports, 'version', {
|
Object.defineProperty(exports, 'version', {
|
||||||
get() {
|
get() {
|
||||||
loadWcscAddon()
|
loadWcscAddon()
|
||||||
return wcsc.version
|
return wcsc.version
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = exports
|
module.exports = exports
|
@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "miniprogram-wcc",
|
"name": "miniprogram-wcc",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "WCC node C++ addon",
|
"description": "WCC node C++ addon",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"rebuild": "node-gyp rebuild",
|
"rebuild": "node-gyp rebuild",
|
||||||
"build": "node-gyp build",
|
"build": "node-gyp build",
|
||||||
"test": "node ./test/wcc/index && node ./test/wcsc/index",
|
"test": "node ./test/wcc/index && node ./test/wcsc/index",
|
||||||
"format": "prettier *.js test/*.js scripts/*.js --write"
|
"format": "prettier *.js test/*.js scripts/*.js --write"
|
||||||
},
|
},
|
||||||
"author": "coverguo",
|
"author": "coverguo",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"licia": "^1.21.2",
|
"licia": "^1.21.2",
|
||||||
"node-gyp": "^7.0.0"
|
"node-gyp": "^7.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
38
node/test/node-modules/wcsc_test.js
Normal file
38
node/test/node-modules/wcsc_test.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const scan = require('./utils/scan')
|
||||||
|
const MODE = typeof nw === 'object' ? 'wine': 'linux'
|
||||||
|
const COMPILER = require(`./wcc_${MODE}/lib`)
|
||||||
|
|
||||||
|
const init = async ()=>{
|
||||||
|
const configPaths = scan.scanFiles(`${__dirname}/cases/wcsc`);
|
||||||
|
for (const configPath of configPaths) {
|
||||||
|
const casePath = path.dirname(configPath);
|
||||||
|
const caseName = path.basename(casePath);
|
||||||
|
const type = path.basename(path.dirname(casePath));
|
||||||
|
const config = JSON.parse(fs.readFileSync(configPath).toString());
|
||||||
|
// const projectPath = path.join(casePath, config.cwd);
|
||||||
|
const storagePath = path.join(casePath, `output`);
|
||||||
|
config.cwd = path.join(configPath, config.cwd);
|
||||||
|
if(!fs.existsSync(config.cwd)){
|
||||||
|
throw new Error('cwd not exists!')
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
let nodeResult = await COMPILER.wcsc(config);
|
||||||
|
|
||||||
|
if(config.lazyload){
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.json`, JSON.stringify(nodeResult, null, 4));
|
||||||
|
}else{
|
||||||
|
// nodeResult = nodeResult.substring(0, nodeResult.length - 1);
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.json`, JSON.stringify(nodeResult, null, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
init
|
||||||
|
}
|
21
node/test/runner/ast-helper.js
Normal file
21
node/test/runner/ast-helper.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
const parser = require("@babel/parser");
|
||||||
|
const tool = require('./tool')
|
||||||
|
|
||||||
|
|
||||||
|
const code2ast = (str)=>{
|
||||||
|
|
||||||
|
const nodeData = JSON.parse(str)
|
||||||
|
|
||||||
|
for(let key in nodeData.generateFunctionContent){
|
||||||
|
const nData = nodeData.generateFunctionContent[key]
|
||||||
|
|
||||||
|
let nodeAST = JSON.parse(JSON.stringify(parser.parse(nData)))
|
||||||
|
nodeAST = tool.removeVariables(nodeAST)
|
||||||
|
nodeData.generateFunctionContent[key] = nodeAST
|
||||||
|
}
|
||||||
|
return nodeData
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
code2ast
|
||||||
|
}
|
93
node/test/runner/node.js
Normal file
93
node/test/runner/node.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { spawn } = require("child_process");
|
||||||
|
|
||||||
|
const wcsc = (args, projectPath, outputPath = undefined) => {
|
||||||
|
if(!fs.existsSync(projectPath)){
|
||||||
|
throw new Error('projectPath not exists.')
|
||||||
|
}
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../nodejs/wcsc"),
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: outputPath,
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
outputPath && require('fs').writeFileSync(`${outputPath}/linux_err.js`, Buffer.concat(errData).toString())
|
||||||
|
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// result = JSON.parse(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
// process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const wcc = (args, projectPath, outputPath = undefined) => {
|
||||||
|
if(!fs.existsSync(projectPath)){
|
||||||
|
throw new Error('projectPath not exists.')
|
||||||
|
}
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../nodejs/wcc"),
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: outputPath,
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
// console.log("node n: ", n);
|
||||||
|
outputPath && require('fs').writeFileSync(`${outputPath}/linux_err.js`, Buffer.concat(errData).toString())
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// process.stdout.write(result);
|
||||||
|
// result = JSON.parse(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports= {
|
||||||
|
wcsc,
|
||||||
|
wcc
|
||||||
|
}
|
43
node/test/runner/tool.js
Normal file
43
node/test/runner/tool.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
const clearNum = ["start", "end", "line", "column", "index", 'parenStart']
|
||||||
|
|
||||||
|
const FUNC = {
|
||||||
|
'[object Object]': (ast)=>{
|
||||||
|
for(let key in ast){
|
||||||
|
const type = Object.prototype.toString.call(ast[key])
|
||||||
|
// console.log(key, ' - ', type)
|
||||||
|
if(clearNum.includes(key))ast[key] = 0
|
||||||
|
else if(FUNC[type]){
|
||||||
|
ast[key] = FUNC[type](ast[key])
|
||||||
|
}else{
|
||||||
|
// console.log('无法识别的类型:', type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ast.type && ast.type === 'Identifier'){
|
||||||
|
ast.name = ''
|
||||||
|
ast.loc.identifierName = ''
|
||||||
|
}
|
||||||
|
return ast
|
||||||
|
},
|
||||||
|
'[object Array]': (arr)=>{
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
const ele = arr[i];
|
||||||
|
const type = Object.prototype.toString.call(ele)
|
||||||
|
arr[i] = FUNC[type](ele)
|
||||||
|
}
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
const removeVariables = (ast)=>{
|
||||||
|
const type = Object.prototype.toString.call(ast)
|
||||||
|
// console.log(type)
|
||||||
|
if(FUNC[type]){
|
||||||
|
return FUNC[type](ast)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
removeVariables
|
||||||
|
}
|
85
node/test/runner/wine.js
Normal file
85
node/test/runner/wine.js
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { spawn } = require("child_process");
|
||||||
|
|
||||||
|
|
||||||
|
const wcsc = (args, projectPath) => {
|
||||||
|
if(!fs.existsSync(projectPath)){
|
||||||
|
throw new Error('projectPath not exists.')
|
||||||
|
}
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../wine/wcsc.exe"),
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
// console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// result = JSON.parse(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const wcc = (args, projectPath) => {
|
||||||
|
if(!fs.existsSync(projectPath)){
|
||||||
|
throw new Error('projectPath not exists.')
|
||||||
|
}
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../wine/wcc.exe"),
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
// console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// result = JSON.parse(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
wcsc,
|
||||||
|
wcc
|
||||||
|
}
|
0
node/test/wcc/lla/LOG.MD
Normal file
0
node/test/wcc/lla/LOG.MD
Normal file
217
node/test/wcc/lla/lla.js
Normal file
217
node/test/wcc/lla/lla.js
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { spawn, spawnSync } = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
|
const samples = []
|
||||||
|
const config3 = {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/",
|
||||||
|
args: [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<109",
|
||||||
|
"-xc",
|
||||||
|
"9>_<109./miniprogram_npm/miniprogram-barrage/index.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<1090>_<109./miniprogram_npm/wxml-to-canvas/index.wxml>_<1090>_<109./page/API/index.wxml>_<1091>_<109set-tab-bar>_<109./page/API/components/set-tab-bar/set-tab-bar.wxml>_<1090>_<109./page/cloud/index.wxml>_<1090>_<109./page/component/index.wxml>_<1090>_<109./page/extend/index.wxml>_<1090",
|
||||||
|
"-lla",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<109./miniprogram_npm/wxml-to-canvas/index>_<109./page/API/index>_<109./page/API/components/set-tab-bar/set-tab-bar>_<109./page/cloud/index>_<109./page/component/index>_<109./page/extend/index",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
samples.push([config3, 3])
|
||||||
|
const config4 = {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/",
|
||||||
|
args: [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<4362",
|
||||||
|
"-xc",
|
||||||
|
"34>_<4362./packageComponent/pages/canvas/canvas-2d/canvas-2d.wxml>_<43620>_<4362./packageComponent/pages/canvas/webgl/webgl.wxml>_<43620>_<4362./packageComponent/pages/content/icon/icon.wxml>_<43620>_<4362./packageComponent/pages/content/progress/progress.wxml>_<43620>_<4362./packageComponent/pages/content/rich-text/rich-text.wxml>_<43620>_<4362./packageComponent/pages/content/text/text.wxml>_<43620>_<4362./packageComponent/pages/form/button/button.wxml>_<43620>_<4362./packageComponent/pages/form/checkbox/checkbox.wxml>_<43620>_<4362./packageComponent/pages/form/editor/editor.wxml>_<43620>_<4362./packageComponent/pages/form/form/form.wxml>_<43620>_<4362./packageComponent/pages/form/input/input.wxml>_<43620>_<4362./packageComponent/pages/form/label/label.wxml>_<43620>_<4362./packageComponent/pages/form/picker/picker.wxml>_<43620>_<4362./packageComponent/pages/form/picker-view/picker-view.wxml>_<43620>_<4362./packageComponent/pages/form/radio/radio.wxml>_<43620>_<4362./packageComponent/pages/form/slider/slider.wxml>_<43620>_<4362./packageComponent/pages/form/switch/switch.wxml>_<43620>_<4362./packageComponent/pages/form/textarea/textarea.wxml>_<43620>_<4362./packageComponent/pages/map/map/map.wxml>_<43620>_<4362./packageComponent/pages/media/camera/camera.wxml>_<43620>_<4362./packageComponent/pages/media/image/image.wxml>_<43620>_<4362./packageComponent/pages/media/live-player/live-player.wxml>_<43620>_<4362./packageComponent/pages/media/live-pusher/live-pusher.wxml>_<43620>_<4362./packageComponent/pages/media/video/video.wxml>_<43620>_<4362./packageComponent/pages/nav/navigator/navigator.wxml>_<43620>_<4362./packageComponent/pages/obstacle-free/aria-component/aria-component.wxml>_<43620>_<4362./packageComponent/pages/open/ad/ad.wxml>_<43620>_<4362./packageComponent/pages/open/open-data/open-data.wxml>_<43620>_<4362./packageComponent/pages/open/web-view/web-view.wxml>_<43620>_<4362./packageComponent/pages/view/cover-view/cover-view.wxml>_<43620>_<4362./packageComponent/pages/view/movable-view/movable-view.wxml>_<43620>_<4362./packageComponent/pages/view/scroll-view/scroll-view.wxml>_<43620>_<4362./packageComponent/pages/view/swiper/swiper.wxml>_<43620>_<4362./packageComponent/pages/view/view/view.wxml>_<43620",
|
||||||
|
"-lla",
|
||||||
|
"./packageComponent/pages/canvas/canvas-2d/canvas-2d>_<4362./packageComponent/pages/canvas/webgl/webgl>_<4362./packageComponent/pages/content/icon/icon>_<4362./packageComponent/pages/content/progress/progress>_<4362./packageComponent/pages/content/rich-text/rich-text>_<4362./packageComponent/pages/content/text/text>_<4362./packageComponent/pages/form/button/button>_<4362./packageComponent/pages/form/checkbox/checkbox>_<4362./packageComponent/pages/form/editor/editor>_<4362./packageComponent/pages/form/form/form>_<4362./packageComponent/pages/form/input/input>_<4362./packageComponent/pages/form/label/label>_<4362./packageComponent/pages/form/picker/picker>_<4362./packageComponent/pages/form/picker-view/picker-view>_<4362./packageComponent/pages/form/radio/radio>_<4362./packageComponent/pages/form/slider/slider>_<4362./packageComponent/pages/form/switch/switch>_<4362./packageComponent/pages/form/textarea/textarea>_<4362./packageComponent/pages/map/map/map>_<4362./packageComponent/pages/media/camera/camera>_<4362./packageComponent/pages/media/image/image>_<4362./packageComponent/pages/media/live-player/live-player>_<4362./packageComponent/pages/media/live-pusher/live-pusher>_<4362./packageComponent/pages/media/video/video>_<4362./packageComponent/pages/nav/navigator/navigator>_<4362./packageComponent/pages/obstacle-free/aria-component/aria-component>_<4362./packageComponent/pages/open/ad/ad>_<4362./packageComponent/pages/open/open-data/open-data>_<4362./packageComponent/pages/open/web-view/web-view>_<4362./packageComponent/pages/view/cover-view/cover-view>_<4362./packageComponent/pages/view/movable-view/movable-view>_<4362./packageComponent/pages/view/scroll-view/scroll-view>_<4362./packageComponent/pages/view/swiper/swiper>_<4362./packageComponent/pages/view/view/view",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"./packageComponent/pages/canvas/canvas-2d/canvas-2d.wxml",
|
||||||
|
"./packageComponent/pages/canvas/webgl/webgl.wxml",
|
||||||
|
"./packageComponent/pages/content/icon/icon.wxml",
|
||||||
|
"./packageComponent/pages/content/progress/progress.wxml",
|
||||||
|
"./packageComponent/pages/content/rich-text/rich-text.wxml",
|
||||||
|
"./packageComponent/pages/content/text/text.wxml",
|
||||||
|
"./packageComponent/pages/form/button/button.wxml",
|
||||||
|
"./packageComponent/pages/form/checkbox/checkbox.wxml",
|
||||||
|
"./packageComponent/pages/form/editor/editor.wxml",
|
||||||
|
"./packageComponent/pages/form/form/form.wxml",
|
||||||
|
"./packageComponent/pages/form/input/input.wxml",
|
||||||
|
"./packageComponent/pages/form/label/label.wxml",
|
||||||
|
"./packageComponent/pages/form/picker/picker.wxml",
|
||||||
|
"./packageComponent/pages/form/picker-view/picker-view.wxml",
|
||||||
|
"./packageComponent/pages/form/radio/radio.wxml",
|
||||||
|
"./packageComponent/pages/form/slider/slider.wxml",
|
||||||
|
"./packageComponent/pages/form/switch/switch.wxml",
|
||||||
|
"./packageComponent/pages/form/textarea/textarea.wxml",
|
||||||
|
"./packageComponent/pages/map/map/map.wxml",
|
||||||
|
"./packageComponent/pages/media/camera/camera.wxml",
|
||||||
|
"./packageComponent/pages/media/image/image.wxml",
|
||||||
|
"./packageComponent/pages/media/live-player/live-player.wxml",
|
||||||
|
"./packageComponent/pages/media/live-pusher/live-pusher.wxml",
|
||||||
|
"./packageComponent/pages/media/video/video.wxml",
|
||||||
|
"./packageComponent/pages/nav/navigator/navigator.wxml",
|
||||||
|
"./packageComponent/pages/obstacle-free/aria-component/aria-component.wxml",
|
||||||
|
"./packageComponent/pages/open/ad/ad.wxml",
|
||||||
|
"./packageComponent/pages/open/open-data/open-data.wxml",
|
||||||
|
"./packageComponent/pages/open/web-view/web-view.wxml",
|
||||||
|
"./packageComponent/pages/view/cover-view/cover-view.wxml",
|
||||||
|
"./packageComponent/pages/view/movable-view/movable-view.wxml",
|
||||||
|
"./packageComponent/pages/view/scroll-view/scroll-view.wxml",
|
||||||
|
"./packageComponent/pages/view/swiper/swiper.wxml",
|
||||||
|
"./packageComponent/pages/view/view/view.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$7061636b616765436f6d706f6e656e742f",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
samples.push([config4, 4])
|
||||||
|
|
||||||
|
const config5 = {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/we1",
|
||||||
|
args: ["-d","--split",">_<2460","-xc","2>_<2460./pages/index/index.wxml>_<24600>_<2460./pages/logs/logs.wxml>_<24600","-lla","./pages/index/index>_<2460./pages/logs/logs","./pages/index/index.wxml","./pages/logs/logs.wxml","-gn","$gwx"]
|
||||||
|
}
|
||||||
|
samples.push([config5, 5])
|
||||||
|
|
||||||
|
const test_wine = (config, id) => {
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../../wine/wcc.exe"),
|
||||||
|
config.args,
|
||||||
|
{
|
||||||
|
cwd: config.projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, `./${id}/wine_output.json`),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
// process.stdout.write(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const test_node = (config, id) => {
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(path.resolve(__dirname, id))
|
||||||
|
} catch (ignore) {
|
||||||
|
|
||||||
|
}
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../../nodejs/wcc"),
|
||||||
|
config.args,
|
||||||
|
{
|
||||||
|
cwd: config.projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: path.resolve(__dirname, id),
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
console.log("node n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// require('fs').writeFileSync('/mnt/disk2/wechat-web-devtools-linux/tmp/llw2.json', result)
|
||||||
|
// process.stdout.write(result);
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// fs.writeFileSync(
|
||||||
|
// path.resolve(__dirname, "./3/node_output1.json"),
|
||||||
|
// JSON.stringify(result, null, 4)
|
||||||
|
// );
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, `./${id}/node_output.json`),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, `./${id}/node_stderr.json`),
|
||||||
|
Buffer.concat(errData)
|
||||||
|
);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const test = async (config) => {
|
||||||
|
try {
|
||||||
|
const node_result = await test_node(config[0], config[1] + '');
|
||||||
|
const wine_result = await test_wine(config[0], config[1] + '');
|
||||||
|
console.log("结果是否一致:", wine_result.trim() === node_result);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("错误:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(async ()=>{
|
||||||
|
for(let sample of samples){
|
||||||
|
await test(sample)
|
||||||
|
}
|
||||||
|
})()
|
455
node/test/wcc/lla/lla.test.js
Normal file
455
node/test/wcc/lla/lla.test.js
Normal file
File diff suppressed because one or more lines are too long
84
node/test/wcc/lla/raw-parse.js
Normal file
84
node/test/wcc/lla/raw-parse.js
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { spawn } = require("child_process");
|
||||||
|
|
||||||
|
const wxmlParser = (()=>{
|
||||||
|
const getFileArr = (code)=>{
|
||||||
|
// 获取x数组并解析
|
||||||
|
const indexArr = eval(code.match(/var x=(\[.*\]);/)[1]);
|
||||||
|
return indexArr;
|
||||||
|
}
|
||||||
|
const parseGZFuncMap = (code)=>{
|
||||||
|
const exp = `function gz\\$(.*?)\\(\\)\\{[\\s\\S]*?__WXML_GLOBAL__\\.ops_cached\\.\\$.*?\n}`;
|
||||||
|
const gzs = code.matchAll(new RegExp(exp, 'g'));
|
||||||
|
const gzFunc = {}
|
||||||
|
for (const gz of gzs) {
|
||||||
|
gzFunc[`gz$${gz[1]}`] = gz[0];
|
||||||
|
}
|
||||||
|
return gzFunc;
|
||||||
|
}
|
||||||
|
const parseDepsMap = (code, fileArr)=>{
|
||||||
|
|
||||||
|
// 获取所有依赖 _ai函数 被引入的文件, 文件
|
||||||
|
// _ai(i, depPath, e, mainPath, r, c)
|
||||||
|
const deps = code.matchAll(
|
||||||
|
/_ai\(.*?,x\[(\d+)\],.*?,x\[(\d+)\],\d+,\d+\)/g
|
||||||
|
);
|
||||||
|
// 处理依赖
|
||||||
|
const depsResult = {}
|
||||||
|
for (let dep of deps) {
|
||||||
|
const file = fileArr[dep[2]]
|
||||||
|
let depFile = fileArr[dep[1]]
|
||||||
|
depFile = `./${path.join(path.dirname(file), depFile)}`
|
||||||
|
if(depsResult[file]){
|
||||||
|
depsResult[file].push(depFile)
|
||||||
|
}else{
|
||||||
|
depsResult[file] = [depFile]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return depsResult
|
||||||
|
}
|
||||||
|
const parseDMEMap = (code)=>{
|
||||||
|
// ti: import依赖引入
|
||||||
|
const regExp = /d_\[x\[(\d+)\]\]={}[\s\S]*?e_\[x\[\d+\]\]={f:m\d+,j:\[.*?\],i:\[.*?\],ti:\[(.*?)\],ic:\[.*?\]}/g;
|
||||||
|
const ms = code.matchAll(regExp);
|
||||||
|
const mFunc = {}
|
||||||
|
for (const m of ms) {
|
||||||
|
mFunc[`x[${m[1]}]`] = m[0]
|
||||||
|
}
|
||||||
|
return mFunc
|
||||||
|
}
|
||||||
|
const parseNvRequireCode = (code)=>{
|
||||||
|
const ret = code.match(/(__WXML_GLOBAL__\.ops_set\.\$.*?=[\s\S]*)var x=\[/)
|
||||||
|
return ret[1]
|
||||||
|
}
|
||||||
|
const parseCSCode = (code)=>{
|
||||||
|
const cs = code.match(/var cs([\s\S]*?)function gz/);
|
||||||
|
return cs[1];
|
||||||
|
}
|
||||||
|
const parse = (data, code)=>{
|
||||||
|
data.nv_require = parseNvRequireCode(code)
|
||||||
|
data.cs = parseCSCode(code)
|
||||||
|
data.gz = parseGZFuncMap(code)
|
||||||
|
data.fileArr = getFileArr(code);
|
||||||
|
data.deps = parseDepsMap(code, data.fileArr)
|
||||||
|
data.dme = parseDMEMap(code)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
parse
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
|
const data = fs.readFileSync('/home/msojocs/Documents/Work/compiler/test/wcc/lla/miniprogram-demo/初次加载1/linux_output.js')
|
||||||
|
const code = data.toString();
|
||||||
|
|
||||||
|
const fileArr = wxmlParser.getFileArr(code)
|
||||||
|
// console.log(fileArr)
|
||||||
|
const gzFunc = wxmlParser.parseGZFuncMap(code)
|
||||||
|
// console.log(gzFunc)
|
||||||
|
const deps = wxmlParser.parseDepsMap(code, fileArr)
|
||||||
|
// console.log(deps)
|
||||||
|
const mFunc = wxmlParser.parseDMEMap(code)
|
||||||
|
const nvRequire = wxmlParser.parseNvRequireCode(code)
|
||||||
|
console.log(nvRequire)
|
96
node/test/wcc/lla/wcc.js
Normal file
96
node/test/wcc/lla/wcc.js
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { spawn } = require("child_process");
|
||||||
|
|
||||||
|
|
||||||
|
const wcc = (args, projectPath, outputPath = undefined) => {
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../../nodejs/wcc"),
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
cwd: projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: outputPath,
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
// console.log("node n: ", n);
|
||||||
|
outputPath && require('fs').writeFileSync(`${outputPath}/linux_err.js`, Buffer.concat(errData).toString())
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// process.stdout.write(result);
|
||||||
|
// result = JSON.parse(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(Buffer.concat(errData).toString());
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const test = async () => {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<1989",
|
||||||
|
"-xc",
|
||||||
|
"12>_<1989./component/navigation-bar/navigation-bar.wxml>_<19891>_<1989mp-navigation-bar>_<1989./components/navigation-bar/index.wxml>_<19891>_<1989mp-navigation-bar>_<1989./components/page-scroll/index.wxml>_<19891>_<1989mp-navigation-bar>_<1989./miniprogram_npm/miniprogram-barrage/index.wxml>_<19890>_<1989./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<19890>_<1989./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<19890>_<1989./miniprogram_npm/wxml-to-canvas/index.wxml>_<19890>_<1989./page/API/index.wxml>_<19892>_<1989set-tab-bar>_<1989mp-navigation-bar>_<1989./page/API/components/set-tab-bar/set-tab-bar.wxml>_<19891>_<1989mp-navigation-bar>_<1989./page/cloud/index.wxml>_<19891>_<1989mp-navigation-bar>_<1989./page/component/index.wxml>_<19891>_<1989mp-navigation-bar>_<1989./page/extend/index.wxml>_<19891>_<1989mp-navigation-bar",
|
||||||
|
"-lla",
|
||||||
|
"./component/navigation-bar/navigation-bar>_<1989./components/navigation-bar/index>_<1989./components/page-scroll/index>_<1989./miniprogram_npm/miniprogram-barrage/index>_<1989./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<1989./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<1989./miniprogram_npm/wxml-to-canvas/index>_<1989./page/API/index>_<1989./page/API/components/set-tab-bar/set-tab-bar>_<1989./page/cloud/index>_<1989./page/component/index>_<1989./page/extend/index",
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
];
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/tmp`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
const n = JSON.parse(await wcc(args, projectPath, storagePath));
|
||||||
|
// const w = JSON.parse(await wine.wcc(args, projectPath));
|
||||||
|
// fs.writeFileSync(
|
||||||
|
// `${storagePath}/wine-output.json`,
|
||||||
|
// JSON.stringify(w, null, 4)
|
||||||
|
// );
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/node-output.json`,
|
||||||
|
JSON.stringify(n, null, 4)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
test();
|
26
node/test/wcc/llw/LOG.MD
Normal file
26
node/test/wcc/llw/LOG.MD
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# unicode
|
||||||
|
| 符号 | unicode |
|
||||||
|
|-----|---------|
|
||||||
|
| tab | \u0009 |
|
||||||
|
| t | \u0074 |
|
||||||
|
|
||||||
|
# 起始
|
||||||
|
var cs = cs || [];\u000a$gwx_XC_1=function(_,_v,_n,_p,_s,_wp,_wl,$gwn,$gwl,$gwh,wh,$gstack,$gwrt,gra,grb,TestTest,wfor,_ca,_da,_r,_rz,_o,_oz,_1,_1z,_2,_2z,_m,_mz,nv_getDate,nv_getRegExp,nv_console,nv_parseInt,nv_parseFloat,nv_isNaN,nv_isFinite,nv_decodeURI,nv_decodeURIComponent,nv_encodeURI,nv_encodeURIComponent,$gdc,nv_JSON,_af,_gv,_ai,_grp,_gd,_gapi,$ixc,_ic,_w,_ev,_tsd){return function(path,global){\u000aif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\u000a}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\u000a
|
||||||
|
|
||||||
|
#
|
||||||
|
var e_={}\u000aif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\u000avar d_={}\u000aif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\u000avar f_={}\u000aif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\u000avar p_={}\u000avar cs = cs || [];\u000a__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\u000a__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\u000a__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\u000avar z=__WXML_GLOBAL__.ops_set.$gwx_XC_1 || [];\u000a
|
||||||
|
|
||||||
|
# 函数
|
||||||
|
function gz$gwx_XC_0_1(){\u000aif( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\u000a__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[];\u000a(function(z){var a=11;function Z(ops){z.push(ops)}\u000aZ([3,'container'])\u000aZ([3,'userinfo'])\u000aZ([[7],[3,'canIUseOpenData']])\u000aZ([3,'bindViewTap'])\u000aZ([3,'userinfo-avatar'])\u000aZ([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box'])\u000aZ([3,'userAvatarUrl'])\u000aZ([3,'userNickName'])\u000aZ([[2,'!'],[[7],[3,'hasUserInfo']]])\u000aZ([[7],[3,'canIUseGetUserProfile']])\u000aZ([3,'getUserProfile'])\u000aZ([3,' 获取头像昵称 '])\u000aZ([[7],[3,'canIUse']])\u000aZ([3,'getUserInfo'])\u000aZ(z[13])\u000aZ(z[11])\u000aZ([3,' 请使用1.4.4及以上版本基础库 '])\u000aZ(z[3])\u000aZ(z[4])\u000aZ([3,'cover'])\u000aZ([[6],[[7],[3,'userInfo']],[3,'avatarUrl']])\u000aZ([3,'userinfo-nickname'])\u000aZ([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]])\u000aZ([3,'usermotto'])\u000aZ([3,'user-motto'])\u000aZ([a,[[7],[3,'motto']]])\u000a})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\u000a}
|
||||||
|
|
||||||
|
#
|
||||||
|
\u000a__WXML_GLOBAL__.ops_set.$gwx_XC_0=z;\u000a__WXML_GLOBAL__.ops_init.$gwx_XC_0=true;\u000avar x=['./pages/index/index.wxml'];d_[x[0]]={}\u000a
|
||||||
|
|
||||||
|
|
||||||
|
var m0=function(e,s,r,gg){\u000avar z=gz$gwx_XC_0_1()\u000acs.push(\u0022./pages/index/index.wxml:view:2:2\u0022)\u000avar oB=_n('view')\u000a_rz(z,oB,'class',0,e,s,gg)\u000acs.push(\u0022./pages/index/index.wxml:view:3:4\u0022)\u000avar xC=_n('view')\u000a_rz(z,xC,'class',1,e,s,gg)\u000avar oD=_v()\u000a_(xC,oD)\u000aif(_oz(z,2,e,s,gg)){oD.wxVkey=1\u000acs.push(\u0022./pages/index/index.wxml:block:4:6\u0022)\u000acs.push(\u0022./pages/index/index.wxml:view:5:8\u0022)\u000avar fE=_mz(z,'view',['bindtap',3,'class',1,'style',2],[],e,s,gg)\u000acs.push(\u0022./pages/index/index.wxml:open-data:6:10\u0022)\u000avar cF=_n('open-data')\u000a_rz(z,cF,'type',6,e,s,gg)\u000acs.pop()\u000a_(fE,cF)\u000acs.pop()\u000a_(oD,fE)\u000acs.push(\u0022./pages/index/index.wxml:open-data:8:8\u0022)\u000avar hG=_n('open-data')\u000a_rz(z,hG,'type',7,e,s,gg)\u000acs.pop()\u000a_(oD,hG)\u000acs.pop()\u000a}\u000aelse if(_oz(z,8,e,s,gg)){oD.wxVkey=2\u000acs.push(\u0022./pages/index/index.wxml:block:10:6\u0022)\u000avar oH=_v()\u000a_(oD,oH)\u000aif(_oz(z,9,e,s,gg)){oH.wxVkey=1\u000acs.push(\u0022./pages/index/index.wxml:button:11:8\u0022)\u000acs.push(\u0022./pages/index/index.wxml:button:11:8\u0022)\u000avar cI=_n('button')\u000a_rz(z,cI,'bindtap',10,e,s,gg)\u000avar oJ=_oz(z,11,e,s,gg)\u000a_(cI,oJ)\u000acs.pop()\u000a_(oH,cI)\u000acs.pop()\u000a}\u000aelse if(_oz(z,12,e,s,gg)){oH.wxVkey=2\u000acs.push(\u0022./pages/index/index.wxml:button:12:8\u0022)\u000acs.push(\u0022./pages/index/index.wxml:button:12:8\u0022)\u000avar lK=_mz(z,'button',['bindgetuserinfo',13,'openType',1],[],e,s,gg)\u000avar aL=_oz(z,15,e,s,gg)\u000a_(lK,aL)\u000acs.pop()\u000a_(oH,lK)\u000acs.pop()\u000a}\u000aelse{oH.wxVkey=3\u000acs.push(\u0022./pages/index/index.wxml:view:13:8\u0022)\u000acs.push(\u0022./pages/index/index.wxml:view:13:8\u0022)\u000avar tM=_n('view')\u000avar eN=_oz(z,16,e,s,gg)\u000a_(tM,eN)\u000acs.pop()\u000a_(oH,tM)\u000acs.pop()\u000a}\u000aoH.wxXCkey=1\u000acs.pop()\u000a}\u000aelse{oD.wxVkey=3\u000acs.push(\u0022./pages/index/index.wxml:block:15:6\u0022)\u000acs.push(\u0022./pages/index/index.wxml:image:16:8\u0022)\u000avar bO=_mz(z,'image',['bindtap',17,'class',1,'mode',2,'src',3],[],e,s,gg)\u000acs.pop()\u000a_(oD,bO)\u000acs.push(\u0022./pages/index/index.wxml:text:17:8\u0022)\u000avar oP=_n('text')\u000a_rz(z,oP,'class',21,e,s,gg)\u000avar xQ=_oz(z,22,e,s,gg)\u000a_(oP,xQ)\u000acs.pop()\u000a_(oD,oP)\u000acs.pop()\u000a}\u000aoD.wxXCkey=1\u000acs.pop()\u000a_(oB,xC)\u000acs.push(\u0022./pages/index/index.wxml:view:20:4\u0022)\u000avar oR=_n('view')\u000a_rz(z,oR,'class',23,e,s,gg)\u000acs.push(\u0022./pages/index/index.wxml:text:21:6\u0022)\u000avar fS=_n('text')\u000a_rz(z,fS,'class',24,e,s,gg)\u000avar cT=_oz(z,25,e,s,gg)\u000a_(fS,cT)\u000acs.pop()\u000a_(oR,fS)\u000acs.pop()\u000a_(oB,oR)\u000acs.pop()\u000a_(r,oB)\u000areturn r\u000a}\u000ae_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\u000a
|
||||||
|
|
||||||
|
#
|
||||||
|
if(path&&e_[path]){\u000aouterGlobal.__wxml_comp_version__=0.02\u000areturn function(env,dd,global){$gwxc=0;var root={\u0022tag\u0022:\u0022wx-page\u0022};root.children=[]\u000a;g=\u0022$gwx_XC_0\u0022;var main=e_[path].f\u000acs=[]\u000aif (typeof global===\u0022undefined\u0022)global={};global.f=$gdc(f_[path],\u0022\u0022,1);\u000aif(typeof(outerGlobal.__webview_engine_version__)!='undefined'&&outerGlobal.__webview_engine_version__+1e-6>=0.02+1e-6&&outerGlobal.__mergeData__)\u000a{\u000aenv=outerGlobal.__mergeData__(env,dd);\u000a}\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000aif(typeof(outerGlobal.__webview_engine_version__)=='undefined'|| outerGlobal.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\u000a}catch(err){\u000aconsole.log(cs, env);\u000aconsole.log(err)\u000athrow err\u000a}\u000a;g=\u0022\u0022;\u000areturn root;\u000a}\u000a}\u000a}\u000a}
|
||||||
|
|
||||||
|
# end
|
||||||
|
(__g.a,__g.b,__g.c,__g.d,__g.e,__g.f,__g.g,__g.h,__g.i,__g.j,__g.k,__g.l,__g.m,__g.n,__g.o,__g.p,__g.q,__g.r,__g.s,__g.t,__g.u,__g.v,__g.w,__g.x,__g.y,__g.z,__g.A,__g.B,__g.C,__g.D,__g.E,__g.F,__g.G,__g.H,__g.I,__g.J,__g.K,__g.L,__g.M,__g.N,__g.O,__g.P,__g.Q,__g.R,__g.S,__g.T,__g.U,__g.V,__g.W,__g.X,__g.Y,__g.Z,__g.aa);if(__vd_version_info__.delayedGwx||false)$gwx_XC_0();
|
228
node/test/wcc/llw/llw.js
Normal file
228
node/test/wcc/llw/llw.js
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { spawn, spawnSync } = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
|
const samples = []
|
||||||
|
const sample2 = {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/qs-wxapp/",
|
||||||
|
args:[
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<9912",
|
||||||
|
"-cc",
|
||||||
|
"1>_<9912./pages/index/index.wxml>_<99120",
|
||||||
|
"-llw",
|
||||||
|
"./pages/index/index",
|
||||||
|
"./pages/index/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
]};
|
||||||
|
samples.push([sample2, 2])
|
||||||
|
const sample3 = {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/",
|
||||||
|
args:[
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<4685",
|
||||||
|
"-cc",
|
||||||
|
"9>_<4685./miniprogram_npm/miniprogram-barrage/index.wxml>_<46850>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<46850>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<46850>_<4685./miniprogram_npm/wxml-to-canvas/index.wxml>_<46850>_<4685./page/API/index.wxml>_<46851>_<4685set-tab-bar>_<4685./page/API/components/set-tab-bar/set-tab-bar.wxml>_<46850>_<4685./page/cloud/index.wxml>_<46850>_<4685./page/component/index.wxml>_<46850>_<4685./page/extend/index.wxml>_<46850",
|
||||||
|
"-llw",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<4685./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<4685./miniprogram_npm/wxml-to-canvas/index>_<4685./page/API/index>_<4685./page/API/components/set-tab-bar/set-tab-bar>_<4685./page/cloud/index>_<4685./page/component/index>_<4685./page/extend/index",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
]};
|
||||||
|
samples.push([sample3, 3])
|
||||||
|
const sample4= {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/miniprogram-demo/miniprogram/",
|
||||||
|
args: [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<3975",
|
||||||
|
"-cc",
|
||||||
|
"34>_<3975./packageComponent/pages/canvas/canvas-2d/canvas-2d.wxml>_<39750>_<3975./packageComponent/pages/canvas/webgl/webgl.wxml>_<39750>_<3975./packageComponent/pages/content/icon/icon.wxml>_<39750>_<3975./packageComponent/pages/content/progress/progress.wxml>_<39750>_<3975./packageComponent/pages/content/rich-text/rich-text.wxml>_<39750>_<3975./packageComponent/pages/content/text/text.wxml>_<39750>_<3975./packageComponent/pages/form/button/button.wxml>_<39750>_<3975./packageComponent/pages/form/checkbox/checkbox.wxml>_<39750>_<3975./packageComponent/pages/form/editor/editor.wxml>_<39750>_<3975./packageComponent/pages/form/form/form.wxml>_<39750>_<3975./packageComponent/pages/form/input/input.wxml>_<39750>_<3975./packageComponent/pages/form/label/label.wxml>_<39750>_<3975./packageComponent/pages/form/picker/picker.wxml>_<39750>_<3975./packageComponent/pages/form/picker-view/picker-view.wxml>_<39750>_<3975./packageComponent/pages/form/radio/radio.wxml>_<39750>_<3975./packageComponent/pages/form/slider/slider.wxml>_<39750>_<3975./packageComponent/pages/form/switch/switch.wxml>_<39750>_<3975./packageComponent/pages/form/textarea/textarea.wxml>_<39750>_<3975./packageComponent/pages/map/map/map.wxml>_<39750>_<3975./packageComponent/pages/media/camera/camera.wxml>_<39750>_<3975./packageComponent/pages/media/image/image.wxml>_<39750>_<3975./packageComponent/pages/media/live-player/live-player.wxml>_<39750>_<3975./packageComponent/pages/media/live-pusher/live-pusher.wxml>_<39750>_<3975./packageComponent/pages/media/video/video.wxml>_<39750>_<3975./packageComponent/pages/nav/navigator/navigator.wxml>_<39750>_<3975./packageComponent/pages/obstacle-free/aria-component/aria-component.wxml>_<39750>_<3975./packageComponent/pages/open/ad/ad.wxml>_<39750>_<3975./packageComponent/pages/open/open-data/open-data.wxml>_<39750>_<3975./packageComponent/pages/open/web-view/web-view.wxml>_<39750>_<3975./packageComponent/pages/view/cover-view/cover-view.wxml>_<39750>_<3975./packageComponent/pages/view/movable-view/movable-view.wxml>_<39750>_<3975./packageComponent/pages/view/scroll-view/scroll-view.wxml>_<39750>_<3975./packageComponent/pages/view/swiper/swiper.wxml>_<39750>_<3975./packageComponent/pages/view/view/view.wxml>_<39750",
|
||||||
|
"-llw",
|
||||||
|
"./packageComponent/pages/canvas/canvas-2d/canvas-2d>_<3975./packageComponent/pages/canvas/webgl/webgl>_<3975./packageComponent/pages/content/icon/icon>_<3975./packageComponent/pages/content/progress/progress>_<3975./packageComponent/pages/content/rich-text/rich-text>_<3975./packageComponent/pages/content/text/text>_<3975./packageComponent/pages/form/button/button>_<3975./packageComponent/pages/form/checkbox/checkbox>_<3975./packageComponent/pages/form/editor/editor>_<3975./packageComponent/pages/form/form/form>_<3975./packageComponent/pages/form/input/input>_<3975./packageComponent/pages/form/label/label>_<3975./packageComponent/pages/form/picker/picker>_<3975./packageComponent/pages/form/picker-view/picker-view>_<3975./packageComponent/pages/form/radio/radio>_<3975./packageComponent/pages/form/slider/slider>_<3975./packageComponent/pages/form/switch/switch>_<3975./packageComponent/pages/form/textarea/textarea>_<3975./packageComponent/pages/map/map/map>_<3975./packageComponent/pages/media/camera/camera>_<3975./packageComponent/pages/media/image/image>_<3975./packageComponent/pages/media/live-player/live-player>_<3975./packageComponent/pages/media/live-pusher/live-pusher>_<3975./packageComponent/pages/media/video/video>_<3975./packageComponent/pages/nav/navigator/navigator>_<3975./packageComponent/pages/obstacle-free/aria-component/aria-component>_<3975./packageComponent/pages/open/ad/ad>_<3975./packageComponent/pages/open/open-data/open-data>_<3975./packageComponent/pages/open/web-view/web-view>_<3975./packageComponent/pages/view/cover-view/cover-view>_<3975./packageComponent/pages/view/movable-view/movable-view>_<3975./packageComponent/pages/view/scroll-view/scroll-view>_<3975./packageComponent/pages/view/swiper/swiper>_<3975./packageComponent/pages/view/view/view",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"./packageComponent/pages/canvas/canvas-2d/canvas-2d.wxml",
|
||||||
|
"./packageComponent/pages/canvas/webgl/webgl.wxml",
|
||||||
|
"./packageComponent/pages/content/icon/icon.wxml",
|
||||||
|
"./packageComponent/pages/content/progress/progress.wxml",
|
||||||
|
"./packageComponent/pages/content/rich-text/rich-text.wxml",
|
||||||
|
"./packageComponent/pages/content/text/text.wxml",
|
||||||
|
"./packageComponent/pages/form/button/button.wxml",
|
||||||
|
"./packageComponent/pages/form/checkbox/checkbox.wxml",
|
||||||
|
"./packageComponent/pages/form/editor/editor.wxml",
|
||||||
|
"./packageComponent/pages/form/form/form.wxml",
|
||||||
|
"./packageComponent/pages/form/input/input.wxml",
|
||||||
|
"./packageComponent/pages/form/label/label.wxml",
|
||||||
|
"./packageComponent/pages/form/picker/picker.wxml",
|
||||||
|
"./packageComponent/pages/form/picker-view/picker-view.wxml",
|
||||||
|
"./packageComponent/pages/form/radio/radio.wxml",
|
||||||
|
"./packageComponent/pages/form/slider/slider.wxml",
|
||||||
|
"./packageComponent/pages/form/switch/switch.wxml",
|
||||||
|
"./packageComponent/pages/form/textarea/textarea.wxml",
|
||||||
|
"./packageComponent/pages/map/map/map.wxml",
|
||||||
|
"./packageComponent/pages/media/camera/camera.wxml",
|
||||||
|
"./packageComponent/pages/media/image/image.wxml",
|
||||||
|
"./packageComponent/pages/media/live-player/live-player.wxml",
|
||||||
|
"./packageComponent/pages/media/live-pusher/live-pusher.wxml",
|
||||||
|
"./packageComponent/pages/media/video/video.wxml",
|
||||||
|
"./packageComponent/pages/nav/navigator/navigator.wxml",
|
||||||
|
"./packageComponent/pages/obstacle-free/aria-component/aria-component.wxml",
|
||||||
|
"./packageComponent/pages/open/ad/ad.wxml",
|
||||||
|
"./packageComponent/pages/open/open-data/open-data.wxml",
|
||||||
|
"./packageComponent/pages/open/web-view/web-view.wxml",
|
||||||
|
"./packageComponent/pages/view/cover-view/cover-view.wxml",
|
||||||
|
"./packageComponent/pages/view/movable-view/movable-view.wxml",
|
||||||
|
"./packageComponent/pages/view/scroll-view/scroll-view.wxml",
|
||||||
|
"./packageComponent/pages/view/swiper/swiper.wxml",
|
||||||
|
"./packageComponent/pages/view/view/view.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$7061636b616765436f6d706f6e656e742f",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
samples.push([sample4, 4])
|
||||||
|
|
||||||
|
const sample5 = {
|
||||||
|
projectPath: "/mnt/disk1/WeChatProjects/we1",
|
||||||
|
args: ["-d","--split",">_<7271","-cc","2>_<7271./pages/index/index.wxml>_<72710>_<7271./pages/logs/logs.wxml>_<72710","-llw","./pages/index/index>_<7271./pages/logs/logs","./pages/index/index.wxml","./pages/logs/logs.wxml","-gn","$gwx"]
|
||||||
|
}
|
||||||
|
samples.push([sample5, 5])
|
||||||
|
|
||||||
|
const test_wine = (config, id) => {
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(path.resolve(__dirname, '' + id))
|
||||||
|
} catch (ignore) {
|
||||||
|
|
||||||
|
}
|
||||||
|
const wine = spawn(
|
||||||
|
path.resolve(__dirname, "../../../wine/wcc.exe"),
|
||||||
|
config.args,
|
||||||
|
{
|
||||||
|
cwd: config.projectPath,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wine.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wine.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wine.on("close", (n) => {
|
||||||
|
console.log("wine n: ", n);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, `./${id}/wine_output.json`),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
// process.stdout.write(result);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(
|
||||||
|
"wine error:",
|
||||||
|
Buffer.concat(errData).toString()
|
||||||
|
);
|
||||||
|
// process.stderr.write(Buffer.concat(spwanData).toString());
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const test_node = (config, id) => {
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(path.resolve(__dirname, '' + id))
|
||||||
|
} catch (ignore) {
|
||||||
|
|
||||||
|
}
|
||||||
|
const node_exec = spawn(
|
||||||
|
path.resolve(__dirname, "../../../nodejs/wcc"),
|
||||||
|
config.args,
|
||||||
|
{
|
||||||
|
cwd: config.projectPath,
|
||||||
|
env: {
|
||||||
|
WX_DEBUG_COMPILER_OUTPUT: path.resolve(__dirname, `./${id}`),
|
||||||
|
},
|
||||||
|
// stdio: 'inherit'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
node_exec.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
node_exec.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
// console.log(e.toString())
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
node_exec.on("close", (n) => {
|
||||||
|
console.log("node n: ", n);
|
||||||
|
process.stderr.write(`=========stderr输出=========\n${Buffer.concat(errData).toString()}\n\n=========stderr输出 END=========\n`);
|
||||||
|
if (0 === n) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
// require('fs').writeFileSync('/mnt/disk2/wechat-web-devtools-linux/tmp/llw2.json', result)
|
||||||
|
// process.stdout.write(result);
|
||||||
|
result = JSON.parse(result);
|
||||||
|
// delete result.generateFunctionContent["__COMMON__"];
|
||||||
|
result = JSON.stringify(result, null, 4)
|
||||||
|
// result = result.generateFunctionContent["__COMMON__"];
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(__dirname, `./${id}/node_output.json`),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
reject(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const test = async (config, id) => {
|
||||||
|
try {
|
||||||
|
const node_result = await test_node(config, id);
|
||||||
|
const wine_result = await test_wine(config, id);
|
||||||
|
console.log("结果是否一致:", wine_result.trim() === node_result);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("错误:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(async ()=>{
|
||||||
|
for (const sample of samples) {
|
||||||
|
// if(sample[1] === 2)
|
||||||
|
await test(sample[0], sample[1])
|
||||||
|
}
|
||||||
|
})()
|
410
node/test/wcc/llw/llw.test.js
Normal file
410
node/test/wcc/llw/llw.test.js
Normal file
File diff suppressed because one or more lines are too long
202
node/test/wcc/raw/raw.test.js
Normal file
202
node/test/wcc/raw/raw.test.js
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const node = require("../../runner/node");
|
||||||
|
const wine = require("../../runner/wine");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
describe("wcc - raw", function () {
|
||||||
|
describe("Raw: node output should equal with wine", function () {
|
||||||
|
// afterEach(function(){
|
||||||
|
// if(this.currentTest.state === 'failed'){
|
||||||
|
// console.error('failed', this.currentTest)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
it("初次加载1", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<8005",
|
||||||
|
"-xc",
|
||||||
|
"12>_<8005./component/navigation-bar/navigation-bar.wxml>_<80051>_<8005mp-navigation-bar>_<8005./components/navigation-bar/index.wxml>_<80051>_<8005mp-navigation-bar>_<8005./components/page-scroll/index.wxml>_<80051>_<8005mp-navigation-bar>_<8005./miniprogram_npm/miniprogram-barrage/index.wxml>_<80050>_<8005./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<80050>_<8005./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<80050>_<8005./miniprogram_npm/wxml-to-canvas/index.wxml>_<80050>_<8005./page/API/index.wxml>_<80052>_<8005set-tab-bar>_<8005mp-navigation-bar>_<8005./page/API/components/set-tab-bar/set-tab-bar.wxml>_<80051>_<8005mp-navigation-bar>_<8005./page/cloud/index.wxml>_<80051>_<8005mp-navigation-bar>_<8005./page/component/index.wxml>_<80051>_<8005mp-navigation-bar>_<8005./page/extend/index.wxml>_<80051>_<8005mp-navigation-bar",
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
];
|
||||||
|
const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n");
|
||||||
|
const n = await node.wcc(args, projectPath);
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/${this.test.title}`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.js`, n);
|
||||||
|
assert.equal(w, n);
|
||||||
|
});
|
||||||
|
it("初次加载2", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram/"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<4987",
|
||||||
|
"-xc",
|
||||||
|
"7>_<4987./packageSkyline/pages/flutter/half-page/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar>_<4987./packageSkyline/pages/flutter/scale-page/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar>_<4987./packageSkyline/pages/share-element/card/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar>_<4987./packageSkyline/pages/share-element/list/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar>_<4987./packageSkyline/pages/worklet/animation/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar>_<4987./packageSkyline/pages/worklet/bottom-sheet/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar>_<4987./packageSkyline/pages/worklet/gesture/index.wxml>_<49873>_<4987navigation-bar>_<4987page-scroll>_<4987mp-navigation-bar",
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"./packageSkyline/pages/flutter/half-page/index.wxml",
|
||||||
|
"./packageSkyline/pages/flutter/scale-page/index.wxml",
|
||||||
|
"./packageSkyline/pages/share-element/card/index.wxml",
|
||||||
|
"./packageSkyline/pages/share-element/list/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/animation/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/bottom-sheet/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/gesture/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$7061636b616765536b796c696e652f",
|
||||||
|
];
|
||||||
|
const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n");
|
||||||
|
const n = await node.wcc(args, projectPath);
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/${this.test.title}`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.js`, n);
|
||||||
|
assert.equal(w, n);
|
||||||
|
});
|
||||||
|
it("组件 - skyline - 自定义路由", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram/"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<9107",
|
||||||
|
"-xc",
|
||||||
|
"12>_<9107./component/navigation-bar/navigation-bar.wxml>_<91071>_<9107mp-navigation-bar>_<9107./components/navigation-bar/index.wxml>_<91071>_<9107mp-navigation-bar>_<9107./components/page-scroll/index.wxml>_<91071>_<9107mp-navigation-bar>_<9107./miniprogram_npm/miniprogram-barrage/index.wxml>_<91070>_<9107./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<91070>_<9107./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<91070>_<9107./miniprogram_npm/wxml-to-canvas/index.wxml>_<91070>_<9107./page/API/index.wxml>_<91072>_<9107set-tab-bar>_<9107mp-navigation-bar>_<9107./page/API/components/set-tab-bar/set-tab-bar.wxml>_<91071>_<9107mp-navigation-bar>_<9107./page/cloud/index.wxml>_<91071>_<9107mp-navigation-bar>_<9107./page/component/index.wxml>_<91071>_<9107mp-navigation-bar>_<9107./page/extend/index.wxml>_<91071>_<9107mp-navigation-bar",
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$gwx",
|
||||||
|
];
|
||||||
|
const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n");
|
||||||
|
const n = await node.wcc(args, projectPath);
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/${this.test.title}`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.js`, n);
|
||||||
|
assert.equal(w, n);
|
||||||
|
});
|
||||||
|
it("组件 - skyline - 自定义路由 -2", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram/"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-d",
|
||||||
|
"--split",
|
||||||
|
">_<657",
|
||||||
|
"-xc",
|
||||||
|
"7>_<657./packageSkyline/pages/flutter/half-page/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar>_<657./packageSkyline/pages/flutter/scale-page/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar>_<657./packageSkyline/pages/share-element/card/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar>_<657./packageSkyline/pages/share-element/list/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar>_<657./packageSkyline/pages/worklet/animation/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar>_<657./packageSkyline/pages/worklet/bottom-sheet/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar>_<657./packageSkyline/pages/worklet/gesture/index.wxml>_<6573>_<657navigation-bar>_<657page-scroll>_<657mp-navigation-bar",
|
||||||
|
"./common/foot.wxml",
|
||||||
|
"./common/head.wxml",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxml",
|
||||||
|
"./components/navigation-bar/index.wxml",
|
||||||
|
"./components/page-scroll/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxml",
|
||||||
|
"./page/API/index.wxml",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxml",
|
||||||
|
"./page/cloud/index.wxml",
|
||||||
|
"./page/common/foot.wxml",
|
||||||
|
"./page/common/head.wxml",
|
||||||
|
"./page/component/index.wxml",
|
||||||
|
"./page/extend/index.wxml",
|
||||||
|
"./packageSkyline/pages/flutter/half-page/index.wxml",
|
||||||
|
"./packageSkyline/pages/flutter/scale-page/index.wxml",
|
||||||
|
"./packageSkyline/pages/share-element/card/index.wxml",
|
||||||
|
"./packageSkyline/pages/share-element/list/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/animation/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/bottom-sheet/index.wxml",
|
||||||
|
"./packageSkyline/pages/worklet/gesture/index.wxml",
|
||||||
|
"-gn",
|
||||||
|
"$7061636b616765536b796c696e652f",
|
||||||
|
];
|
||||||
|
const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n");
|
||||||
|
const n = await node.wcc(args, projectPath);
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/${this.test.title}`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
|
||||||
|
fs.writeFileSync(`${storagePath}/node-output.js`, n);
|
||||||
|
assert.equal(w, n);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
81
node/test/wcsc/ll/ll.test.js
Normal file
81
node/test/wcsc/ll/ll.test.js
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const node = require("../../runner/node");
|
||||||
|
const wine = require("../../runner/wine");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
describe("wcsc", function () {
|
||||||
|
describe("LazyLoad: node output should deep equal with wine", function () {
|
||||||
|
// afterEach(function(){
|
||||||
|
// if(this.currentTest.state === 'failed'){
|
||||||
|
// console.error('failed', this.currentTest)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
it("主界面", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-db",
|
||||||
|
"-pc",
|
||||||
|
"12",
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxss",
|
||||||
|
"./components/navigation-bar/index.wxss",
|
||||||
|
"./components/page-scroll/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/common-skyline.wxss",
|
||||||
|
"./common/reset.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./page/common/index-skyline.wxss",
|
||||||
|
"-ll",
|
||||||
|
];
|
||||||
|
const w = JSON.parse(await wine.wcsc(args, projectPath));
|
||||||
|
const n = JSON.parse(await node.wcsc(args, projectPath));
|
||||||
|
const storagePath = path.resolve(__dirname, `miniprogram-demo/${this.test.title}`)
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, {recursive: true});
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/wine-output.json`,
|
||||||
|
JSON.stringify(w, null, 4)
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/node-output.json`,
|
||||||
|
JSON.stringify(n, null, 4)
|
||||||
|
);
|
||||||
|
assert.deepEqual(w, n);
|
||||||
|
});
|
||||||
|
it("接口-设置界面标题", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram/"
|
||||||
|
);
|
||||||
|
const args = ["-db","-pc","74","./packageAPI/pages/api/login/login.wxss","./packageAPI/pages/api/get-user-info/get-user-info.wxss","./packageAPI/pages/api/request-payment/request-payment.wxss","./packageAPI/pages/api/jump/jump.wxss","./packageAPI/pages/api/share/share.wxss","./packageAPI/pages/api/share-button/share-button.wxss","./packageAPI/pages/api/custom-message/custom-message.wxss","./packageAPI/pages/api/subscribe-message/subscribe-message.wxss","./packageAPI/pages/api/choose-address/choose-address.wxss","./packageAPI/pages/api/choose-invoice-title/choose-invoice-title.wxss","./packageAPI/pages/api/soter-authentication/soter-authentication.wxss","./packageAPI/pages/api/setting/setting.wxss","./packageAPI/pages/ar/visionkit-basic/visionkit-basic.wxss","./packageAPI/pages/ar/plane-ar/plane-ar.wxss","./packageAPI/pages/ar/2dmarker-ar/2dmarker-ar.wxss","./packageAPI/pages/ar/osd-ar/osd-ar.wxss","./packageAPI/pages/page/set-navigation-bar-title/set-navigation-bar-title.wxss","./packageAPI/pages/page/navigation-bar-loading/navigation-bar-loading.wxss","./packageAPI/pages/page/navigator/navigator.wxss","./packageAPI/pages/page/pull-down-refresh/pull-down-refresh.wxss","./packageAPI/pages/page/animation/animation.wxss","./packageAPI/pages/page/action-sheet/action-sheet.wxss","./packageAPI/pages/page/modal/modal.wxss","./packageAPI/pages/page/toast/toast.wxss","./packageAPI/pages/page/canvas/canvas.wxss","./packageAPI/pages/page/get-wxml-node-info/get-wxml-node-info.wxss","./packageAPI/pages/page/page-scroll/page-scroll.wxss","./packageAPI/pages/page/intersection-observer/intersection-observer.wxss","./packageAPI/pages/device/clipboard-data/clipboard-data.wxss","./packageAPI/pages/device/bluetooth/bluetooth.wxss","./packageAPI/pages/device/bluetooth/slave/slave.wxss","./packageAPI/pages/device/screen-brightness/screen-brightness.wxss","./packageAPI/pages/device/vibrate/vibrate.wxss","./packageAPI/pages/device/add-contact/add-contact.wxss","./packageAPI/pages/device/wifi/wifi.wxss","./packageAPI/pages/device/get-network-type/get-network-type.wxss","./packageAPI/pages/device/on-network-status-change/on-network-status-change.wxss","./packageAPI/pages/device/get-system-info/get-system-info.wxss","./packageAPI/pages/device/on-compass-change/on-compass-change.wxss","./packageAPI/pages/device/make-phone-call/make-phone-call.wxss","./packageAPI/pages/device/scan-code/scan-code.wxss","./packageAPI/pages/device/on-accelerometer-change/on-accelerometer-change.wxss","./packageAPI/pages/device/capture-screen/capture-screen.wxss","./packageAPI/pages/device/ibeacon/ibeacon.wxss","./packageAPI/pages/device/get-battery-info/get-battery-info.wxss","./packageAPI/pages/media/image/image.wxss","./packageAPI/pages/media/voice/voice.wxss","./packageAPI/pages/media/file/file.wxss","./packageAPI/pages/media/load-font-face/load-font-face.wxss","./packageAPI/pages/media/background-audio/background-audio.wxss","./packageAPI/pages/media/video/video.wxss","./packageAPI/pages/media/audio/audio.wxss","./packageAPI/pages/media/media-container/media-container.wxss","./packageAPI/pages/location/get-location/get-location.wxss","./packageAPI/pages/location/open-location/open-location.wxss","./packageAPI/pages/location/choose-location/choose-location.wxss","./packageAPI/pages/network/request/request.wxss","./packageAPI/pages/network/web-socket/web-socket.wxss","./packageAPI/pages/network/upload-file/upload-file.wxss","./packageAPI/pages/network/download-file/download-file.wxss","./packageAPI/pages/network/mdns/mdns.wxss","./packageAPI/pages/network/udp-socket/udp-socket.wxss","./packageAPI/pages/storage/storage/storage.wxss","./packageAPI/pages/storage/get-background-fetch-data/get-background-fetch-data.wxss","./packageAPI/pages/storage/get-background-prefetch-data/get-background-prefetch-data.wxss","./packageAPI/pages/performance/get-performance/get-performance.wxss","./packageAPI/pages/worker/worker/worker.wxss","./packageAPI/pages/framework/two-way-bindings/two-way-bindings.wxss","./packageAPI/pages/framework/wxs/wxs.wxss","./packageAPI/pages/framework/resizable/resizable.wxss","./packageAPI/pages/framework/wxs/movable.wxss","./packageAPI/pages/framework/wxs/sidebar.wxss","./packageAPI/pages/framework/wxs/stick-top.wxss","./packageAPI/pages/framework/wxs/nearby.wxss","./app.wxss","./common/common-skyline.wxss","./common/reset.wxss","./common/lib/weui.wxss","./component/navigation-bar/navigation-bar.wxss","./components/navigation-bar/index.wxss","./components/page-scroll/index.wxss","./page/API/index.wxss","./page/API/components/set-tab-bar/set-tab-bar.wxss","./page/cloud/index.wxss","./page/common/index-skyline.wxss","./page/component/index.wxss","./page/extend/index.wxss","./miniprogram_npm/miniprogram-barrage/index.wxss","./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss","./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss","./miniprogram_npm/wxml-to-canvas/index.wxss","--subpackage","packageAPI","-ll"]
|
||||||
|
const w = JSON.parse(await wine.wcsc(args, projectPath));
|
||||||
|
const n = JSON.parse(await node.wcsc(args, projectPath));
|
||||||
|
const storagePath = path.resolve(__dirname, `miniprogram-demo/${this.test.title}`)
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, {recursive: true});
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/wine-output.json`,
|
||||||
|
JSON.stringify(w, null, 4)
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/node-output.json`,
|
||||||
|
JSON.stringify(n, null, 4)
|
||||||
|
);
|
||||||
|
assert.deepEqual(w, n);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
185
node/test/wcsc/raw/raw.test.js
Normal file
185
node/test/wcsc/raw/raw.test.js
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const node = require("../../runner/node");
|
||||||
|
const wine = require("../../runner/wine");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
describe("wcsc", function () {
|
||||||
|
describe("Raw: node output should equal with wine", function () {
|
||||||
|
// afterEach(function(){
|
||||||
|
// if(this.currentTest.state === 'failed'){
|
||||||
|
// console.error('failed', this.currentTest)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
it("主界面", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-db",
|
||||||
|
"-pc",
|
||||||
|
"12",
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxss",
|
||||||
|
"./components/navigation-bar/index.wxss",
|
||||||
|
"./components/page-scroll/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/common-skyline.wxss",
|
||||||
|
"./common/reset.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./page/common/index-skyline.wxss",
|
||||||
|
// "-ll",
|
||||||
|
];
|
||||||
|
const w = await wine.wcsc(args, projectPath);
|
||||||
|
const n = await node.wcsc(args, projectPath);
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/${this.test.title}`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/wine-output.js`,
|
||||||
|
w
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/node-output.js`,
|
||||||
|
n
|
||||||
|
);
|
||||||
|
assert.equal(w, n);
|
||||||
|
});
|
||||||
|
it("接口-设置界面标题", async function () {
|
||||||
|
const projectPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../examples/miniprogram-demo/miniprogram/"
|
||||||
|
);
|
||||||
|
const args = [
|
||||||
|
"-db",
|
||||||
|
"-pc",
|
||||||
|
"74",
|
||||||
|
"./packageAPI/pages/api/login/login.wxss",
|
||||||
|
"./packageAPI/pages/api/get-user-info/get-user-info.wxss",
|
||||||
|
"./packageAPI/pages/api/request-payment/request-payment.wxss",
|
||||||
|
"./packageAPI/pages/api/jump/jump.wxss",
|
||||||
|
"./packageAPI/pages/api/share/share.wxss",
|
||||||
|
"./packageAPI/pages/api/share-button/share-button.wxss",
|
||||||
|
"./packageAPI/pages/api/custom-message/custom-message.wxss",
|
||||||
|
"./packageAPI/pages/api/subscribe-message/subscribe-message.wxss",
|
||||||
|
"./packageAPI/pages/api/choose-address/choose-address.wxss",
|
||||||
|
"./packageAPI/pages/api/choose-invoice-title/choose-invoice-title.wxss",
|
||||||
|
"./packageAPI/pages/api/soter-authentication/soter-authentication.wxss",
|
||||||
|
"./packageAPI/pages/api/setting/setting.wxss",
|
||||||
|
"./packageAPI/pages/ar/visionkit-basic/visionkit-basic.wxss",
|
||||||
|
"./packageAPI/pages/ar/plane-ar/plane-ar.wxss",
|
||||||
|
"./packageAPI/pages/ar/2dmarker-ar/2dmarker-ar.wxss",
|
||||||
|
"./packageAPI/pages/ar/osd-ar/osd-ar.wxss",
|
||||||
|
"./packageAPI/pages/page/set-navigation-bar-title/set-navigation-bar-title.wxss",
|
||||||
|
"./packageAPI/pages/page/navigation-bar-loading/navigation-bar-loading.wxss",
|
||||||
|
"./packageAPI/pages/page/navigator/navigator.wxss",
|
||||||
|
"./packageAPI/pages/page/pull-down-refresh/pull-down-refresh.wxss",
|
||||||
|
"./packageAPI/pages/page/animation/animation.wxss",
|
||||||
|
"./packageAPI/pages/page/action-sheet/action-sheet.wxss",
|
||||||
|
"./packageAPI/pages/page/modal/modal.wxss",
|
||||||
|
"./packageAPI/pages/page/toast/toast.wxss",
|
||||||
|
"./packageAPI/pages/page/canvas/canvas.wxss",
|
||||||
|
"./packageAPI/pages/page/get-wxml-node-info/get-wxml-node-info.wxss",
|
||||||
|
"./packageAPI/pages/page/page-scroll/page-scroll.wxss",
|
||||||
|
"./packageAPI/pages/page/intersection-observer/intersection-observer.wxss",
|
||||||
|
"./packageAPI/pages/device/clipboard-data/clipboard-data.wxss",
|
||||||
|
"./packageAPI/pages/device/bluetooth/bluetooth.wxss",
|
||||||
|
"./packageAPI/pages/device/bluetooth/slave/slave.wxss",
|
||||||
|
"./packageAPI/pages/device/screen-brightness/screen-brightness.wxss",
|
||||||
|
"./packageAPI/pages/device/vibrate/vibrate.wxss",
|
||||||
|
"./packageAPI/pages/device/add-contact/add-contact.wxss",
|
||||||
|
"./packageAPI/pages/device/wifi/wifi.wxss",
|
||||||
|
"./packageAPI/pages/device/get-network-type/get-network-type.wxss",
|
||||||
|
"./packageAPI/pages/device/on-network-status-change/on-network-status-change.wxss",
|
||||||
|
"./packageAPI/pages/device/get-system-info/get-system-info.wxss",
|
||||||
|
"./packageAPI/pages/device/on-compass-change/on-compass-change.wxss",
|
||||||
|
"./packageAPI/pages/device/make-phone-call/make-phone-call.wxss",
|
||||||
|
"./packageAPI/pages/device/scan-code/scan-code.wxss",
|
||||||
|
"./packageAPI/pages/device/on-accelerometer-change/on-accelerometer-change.wxss",
|
||||||
|
"./packageAPI/pages/device/capture-screen/capture-screen.wxss",
|
||||||
|
"./packageAPI/pages/device/ibeacon/ibeacon.wxss",
|
||||||
|
"./packageAPI/pages/device/get-battery-info/get-battery-info.wxss",
|
||||||
|
"./packageAPI/pages/media/image/image.wxss",
|
||||||
|
"./packageAPI/pages/media/voice/voice.wxss",
|
||||||
|
"./packageAPI/pages/media/file/file.wxss",
|
||||||
|
"./packageAPI/pages/media/load-font-face/load-font-face.wxss",
|
||||||
|
"./packageAPI/pages/media/background-audio/background-audio.wxss",
|
||||||
|
"./packageAPI/pages/media/video/video.wxss",
|
||||||
|
"./packageAPI/pages/media/audio/audio.wxss",
|
||||||
|
"./packageAPI/pages/media/media-container/media-container.wxss",
|
||||||
|
"./packageAPI/pages/location/get-location/get-location.wxss",
|
||||||
|
"./packageAPI/pages/location/open-location/open-location.wxss",
|
||||||
|
"./packageAPI/pages/location/choose-location/choose-location.wxss",
|
||||||
|
"./packageAPI/pages/network/request/request.wxss",
|
||||||
|
"./packageAPI/pages/network/web-socket/web-socket.wxss",
|
||||||
|
"./packageAPI/pages/network/upload-file/upload-file.wxss",
|
||||||
|
"./packageAPI/pages/network/download-file/download-file.wxss",
|
||||||
|
"./packageAPI/pages/network/mdns/mdns.wxss",
|
||||||
|
"./packageAPI/pages/network/udp-socket/udp-socket.wxss",
|
||||||
|
"./packageAPI/pages/storage/storage/storage.wxss",
|
||||||
|
"./packageAPI/pages/storage/get-background-fetch-data/get-background-fetch-data.wxss",
|
||||||
|
"./packageAPI/pages/storage/get-background-prefetch-data/get-background-prefetch-data.wxss",
|
||||||
|
"./packageAPI/pages/performance/get-performance/get-performance.wxss",
|
||||||
|
"./packageAPI/pages/worker/worker/worker.wxss",
|
||||||
|
"./packageAPI/pages/framework/two-way-bindings/two-way-bindings.wxss",
|
||||||
|
"./packageAPI/pages/framework/wxs/wxs.wxss",
|
||||||
|
"./packageAPI/pages/framework/resizable/resizable.wxss",
|
||||||
|
"./packageAPI/pages/framework/wxs/movable.wxss",
|
||||||
|
"./packageAPI/pages/framework/wxs/sidebar.wxss",
|
||||||
|
"./packageAPI/pages/framework/wxs/stick-top.wxss",
|
||||||
|
"./packageAPI/pages/framework/wxs/nearby.wxss",
|
||||||
|
"./app.wxss",
|
||||||
|
"./common/common-skyline.wxss",
|
||||||
|
"./common/reset.wxss",
|
||||||
|
"./common/lib/weui.wxss",
|
||||||
|
"./component/navigation-bar/navigation-bar.wxss",
|
||||||
|
"./components/navigation-bar/index.wxss",
|
||||||
|
"./components/page-scroll/index.wxss",
|
||||||
|
"./page/API/index.wxss",
|
||||||
|
"./page/API/components/set-tab-bar/set-tab-bar.wxss",
|
||||||
|
"./page/cloud/index.wxss",
|
||||||
|
"./page/common/index-skyline.wxss",
|
||||||
|
"./page/component/index.wxss",
|
||||||
|
"./page/extend/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-barrage/index.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxss",
|
||||||
|
"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxss",
|
||||||
|
"./miniprogram_npm/wxml-to-canvas/index.wxss",
|
||||||
|
"--subpackage",
|
||||||
|
"packageAPI",
|
||||||
|
// "-ll",
|
||||||
|
];
|
||||||
|
const w = await wine.wcsc(args, projectPath);
|
||||||
|
const n = await node.wcsc(args, projectPath);
|
||||||
|
const storagePath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
`miniprogram-demo/${this.test.title}`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/wine-output.js`,
|
||||||
|
w
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${storagePath}/node-output.js`,
|
||||||
|
n
|
||||||
|
);
|
||||||
|
assert.equal(w, n);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
1
node/wcc_node/bin
Symbolic link
1
node/wcc_node/bin
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../node_modules/miniprogram-compiler/bin
|
@ -1,4 +1,4 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
wcc: require('./wcc'),
|
wcc: require('./wcc'),
|
||||||
wcsc: require('./wcsc')
|
wcsc: require('./wcsc')
|
||||||
}
|
}
|
1134
node/wcc_node/lib/util.js
Normal file
1134
node/wcc_node/lib/util.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,94 +1,95 @@
|
|||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
let wcc
|
let wcc
|
||||||
|
|
||||||
function loadWccAddon() {
|
function loadWccAddon() {
|
||||||
if (wcc) return
|
if (wcc) return
|
||||||
wcc = require('../build/Release/wcc.node')
|
// wcc = require('../build/Release/wcc.node')
|
||||||
}
|
wcc = require('../src/wcc')
|
||||||
|
}
|
||||||
const fs = util.fs
|
|
||||||
|
const fs = util.fs
|
||||||
exports = async function (options) {
|
|
||||||
|
exports = async function (options) {
|
||||||
loadWccAddon()
|
|
||||||
|
loadWccAddon()
|
||||||
if (!options) throw Error('options is required')
|
|
||||||
|
if (!options) throw Error('options is required')
|
||||||
const lazyload = !!options.lazyloadConfig
|
|
||||||
|
const lazyload = !!options.lazyloadConfig
|
||||||
options = Object.assign(
|
|
||||||
{
|
options = Object.assign(
|
||||||
files: [],
|
{
|
||||||
contents: [],
|
files: [],
|
||||||
replaceContent: {},
|
contents: [],
|
||||||
verbose: false,
|
replaceContent: {},
|
||||||
debug: false,
|
verbose: false,
|
||||||
debugWXS: false,
|
debug: false,
|
||||||
showNewTree: false,
|
debugWXS: false,
|
||||||
isPlugin: false,
|
showNewTree: false,
|
||||||
addTestAttre: false,
|
isPlugin: false,
|
||||||
independent: false,
|
addTestAttre: false,
|
||||||
genfuncname: '$gwx',
|
independent: false,
|
||||||
isCut: false,
|
genfuncname: '$gwx',
|
||||||
cwd: process.cwd,
|
isCut: false,
|
||||||
debug: false,
|
cwd: process.cwd,
|
||||||
lazyload,
|
debug: false,
|
||||||
lazyloadConfig: '',
|
lazyload,
|
||||||
},
|
lazyloadConfig: '',
|
||||||
options,
|
},
|
||||||
)
|
options,
|
||||||
|
)
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
let st = Date.now()
|
return new Promise(async (resolve, reject) => {
|
||||||
|
let st = Date.now()
|
||||||
// 获取文件内容
|
|
||||||
if (!options.contents.length) {
|
// 获取文件内容
|
||||||
const tasks = options.files.map((file) => {
|
if (!options.contents.length) {
|
||||||
if (typeof options.replaceContent[file] === 'string') {
|
const tasks = options.files.map((file) => {
|
||||||
return options.replaceContent[file]
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
}
|
return options.replaceContent[file]
|
||||||
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
}
|
||||||
})
|
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
||||||
options.contents = await Promise.all(tasks) || []
|
})
|
||||||
}
|
options.contents = await Promise.all(tasks) || []
|
||||||
// console.log('wcc get files', Date.now() - st, options.contents)
|
}
|
||||||
let result
|
// console.log('wcc get files', Date.now() - st, options.contents)
|
||||||
try {
|
let result
|
||||||
result = wcc(options)
|
try {
|
||||||
} catch(errmsg) {
|
result = wcc(options)
|
||||||
reject(new Error(errmsg))
|
} catch(errmsg) {
|
||||||
return
|
reject(new Error(errmsg))
|
||||||
}
|
return
|
||||||
|
}
|
||||||
console.log('wcc get compile', Date.now() - st)
|
|
||||||
if (options.output) {
|
console.log('wcc get compile', Date.now() - st)
|
||||||
const output = path.resolve(options.cwd, options.output)
|
if (options.output) {
|
||||||
const dir = path.dirname(output)
|
const output = path.resolve(options.cwd, options.output)
|
||||||
if (lazyload) {
|
const dir = path.dirname(output)
|
||||||
// lazyload 为 true时,wcc 返回值是个对象, 需要序列化一下
|
if (lazyload) {
|
||||||
result = JSON.stringify(result)
|
// lazyload 为 true时,wcc 返回值是个对象, 需要序列化一下
|
||||||
}
|
result = JSON.stringify(result)
|
||||||
try {
|
}
|
||||||
await fs.stat(dir)
|
try {
|
||||||
} catch (e) {
|
await fs.stat(dir)
|
||||||
await fs.mkdir(dir, {
|
} catch (e) {
|
||||||
recursive: true,
|
await fs.mkdir(dir, {
|
||||||
})
|
recursive: true,
|
||||||
}
|
})
|
||||||
await fs.writeFile(output, result, 'utf8')
|
}
|
||||||
}
|
await fs.writeFile(output, result, 'utf8')
|
||||||
console.log('wcc get output', Date.now() - st)
|
}
|
||||||
resolve(result)
|
console.log('wcc get output', Date.now() - st)
|
||||||
})
|
resolve(result)
|
||||||
}
|
})
|
||||||
|
}
|
||||||
Object.defineProperty(exports, 'version', {
|
|
||||||
get() {
|
Object.defineProperty(exports, 'version', {
|
||||||
loadWccAddon()
|
get() {
|
||||||
return wcc.version
|
loadWccAddon()
|
||||||
},
|
return wcc.version
|
||||||
})
|
},
|
||||||
|
})
|
||||||
module.exports = exports
|
|
||||||
|
module.exports = exports
|
@ -1,92 +1,93 @@
|
|||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = util.fs
|
const fs = util.fs
|
||||||
|
|
||||||
let wcsc
|
let wcsc
|
||||||
|
|
||||||
function loadWcscAddon() {
|
function loadWcscAddon() {
|
||||||
if (wcsc) return
|
if (wcsc) return
|
||||||
wcsc = require('../build/Release/wcsc.node')
|
// wcsc = require('../build/Release/wcsc.node')
|
||||||
}
|
wcsc = require('../src/wcsc')
|
||||||
|
}
|
||||||
function tranWcscResultToObject(resultStr) {
|
|
||||||
const resultArr = resultStr.split('=')
|
function tranWcscResultToObject(resultStr) {
|
||||||
const result = {}
|
const resultArr = resultStr.split('=')
|
||||||
for (let i = 0, len = resultArr.length; i < len && resultArr[i + 1]; i += 2) {
|
const result = {}
|
||||||
result[resultArr[i]] = resultArr[i + 1]
|
for (let i = 0, len = resultArr.length; i < len && resultArr[i + 1]; i += 2) {
|
||||||
}
|
result[resultArr[i]] = resultArr[i + 1]
|
||||||
return result
|
}
|
||||||
}
|
return result
|
||||||
|
}
|
||||||
exports = async function (options) {
|
|
||||||
|
exports = async function (options) {
|
||||||
loadWcscAddon()
|
|
||||||
|
loadWcscAddon()
|
||||||
if (!options) throw Error('options is required')
|
|
||||||
|
if (!options) throw Error('options is required')
|
||||||
// avoid undefined or null
|
|
||||||
if (typeof options.subPackage !== 'string') {
|
// avoid undefined or null
|
||||||
delete options.subPackage
|
if (typeof options.subPackage !== 'string') {
|
||||||
}
|
delete options.subPackage
|
||||||
|
}
|
||||||
if (typeof options.lazyload !== 'boolean') {
|
|
||||||
delete options.lazyload
|
if (typeof options.lazyload !== 'boolean') {
|
||||||
}
|
delete options.lazyload
|
||||||
|
}
|
||||||
options = Object.assign(
|
|
||||||
{
|
options = Object.assign(
|
||||||
files: [],
|
{
|
||||||
contents: [],
|
files: [],
|
||||||
pageCount: 0,
|
contents: [],
|
||||||
cwd: process.cwd,
|
pageCount: 0,
|
||||||
replaceContent: {},
|
cwd: process.cwd,
|
||||||
debug: false,
|
replaceContent: {},
|
||||||
classPrefix: '',
|
debug: false,
|
||||||
lazyload: false,
|
classPrefix: '',
|
||||||
},
|
lazyload: false,
|
||||||
options,
|
},
|
||||||
)
|
options,
|
||||||
|
)
|
||||||
if (!options.contents.length) {
|
|
||||||
const tasks = options.files.map((file) => {
|
if (!options.contents.length) {
|
||||||
if (typeof options.replaceContent[file] === 'string') {
|
const tasks = options.files.map((file) => {
|
||||||
return options.replaceContent[file]
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
}
|
return options.replaceContent[file]
|
||||||
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
}
|
||||||
})
|
return fs.readFile(path.resolve(options.cwd, file), 'utf8')
|
||||||
options.contents = await Promise.all(tasks) || []
|
})
|
||||||
}
|
options.contents = await Promise.all(tasks) || []
|
||||||
|
}
|
||||||
let wccResult
|
|
||||||
try {
|
let wccResult
|
||||||
wccResult = wcsc(options)
|
try {
|
||||||
} catch (errmsg) {
|
wccResult = await wcsc(options)
|
||||||
throw new Error(errmsg)
|
} catch (errmsg) {
|
||||||
}
|
throw new Error(errmsg)
|
||||||
|
}
|
||||||
const result = options.lazyload ? wccResult : tranWcscResultToObject(wccResult)
|
|
||||||
|
const result = options.lazyload ? wccResult : tranWcscResultToObject(wccResult)
|
||||||
if (options.output) {
|
|
||||||
const output = path.resolve(options.cwd, options.output)
|
if (options.output) {
|
||||||
const dir = path.dirname(output)
|
const output = path.resolve(options.cwd, options.output)
|
||||||
try {
|
const dir = path.dirname(output)
|
||||||
await fs.stat(dir)
|
try {
|
||||||
} catch (e) {
|
await fs.stat(dir)
|
||||||
await fs.mkdir(dir, {
|
} catch (e) {
|
||||||
recursive: true,
|
await fs.mkdir(dir, {
|
||||||
})
|
recursive: true,
|
||||||
}
|
})
|
||||||
await fs.writeFile(output, JSON.stringify(result, null, 2), 'utf8')
|
}
|
||||||
}
|
await fs.writeFile(output, JSON.stringify(result, null, 2), 'utf8')
|
||||||
|
}
|
||||||
return result
|
|
||||||
}
|
return result
|
||||||
|
}
|
||||||
Object.defineProperty(exports, 'version', {
|
|
||||||
get() {
|
Object.defineProperty(exports, 'version', {
|
||||||
loadWcscAddon()
|
get() {
|
||||||
return wcsc.version
|
loadWcscAddon()
|
||||||
},
|
return wcsc.version
|
||||||
})
|
},
|
||||||
|
})
|
||||||
module.exports = exports
|
|
||||||
|
module.exports = exports
|
@ -1,18 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "miniprogram-wcc",
|
"name": "miniprogram-wcc",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "WCC node C++ addon",
|
"description": "WCC node C++ addon",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"rebuild": "node-gyp rebuild",
|
"test": "node ./test/wcc/index && node ./test/wcsc/index",
|
||||||
"build": "node-gyp build",
|
"format": "prettier *.js test/*.js scripts/*.js --write"
|
||||||
"test": "node ./test/wcc/index && node ./test/wcsc/index",
|
},
|
||||||
"format": "prettier *.js test/*.js scripts/*.js --write"
|
"author": "coverguo",
|
||||||
},
|
"license": "MIT",
|
||||||
"author": "coverguo",
|
"devDependencies": {
|
||||||
"license": "MIT",
|
"licia": "^1.21.2",
|
||||||
"devDependencies": {
|
"node-gyp": "^7.0.0"
|
||||||
"licia": "^1.21.2",
|
}
|
||||||
"node-gyp": "^7.0.0"
|
}
|
||||||
}
|
|
||||||
}
|
|
504
node/wcc_node/src/wcc.js
Normal file
504
node/wcc_node/src/wcc.js
Normal file
File diff suppressed because one or more lines are too long
142
node/wcc_node/src/wcsc.js
Normal file
142
node/wcc_node/src/wcsc.js
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
const { spawn, spawnSync } = require('child_process')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const os = require('os')
|
||||||
|
const { throws } = require('assert')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 wxss 编译器路径
|
||||||
|
*/
|
||||||
|
let wxssParserPath = ''
|
||||||
|
function getWXSSParsePath() {
|
||||||
|
if (wxssParserPath) return wxssParserPath
|
||||||
|
|
||||||
|
const fileName = process.platform === 'darwin' ? '../bin/mac/wcsc' : process.platform === 'linux' ? '../bin/linux/wcsc' : '../bin/windows/wcsc.exe'
|
||||||
|
wxssParserPath = path.join(__dirname, fileName)
|
||||||
|
|
||||||
|
// 尝试修改权限
|
||||||
|
try {
|
||||||
|
fs.chmodSync(wxssParserPath, 0o777)
|
||||||
|
} catch (err) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxssParserPath
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取完整文件列表
|
||||||
|
*/
|
||||||
|
function getAllFiles(rootPath, files) {
|
||||||
|
const ret = []
|
||||||
|
let compWxssNum = 0
|
||||||
|
|
||||||
|
for (let i = 0, len = files.length; i < len; i++) {
|
||||||
|
const file = files[i]
|
||||||
|
|
||||||
|
let fileJson = null
|
||||||
|
try {
|
||||||
|
fileJson = require(path.join(rootPath, `${file}.json`))
|
||||||
|
} catch(err) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileJson) {
|
||||||
|
// 组件 wxss
|
||||||
|
compWxssNum++
|
||||||
|
ret.unshift(`${file}.wxss`)
|
||||||
|
} else {
|
||||||
|
ret.push(`${file}.wxss`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
list: ret,
|
||||||
|
compWxssNum,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编译 wxss 到 js
|
||||||
|
*/
|
||||||
|
async function wxssToJS(options) {
|
||||||
|
// 创建临时目录
|
||||||
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'wcsc_'))
|
||||||
|
// 判断是否replace,是写入replace,否则拷贝文件到临时目录
|
||||||
|
for(let file of options.files){
|
||||||
|
if (typeof options.replaceContent[file] === 'string') {
|
||||||
|
// 写入替换内容
|
||||||
|
fs.mkdirSync(path.dirname(path.resolve(tmp, file)), {recursive:true})
|
||||||
|
fs.writeFileSync(path.resolve(tmp, file), options.replaceContent[file])
|
||||||
|
}else{
|
||||||
|
// 复制原文件
|
||||||
|
fs.mkdirSync(path.dirname(path.resolve(tmp, file)), {recursive:true})
|
||||||
|
fs.copyFileSync(path.resolve(options.cwd, file), path.resolve(tmp, file))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 使用临时目录执行wcc
|
||||||
|
options.cwd = tmp
|
||||||
|
|
||||||
|
let rootPath = options.cwd, files=options.files
|
||||||
|
// files = getAllFiles(rootPath, files)
|
||||||
|
|
||||||
|
const args = ['-db', '-pc', String(options.pageCount)].concat(files)
|
||||||
|
options.subPackage && (args.push("--subpackage"), args.push(options.subPackage.replace(/\/$/, "")));
|
||||||
|
const wxssParserPath = getWXSSParsePath()
|
||||||
|
// console.warn('wcsc args: ', args)
|
||||||
|
// const wcsc = spawnSync(wxssParserPath, args, { cwd: rootPath })
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
|
||||||
|
const wcsc = spawn(wxssParserPath, args, {
|
||||||
|
cwd: rootPath,
|
||||||
|
});
|
||||||
|
const spwanData = [],
|
||||||
|
errData = [];
|
||||||
|
wcsc.stdout.on("data", (e) => {
|
||||||
|
spwanData.push(e);
|
||||||
|
});
|
||||||
|
wcsc.stderr.on("data", (e) => {
|
||||||
|
errData.push(e);
|
||||||
|
});
|
||||||
|
wcsc.on("close", (code) => {
|
||||||
|
console.warn('close', new Date().getTime()/1000)
|
||||||
|
if (code === 0) {
|
||||||
|
let result = Buffer.concat(spwanData).toString();
|
||||||
|
if(options.lazyload){
|
||||||
|
result = result.split('=')
|
||||||
|
let funcList = {}
|
||||||
|
for (let i = 0, len = result.length; i < len && result[i + 1]; i += 2) {
|
||||||
|
funcList[result[i]] = result[i + 1]
|
||||||
|
.replace(
|
||||||
|
/[^\\]((\\x[\da-f]{2}|\\u[\da-f]{4})){1,}/gi,
|
||||||
|
function ($0, $1, $2) {
|
||||||
|
return eval('"' + $0 + '"');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) {
|
||||||
|
// console.log($0, $1)
|
||||||
|
const c = $0 === "\\n" ? "\n" : $0[1];
|
||||||
|
return c
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const t = Object.keys(funcList).sort()
|
||||||
|
result = {
|
||||||
|
common: funcList.comm,
|
||||||
|
pageWxss: {}
|
||||||
|
}
|
||||||
|
for(let key of t){
|
||||||
|
if(key.endsWith('.wxss')){
|
||||||
|
result.pageWxss[key] = funcList[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(result)
|
||||||
|
} else {
|
||||||
|
throw new Error(`编译 .wxss 文件错误(${wcsc.status}):${wcsc.stderr.toString()}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = wxssToJS
|
15
node/wine/wcc
Normal file
15
node/wine/wcc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
SOURCE="$(readlink "$SOURCE")"
|
||||||
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||||
|
done
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
if [[ $@ =~ -ll ]];then
|
||||||
|
wine "$DIR/wcc.exe" "$@"
|
||||||
|
else
|
||||||
|
"$DIR/wcc.bin" "$@"
|
||||||
|
fi
|
BIN
node/wine/wcc.exe
Executable file
BIN
node/wine/wcc.exe
Executable file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user