This commit is contained in:
msojocs 2022-01-25 00:02:19 +08:00
parent 6be4cb5883
commit 63136b510f
9 changed files with 137 additions and 21 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@ node/
package.nw/
cache/
tmp/
mew/
node_modules

View File

@ -12,7 +12,7 @@ cd $DIR/..
export WECHAT_DEVTOOLS_DIR="$DIR/../nwjs"
export APPDATA="$( echo ~ )/.config/wechat_devtools"
export PATH="$DIR/../node/bin:$DIR/../nwjs:$PATH"
export PATH="$DIR/../wine:$DIR/../node/bin:$DIR/../nwjs:$PATH"
# LANG=zh_CN.UTF-8 exec "$DIR"/../nwjs/nw --load-extension="$DIR"/../nwjs/package.nw/js/ideplugin "$@"
@ -22,5 +22,6 @@ INSPECTOR1="--custom-devtools-frontend=$DIR/../nwjs/package.nw/js/ideplugin/insp
INSPECTOR2="--custom-devtools-frontend=$( echo ~ )/.config/wechat_devtools/WeappPlugin/inspector"
USERDATADIR="$( echo ~ )/.config/wechat_devtools"
# "$@"参数
LANG=zh_CN.UTF-8
exec "$DIR"/../nwjs/nw $EXTENSION2 $INSPECTOR2 --user-data-dir=$USERDATADIR "$@" --app-session-id=XzpLGIehps
exec "$DIR"/../nwjs/nw $DIR/../package.nw $EXTENSION2 $INSPECTOR2 --user-data-dir=$USERDATADIR "$@" --app-session-id=XzpLGIehps

View File

@ -51,3 +51,4 @@
猜想也许可以在0.49.2版本基础上将这个fix操作回滚形成0.49.3版本
Fix: Window opened with new_instance creates always mixed context
https://github.com/nwjs/nw.js/blob/nw60/CHANGELOG.md#0471--07-24-2020
似乎出现过https://github.com/nwjs/nw.js/issues/7609

36
docs/log.log Normal file
View File

@ -0,0 +1,36 @@
window.parent.$messager
$messager: Messenger
tryTime: 0
_callback: (16) [ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ, ƒ]
_msgQueue: []
_needToken: true
_protocol: "APPSERVICEDEVTOOLS"
_ws: WebSocket
binaryType: "blob"
bufferedAmount: 0
extensions: ""
onclose: t=> {…}
onerror: null
onmessage: t=> {…}
onopen: t=> {…}
protocol: "APPSERVICEDEVTOOLS#ddeb6731d63c79e3b5b91c0f99ebc5da#"
readyState: 1
url: "ws://127.0.0.1:47138/"
__proto__: WebSocket
__proto__: Object
location.href
chrome-extension://mbeenbnhnmdhkbicabncjghgnikfbgjh/html/index.html?appid=wxfa2ea65288e28233&projectpath=D%3A%5CProject%5CWeCuit-Project%5CWeCuit-Mini-uni-test_uni_vue-cli%5Cdist%5Cdev%5Cmp-weixin&projectname=mp-weixin&projectid=D%3A%5CProject%5CWeCuit-Project%5CWeCuit-Mini-uni-test_uni_vue-cli%5Cdist%5Cdev%5Cmp-weixin&parentid=&runtimeid=0&isTemp=&isOnline=&theme=dark&bgwsurl=ws%3A%2F%2F127.0.0.1%3A23740&bgwstoken=9f53cf0d5af65d07603b418b2360ca5f&autoPort=&testTicket=&skeletonPath=C%3A%5CUsers%5Cjiyec%5CAppData%5CLocal%5C%E5%BE%AE%E4%BF%A1%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7%5CUser%20Data%5Cf13f1c30f325514de496c9db6e27b110%5CWeappCache%5CskeletonCache%5Cdf11d8701a010a8b2a2b0d14471e492b%2Fpageskeleton.html&openedFile=&masterH2ProxyPort=&masterProxyPort=&masterUAToken=&openidMD5=&devtype=miniprogram&frame=0&devid=16d80095a3bb2637b9444afa985c63b3
修改devtools_app.html
点击“调试调试器”
调试器源代码有相应变化
nw.js v0.49.3
Node v15.0.1
Chromium 86.0.4240.111
commit hash: e587598-d7277f7-d507c96-bbb240e
NW.JS
并未出现“devtools is not loaded properly“

59
tools/pack Normal file
View File

