From 59f9e54776abe4665a3397feb71005dda96b7383 Mon Sep 17 00:00:00 2001 From: sawka Date: Mon, 16 Oct 2023 15:14:24 -0700 Subject: [PATCH 01/10] remove scripts from package.json (using scripthaus) --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index a065239d..3fde0194 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,5 @@ "webpack-merge": "^5.8.0" }, "scripts": { - "start": "electron-forge start", - "package": "electron-forge package", - "make": "electron-forge make" } } From 90e098e65a7f8e6d9adb4bbdeda61af1a22ecafa Mon Sep 17 00:00:00 2001 From: sawka Date: Mon, 16 Oct 2023 15:21:21 -0700 Subject: [PATCH 02/10] add notice and license in package.json --- NOTICE | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 NOTICE diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..ceb4d036 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +Copyright 2023, Command Line Inc. diff --git a/package.json b/package.json index 3fde0194..a8689c88 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "Prompt", "version": "0.4.0", "main": "dist/emain.js", - "license": "Proprietary", + "license": "Apache-2.0", "dependencies": { "@monaco-editor/react": "^4.5.1", "@tanstack/match-sorter-utils": "^8.8.4", From cad052667887ee64c2b8564d5c4c453f099a9b1f Mon Sep 17 00:00:00 2001 From: sawka Date: Mon, 16 Oct 2023 15:22:41 -0700 Subject: [PATCH 03/10] Add Apache 2.0 License --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From f2eaa2e278ca2d27ae5440c1495c0ec2341210ab Mon Sep 17 00:00:00 2001 From: sawka Date: Mon, 16 Oct 2023 15:33:07 -0700 Subject: [PATCH 04/10] add example copyright to index.ts --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 7f205343..f933174c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,6 @@ +// Copyright 2023, Command Line Inc. +// SPDX-License-Identifier: Apache-2.0 + import * as mobx from "mobx"; import * as React from "react"; import { createRoot } from "react-dom/client"; From e920e09ccfc89f33a6b142a016f1bde2ab0a3343 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 17 Oct 2023 21:54:44 -0700 Subject: [PATCH 05/10] backport linux changes to main --- src/electron/emain.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/electron/emain.ts b/src/electron/emain.ts index cbc6d7fd..7348071a 100644 --- a/src/electron/emain.ts +++ b/src/electron/emain.ts @@ -294,11 +294,11 @@ function createMainWindow(clientData) { win.webContents.on("will-navigate", shNavHandler); win.webContents.on("will-frame-navigate", shFrameNavHandler); win.on( - "resized", + "resize", debounce(400, (e) => mainResizeHandler(e, win)) ); win.on( - "moved", + "move", debounce(400, (e) => mainResizeHandler(e, win)) ); win.on("focus", () => { @@ -350,7 +350,7 @@ function mainResizeHandler(e, win) { function calcBounds(clientData) { let primaryDisplay = electron.screen.getPrimaryDisplay(); let pdBounds = primaryDisplay.bounds; - let size = { x: 50, y: 50, width: pdBounds.width - 150, height: pdBounds.height - 150 }; + let size = { x: 100, y: 100, width: pdBounds.width - 200, height: pdBounds.height - 200 }; if (clientData != null && clientData.winsize != null && clientData.winsize.width > 0) { let cwinSize = clientData.winsize; if (cwinSize.width > 0) { From 4e98db9745052f15b3f821125e12e8357cc8270d Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 18 Oct 2023 05:54:07 +0000 Subject: [PATCH 06/10] add linux support for maker-zip --- forge.config.js | 14 +------------- package.json | 4 ++-- scripthaus.md | 17 +++++++++++++++++ yarn.lock | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 15 deletions(-) diff --git a/forge.config.js b/forge.config.js index 30e0e712..83b60401 100644 --- a/forge.config.js +++ b/forge.config.js @@ -74,21 +74,9 @@ module.exports = { }, rebuildConfig: {}, makers: [ - { - name: "@electron-forge/maker-squirrel", - config: {}, - }, { name: "@electron-forge/maker-zip", - platforms: ["darwin"], - }, - { - name: "@electron-forge/maker-deb", - config: {}, - }, - { - name: "@electron-forge/maker-rpm", - config: {}, + platforms: ["darwin", "linux"], }, ], }; diff --git a/package.json b/package.json index a8689c88..9c4f590a 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@electron-forge/cli": "^6.0.0-beta.70", "@electron-forge/maker-deb": "^6.0.0-beta.70", "@electron-forge/maker-rpm": "^6.0.0-beta.70", + "@electron-forge/maker-snap": "^6.4.2", "@electron-forge/maker-squirrel": "^6.0.0-beta.70", "@electron-forge/maker-zip": "^6.0.0-beta.70", "@svgr/webpack": "^8.1.0", @@ -77,6 +78,5 @@ "webpack-dev-server": "^4.9.1", "webpack-merge": "^5.8.0" }, - "scripts": { - } + "scripts": {} } diff --git a/scripthaus.md b/scripthaus.md index 9d1b52d0..5d3245ab 100644 --- a/scripthaus.md +++ b/scripthaus.md @@ -91,6 +91,23 @@ lipo -create -output bin/wavesrv build/wavesrv.amd64 build/wavesrv.arm64 node_modules/.bin/electron-forge make ``` +```bash +# @scripthaus command build-package-linux +# @scripthaus cd :playbook +rm -rf dist/ +rm -rf bin/ +rm -rf build/ +node_modules/.bin/webpack --config webpack.prod.js +node_modules/.bin/webpack --config webpack.electron.prod.js +GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')" +(cd waveshell; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.amd64 main-waveshell.go) +(cd waveshell; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.arm64 main-waveshell.go) +(cd waveshell; GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-linux.amd64 main-waveshell.go) +(cd waveshell; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-linux.arm64 main-waveshell.go) +(cd wavesrv; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/wavesrv ./cmd) +node_modules/.bin/electron-forge make +``` + ```bash # @scripthaus command open-electron-package # @scripthaus cd :playbook diff --git a/yarn.lock b/yarn.lock index 120d47c9..129fe9ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1217,6 +1217,16 @@ optionalDependencies: electron-installer-redhat "^3.2.0" +"@electron-forge/maker-snap@^6.4.2": + version "6.4.2" + resolved "https://registry.yarnpkg.com/@electron-forge/maker-snap/-/maker-snap-6.4.2.tgz#6a87e92ee07d460e91697064e0d8369c55114aba" + integrity sha512-07ge28xLdcUpLQFu9POuNuaR8rWjU3c9r2PX8dMrvgAi00DooVaLuZFF7DIOPRDxFO5JfX1BwgzjO7KZhMA3og== + dependencies: + "@electron-forge/maker-base" "6.4.2" + "@electron-forge/shared-types" "6.4.2" + optionalDependencies: + electron-installer-snap "^5.2.0" + "@electron-forge/maker-squirrel@^6.0.0-beta.70": version "6.4.2" resolved "https://registry.yarnpkg.com/@electron-forge/maker-squirrel/-/maker-squirrel-6.4.2.tgz#92d44fc6cadf6ff23c65dc901c8044d7c8b53f95" @@ -2264,6 +2274,13 @@ are-we-there-yet@^3.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + argparse@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" @@ -3277,6 +3294,22 @@ electron-installer-redhat@^3.2.0: word-wrap "^1.2.3" yargs "^16.0.2" +electron-installer-snap@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/electron-installer-snap/-/electron-installer-snap-5.2.0.tgz#8dd637dc94d4279d790d728b7bdb23fe9415377d" + integrity sha512-SRm7pCpNHMXV545JjScV8fLC9NhFli5r8L8Ju4EHdXwRh76+mwrJoUEDLItixBudZ5Mcgz1SJcDPJfWpEQWX7Q== + dependencies: + "@malept/cross-spawn-promise" "^1.0.0" + debug "^4.3.4" + electron-installer-common "^0.10.2" + fs-extra "^9.0.0" + js-yaml "^3.10.0" + lodash "^4.17.15" + semver "^7.1.1" + tmp-promise "^3.0.2" + which "^2.0.1" + yargs "^16.0.2" + electron-packager@^17.1.2: version "17.1.2" resolved "https://registry.yarnpkg.com/electron-packager/-/electron-packager-17.1.2.tgz#18030b28024d242b706d0a8a67ed4cd1a57311aa" @@ -3478,6 +3511,11 @@ eslint-scope@5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + esrecurse@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" @@ -4609,6 +4647,14 @@ jest-worker@^27.4.5: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +js-yaml@^3.10.0: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" @@ -7145,6 +7191,11 @@ sprintf-js@^1.1.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + ssri@^10.0.0: version "10.0.5" resolved "https://registry.yarnpkg.com/ssri/-/ssri-10.0.5.tgz#e49efcd6e36385196cb515d3a2ad6c3f0265ef8c" From b01472a91747ce6fbec3c5cdffc9df1c57dbce5d Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 18 Oct 2023 13:32:23 -0700 Subject: [PATCH 07/10] add platform class into main div --- scripthaus.md | 8 ++++---- src/app/app.tsx | 5 +++-- src/electron/emain.ts | 7 ++++++- src/electron/preload.js | 1 + src/model/model.ts | 10 ++++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/scripthaus.md b/scripthaus.md index 5d3245ab..ec914988 100644 --- a/scripthaus.md +++ b/scripthaus.md @@ -81,10 +81,10 @@ rm -rf build/ node_modules/.bin/webpack --config webpack.prod.js node_modules/.bin/webpack --config webpack.electron.prod.js GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')" -(cd ../apishell; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-darwin.amd64 main-mshell.go) -(cd ../apishell; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-darwin.arm64 main-mshell.go) -(cd ../apishell; GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-linux.amd64 main-mshell.go) -(cd ../apishell; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-linux.arm64 main-mshell.go) +(cd waveshell; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.amd64 main-waveshell.go) +(cd waveshell; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.arm64 main-waveshell.go) +(cd waveshell; GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-linux.amd64 main-waveshell.go) +(cd waveshell; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-linux.arm64 main-waveshell.go) (cd wavesrv; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../build/wavesrv.amd64 ./cmd) (cd wavesrv; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../build/wavesrv.arm64 ./cmd) lipo -create -output bin/wavesrv build/wavesrv.amd64 build/wavesrv.arm64 diff --git a/src/app/app.tsx b/src/app/app.tsx index 59d2fe73..b15daf7a 100644 --- a/src/app/app.tsx +++ b/src/app/app.tsx @@ -78,12 +78,13 @@ class App extends React.Component<{}, {}> { let disconnected = !GlobalModel.ws.open.get() || !GlobalModel.waveSrvRunning.get(); let hasClientStop = GlobalModel.getHasClientStop(); let dcWait = this.dcWait.get(); + let platform = GlobalModel.getPlatform(); if (disconnected || hasClientStop) { if (!dcWait) { setTimeout(() => this.updateDcWait(true), 1500); } return ( -
+
@@ -103,7 +104,7 @@ class App extends React.Component<{}, {}> { setTimeout(() => this.updateDcWait(false), 0); } return ( -
+
diff --git a/src/electron/emain.ts b/src/electron/emain.ts index 7348071a..6e7a6d7a 100644 --- a/src/electron/emain.ts +++ b/src/electron/emain.ts @@ -388,7 +388,7 @@ function calcBounds(clientData) { } app.on("window-all-closed", () => { - if (process.platform !== "darwin") app.quit(); + if (unamePlatform !== "darwin") app.quit(); }); electron.ipcMain.on("get-id", (event) => { @@ -396,6 +396,11 @@ electron.ipcMain.on("get-id", (event) => { return; }); +electron.ipcMain.on("get-platform", (event) => { + event.returnValue = unamePlatform; + return; +}); + electron.ipcMain.on("get-isdev", (event) => { event.returnValue = isDev; return; diff --git a/src/electron/preload.js b/src/electron/preload.js index 503db912..701d7ee3 100644 --- a/src/electron/preload.js +++ b/src/electron/preload.js @@ -2,6 +2,7 @@ let { contextBridge, ipcRenderer } = require("electron"); contextBridge.exposeInMainWorld("api", { getId: () => ipcRenderer.sendSync("get-id"), + getPlatform: () => ipcRenderer.sendSync("get-platform"), getIsDev: () => ipcRenderer.sendSync("get-isdev"), getAuthKey: () => ipcRenderer.sendSync("get-authkey"), getWaveSrvStatus: () => ipcRenderer.sendSync("wavesrv-status"), diff --git a/src/model/model.ts b/src/model/model.ts index fba2718e..3129a92c 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -165,6 +165,7 @@ type KeyModsType = { type ElectronApi = { getId: () => string; getIsDev: () => boolean; + getPlatform: () => string; getAuthKey: () => string; getWaveSrvStatus: () => boolean; restartWaveSrv: () => boolean; @@ -2640,6 +2641,7 @@ class Model { waveSrvRunning: OV; authKey: string; isDev: boolean; + platform: string; activeMainView: OV<"session" | "history" | "bookmarks" | "webshare"> = mobx.observable.box("session", { name: "activeMainView", }); @@ -2721,6 +2723,14 @@ class Model { setTimeout(() => this.getClientDataLoop(1), 10); } + getPlatform(): string { + if (this.platform != null) { + return this.platform; + } + this.platform = getApi().getPlatform(); + return this.platform; + } + needsTos(): boolean { let cdata = this.clientData.get(); if (cdata == null) { From c1ca3a046046d24e5cdb898a3aaae0a479defa2d Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 18 Oct 2023 13:45:30 -0700 Subject: [PATCH 08/10] update BUILD.md and create a build-linux.md --- BUILD.md | 3 ++ build-linux.md | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 build-linux.md diff --git a/BUILD.md b/BUILD.md index 1a18a025..d0b8ac16 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,5 +1,8 @@ # Build Instructions for Wave Terminal +These instructions are for setting up the build on MacOS. +If you're developing on Linux please use the [Linux Build Instructions](./build-linux.md). + ## Running the Development Version of Wave If you install the production version of Wave, you'll see a semi-transparent sidebar, and the data for Wave is stored in the directory ~/prompt. The development version has a red/brown sidebar and stores its data in ~/prompt-dev. This allows the production and development versions to be run simultaneously with no conflicts. If the dev database is corrupted by development bugs, or the schema changes in development it will not affect the production copy. diff --git a/build-linux.md b/build-linux.md new file mode 100644 index 00000000..6449d024 --- /dev/null +++ b/build-linux.md @@ -0,0 +1,100 @@ +# Build Instructions for Wave Terminal on Linux + +These instructions are for setting up the build on Linux. +If you're developing on MacOS please use the [MacOS Build Instructions](./BUILD.md). + +## Running the Development Version of Wave + +If you install the production version of Wave, you'll see a semi-transparent sidebar, and the data for Wave is stored in the directory ~/prompt. The development version has a red/brown sidebar and stores its data in ~/prompt-dev. This allows the production and development versions to be run simultaneously with no conflicts. If the dev database is corrupted by development bugs, or the schema changes in development it will not affect the production copy. + +## Prereqs and Tools + +Download and install Go (must be at least go 1.18): +``` +sudo snap install go --classic +``` + +Download and install [ScriptHaus](https://github.com/scripthaus-dev/scripthaus) (to run the build commands): + +``` +git clone https://github.com/scripthaus-dev/scripthaus.git +cd scripthaus +CGO_ENABLED=1 go build -o scripthaus cmd/main.go +``` + +You'll now have to move the built `scripthaus` binary to a directory in your path (e.g. /usr/local/bin): + +``` +sudo cp scripthaus /usr/local/bin +``` + + +## Clone the Wave Repo + +``` +git clone git@github.com:wavetermdev/waveterm.git +``` + +## Building WaveShell / WaveSrv + +``` +scripthaus run build-backend +``` + +This builds the Golang backends for Wave. The binaries will put in waveshell/bin and wavesrv/bin respectively. If you're working on a new plugin or other pure frontend changes to Wave, you won't need to rebuild these unless you pull new code from the Wave Repository. + +## Install nodejs, npm, and yarn + +We use [nvm](https://github.com/nvm-sh/nvm) to install nodejs on Linux (you can use an alternate installer if you wish). You must have a relatively recent version of node in order to build the terminal. Different distributions and shells will require different setup instructions. These instructions work for Ubuntu 22 using bash (will install node v20.8.1): + +``` +wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash +source ~/.bashrc +nvm install v20.8.1 +``` + +Now we can install yarn: + +``` +sudo npm install -g yarn +``` + +## One-Time Setup + +Install Wave modules (we use yarn): +``` +yarn +``` + +Electron also requires specific builds of node_modules to work (because Electron embeds a specific node.js version that might not match your development node.js version). We use a special electron command to cross-compile those modules: + +``` +scripthaus run electron-rebuild +``` + +## Running WebPack + +Two webpacks are required to run the client. One webpack will build the React code that runs inside of Electron. The other webpack builds the node.js code for the Electron App Wrapper. + +For the React code: +``` +scripthaus run webpack-watch +``` + +For the Electron App: +``` +scripthaus run webpack-electron-watch +``` + +## Running the Prompt Dev Client + +Now that webpack is running (and watching for file changes) we can finally run the Prompt Dev Client! To start the client run: +``` +scripthaus run electron +``` + +To kill the client, either exit the Electron App normally or just Ctrl-C the ```scripthaus run electron``` command. + +Because we're running webpack in watch mode, any changes you make to the typescript will be automatically picked up by the client after a refresh. Note that I've disabled hot-reloading in the webpack config, so to pick up new changes you'll have to manually refresh the Prompt Client window. To do that use "Command-Shift-R" (Command-R is used internally by Prompt and will not force a refresh). + + From 19bcf4f3ed4b1aeaebbf8edd76438fba692b509f Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 18 Oct 2023 14:23:40 -0700 Subject: [PATCH 09/10] update build-linux and scripthaus for linux builds --- build-linux.md | 43 +++++++++++++++++++++++++------------------ scripthaus.md | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/build-linux.md b/build-linux.md index 6449d024..9d9c8c05 100644 --- a/build-linux.md +++ b/build-linux.md @@ -1,7 +1,8 @@ # Build Instructions for Wave Terminal on Linux -These instructions are for setting up the build on Linux. +These instructions are for setting up the build on Linux (Ubuntu). If you're developing on MacOS please use the [MacOS Build Instructions](./BUILD.md). +If you are working on a different Linux distribution, you may need to adapt some of these instructions to fit your environment. ## Running the Development Version of Wave @@ -9,9 +10,10 @@ If you install the production version of Wave, you'll see a semi-transparent sid ## Prereqs and Tools -Download and install Go (must be at least go 1.18): +Download and install Go (must be at least go 1.18). We also need gcc installed to run a CGO build (for Golang): ``` sudo snap install go --classic +sudo apt-get install gcc ``` Download and install [ScriptHaus](https://github.com/scripthaus-dev/scripthaus) (to run the build commands): @@ -28,21 +30,6 @@ You'll now have to move the built `scripthaus` binary to a directory in your pat sudo cp scripthaus /usr/local/bin ``` - -## Clone the Wave Repo - -``` -git clone git@github.com:wavetermdev/waveterm.git -``` - -## Building WaveShell / WaveSrv - -``` -scripthaus run build-backend -``` - -This builds the Golang backends for Wave. The binaries will put in waveshell/bin and wavesrv/bin respectively. If you're working on a new plugin or other pure frontend changes to Wave, you won't need to rebuild these unless you pull new code from the Wave Repository. - ## Install nodejs, npm, and yarn We use [nvm](https://github.com/nvm-sh/nvm) to install nodejs on Linux (you can use an alternate installer if you wish). You must have a relatively recent version of node in order to build the terminal. Different distributions and shells will require different setup instructions. These instructions work for Ubuntu 22 using bash (will install node v20.8.1): @@ -56,9 +43,29 @@ nvm install v20.8.1 Now we can install yarn: ``` -sudo npm install -g yarn +npm install -g yarn ``` + +## Clone the Wave Repo + +Move out of the `scripthaus` directory if you're still in it. Clone the wave repository into the directory that you'd like to use for development. + +``` +git clone git@github.com:wavetermdev/waveterm.git +``` + +## Building WaveShell / WaveSrv + +cd into the waveterm directory (if you haven't already) and run the build-backend command using `scripthaus`. + +``` +cd waveterm +scripthaus run build-backend +``` + +This builds the Golang backends for Wave. The binaries will put in waveshell/bin and wavesrv/bin respectively. If you're working on a new plugin or other pure frontend changes to Wave, you won't need to rebuild these unless you pull new code from the Wave Repository. + ## One-Time Setup Install Wave modules (we use yarn): diff --git a/scripthaus.md b/scripthaus.md index ec914988..c62c0061 100644 --- a/scripthaus.md +++ b/scripthaus.md @@ -104,7 +104,7 @@ GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')" (cd waveshell; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.arm64 main-waveshell.go) (cd waveshell; GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-linux.amd64 main-waveshell.go) (cd waveshell; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-linux.arm64 main-waveshell.go) -(cd wavesrv; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/wavesrv ./cmd) +(cd wavesrv; go build -ldflags="$GO_LDFLAGS" -o ../bin/wavesrv ./cmd) node_modules/.bin/electron-forge make ``` From e5f500e34f7753ca145ba50443115e89e8d9670d Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 18 Oct 2023 14:33:45 -0700 Subject: [PATCH 10/10] note about nodejs, npm, and yarn --- BUILD.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BUILD.md b/BUILD.md index d0b8ac16..dfedac33 100644 --- a/BUILD.md +++ b/BUILD.md @@ -20,6 +20,9 @@ brew tap scripthaus-dev/scripthaus brew install scripthaus ``` +You also need a relatively modern nodejs with npm and yarn installed. +Node can be installed from [here](https://nodejs.org). npm can install yarn using `npm install -g yarn`. + ## Clone the Repo ```