mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
Compare commits
15 Commits
v1.06.2503
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
5b68973fc4 | ||
|
080ee2b6df | ||
|
465af9b79a | ||
|
322de01a35 | ||
|
8c9eeed51f | ||
|
a3e75a647f | ||
|
54ce4f4565 | ||
|
4b9612b7a6 | ||
|
940cd4a12d | ||
|
bf2fbd90ed | ||
|
7972c036f2 | ||
|
75ea918b71 | ||
|
df2d94f3f2 | ||
|
2778d18e9e | ||
|
e2d698f573 |
1
.github/workflows/build-deb.yml
vendored
1
.github/workflows/build-deb.yml
vendored
@ -46,6 +46,7 @@ jobs:
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt-get install -y build-essential fakeroot devscripts debhelper # debmake lintian pbuilder
|
||||
|
||||
- name: Build Deb Package
|
||||
|
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -10,6 +10,10 @@ on:
|
||||
tags:
|
||||
- v*
|
||||
branches: [ master, dev, ci, skyline]
|
||||
paths-ignore:
|
||||
- 'README.MD'
|
||||
- 'CHANGELOG.MD'
|
||||
- 'docs/**'
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
# # Allows you to run this workflow manually from the Actions tab
|
||||
|
17
CHANGELOG.MD
17
CHANGELOG.MD
@ -1,3 +1,20 @@
|
||||
# 1.06.2504010-3 / 2025-07-
|
||||
- refactor: 重构主题监听处理方案
|
||||
|
||||
# 1.06.2504010-2 / 2025-07-15
|
||||
- fix: cli使用异常。#147
|
||||
|
||||
# 1.06.2504010-1 / 2025-07-05
|
||||
- fix: 更新弹窗无法关闭。
|
||||
- update: devtools to v1.06.2504010
|
||||
|
||||
# 1.06.2503290-3 / 2025-05-23
|
||||
- update: compiler(Linux) v0.1.5
|
||||
- fix: worker无法使用 #145
|
||||
|
||||
# 1.06.2503290-2 / 2025-05-02
|
||||
- update: compiler(Linux) v0.1.4
|
||||
|
||||
# 1.06.2503290-1 / 2025-04-30
|
||||
|
||||
- update: node v16.11.0 (解决codebuddy无法使用。)
|
||||
|
@ -10,7 +10,7 @@
|
||||
----
|
||||
|
||||
[](https://github.com/msojocs/wechat-devtools-linux/actions/workflows/release.yml)
|
||||
[](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)
|
||||
[](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)
|
||||
[](https://nwjs.io/downloads/)
|
||||
[](https://nodejs.org/en/)
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
# 进度
|
||||
|
||||
当前工具可以在Linux上构筑最新版 `1.06.2412050`,支持CLI模式。
|
||||
当前工具可以在Linux上构筑最新版 `1.06.2503290`,支持CLI模式。
|
||||
另现在已经可以直接在设置界面里面修改字体,手工输入字体名称就可以。
|
||||
|
||||
# 功能测试记录
|
||||
@ -163,6 +163,11 @@
|
||||
|
||||
| 赞赏人 | 赞赏 | 时间 |
|
||||
|-------|---------|-----|
|
||||
| returning | 10.00¥ | 2025-07-12 |
|
||||
| 👍 | 10.00¥ | 2025-07-10 |
|
||||
| hanwor | 20.00¥ | 2025-06-17 |
|
||||
| 。。。 | 10.00¥ | 2025-03-29 |
|
||||
| SakuraPuare | 20.00¥ | 2025-03-24 |
|
||||
| [senseab](https://github.com/senseab) | 50.00¥ | 2024-12-21 |
|
||||
| l | 10.00¥ | 2024-12-08 |
|
||||
| lcurk0 | 50.00¥ | 2024-11-29 |
|
||||
|
@ -53,11 +53,11 @@ else
|
||||
fi;
|
||||
|
||||
EXTENSION1="--load-extension=$root_dir/nwjs/package.nw/js/ideplugin"
|
||||
EXTENSION2=--load-extension=$APPDATA/WeappPlugin
|
||||
EXTENSION2="--load-extension=$APPDATA/WeappPlugin/inspector"
|
||||
INSPECTOR1="--custom-devtools-frontend=file://$root_dir/package.nw/js/ideplugin/inspector" # 要加file://指明为本地文件路径
|
||||
INSPECTOR2="--custom-devtools-frontend=file://$APPDATA/WeappPlugin/inspector/"
|
||||
USERDATADIR="$APPDATA"
|
||||
|
||||
# "$@"参数
|
||||
LANG=zh_CN.UTF-8
|
||||
exec "$root_dir/nwjs/nw" $root_dir/package.nw $EXTENSION2 $INSPECTOR1 "$@"
|
||||
exec "$root_dir/nwjs/nw" $root_dir/package.nw $EXTENSION1 $INSPECTOR1 "$@"
|
@ -8,7 +8,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
||||
done
|
||||
root_dir="$( cd -P "$( dirname "$SOURCE" )"/.. >/dev/null 2>&1 && pwd )"
|
||||
|
||||
cd $root_dir
|
||||
cd $root_dir/bin
|
||||
|
||||
export WECHAT_DEVTOOLS_DIR="$root_dir/nwjs"
|
||||
export APPDATA="$root_dir/nwjs"
|
||||
|
@ -1 +1 @@
|
||||
WX_COMPILER_VERSION=v0.1.3
|
||||
WX_COMPILER_VERSION=v0.1.5
|
@ -1 +1 @@
|
||||
1.06.2503290,1296c756bb2af7fa7550216dfdc315e3
|
||||
1.06.2504010,6a579ac93961fbfe04774b26f0c85b78
|
@ -89,7 +89,7 @@ build() {
|
||||
_log "prepare nw-gyp"
|
||||
node --version
|
||||
npm uninstall node-gyp -g
|
||||
npm install nw-gyp node-gyp -g
|
||||
npm install nw-gyp@3.6.6 node-gyp -g
|
||||
|
||||
# node bin
|
||||
_log "copy node exectuable"
|
||||
|
@ -12,6 +12,11 @@ DH_VERBOSE = 1
|
||||
# package maintainers to append LDFLAGS
|
||||
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
|
||||
|
||||
# 1.20.9ubuntu1 -> 1.20.9ubuntu2修改了默认打包工具为zstd,导致统信平台不能识别,强制设定为xz
|
||||
# changelog: https://launchpad.net/ubuntu/+source/dpkg/1.20.9ubuntu2
|
||||
override_dh_builddeb:
|
||||
dh_builddeb -- -Zxz
|
||||
|
||||
override_dh_strip_nondeterminism:
|
||||
|
||||
override_dh_shlibdeps:
|
||||
|
29
res/scripts/cli.js
Normal file
29
res/scripts/cli.js
Normal file
@ -0,0 +1,29 @@
|
||||
(() => {
|
||||
process.argv[0] = 'wechat-devtools-cli'
|
||||
process.env.USERPROFILE = require('os').homedir()
|
||||
Object.defineProperty(global, 'userDirPath', {
|
||||
set: function(value) {
|
||||
if (value.includes('AppData/Local')) {
|
||||
value = value.replace('AppData/Local', '.config')
|
||||
value = value.replace(/User Data\/.*?\//, '')
|
||||
// value = value.replace('~', require('os').homedir())
|
||||
}
|
||||
this._userDirPath = value
|
||||
},
|
||||
get: function() {
|
||||
return this._userDirPath
|
||||
}
|
||||
})
|
||||
// appPath
|
||||
Object.defineProperty(global, 'appPath', {
|
||||
set: function(value) {
|
||||
if (value.includes('.exe')) {
|
||||
value = value.replace('.exe', '')
|
||||
}
|
||||
this._appPath = value
|
||||
},
|
||||
get: function() {
|
||||
return this._appPath
|
||||
}
|
||||
})
|
||||
})();
|
@ -1,11 +1,11 @@
|
||||
(() => {
|
||||
const http = require('http')
|
||||
const originaleListen = http.Server.prototype.listen
|
||||
http.Server.prototype.listen = function(port) {
|
||||
if (port == 33233) {
|
||||
console.warn('block port of http server:', port)
|
||||
http.Server.prototype.listen = function(...args) {
|
||||
if (args[0] == 33233) {
|
||||
console.warn('block port of http server:', args[0])
|
||||
return
|
||||
}
|
||||
return originaleListen.apply(this, [port])
|
||||
return originaleListen.apply(this, args)
|
||||
}
|
||||
})();
|
347
res/scripts/hackrequire.js
Normal file
347
res/scripts/hackrequire.js
Normal file
@ -0,0 +1,347 @@
|
||||
/* patch wechat devtools begin */
|
||||
(() => {
|
||||
try {
|
||||
{
|
||||
// 修正编译器路径
|
||||
const originalSpawn = require("child_process").spawn;
|
||||
require("child_process").spawn = function (command, args, options) {
|
||||
if (command.includes("wcc.exe")) {
|
||||
command = command.replace("code/package.nw", "package.nw");
|
||||
command = command.replace("wcc.exe", "wcc");
|
||||
} else if (command.includes("wcsc.exe")) {
|
||||
command = command.replace("code/package.nw", "package.nw");
|
||||
command = command.replace("wcsc.exe", "wcsc");
|
||||
}
|
||||
return originalSpawn.apply(this, [command, args, options]);
|
||||
};
|
||||
}
|
||||
{
|
||||
// 修正路径错误
|
||||
const originalResolve = require("path").resolve;
|
||||
require("path").resolve = function (...paths) {
|
||||
if (paths.length === 2 && paths[1].includes("code/package.nw")) {
|
||||
paths[1] = paths[1].replace("code/package.nw", "package.nw");
|
||||
}
|
||||
return originalResolve.apply(this, paths);
|
||||
};
|
||||
}
|
||||
if (typeof nw === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
let log = function (content) {
|
||||
process.stderr.write(content + "\n");
|
||||
};
|
||||
|
||||
let originMenuItem = nw.MenuItem;
|
||||
nw.MenuItem = function MenuItem(options) {
|
||||
|
||||
options = Object.assign({}, options);
|
||||
|
||||
delete options.shortcutName;
|
||||
delete options.shouldEnabled;
|
||||
|
||||
if (options.label && (typeof options.label === "string")) {
|
||||
|
||||
if (options.label.indexOf("[") !== -1) {
|
||||
let rest = options.label.split("[").slice(1).join("[").trim();
|
||||
if (rest[rest.length - 1] === "]") {
|
||||
rest = rest.slice(0, -1).split("+").map((x) => {
|
||||
if (!x) { return "+" }
|
||||
switch (x) {
|
||||
case "↓": { return "Down"; }
|
||||
case "↑": { return "Up"; }
|
||||
case "PAGE↓": { return "PageDown"; }
|
||||
case "PAGE↑": { return "PageUp"; }
|
||||
case "←": { return "Left"; }
|
||||
case "→": { return "Right"; }
|
||||
default: { return x; }
|
||||
}
|
||||
});
|
||||
if (rest.length > 1) {
|
||||
options.key = rest[rest.length - 1];
|
||||
options.modifiers = rest.slice(0, -1).join("+");
|
||||
} else {
|
||||
options.key = rest[0];
|
||||
}
|
||||
}
|
||||
options.label = options.label.split("[")[0];
|
||||
}
|
||||
|
||||
if (options.label.indexOf("(&") !== -1) {
|
||||
options.label = options.label.split("(&")[0];
|
||||
}
|
||||
options.label = options.label.replace("&", "").trim();
|
||||
|
||||
switch (options.label) {
|
||||
case "Go to Declaration": { options.label = "转到声明"; break; }
|
||||
case "Go to References": { options.label = "转到引用"; break; }
|
||||
case "Find All References": { options.label = "查找所有引用"; break; }
|
||||
case "Find All Implementations": { options.label = "查找所有实现"; break; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new originMenuItem(options);
|
||||
|
||||
};
|
||||
|
||||
let originAppend = nw.Menu.prototype.append;
|
||||
nw.Menu.prototype.append = function (item) {
|
||||
|
||||
if (item.parentMenu) {
|
||||
item.parentMenu.remove(item);
|
||||
}
|
||||
item.parentMenu = this;
|
||||
|
||||
if ((this.items.length > 0) &&
|
||||
(this.items[this.items.length - 1].type === "separator") &&
|
||||
(item.type === "separator")) {
|
||||
originInsert.call(this, item, this.items.length);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this.items.length === 0) && (item.type === "separator")) {
|
||||
originInsert.call(this, item, this.items.length);
|
||||
return;
|
||||
}
|
||||
|
||||
return originAppend.call(this, item);
|
||||
};
|
||||
|
||||
let originInsert = nw.Menu.prototype.insert;
|
||||
nw.Menu.prototype.insert = function (item, index) {
|
||||
if (item.parentMenu) {
|
||||
item.parentMenu.remove(item);
|
||||
}
|
||||
item.parentMenu = this;
|
||||
return originInsert.call(this, item, index);
|
||||
};
|
||||
{
|
||||
// 修正新窗口数据丢失的问题
|
||||
const originalOpen = nw.Window.open
|
||||
nw.Window.open = function (url, options, callback) {
|
||||
console.warn('[wechat-devtools] nw.Window.open is called, url:', url, 'options:', options);
|
||||
let cb = callback
|
||||
if (options.title === '版本更新提示') {
|
||||
options.inject_js_start = 'js/unpack/hackrequire/index.js';
|
||||
cb = (...args) => {
|
||||
const keys = [
|
||||
"shareData",
|
||||
"windowMap",
|
||||
"isSimple",
|
||||
"masterProxyPort",
|
||||
"proxyPort",
|
||||
"masterH2ProxyPort",
|
||||
"h2ProxyPort"
|
||||
];
|
||||
for(let k of keys)
|
||||
args[0].window.global[k] = global[k];
|
||||
callback(...args)
|
||||
}
|
||||
}
|
||||
else if (options.title === '云开发控制台') {
|
||||
cb = (...args) => {
|
||||
const keys = [
|
||||
"shareData",
|
||||
"windowMap",
|
||||
"isSimple",
|
||||
"masterProxyPort",
|
||||
"proxyPort",
|
||||
"masterH2ProxyPort",
|
||||
"h2ProxyPort",
|
||||
'tokenData',
|
||||
];
|
||||
for(let k of keys)
|
||||
args[0].window.global[k] = global[k];
|
||||
callback(...args)
|
||||
}
|
||||
}
|
||||
else if (options.title.includes('微信开发者工具')) {
|
||||
cb = (...args) => {
|
||||
const keys = [
|
||||
"shareData",
|
||||
"windowMap",
|
||||
"isSimple",
|
||||
"masterProxyPort",
|
||||
"proxyPort",
|
||||
"masterH2ProxyPort",
|
||||
"h2ProxyPort",
|
||||
'tokenData',
|
||||
];
|
||||
for(let k of keys)
|
||||
args[0].window.global[k] = global[k];
|
||||
callback(...args)
|
||||
}
|
||||
}
|
||||
return originalOpen.apply(this, [url, options, cb])
|
||||
}
|
||||
}
|
||||
{
|
||||
// 修正打开外部Terminal的功能
|
||||
const originalExec = require('child_process').exec;
|
||||
require('child_process').exec = function (command, options, callback) {
|
||||
if (command.includes('open -a Terminal')) {
|
||||
command = 'gnome-terminal'
|
||||
}
|
||||
return originalExec.apply(this, [command, options, callback])
|
||||
}
|
||||
}
|
||||
{
|
||||
// 修正 暗色/亮色 自动跟随系统
|
||||
const {spawn, execSync} = require('child_process')
|
||||
let isDark = (function () {
|
||||
try {
|
||||
const { DESKTOP_SESSION } = process.env;
|
||||
console.log(DESKTOP_SESSION);
|
||||
let theme = "";
|
||||
switch (DESKTOP_SESSION) {
|
||||
case "deepin":
|
||||
theme = execSync(
|
||||
`gsettings get com.deepin.dde.appearance gtk-theme`
|
||||
);
|
||||
break;
|
||||
case "gnome":
|
||||
case "gnome-classic":
|
||||
theme = execSync(
|
||||
`gsettings get org.gnome.desktop.interface ${this.gnomeScheme}`
|
||||
);
|
||||
break;
|
||||
|
||||
case "plasma":
|
||||
theme = execSync(
|
||||
`gsettings get org.gnome.desktop.interface color-scheme`,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
console.warn(
|
||||
`NOT SUPPORTED !!! DESKTOP_SESSION: ${DESKTOP_SESSION}`
|
||||
);
|
||||
break;
|
||||
}
|
||||
console.log(theme.toString());
|
||||
return theme.toString().toLowerCase().includes("dark");
|
||||
} catch (error) {
|
||||
console.error("尝试获取主题信息失败,使用默认暗色");
|
||||
return true;
|
||||
}
|
||||
})()
|
||||
const originalMatchMedia = window.matchMedia
|
||||
window.matchMedia = function (...args) {
|
||||
console.warn('----------------> matchMedia:', ...args)
|
||||
const mm = originalMatchMedia.apply(this, args)
|
||||
Object.defineProperty(mm, 'matches', {
|
||||
get(){
|
||||
return isDark
|
||||
}
|
||||
})
|
||||
return mm
|
||||
}
|
||||
class CheckDark {
|
||||
// 监听gsettings monitor org.gnome.desktop.interface gtk-theme
|
||||
monitorTheme(callback) {
|
||||
try {
|
||||
if (this.callback) {
|
||||
this.callback = callback
|
||||
return;
|
||||
}
|
||||
this.callback = callback
|
||||
let monitor = null;
|
||||
const { DESKTOP_SESSION } = process.env;
|
||||
switch (DESKTOP_SESSION) {
|
||||
case "deepin":
|
||||
monitor = spawn("gsettings", [
|
||||
"monitor",
|
||||
"com.deepin.dde.appearance",
|
||||
"gtk-theme",
|
||||
]);
|
||||
break;
|
||||
case "gnome":
|
||||
case "gnome-classic":
|
||||
monitor = spawn("gsettings", [
|
||||
"monitor",
|
||||
"org.gnome.desktop.interface",
|
||||
this.gnomeScheme,
|
||||
]);
|
||||
break;
|
||||
case "plasma":
|
||||
monitor = spawn("gsettings", [
|
||||
"monitor",
|
||||
"org.gnome.desktop.interface",
|
||||
'color-scheme',
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
console.warn(
|
||||
`NOT SUPPORTED !!! DESKTOP_SESSION: ${DESKTOP_SESSION}`
|
||||
);
|
||||
break;
|
||||
}
|
||||
monitor &&
|
||||
monitor.on("error", (err) => {
|
||||
console.error("monitorTheme", err);
|
||||
});
|
||||
monitor &&
|
||||
monitor.stdout.on("data", (chunk) => {
|
||||
const data = chunk.toString();
|
||||
console.warn('Theme changed:', data)
|
||||
isDark = data.toLowerCase().includes("dark");
|
||||
this.callback(isDark)
|
||||
});
|
||||
process.on("SIGTERM", (signal) => {
|
||||
monitor.kill(signal);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("尝试监听主题失败!", err);
|
||||
}
|
||||
}
|
||||
get gnomeScheme() {
|
||||
try {
|
||||
// 判断 Gnome-Shell 版本 from @icepie
|
||||
const gnomeVersion = execSync(`gnome-shell --version`)
|
||||
.toString()
|
||||
.replace(/[\r\n]/g, "")
|
||||
.split(" ");
|
||||
const gnomeVersionNum =
|
||||
gnomeVersion.length == 3 ? Number(gnomeVersion[2]) : 0;
|
||||
return gnomeVersionNum >= 42 ? "color-scheme" : "gtk-theme";
|
||||
} catch (err) {
|
||||
console.error("检查gnome版本失败, 使用gtk-theme", err);
|
||||
return "gtk-theme";
|
||||
}
|
||||
}
|
||||
}
|
||||
const checkDark = new CheckDark()
|
||||
const original = MediaQueryList.prototype.addEventListener
|
||||
MediaQueryList.prototype.addEventListener = function (...args) {
|
||||
console.warn('----------> MediaQueryList.addEventListener:', ...args)
|
||||
checkDark.monitorTheme((isDark) => {
|
||||
args[1]({
|
||||
matches: isDark
|
||||
})
|
||||
})
|
||||
return original.apply(this, args)
|
||||
}
|
||||
}
|
||||
{
|
||||
// 修复云开发控制台
|
||||
const originalBind = Function.prototype.bind
|
||||
Function.prototype.bind = function(...args) {
|
||||
if (args[0]?._tokenMap) {
|
||||
console.warn('---------set tokenData')
|
||||
if (window.tokenData) {
|
||||
args[0]._sessionToken = window.tokenData._sessionToken
|
||||
args[0]._tokenMap = window.tokenData._tokenMap
|
||||
}
|
||||
else
|
||||
window.tokenData = args[0]
|
||||
}
|
||||
return originalBind.apply(this, args)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
process.stderr.write(error.message);
|
||||
process.stderr.write(error.stack);
|
||||
}
|
||||
})();
|
||||
/* patch wechat devtools end */
|
@ -3,7 +3,7 @@ const { execSync, spawn } = require("child_process");
|
||||
|
||||
class CheckDark {
|
||||
// 监听gsettings monitor org.gnome.desktop.interface gtk-theme
|
||||
monitorTheme() {
|
||||
monitorTheme(callback) {
|
||||
try {
|
||||
let monitor = null;
|
||||
const { DESKTOP_SESSION } = process.env;
|
||||
@ -37,11 +37,8 @@ class CheckDark {
|
||||
monitor.stdout.on("data", (chunk) => {
|
||||
// TODO: 防抖动包装
|
||||
const data = chunk.toString();
|
||||
const t = data.toLowerCase().includes("dark");
|
||||
console.log(data);
|
||||
console.log("dark", t);
|
||||
// (this._theme = t ? i.Dark : i.Light),
|
||||
// this._onDidThemeChange.fire(this._theme);
|
||||
const isDark = data.toLowerCase().includes("dark");
|
||||
callback(isDark)
|
||||
});
|
||||
process.on("SIGTERM", (signal) => {
|
||||
monitor.kill(signal);
|
||||
@ -83,7 +80,7 @@ class CheckDark {
|
||||
}
|
||||
get gnomeScheme() {
|
||||
try {
|
||||
// 判断 Gnome-Shell 版本
|
||||
// 判断 Gnome-Shell 版本 from @icepie
|
||||
const gnomeVersion = execSync(`gnome-shell --version`)
|
||||
.toString()
|
||||
.replace(/[\r\n]/g, "")
|
||||
@ -98,7 +95,9 @@ class CheckDark {
|
||||
}
|
||||
}
|
||||
const cd = new CheckDark();
|
||||
cd.monitorTheme();
|
||||
cd.monitorTheme((isDark) => {
|
||||
console.info('is dark:', isDark)
|
||||
});
|
||||
console.log(cd.isDark);
|
||||
|
||||
function original() {
|
||||
|
10
test/wxvpkg-test
Normal file → Executable file
10
test/wxvpkg-test
Normal file → Executable file
@ -4,12 +4,4 @@ root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||
tmp_dir="$root_dir/tmp"
|
||||
|
||||
# unpack 文件 到 路径
|
||||
node "$root_dir/tools/wxvpkg/unpack" "$tmp_dir/core.wxvpkg" "$tmp_dir/core.wxvpkg.ext"
|
||||
|
||||
# pack 路径 到 文件
|
||||
node "$root_dir/tools/wxvpkg/pack" "$tmp_dir/core.wxvpkg.ext" "$tmp_dir/core.wxvpkg.test"
|
||||
|
||||
# unpack 文件 到 路径
|
||||
rm -rf "$tmp_dir/core.wxvpkg.ext1"
|
||||
node "$root_dir/tools/wxvpkg/unpack" "$tmp_dir/core.wxvpkg.test" "$tmp_dir/core.wxvpkg.ext1"
|
||||
|
||||
node "$root_dir/tools/wxvpkg_unpack.js" "/home/msojocs/.config/wechat-devtools/WeappVendor/3.8.5.wxvpkg" "/home/msojocs/.config/wechat-devtools/WeappVendor/3.8.5.wxvpkg.ext"
|
||||
|
@ -11,7 +11,8 @@ fi
|
||||
|
||||
cd "$NW_PACKAGE_DIR"
|
||||
|
||||
sed -i 's#AppData/Local/\${global.userDirName}/User Data/\${global.productHash}/Default#.config/\${global.userDirName}/Default#g' js/common/cli/index.js
|
||||
sed -i 's#USERPROFILE#HOME#g' js/common/cli/index.js
|
||||
sed -i 's#`./\${global.appname}.exe`#`./bin/\${global.appname}`#g' js/common/cli/index.js
|
||||
sed -i 's#,""));const T#,""));_.$0="wechat-devtools-cli";const T#' js/common/cli/index.js
|
||||
cd $root_dir/package.nw/js/common/cli
|
||||
cat $root_dir/res/scripts/cli.js > temp.js
|
||||
cat index.js >> temp.js
|
||||
rm index.js
|
||||
mv temp.js index.js
|
@ -37,61 +37,17 @@ node "$unpack_script" "$package_dir/core.wxvpkg" "$tmp_dir/core.wxvpkg"
|
||||
# |_| \_\_____|_| |_____/_/ \_\____|_____| \____\___/|_| \_\_____|
|
||||
#
|
||||
|
||||
# find
|
||||
open_find_result=$( grep -lr "this.props.onWindowOpenFail());if" "$tmp_dir/core.wxvpkg" )
|
||||
echo "云开发控制台启动点: $open_find_result"
|
||||
if [[ ! -z $open_find_result ]];then
|
||||
# replace
|
||||
new_cb_handle="this.props.onWindowOpenFail());Object.keys(window).forEach(key=>{if(!e.window[key]){try{e.window[key]=window[key];}catch(e){console.error(e);}}});"
|
||||
sed -i "s/this.props.onWindowOpenFail());/$new_cb_handle/g" $open_find_result
|
||||
else
|
||||
warn "云开发控制台启动点未找到"
|
||||
fi
|
||||
|
||||
token_find_result=$( grep -lr "constructor(){this._sessionToken=\"\",this._tokenMap={}}" "$tmp_dir/core.wxvpkg" )
|
||||
echo "WebSocket token存储对象位置: $token_find_result"
|
||||
if [[ ! -z $token_find_result ]];then
|
||||
new_constructor="constructor(){if(window.tokenData){/*有就直接用*/this._sessionToken=window.tokenData._sessionToken;this._tokenMap=window.tokenData._tokenMap;}else{/*没有就新建*/this._sessionToken=\"\",this._tokenMap={};window.tokenData=this;/*新建完要给中间人*/}}"
|
||||
sed -i "s#constructor(){this._sessionToken=\"\",this._tokenMap={}}#$new_constructor#g" "$token_find_result"
|
||||
else
|
||||
warn "WebSocket token存储对象位置未找到"
|
||||
fi
|
||||
|
||||
# open -a Terminal "`pwd`" --> gnome-terminal
|
||||
notice "fix terminal"
|
||||
find_result=$( grep -lr 'open -a Terminal "`pwd`"' "$tmp_dir/core.wxvpkg" )
|
||||
echo "Terminal启动位置: $find_result"
|
||||
if [[ ! -z $find_result ]];then
|
||||
new_str="gnome-terminal"
|
||||
sed -i "s#open -a Terminal \"\`pwd\`\"#$new_str#g" "$find_result"
|
||||
else
|
||||
warn "Terminal启动位置未找到"
|
||||
fi
|
||||
# token_find_result=$( grep -lr "constructor(){this._sessionToken=\"\",this._tokenMap={}}" "$tmp_dir/core.wxvpkg" )
|
||||
# echo "WebSocket token存储对象位置: $token_find_result"
|
||||
# if [[ ! -z $token_find_result ]];then
|
||||
# new_constructor="constructor(){if(window.tokenData){/*有就直接用*/this._sessionToken=window.tokenData._sessionToken;this._tokenMap=window.tokenData._tokenMap;}else{/*没有就新建*/this._sessionToken=\"\",this._tokenMap={};window.tokenData=this;/*新建完要给中间人*/}}"
|
||||
# sed -i "s#constructor(){this._sessionToken=\"\",this._tokenMap={}}#$new_constructor#g" "$token_find_result"
|
||||
# else
|
||||
# warn "WebSocket token存储对象位置未找到"
|
||||
# fi
|
||||
|
||||
# wcc、wcsc处理,设置WINE=fasle环境变量生效
|
||||
if [[ "$WINE" != 'true' ]];then
|
||||
# "wcc.exe":!0,"wcsc.exe":!0
|
||||
find_result=$( grep -lr 'wcc-exec' "$tmp_dir/core.wxvpkg" )
|
||||
echo "wcc: $find_result"
|
||||
if [[ ! -z $find_result ]];then
|
||||
# new_str='{"wcc.bin":!0,"wcsc.bin":!0,wcc:!0,wcsc:!0}'
|
||||
# sed -i "s#{wcc:!0,wcsc:!0}#$new_str#g" "$find_result"
|
||||
# new_str='"linux"===process.platform'
|
||||
# sed -i "s#\"darwin\"===process.platform#$new_str#g" "$find_result"
|
||||
|
||||
# return_exp_wcc=$(cat $find_result | grep -P 'return [a-z]+\("wcc"\)' -o) # return ?("wcc")
|
||||
# return_exp_wcc_replace="${return_exp_wcc//wcc/wcc.bin}" # return ?("wcc.bin")
|
||||
# return_exp_wcc_replace="${return_exp_wcc//return /${return_exp_wcc_replace},}" # return ?("wcc.bin")
|
||||
|
||||
# return_exp_wcsc=$(cat $find_result | grep -P 'return [a-z]+\("wcsc"\)' -o) # return ?("wcsc")
|
||||
# return_exp_wcsc_replace="${return_exp_wcc_replace//wcc/wcsc}"
|
||||
|
||||
sed -i "s#wcc\\.exe#wcc#g" "$find_result"
|
||||
sed -i "s#wcsc\\.exe#wcsc#g" "$find_result"
|
||||
sed -i "s#code/package.nw#package.nw#g" "$find_result"
|
||||
else
|
||||
warn "wcc位置未找到"
|
||||
fi
|
||||
# 处理报错时控制台显示的环境
|
||||
find_result=$( grep -lr '(env:' "$tmp_dir/core.wxvpkg" )
|
||||
echo "env: $find_result"
|
||||
@ -108,30 +64,6 @@ if [[ "$WINE" != 'true' ]];then
|
||||
echo $timeStamp > "${package_dir}/.build_time"
|
||||
fi
|
||||
|
||||
# fix theme
|
||||
notice "fix theme"
|
||||
find_result=$( grep -lr "OSThemeController=" "$tmp_dir/core.wxvpkg" )
|
||||
echo "theme: $find_result"
|
||||
if [[ -n $find_result ]];then
|
||||
# require of child_process
|
||||
sed -i 's/"use strict";O/"use strict";const {execSync,spawn}=require("child_process");O/' $find_result
|
||||
# replace listener to monitor
|
||||
sed -i 's/this.registerListeners()/this.monitorTheme()/' $find_result
|
||||
# replace check func
|
||||
sed -i 's/mediaQuery.matches/isDark/' $find_result
|
||||
# add functions
|
||||
sed -i 's#}getDefaultTheme#}get isDark(){try{const{DESKTOP_SESSION}=process.env;console.log(DESKTOP_SESSION);let theme="";switch(DESKTOP_SESSION){case"deepin":theme=execSync(`gsettings get com.deepin.dde.appearance gtk-theme`);break;case"gnome":case"gnome-classic":theme=execSync(`gsettings get org.gnome.desktop.interface ${this.gnomeScheme}`);break;default:break}return theme.includes("dark");}catch(err){console.error("尝试获取主题信息失败,使用默认暗色",err);return true;}}get gnomeScheme(){try{const gnomeVersion=execSync(`gnome-shell --version`).toString().replace(/[\\r\\n]/g,"").split(" ");const gnomeVersionNum=gnomeVersion.length==3?Number(gnomeVersion[2]):0;return gnomeVersionNum>=42?"color-scheme":"gtk-theme";}catch(err){console.error("检查gnome版本失败, 使用gtk-theme", err);return "gtk-theme";}}monitorTheme(){try{let monitor=null;const{DESKTOP_SESSION}=process.env;switch(DESKTOP_SESSION){case"deepin":monitor=spawn("gsettings",["monitor","com.deepin.dde.appearance","gtk-theme",]);break;case"gnome":case"gnome-classic":monitor=spawn("gsettings",["monitor","org.gnome.desktop.interface",this.gnomeScheme,]);break;default:console.warn(`NOT SUPPORTED!!!DESKTOP_SESSION:${DESKTOP_SESSION}`);break}monitor\&\&monitor.on("error",(err)=>{console.error("monitorTheme",err)});monitor\&\&monitor.stdout.on("data",e.debounce((chunk)=>{const data=chunk.toString();const t=data.toLowerCase().includes("dark");(this._theme=t?i.Dark:i.Light),this._onDidThemeChange.fire(this._theme)},400));process.on("SIGTERM",(signal)=>{monitor.kill(signal);});}catch(err){console.error("尝试监听主题失败!", err);}}getDefaultTheme#' $find_result
|
||||
else
|
||||
warn "theme位置未找到"
|
||||
fi
|
||||
|
||||
# fix update check
|
||||
notice "fix update check"
|
||||
sed -i 's#</body><script src=../js/core#</body><script src="../js/unpack/hackrequire/index.js"></script><script src=../js/core#' "$package_dir/html/whatsnew.html"
|
||||
find_result=$( grep -lr "whatsnew.html" "$tmp_dir/core.wxvpkg" )
|
||||
grep -lr "t=>{R(\"new_version_hint" "$find_result"
|
||||
sed -i 's#t=>{R("new_version_hint#t=>{const keys = ["shareData", "windowMap", "isSimple","masterProxyPort", "proxyPort", "masterH2ProxyPort", "h2ProxyPort"];for(let k of keys)t.window.global[k] = global[k];R("new_version_hint#' $find_result
|
||||
|
||||
# pack 路径 到 文件
|
||||
notice "pack"
|
||||
node "$pack_script" "$tmp_dir/core.wxvpkg" "$package_dir/core.wxvpkg"
|
||||
|
@ -23,110 +23,7 @@ if [ `grep -c "patch wechat devtools begin" $target_file` -ne '0' ];then
|
||||
fi
|
||||
|
||||
tmp_file=$(mktemp)
|
||||
cat > "$tmp_file" <<EOF
|
||||
/* patch wechat devtools begin */
|
||||
/* nw-menu.js */
|
||||
(() => {
|
||||
try {
|
||||
if (typeof nw === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
let log = function (content) {
|
||||
process.stderr.write(content + "\n");
|
||||
};
|
||||
|
||||
let originMenuItem = nw.MenuItem;
|
||||
nw.MenuItem = function MenuItem(options) {
|
||||
|
||||
options = Object.assign({}, options);
|
||||
|
||||
delete options.shortcutName;
|
||||
delete options.shouldEnabled;
|
||||
|
||||
if (options.label && (typeof options.label === "string")) {
|
||||
|
||||
if (options.label.indexOf("[") !== -1) {
|
||||
let rest = options.label.split("[").slice(1).join("[").trim();
|
||||
if (rest[rest.length - 1] === "]") {
|
||||
rest = rest.slice(0, -1).split("+").map((x) => {
|
||||
if (!x) { return "+" }
|
||||
switch (x) {
|
||||
case "↓": { return "Down"; }
|
||||
case "↑": { return "Up"; }
|
||||
case "PAGE↓": { return "PageDown"; }
|
||||
case "PAGE↑": { return "PageUp"; }
|
||||
case "←": { return "Left"; }
|
||||
case "→": { return "Right"; }
|
||||
default: { return x; }
|
||||
}
|
||||
});
|
||||
if (rest.length > 1) {
|
||||
options.key = rest[rest.length - 1];
|
||||
options.modifiers = rest.slice(0, -1).join("+");
|
||||
} else {
|
||||
options.key = rest[0];
|
||||
}
|
||||
}
|
||||
options.label = options.label.split("[")[0];
|
||||
}
|
||||
|
||||
if (options.label.indexOf("(&") !== -1) {
|
||||
options.label = options.label.split("(&")[0];
|
||||
}
|
||||
options.label = options.label.replace("&", "").trim();
|
||||
|
||||
switch (options.label) {
|
||||
case "Go to Declaration": { options.label = "转到声明"; break; }
|
||||
case "Go to References": { options.label = "转到引用"; break; }
|
||||
case "Find All References": { options.label = "查找所有引用"; break; }
|
||||
case "Find All Implementations": { options.label = "查找所有实现"; break; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new originMenuItem(options);
|
||||
|
||||
};
|
||||
|
||||
let originAppend = nw.Menu.prototype.append;
|
||||
nw.Menu.prototype.append = function (item) {
|
||||
|
||||
if (item.parentMenu) {
|
||||
item.parentMenu.remove(item);
|
||||
}
|
||||
item.parentMenu = this;
|
||||
|
||||
if ((this.items.length > 0) &&
|
||||
(this.items[this.items.length - 1].type === "separator") &&
|
||||
(item.type === "separator")) {
|
||||
originInsert.call(this, item, this.items.length);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this.items.length === 0) && (item.type === "separator")) {
|
||||
originInsert.call(this, item, this.items.length);
|
||||
return;
|
||||
}
|
||||
|
||||
return originAppend.call(this, item);
|
||||
};
|
||||
|
||||
let originInsert = nw.Menu.prototype.insert;
|
||||
nw.Menu.prototype.insert = function (item, index) {
|
||||
if (item.parentMenu) {
|
||||
item.parentMenu.remove(item);
|
||||
}
|
||||
item.parentMenu = this;
|
||||
return originInsert.call(this, item, index);
|
||||
};
|
||||
} catch (error) {
|
||||
process.stderr.write(error.message);
|
||||
process.stderr.write(error.stack);
|
||||
}
|
||||
})();
|
||||
/* patch wechat devtools end */
|
||||
EOF
|
||||
cat "$root_dir/res/scripts/hackrequire.js" > "$tmp_file"
|
||||
cat "$target_file" >> "$tmp_file"
|
||||
|
||||
cat "$tmp_file" > "$target_file"
|
||||
|
@ -13,6 +13,8 @@ const parseFile = function (path) {
|
||||
content.name = "wechat-devtools";
|
||||
// 开启调试,更新参数
|
||||
content['chromium-args'] = content['chromium-args'].replace('--disable-devtools', '--mixed-context').replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist')
|
||||
// fix worker #145
|
||||
.replace('--js-flags=--harmony-weak-refs', '--enable-features=SharedArrayBuffer')
|
||||
content.window.height = content.window.width = 1000
|
||||
fs.writeFileSync(path, JSON.stringify(content));
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
# 参数:
|
||||
# 1 ---- NW版本
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
notice() {
|
||||
echo -e "\033[36m $1 \033[0m "
|
||||
|
@ -79,7 +79,7 @@ fi
|
||||
if [ $CURRENT_STEP == $INSTALL_NPM_CONFIG_SUCCESS ];then
|
||||
notice "=====安装node-gyp nw-gyp===="
|
||||
npm uninstall node-gyp -g
|
||||
npm install node-gyp nw-gyp -g
|
||||
npm install node-gyp nw-gyp@3.6.6 -g
|
||||
echo $PATH
|
||||
node-gyp install
|
||||
node-gyp list
|
||||
|
Loading…
x
Reference in New Issue
Block a user