@ -0,0 +1,59 @@
// https://gist.github.com/chemzqm/9f2334ca201dc2fbc363fdd757aa2ed4
const path = require('path')
const fs = require('fs')
const { execSync } = require('child_process')
let file = path.resolve(__dirname, '../package.nw/core.wxvpkg')
console.log(file)
if (fs.existsSync(file)) {
execSync(`rm -rf ${file}`)
}
let fd = fs.openSync(file, 'w')
let dest = path.join(__dirname, '../package.nw/core.wxvpkg.ext')
function writeSync(buf, start) {
fs.writeSync(fd, buf, 0, buf.length, start)
}
function writeInt32(number, start) {
let buf = Buffer.alloc(4)
buf.writeInt32BE(number, 0)
writeSync(buf, start)
}
let files = fs.readdirSync(dest)
let totalCount = files.length
let buf = Buffer.alloc(4)
buf.writeInt32BE(totalCount, 0)
writeSync(buf, 14)
let start = 18
// 12 + /name.length
let dataOffset = start
for (let file of files) {
let name = `/${file}`
let buf = Buffer.from(name, 'utf8')
dataOffset = dataOffset + 12 + buf.length
}
for (let file of files) {
let nb = Buffer.from(`/${file}`, 'utf8')
// write filename byte length
writeInt32(nb.length, start)
start += 4
// write filename
writeSync(nb, start)
start += nb.length
// write offset
writeInt32(dataOffset, start)
start += 4
// write length
let contentBuf = fs.readFileSync(path.join(dest, file))
writeInt32(contentBuf.length, start)
start += 4
// write content
writeSync(contentBuf, dataOffset)
dataOffset += contentBuf.length
}
fs.closeSync(fd)

View File

@ -11,8 +11,8 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
package_dir="$DIR/../package.nw"
export PATH=$DIR/../node/bin:$PATH
# npm config list
npm --version
node --version
rm -fr "${package_dir}/node_modules/vscode-windows-ca-certs" # the module is only available in windows
rm -fr "${package_dir}/node_modules/vscode-windows-registry" # the module is only available in windows

View File

@ -1,14 +1,31 @@
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const path = require("path")
const fs = require("fs")
const {execSync} = require('child_process')
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/package.nw"))) {
// 链接
fs.symlinkSync(
path.resolve(__dirname, "../package.nw"),
path.resolve(__dirname, "../nwjs/package.nw")
);
}
const workDir = path.resolve(__dirname, "../package.nw")
if(fs.existsSync(`${workDir}/core.wxvpkg`) && fs.stat(`${workDir}/core.wxvpkg`))
fs.renameSync(`${workDir}/core.wxvpkg`, `${workDir}/core.wxvpkg1`)
if(!fs.existsSync(`${workDir}/core.wxvpkg1`)){
console.error('错误')
exit(-1)
}
console.log(`unwxapkg ${workDir}/core.wxvpkg1 ${workDir}/core.wxvpkg.ext`)
execSync(`cd ${workDir} && unwxapkg core.wxvpkg1 core.wxvpkg.ext`)
const search = execSync(`grep -lr "new_instance" ${workDir}/core.wxvpkg.ext`)
console.log(search.toString())
const filepath = search.toString();
execSync(`sed -i 's/"new_instance",/"new_instance","mixed_context",/g' ${filepath}`)
execSync(`sed -i 's/o.new_instance=!0,/o.new_instance=!0,o.mixed_context=!0,/g' ${filepath}`)
execSync(`node ${path.resolve(__dirname, "pack")}`)
// # cd ../package.nw
// # mv core.wxvpkg core.wxvpkg.1
// # unwxapkg core.wxvpkg.1 core.wxvpkg1
// # 添加mixed_context
// # 打包
// # unwxapkg node_modules.wxvpkg node_modules
// # mixed_context

View File

@ -28,8 +28,8 @@ const download = function () {
return;
}
info(`Downloading ${url}`);
spawn("wget", ["c", url, "O", `${localPath}.tmp`], {
console.info(`Downloading ${url} ---> ${localPath}`);
spawn("wget", ["-c", url, "-O", `${localPath}.tmp`], {
stdio: "inherit",
}).on("close", (code) => {
fs.renameSync(`${localPath}.tmp`, localPath);
@ -74,13 +74,13 @@ const upgrade = function (extractPath) {
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node"))) {
fs.linkSync(
"../node/bin/node",
fs.symlinkSync(
path.resolve(__dirname, "../node/bin/node"),
path.resolve(__dirname, "../nwjs/node")
);
}
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node.exe"))) {
fs.linkSync(
fs.symlinkSync(
"node",
path.resolve(__dirname, "../nwjs/node.exe")
);

View File

@ -94,7 +94,7 @@ const upgrade = function (extractPath) {
fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node.exe"));
}
if (fs.existsSync(path.resolve(__dirname, "../package.nw"))) {
fs.linkSync(path.resolve(__dirname, "../package.nw"), path.resolve(__dirname, "../nwjs/package.nw"));
fs.symlinkSync(path.resolve(__dirname, "../package.nw"), path.resolve(__dirname, "../nwjs/package.nw"));
}
resolve();