From 0c714896b1975b755976b95b92cca74d66dbb04f Mon Sep 17 00:00:00 2001 From: Kun Chen Date: Sat, 17 Feb 2024 13:44:46 -0800 Subject: [PATCH] v8 snapshot --- .github/workflows/release-app.yml | 12 +- package-lock.json | 408 +++++++++++++++++++++++++++++- package.json | 8 +- scripts/cp-snapshot.js | 69 +++++ scripts/mk-snapshot.js | 73 ++++++ 5 files changed, 561 insertions(+), 9 deletions(-) create mode 100644 scripts/cp-snapshot.js create mode 100644 scripts/mk-snapshot.js diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml index 6268ca6..90342d9 100644 --- a/.github/workflows/release-app.yml +++ b/.github/workflows/release-app.yml @@ -12,11 +12,11 @@ jobs: CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} steps: - name: setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.7 - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup node uses: actions/setup-node@v4 with: @@ -42,11 +42,11 @@ jobs: APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} steps: - name: setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.7 - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup node uses: actions/setup-node@v4 with: @@ -65,11 +65,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.7 - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup node uses: actions/setup-node@v4 with: diff --git a/package-lock.json b/package-lock.json index 84aed6b..427cb92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@terminalone/monorepo", - "version": "1.6.1", + "version": "1.6.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@terminalone/monorepo", - "version": "1.6.1", + "version": "1.6.2", "license": "MIT", "workspaces": [ "packages/*" @@ -22,6 +22,8 @@ "cross-env": "^7.0.3", "electron": "^28.1.3", "electron-builder": "^24.9.1", + "electron-link": "^0.6.0", + "electron-mksnapshot": "^28.2.3", "eslint": "^7.32.0", "prettier": "^2.8.7", "shx": "^0.3.4", @@ -4539,6 +4541,28 @@ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, + "node_modules/abstract-leveldown": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.3.0.tgz", + "integrity": "sha512-TU5nlYgta8YrBMNpc9FwQzRbiXsj49gsALsXadbGHt9CROPzX5fB0rWDR5mtdpOOKa5XqRFpbj1QroPAoPzVjQ==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "immediate": "^3.2.3", + "level-concat-iterator": "~2.0.0", + "level-supports": "~1.0.0", + "xtend": "~4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/abstract-leveldown/node_modules/immediate": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz", + "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==", + "dev": true + }, "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -4998,11 +5022,36 @@ "node": ">=0.8" } }, + "node_modules/ast-types": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.1.tgz", + "integrity": "sha512-pfSiukbt23P1qMhNnsozLzhMLBs7EEeXqPyvPmnuZM+RMfwfqwDbSVKYflgGuVI7/VehR4oMks0igzdNAg4VeQ==", + "dev": true, + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/ast-types-flow": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz", "integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==" }, + "node_modules/ast-util-plus": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ast-util-plus/-/ast-util-plus-0.7.1.tgz", + "integrity": "sha512-j5CjjuBgNUz7lequJ11bboMSOz3WbpUIKDtscmN37bn5WWsxzn7zb3kOCO+jXhvGY9C5IVwssKlG6BA5yqav7w==", + "dev": true, + "dependencies": { + "ast-types": "0.14.1", + "private": "0.1.8" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", @@ -6555,6 +6604,41 @@ "node": ">=10" } }, + "node_modules/deferred-leveldown": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/deferred-leveldown/-/deferred-leveldown-5.3.0.tgz", + "integrity": "sha512-a59VOT+oDy7vtAbLRCZwWgxu2BaCfd5Hk7wxJd48ei7I+nsg8Orlb9CLG0PMZienk9BSUKgeAqkO2+Lw+1+Ukw==", + "dev": true, + "dependencies": { + "abstract-leveldown": "~6.2.1", + "inherits": "^2.0.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/deferred-leveldown/node_modules/abstract-leveldown": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz", + "integrity": "sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "immediate": "^3.2.3", + "level-concat-iterator": "~2.0.0", + "level-supports": "~1.0.0", + "xtend": "~4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/deferred-leveldown/node_modules/immediate": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz", + "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==", + "dev": true + }, "node_modules/define-data-property": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", @@ -6854,6 +6938,95 @@ "unzip-crx-3": "^0.2.0" } }, + "node_modules/electron-link": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/electron-link/-/electron-link-0.6.0.tgz", + "integrity": "sha512-sSxU9c7ABIH8csvAveTwgrG5g7Nbcuh/MBPF5exeWgzd0RLJYNWuD66eMpPRo9/qwqyPc8FJvHRF7EIN5Ylqqg==", + "dev": true, + "dependencies": { + "acorn": "^8.0.4", + "ast-util-plus": "^0.7.1", + "encoding-down": "^6.3.0", + "indent-string": "^4.0.0", + "leveldown": "^5.6.0", + "levelup": "^4.4.0", + "recast": "^0.20.4", + "resolve": "^1.19.0", + "source-map": "^0.7.3" + } + }, + "node_modules/electron-link/node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/electron-link/node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/electron-mksnapshot": { + "version": "28.2.3", + "resolved": "https://registry.npmjs.org/electron-mksnapshot/-/electron-mksnapshot-28.2.3.tgz", + "integrity": "sha512-W8iMSIJZE0K0KqMyV2WxZyB5Mc3ZQb6bzfhuuHG6AIWhWuFgt9YPz0I3awamE93V8QmVBQfrD1cFIwbnPsCQvw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@electron/get": "^2.0.1", + "extract-zip": "^2.0.0", + "fs-extra": "^7.0.1", + "temp": "^0.8.3" + }, + "bin": { + "mksnapshot": "mksnapshot.js" + }, + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/electron-mksnapshot/node_modules/fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/electron-mksnapshot/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/electron-mksnapshot/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/electron-publish": { "version": "24.8.1", "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-24.8.1.tgz", @@ -6969,6 +7142,21 @@ "iconv-lite": "^0.6.2" } }, + "node_modules/encoding-down": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/encoding-down/-/encoding-down-6.3.0.tgz", + "integrity": "sha512-QKrV0iKR6MZVJV08QY0wp1e7vF6QbhnbQhb07bwpEyuz4uZiZgPlEGdkCROuFkUwdxlFaiPIhjyarH1ee/3vhw==", + "dev": true, + "dependencies": { + "abstract-leveldown": "^6.2.1", + "inherits": "^2.0.3", + "level-codec": "^9.0.0", + "level-errors": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -7039,6 +7227,18 @@ "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", "dev": true }, + "node_modules/errno": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", + "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", + "dev": true, + "dependencies": { + "prr": "~1.0.1" + }, + "bin": { + "errno": "cli.js" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -10864,6 +11064,118 @@ "node": ">=8" } }, + "node_modules/level-codec": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-9.0.2.tgz", + "integrity": "sha512-UyIwNb1lJBChJnGfjmO0OR+ezh2iVu1Kas3nvBS/BzGnx79dv6g7unpKIDNPMhfdTEGoc7mC8uAu51XEtX+FHQ==", + "dev": true, + "dependencies": { + "buffer": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/level-concat-iterator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/level-concat-iterator/-/level-concat-iterator-2.0.1.tgz", + "integrity": "sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/level-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-2.0.1.tgz", + "integrity": "sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw==", + "dev": true, + "dependencies": { + "errno": "~0.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/level-iterator-stream": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-4.0.2.tgz", + "integrity": "sha512-ZSthfEqzGSOMWoUGhTXdX9jv26d32XJuHz/5YnuHZzH6wldfWMOVwI9TBtKcya4BKTyTt3XVA0A3cF3q5CY30Q==", + "dev": true, + "dependencies": { + "inherits": "^2.0.4", + "readable-stream": "^3.4.0", + "xtend": "^4.0.2" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/level-supports": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-1.0.1.tgz", + "integrity": "sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg==", + "dev": true, + "dependencies": { + "xtend": "^4.0.2" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/leveldown": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-5.6.0.tgz", + "integrity": "sha512-iB8O/7Db9lPaITU1aA2txU/cBEXAt4vWwKQRrrWuS6XDgbP4QZGj9BL2aNbwb002atoQ/lIotJkfyzz+ygQnUQ==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "abstract-leveldown": "~6.2.1", + "napi-macros": "~2.0.0", + "node-gyp-build": "~4.1.0" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/leveldown/node_modules/abstract-leveldown": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz", + "integrity": "sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "immediate": "^3.2.3", + "level-concat-iterator": "~2.0.0", + "level-supports": "~1.0.0", + "xtend": "~4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/leveldown/node_modules/immediate": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz", + "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==", + "dev": true + }, + "node_modules/levelup": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/levelup/-/levelup-4.4.0.tgz", + "integrity": "sha512-94++VFO3qN95cM/d6eBXvd894oJE0w3cInq9USsyQzzoJxmiYzPAocNcuGCPGGjoXqDVJcr3C1jzt1TSjyaiLQ==", + "dev": true, + "dependencies": { + "deferred-leveldown": "~5.3.0", + "level-errors": "~2.0.0", + "level-iterator-stream": "~4.0.0", + "level-supports": "~1.0.0", + "xtend": "~4.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -11394,6 +11706,12 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/napi-macros": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", + "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==", + "dev": true + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -11575,6 +11893,17 @@ "node": "^12.13 || ^14.13 || >=16" } }, + "node_modules/node-gyp-build": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz", + "integrity": "sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==", + "dev": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -12364,6 +12693,15 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -12430,6 +12768,12 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "dev": true }, + "node_modules/prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", + "dev": true + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", @@ -12611,6 +12955,33 @@ "node": ">=8.10.0" } }, + "node_modules/recast": { + "version": "0.20.5", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.20.5.tgz", + "integrity": "sha512-E5qICoPoNL4yU0H0NoBDntNB0Q5oMSNh9usFctYniLBluTthi3RsQVBXIJNbApOlvSwW/RGxIuokPcAc59J5fQ==", + "dev": true, + "dependencies": { + "ast-types": "0.14.2", + "esprima": "~4.0.0", + "source-map": "~0.6.1", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/recast/node_modules/ast-types": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.2.tgz", + "integrity": "sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==", + "dev": true, + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", @@ -13950,6 +14321,18 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/temp": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.4.tgz", + "integrity": "sha512-s0ZZzd0BzYv5tLSptZooSjK8oj6C+c19p7Vqta9+6NPOf7r+fxq0cJe6/oN4LTC79sy5NY8ucOJNgwsKCSbfqg==", + "dev": true, + "dependencies": { + "rimraf": "~2.6.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/temp-file": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/temp-file/-/temp-file-3.4.0.tgz", @@ -13960,6 +14343,18 @@ "fs-extra": "^10.0.0" } }, + "node_modules/temp/node_modules/rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, "node_modules/terser": { "version": "5.26.0", "resolved": "https://registry.npmjs.org/terser/-/terser-5.26.0.tgz", @@ -15271,6 +15666,15 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, "node_modules/xterm": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/xterm/-/xterm-5.3.0.tgz", diff --git a/package.json b/package.json index 733d482..3e4c741 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,11 @@ "lint:fix": "turbo run lint:fix", "test": "turbo run test", "rebuild:node-pty": "electron-rebuild -f -o node-pty -m packages/app", - "prepare": "node -e \"process.env.NODE_ENV != 'production' && process.exit(1)\" || electron-builder install-app-deps && npm run rebuild:node-pty" + "prepare": "node -e \"process.env.NODE_ENV != 'production' && process.exit(1)\" || npm run v8-snapshot && electron-builder install-app-deps && npm run rebuild:node-pty", + "v8-snapshot": "cross-env npm_config_arch=x64 npm run v8-snapshot:arch && cross-env npm_config_arch=arm64 npm run v8-snapshot:arch", + "v8-snapshot:arch": "npm run mk-snapshot && npm run cp-snapshot", + "mk-snapshot": "cross-env ELECTRON_CUSTOM_VERSION=$npm_package_devDependencies_electron node node_modules/electron-mksnapshot/download-mksnapshot.js && node scripts/mk-snapshot.js", + "cp-snapshot": "node scripts/cp-snapshot.js" }, "main": "packages/app/dist/main.bundle.js", "build": { @@ -82,6 +86,8 @@ "cross-env": "^7.0.3", "electron": "^28.1.3", "electron-builder": "^24.9.1", + "electron-link": "^0.6.0", + "electron-mksnapshot": "^28.2.3", "eslint": "^7.32.0", "prettier": "^2.8.7", "shx": "^0.3.4", diff --git a/scripts/cp-snapshot.js b/scripts/cp-snapshot.js new file mode 100644 index 0000000..e4fac8d --- /dev/null +++ b/scripts/cp-snapshot.js @@ -0,0 +1,69 @@ +/* eslint-disable turbo/no-undeclared-env-vars */ +/* eslint-disable @typescript-eslint/no-var-requires */ +const path = require('path'); +const fs = require('fs'); +const { Arch } = require('electron-builder'); + +function copySnapshot(pathToElectron, archToCopy) { + const snapshotFileName = 'snapshot_blob.bin'; + const v8ContextFileName = getV8ContextFileName(archToCopy); + const pathToBlob = path.resolve( + __dirname, + '..', + 'cache', + archToCopy, + snapshotFileName, + ); + const pathToBlobV8 = path.resolve( + __dirname, + '..', + 'cache', + archToCopy, + v8ContextFileName, + ); + + console.log('Copying v8 snapshots from', pathToBlob, 'to', pathToElectron); + fs.copyFileSync(pathToBlob, path.join(pathToElectron, snapshotFileName)); + fs.copyFileSync(pathToBlobV8, path.join(pathToElectron, v8ContextFileName)); +} + +function getPathToElectron() { + switch (process.platform) { + case 'darwin': + return path.resolve( + __dirname, + '..', + 'node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources', + ); + case 'win32': + case 'linux': + return path.resolve(__dirname, '..', 'node_modules', 'electron', 'dist'); + } +} + +function getV8ContextFileName(archToCopy) { + if (process.platform === 'darwin') { + return `v8_context_snapshot${ + archToCopy === 'arm64' ? '.arm64' : '.x86_64' + }.bin`; + } else { + return `v8_context_snapshot.bin`; + } +} + +exports.default = async (context) => { + const archToCopy = Arch[context.arch]; + const pathToElectron = + process.platform === 'darwin' + ? `${context.appOutDir}/Hyper.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources` + : context.appOutDir; + copySnapshot(pathToElectron, archToCopy); +}; + +if (require.main === module) { + const archToCopy = process.env.npm_config_arch; + const pathToElectron = getPathToElectron(); + if ((process.arch.startsWith('arm') ? 'arm64' : 'x64') === archToCopy) { + copySnapshot(pathToElectron, archToCopy); + } +} diff --git a/scripts/mk-snapshot.js b/scripts/mk-snapshot.js new file mode 100644 index 0000000..bda3598 --- /dev/null +++ b/scripts/mk-snapshot.js @@ -0,0 +1,73 @@ +/* eslint-disable turbo/no-undeclared-env-vars */ +/* eslint-disable no-prototype-builtins */ +/* eslint-disable @typescript-eslint/no-var-requires */ +const childProcess = require('child_process'); +const vm = require('vm'); +const path = require('path'); +const fs = require('fs'); +const electronLink = require('electron-link'); +const { mkdirp } = require('fs-extra'); + +const excludedModules = {}; + +const crossArchDirs = [ + 'clang_x86_v8_arm', + 'clang_x64_v8_arm64', + 'win_clang_x64', +]; + +async function main() { + const baseDirPath = path.resolve(__dirname, '..'); + + console.log('Creating a linked script..'); + const result = await electronLink({ + baseDirPath: baseDirPath, + mainPath: `${__dirname}/snapshot-libs.js`, + cachePath: `${baseDirPath}/cache`, + // eslint-disable-next-line no-prototype-builtins + shouldExcludeModule: (modulePath) => + excludedModules.hasOwnProperty(modulePath), + }); + + const snapshotScriptPath = `${baseDirPath}/cache/snapshot-libs.js`; + fs.writeFileSync(snapshotScriptPath, result.snapshotScript); + + // Verify if we will be able to use this in `mksnapshot` + vm.runInNewContext(result.snapshotScript, undefined, { + filename: snapshotScriptPath, + displayErrors: true, + }); + + const outputBlobPath = `${baseDirPath}/cache/${process.env.npm_config_arch}`; + await mkdirp(outputBlobPath); + + if (process.platform !== 'darwin') { + const mksnapshotBinPath = `${baseDirPath}/node_modules/electron-mksnapshot/bin`; + const matchingDirs = crossArchDirs + .map((dir) => `${mksnapshotBinPath}/${dir}`) + .filter((dir) => fs.existsSync(dir)); + for (const dir of matchingDirs) { + if (fs.existsSync(`${mksnapshotBinPath}/gen/v8/embedded.S`)) { + await mkdirp(`${dir}/gen/v8`); + fs.copyFileSync( + `${mksnapshotBinPath}/gen/v8/embedded.S`, + `${dir}/gen/v8/embedded.S`, + ); + } + } + } + + console.log(`Generating startup blob in "${outputBlobPath}"`); + childProcess.execFileSync( + path.resolve( + __dirname, + '..', + 'node_modules', + '.bin', + 'mksnapshot' + (process.platform === 'win32' ? '.cmd' : ''), + ), + [snapshotScriptPath, '--output_dir', outputBlobPath], + ); +} + +main().catch((err) => console.error(err));