mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-15 21:28:40 -09:00
Compare commits
No commits in common. "canary" and "0.7.0" have entirely different histories.
231 changed files with 4826 additions and 324331 deletions
|
|
@ -7,6 +7,3 @@ end_of_line = lf
|
|||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
|
|
|||
|
|
@ -1,14 +1 @@
|
|||
build
|
||||
app/renderer
|
||||
app/static
|
||||
app/bin
|
||||
app/dist
|
||||
app/node_modules
|
||||
app/typings
|
||||
assets
|
||||
website
|
||||
bin
|
||||
dist
|
||||
target
|
||||
cache
|
||||
schema.json
|
||||
161
.eslintrc.json
161
.eslintrc.json
|
|
@ -1,161 +0,0 @@
|
|||
{
|
||||
"plugins": [
|
||||
"react",
|
||||
"prettier",
|
||||
"@typescript-eslint",
|
||||
"eslint-comments",
|
||||
"lodash",
|
||||
"import"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"plugin:eslint-comments/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"impliedStrict": true,
|
||||
"experimentalObjectRestSpread": true
|
||||
},
|
||||
"allowImportExportEverywhere": true,
|
||||
"project": [
|
||||
"./tsconfig.eslint.json"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
},
|
||||
"import/resolver": {
|
||||
"typescript": {}
|
||||
},
|
||||
"import/internal-regex": "^(electron|react)$"
|
||||
},
|
||||
"rules": {
|
||||
"func-names": [
|
||||
"error",
|
||||
"as-needed"
|
||||
],
|
||||
"no-shadow": "error",
|
||||
"no-extra-semi": 0,
|
||||
"react/prop-types": 0,
|
||||
"react/react-in-jsx-scope": 0,
|
||||
"react/no-unescaped-entities": 0,
|
||||
"react/jsx-no-target-blank": 0,
|
||||
"react/no-string-refs": 0,
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"semi": true,
|
||||
"useTabs": false,
|
||||
"bracketSameLine": false
|
||||
}
|
||||
],
|
||||
"eslint-comments/no-unused-disable": "error",
|
||||
"react/no-unknown-property":[
|
||||
"error",
|
||||
{
|
||||
"ignore": [
|
||||
"jsx",
|
||||
"global"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"**.ts",
|
||||
"**.tsx"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/prefer-optional-chain": "error",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"no-shadow": "off",
|
||||
"@typescript-eslint/no-shadow": ["error"],
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off",
|
||||
"@typescript-eslint/consistent-type-imports": [ "error", { "disallowTypeAnnotations": false } ],
|
||||
"lodash/prop-shorthand": [ "error", "always" ],
|
||||
"lodash/import-scope": [ "error", "method" ],
|
||||
"lodash/collection-return": "error",
|
||||
"lodash/collection-method-value": "error",
|
||||
"import/no-extraneous-dependencies": "error",
|
||||
"import/no-anonymous-default-export": "error",
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
"groups": [
|
||||
"builtin",
|
||||
"internal",
|
||||
"external",
|
||||
"parent",
|
||||
"sibling",
|
||||
"index"
|
||||
],
|
||||
"newlines-between": "always",
|
||||
"alphabetize": {
|
||||
"order": "asc",
|
||||
"orderImportKind": "desc",
|
||||
"caseInsensitive": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"extends": [
|
||||
"plugin:jsonc/recommended-with-json",
|
||||
"plugin:json-schema-validator/recommended"
|
||||
],
|
||||
"files": [
|
||||
"*.json"
|
||||
],
|
||||
"parser": "jsonc-eslint-parser",
|
||||
"plugins": [
|
||||
"jsonc",
|
||||
"json-schema-validator"
|
||||
],
|
||||
"rules": {
|
||||
"jsonc/array-element-newline": [
|
||||
"error",
|
||||
"consistent"
|
||||
],
|
||||
"jsonc/array-bracket-newline": [
|
||||
"error",
|
||||
"consistent"
|
||||
],
|
||||
"jsonc/indent": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"prettier/prettier": "off",
|
||||
"json-schema-validator/no-invalid": "error"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
5
.gitattributes
vendored
5
.gitattributes
vendored
|
|
@ -1,5 +0,0 @@
|
|||
* text=auto
|
||||
*.js text eol=lf
|
||||
*.ts text eol=lf
|
||||
*.tsx text eol=lf
|
||||
bin/* linguist-vendored
|
||||
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help Hyper improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
Hi there! Thank you for discovering and submitting an issue.
|
||||
|
||||
Before you submit this; let's make sure of a few things.
|
||||
Please make sure the following boxes are ticked if they are correct.
|
||||
If not, please try and fulfill these first.
|
||||
-->
|
||||
|
||||
<!-- Checked checkbox should look like this: [x] -->
|
||||
- [ ] I am on the [latest](https://github.com/vercel/hyper/releases/latest) Hyper.app version
|
||||
- [ ] I have searched the [issues](https://github.com/vercel/hyper/issues) of this repo and believe that this is not a duplicate
|
||||
|
||||
<!--
|
||||
Once those are done, if you're able to fill in the following list with your information,
|
||||
it'd be very helpful to whoever handles the issue.
|
||||
-->
|
||||
|
||||
- **OS version and name**: <!-- Replace with version + name -->
|
||||
- **Hyper.app version**: <!-- Replace with version -->
|
||||
- **Link of a [Gist](https://gist.github.com/) with the contents of your hyper.json**: <!-- Gist Link Here -->
|
||||
- **Relevant information from devtools** _(CMD+ALT+I on macOS, CTRL+SHIFT+I elsewhere)_: <!-- Replace with info if applicable, or N/A -->
|
||||
- **The issue is reproducible in vanilla Hyper.app**: <!-- Replace with info if applicable, or `Is Vanilla`. (Vanilla means Hyper.app without any add-ons or extras. Straight out of the box.) -->
|
||||
|
||||
## Issue
|
||||
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea/feature for Hyper
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
137
.github/actions/build-linux-arm/action.yml
vendored
137
.github/actions/build-linux-arm/action.yml
vendored
|
|
@ -1,137 +0,0 @@
|
|||
name: 'Build Linux ARM'
|
||||
description: 'Cross-compiles Hyper app for ARMv7l and ARM64 using arm-runner'
|
||||
inputs:
|
||||
node-version:
|
||||
description: 'Node.js version to use'
|
||||
required: true
|
||||
matrix-name:
|
||||
description: 'Matrix name (arch)'
|
||||
required: true
|
||||
matrix-cpu:
|
||||
description: 'CPU architecture'
|
||||
required: true
|
||||
matrix-image:
|
||||
description: 'Base OS image for ARM emulation'
|
||||
required: true
|
||||
upload-artifact:
|
||||
description: 'Whether to upload artifacts'
|
||||
required: false
|
||||
default: 'true'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ inputs.node-version }}
|
||||
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Fix node-gyp and Python
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m pip install packaging setuptools
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
shell: bash
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Delete old electron headers
|
||||
# These can sometimes be present on a freshly-provisioned github runner, so remove them
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf ~/.electron-gyp || true
|
||||
|
||||
- name: Install dependencies and tools
|
||||
shell: bash
|
||||
run: |
|
||||
yarn install
|
||||
sudo apt update
|
||||
sudo apt install libarchive-tools
|
||||
|
||||
- name: Rebuild node-pty and all native modules for ARM
|
||||
uses: pguyot/arm-runner-action@v2.6.5
|
||||
with:
|
||||
image_additional_mb: 2000
|
||||
base_image: ${{ inputs.matrix-image }}
|
||||
cpu: ${{ inputs.matrix-cpu }}
|
||||
shell: bash
|
||||
copy_artifact_path: target
|
||||
copy_artifact_dest: target
|
||||
commands: |
|
||||
# Install Python distutils in the ARM container
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip python3-setuptools python3-dev
|
||||
pip3 install setuptools --break-system-packages || pip3 install setuptools
|
||||
|
||||
cd target
|
||||
# TODO upgrade node to 20.11.0 to match NODE_VERSION
|
||||
wget https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-${{ inputs.matrix-name }}.tar.xz
|
||||
tar -xJf node-v18.16.0-linux-${{ inputs.matrix-name }}.tar.xz
|
||||
sudo cp node-v18.16.0-linux-${{ inputs.matrix-name }}/* /usr/local/ -R
|
||||
rm node-v18.16.0-linux-${{ inputs.matrix-name }}.tar.xz
|
||||
|
||||
cd ..
|
||||
npm run rebuild-node-pty
|
||||
|
||||
cd target
|
||||
npx electron-rebuild
|
||||
|
||||
- name: Compile
|
||||
shell: bash
|
||||
run: yarn run build
|
||||
|
||||
- name: Chown rebuilt node_modules
|
||||
shell: bash
|
||||
run: |
|
||||
sudo chown -R $USER:$USER target/node_modules
|
||||
|
||||
- name: Prepare v8 snapshot (only armv7l)
|
||||
if: ${{ inputs.matrix-name == 'armv7l' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt update
|
||||
sudo apt install -y libglib2.0-0:i386 libexpat1:i386 libgcc-s1:i386
|
||||
npm_config_arch=armv7l yarn run v8-snapshot:arch
|
||||
|
||||
- name: Build final Electron App for ARM
|
||||
shell: bash
|
||||
run: |
|
||||
yarn run electron-builder -p never -l deb rpm AppImage pacman --${{ inputs.matrix-name }} -c electron-builder-linux-ci.json
|
||||
env:
|
||||
GH_TOKEN: ${{ env.GH_TOKEN }}
|
||||
|
||||
- name: Archive Build Artifacts
|
||||
if: ${{ inputs.upload-artifact == 'true' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: hyper-linux-${{ inputs.matrix-name }}
|
||||
path: |
|
||||
dist/*.snap
|
||||
dist/*.AppImage
|
||||
dist/*.deb
|
||||
dist/*.rpm
|
||||
dist/*.pacman
|
||||
|
||||
# - name: Run E2E Tests on Linux
|
||||
# if: runner.os == 'Linux'
|
||||
# uses: GabrielBB/xvfb-action@v1.7
|
||||
# with:
|
||||
# run: |
|
||||
# yarn run test
|
||||
#
|
||||
172
.github/actions/build/action.yml
vendored
172
.github/actions/build/action.yml
vendored
|
|
@ -1,172 +0,0 @@
|
|||
name: 'Build'
|
||||
description: 'Builds, tests, and packages the app for release'
|
||||
inputs:
|
||||
node-version:
|
||||
description: 'Node.js version to use'
|
||||
required: true
|
||||
matrix-name:
|
||||
description: 'Matrix Name'
|
||||
required: true
|
||||
matrix-os:
|
||||
description: 'Matrix OS'
|
||||
required: true
|
||||
upload-artifact:
|
||||
description: 'Whether to upload artifacts'
|
||||
required: false
|
||||
default: 'true'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js ${{ env.NODE_VERSION }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Fix node-gyp and Python
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "$RUNNER_OS" == "macOS" ]]; then
|
||||
brew install python-setuptools python-packaging
|
||||
else
|
||||
python3 -m pip install $EXTRA_ARGS packaging setuptools
|
||||
fi
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
shell: bash
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Delete old electron headers
|
||||
# These can sometimes be present on a freshly-provisioned github runner, so remove them
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf ~/.electron-gyp || true
|
||||
|
||||
- name: Install
|
||||
shell: bash
|
||||
run: yarn install
|
||||
env:
|
||||
npm_config_node_gyp: ${{ github.workspace }}${{ runner.os == 'Windows' && '\node_modules\node-gyp\bin\node-gyp.js' || '/node_modules/node-gyp/bin/node-gyp.js' }}
|
||||
|
||||
- name: Install libarchive-tools
|
||||
shell: bash
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libarchive-tools
|
||||
|
||||
- name: Rebuild native modules for Electron
|
||||
shell: bash
|
||||
run: npx electron-rebuild
|
||||
|
||||
- name: Lint and Run Unit Tests
|
||||
shell: bash
|
||||
run: yarn run test
|
||||
|
||||
- name: Getting Build Icon
|
||||
shell: bash
|
||||
if: github.ref == 'refs/heads/canary' || github.base_ref == 'canary'
|
||||
run: |
|
||||
cp build/canary.ico build/icon.ico
|
||||
cp build/canary.icns build/icon.icns
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -z "$CSC_LINK" ] ; then unset CSC_LINK ; fi
|
||||
if [ -z "$CSC_KEY_PASSWORD" ] ; then unset CSC_KEY_PASSWORD ; fi
|
||||
if [ -z "$WIN_CSC_LINK" ] ; then unset WIN_CSC_LINK ; fi
|
||||
if [ -z "$WIN_CSC_KEY_PASSWORD" ] ; then unset WIN_CSC_KEY_PASSWORD ; fi
|
||||
if [ -z "$APPLE_ID" ] ; then unset APPLE_ID ; fi
|
||||
if [ -z "$APPLE_APP_SPECIFIC_PASSWORD" ] ; then unset APPLE_APP_SPECIFIC_PASSWORD ; fi
|
||||
|
||||
yarn run dist
|
||||
env:
|
||||
GH_TOKEN: ${{ env.GH_TOKEN }}
|
||||
CSC_LINK: ${{ env.MAC_CERT_P12_BASE64 }}
|
||||
CSC_KEY_PASSWORD: ${{ env.MAC_CERT_P12_PASSWORD }}
|
||||
WIN_CSC_LINK: ${{ env.WIN_CERT_P12_BASE64 }}
|
||||
WIN_CSC_KEY_PASSWORD: ${{ env.WIN_CERT_P12_PASSWORD }}
|
||||
APPLE_ID: ${{ env.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ env.APPLE_PASSWORD }}
|
||||
|
||||
- name: Archive Build Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: hyper-${{ runner.os }}-${{ inputs.matrix-name }}
|
||||
path: |
|
||||
dist/*.dmg
|
||||
dist/*.snap
|
||||
dist/*.AppImage
|
||||
dist/*.deb
|
||||
dist/*.pacman
|
||||
dist/*.exe
|
||||
|
||||
- name: Run E2E Tests
|
||||
shell: bash
|
||||
if: runner.os != 'Linux'
|
||||
run: yarn run test:e2e --verbose
|
||||
|
||||
- name: Run E2E Tests on Linux
|
||||
if: runner.os == 'Linux'
|
||||
uses: GabrielBB/xvfb-action@v1.7
|
||||
with:
|
||||
run: |
|
||||
yarn run test:e2e
|
||||
env:
|
||||
SHELL: /bin/bash
|
||||
DEBUG: "pw:browser*"
|
||||
|
||||
- name: Archive E2E test screenshot
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-${{ inputs.matrix-os }}-${{ strategy.job-index }}
|
||||
path: dist/tmp/*.png
|
||||
|
||||
- name: Save the pr number in an artifact
|
||||
shell: bash
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
PR_NUM: ${{ github.event.number }}
|
||||
run: echo $PR_NUM > pr_num.txt
|
||||
|
||||
- name: Upload the pr num
|
||||
uses: actions/upload-artifact@v4
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
name: pr_num
|
||||
path: ./pr_num.txt
|
||||
|
||||
- uses: actions/cache/save@v4
|
||||
if: github.event_name == 'push'
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }}
|
||||
|
||||
# - name: Run E2E Tests (non-Linux)
|
||||
# if: runner.os != 'Linux'
|
||||
# shell: bash
|
||||
# run: yarn run test:e2e --verbose
|
||||
#
|
||||
# - name: Run E2E Tests on Linux
|
||||
# if: runner.os == 'Linux'
|
||||
# uses: GabrielBB/xvfb-action@v1.7
|
||||
# with:
|
||||
# run: |
|
||||
# yarn run test
|
||||
#
|
||||
39
.github/dependabot.yml
vendored
39
.github/dependabot.yml
vendored
|
|
@ -1,39 +0,0 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
time: '11:00'
|
||||
target-branch: canary
|
||||
versioning-strategy: increase
|
||||
commit-message:
|
||||
prefix: "chore(deps-dev):"
|
||||
groups:
|
||||
minorAndPatch:
|
||||
update-types:
|
||||
- "minor"
|
||||
- "patch"
|
||||
open-pull-requests-limit: 100
|
||||
- package-ecosystem: npm
|
||||
directory: "/app"
|
||||
schedule:
|
||||
interval: weekly
|
||||
time: '11:00'
|
||||
target-branch: canary
|
||||
versioning-strategy: increase
|
||||
commit-message:
|
||||
prefix: "chore(deps):"
|
||||
groups:
|
||||
minorAndPatch:
|
||||
update-types:
|
||||
- "minor"
|
||||
- "patch"
|
||||
open-pull-requests-limit: 100
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
time: '11:00'
|
||||
open-pull-requests-limit: 30
|
||||
target-branch: canary
|
||||
1
.github/pull_request_template.md
vendored
1
.github/pull_request_template.md
vendored
|
|
@ -1 +0,0 @@
|
|||
<!-- Please check `Allow edits from maintainers`. Thanks! -->
|
||||
154
.github/workflows/ci.yml
vendored
154
.github/workflows/ci.yml
vendored
|
|
@ -1,154 +0,0 @@
|
|||
name: Node CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
workflow_dispatch:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
NODE_VERSION: 20.11.0
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# CSC_LINK: ${{ secrets.MAC_CERT_P12_BASE64 }}
|
||||
# CSC_KEY_PASSWORD: ${{ secrets.MAC_CERT_P12_PASSWORD }}
|
||||
# WIN_CSC_LINK: ${{ secrets.WIN_CERT_P12_BASE64 }}
|
||||
# WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_P12_PASSWORD }}
|
||||
# APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
# APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
|
||||
jobs:
|
||||
build-ubuntu:
|
||||
name: Build Ubuntu
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: build-ubuntu-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-os: ubuntu-latest
|
||||
matrix-name: ubuntu
|
||||
upload-artifact: false
|
||||
|
||||
build-macos:
|
||||
name: Build macOS
|
||||
runs-on: macos-latest
|
||||
concurrency:
|
||||
group: build-macos-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-os: macos-latest
|
||||
matrix-name: macos
|
||||
upload-artifact: false
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: windows-latest
|
||||
concurrency:
|
||||
group: build-win-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-os: windows-latest
|
||||
matrix-name: win
|
||||
upload-artifact: false
|
||||
|
||||
# ARM Linux:
|
||||
|
||||
build-linux-armv7l:
|
||||
name: Build Linux ARMv7l
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: build-linux-armv7l-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU and binfmt
|
||||
run: |
|
||||
# Install qemu-user-static
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y qemu-user-static binfmt-support python3-setuptools
|
||||
|
||||
# Install distutils for node-gyp
|
||||
sudo apt-get install -y python3-distutils || sudo apt-get install -y python3-dev python-is-python3
|
||||
|
||||
|
||||
# Download and install binfmt configurations
|
||||
wget https://github.com/qemu/qemu/raw/master/scripts/qemu-binfmt-conf.sh
|
||||
chmod +x qemu-binfmt-conf.sh
|
||||
sudo ./qemu-binfmt-conf.sh --qemu-path /usr/bin --qemu-suffix -static --debian
|
||||
|
||||
# Import the binfmt configurations
|
||||
sudo update-binfmts --import qemu-arm
|
||||
sudo update-binfmts --import qemu-aarch64
|
||||
|
||||
# Verify they exist
|
||||
ls -la /proc/sys/fs/binfmt_misc/qemu-arm* || true
|
||||
|
||||
- name: Build ARMv7l
|
||||
uses: ./.github/actions/build-linux-arm
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-name: armv7l
|
||||
matrix-cpu: cortex-a8
|
||||
matrix-image: raspios_lite:latest
|
||||
upload-artifact: false
|
||||
|
||||
build-linux-arm64:
|
||||
name: Build Linux ARM64
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: build-linux-arm64-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build ARM64
|
||||
uses: ./.github/actions/build-linux-arm
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-name: arm64
|
||||
matrix-cpu: cortex-a53
|
||||
matrix-image: raspios_lite_arm64:latest
|
||||
upload-artifact: false
|
||||
67
.github/workflows/codeql-analysis.yml
vendored
67
.github/workflows/codeql-analysis.yml
vendored
|
|
@ -1,67 +0,0 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ canary ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ canary ]
|
||||
schedule:
|
||||
- cron: '37 6 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
63
.github/workflows/e2e_comment.yml
vendored
63
.github/workflows/e2e_comment.yml
vendored
|
|
@ -1,63 +0,0 @@
|
|||
name: Comment e2e test screenshots on PR
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Node CI']
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
e2e_comment:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
steps:
|
||||
- name: Dump Workflow run info from GitHub context
|
||||
env:
|
||||
WORKFLOW_RUN_INFO: ${{ toJSON(github.event.workflow_run) }}
|
||||
run: echo "$WORKFLOW_RUN_INFO"
|
||||
- name: Download Artifacts
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
workflow: nodejs.yml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: e2e
|
||||
- name: Get PR number
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
workflow: nodejs.yml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: pr_num
|
||||
- name: Read the pr_num file
|
||||
id: pr_num_reader
|
||||
uses: juliangruber/read-file-action@v1.1.7
|
||||
with:
|
||||
path: ./pr_num.txt
|
||||
- name: List images
|
||||
run: ls -al
|
||||
- name: Upload images to imgur
|
||||
id: upload_screenshots
|
||||
uses: devicons/public-upload-to-imgur@v2.2.2
|
||||
with:
|
||||
path: ./*.png
|
||||
client_id: ${{ secrets.IMGUR_CLIENT_ID }}
|
||||
- name: Comment on the PR
|
||||
uses: jungwinter/comment@v1
|
||||
env:
|
||||
IMG_MARKDOWN: ${{ join(fromJSON(steps.upload_screenshots.outputs.markdown_urls), '') }}
|
||||
MESSAGE: |
|
||||
Hi there,
|
||||
Thank you for contributing to Hyper!
|
||||
You can get the build artifacts from [here](https://nightly.link/{1}/actions/runs/{2}).
|
||||
Here are screenshots of Hyper built from this pr.
|
||||
{0}
|
||||
with:
|
||||
type: create
|
||||
issue_number: ${{ steps.pr_num_reader.outputs.content }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: ${{ format(env.MESSAGE, env.IMG_MARKDOWN, github.repository, github.event.workflow_run.id) }}
|
||||
- name: Hide older comments
|
||||
uses: kanga333/comment-hider@v0.4.0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
leave_visible: 1
|
||||
issue_number: ${{ steps.pr_num_reader.outputs.content }}
|
||||
194
.github/workflows/release.yml
vendored
194
.github/workflows/release.yml
vendored
|
|
@ -1,194 +0,0 @@
|
|||
name: Create Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
NODE_VERSION: 20.11.0
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CSC_LINK: ${{ secrets.MAC_CERT_P12_BASE64 }}
|
||||
CSC_KEY_PASSWORD: ${{ secrets.MAC_CERT_P12_PASSWORD }}
|
||||
WIN_CSC_LINK: ${{ secrets.WIN_CERT_P12_BASE64 }}
|
||||
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_P12_PASSWORD }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
|
||||
jobs:
|
||||
build-ubuntu:
|
||||
name: Build Ubuntu
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-os: ubuntu-latest
|
||||
matrix-name: ubuntu
|
||||
upload-artifact: true
|
||||
|
||||
build-macos:
|
||||
name: Build macOS
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-os: macos-latest
|
||||
matrix-name: macos
|
||||
upload-artifact: true
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-os: windows-latest
|
||||
matrix-name: win
|
||||
upload-artifact: true
|
||||
|
||||
# ARM Linux:
|
||||
|
||||
build-linux-armv7l:
|
||||
name: Build Linux ARMv7l
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU and binfmt
|
||||
run: |
|
||||
# Install qemu-user-static
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y qemu-user-static binfmt-support python3-setuptools
|
||||
|
||||
# Install distutils for node-gyp
|
||||
sudo apt-get install -y python3-distutils || sudo apt-get install -y python3-dev python-is-python3
|
||||
|
||||
# Download and install binfmt configurations
|
||||
wget https://github.com/qemu/qemu/raw/master/scripts/qemu-binfmt-conf.sh
|
||||
chmod +x qemu-binfmt-conf.sh
|
||||
sudo ./qemu-binfmt-conf.sh --qemu-path /usr/bin --qemu-suffix -static --debian
|
||||
|
||||
# Import the binfmt configurations
|
||||
sudo update-binfmts --import qemu-arm
|
||||
sudo update-binfmts --import qemu-aarch64
|
||||
|
||||
# Verify they exist
|
||||
ls -la /proc/sys/fs/binfmt_misc/qemu-arm* || true
|
||||
|
||||
- name: Build ARMv7l
|
||||
uses: ./.github/actions/build-linux-arm
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-name: armv7l
|
||||
matrix-cpu: cortex-a8
|
||||
matrix-image: raspios_lite:latest
|
||||
upload-artifact: true
|
||||
|
||||
build-linux-arm64:
|
||||
name: Build Linux ARM64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build ARM64
|
||||
uses: ./.github/actions/build-linux-arm
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
matrix-name: arm64
|
||||
matrix-cpu: cortex-a53
|
||||
matrix-image: raspios_lite_arm64:latest
|
||||
upload-artifact: true
|
||||
|
||||
###
|
||||
|
||||
upload-release:
|
||||
name: Upload and Create Release
|
||||
needs:
|
||||
- build-ubuntu
|
||||
- build-macos
|
||||
- build-windows
|
||||
- build-linux-armv7l
|
||||
- build-linux-arm64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./artifacts
|
||||
|
||||
- name: List downloaded artifacts
|
||||
run: ls -R ./artifacts
|
||||
|
||||
- name: Ensure non-empty artifacts
|
||||
run: |
|
||||
echo "Checking for zero-byte files in artifacts/..."
|
||||
find artifacts/ -type f -empty -print -delete
|
||||
echo "Cleaned up any zero-byte files."
|
||||
echo "Remaining files:"
|
||||
ls -R artifacts/
|
||||
|
||||
- name: Dump release assets for debugging
|
||||
if: always()
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub CLI needs this
|
||||
run: |
|
||||
echo "Fetching release assets for tag: ${{ github.ref_name }}"
|
||||
gh release view "${{ github.ref_name }}" --repo "${{ github.repository }}" --json assets --jq '.assets[] | "\(.name) - \(.url)"' || true
|
||||
|
||||
- name: Create GitHub Release
|
||||
# Pinned to work around https://github.com/softprops/action-gh-release/issues/445
|
||||
uses: softprops/action-gh-release@v2.0.5
|
||||
env:
|
||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||
ACTIONS_STEP_DEBUG: true
|
||||
with:
|
||||
preserve_order: true
|
||||
overwrite: true
|
||||
name: Release ${{ github.ref_name }}
|
||||
tag_name: ${{ github.ref }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
draft: true
|
||||
files: |
|
||||
artifacts/**/*.dmg
|
||||
artifacts/**/*.snap
|
||||
artifacts/**/*.AppImage
|
||||
artifacts/**/*.deb
|
||||
artifacts/**/*.pacman
|
||||
artifacts/**/*.exe
|
||||
15
.gitignore
vendored
15
.gitignore
vendored
|
|
@ -1,23 +1,12 @@
|
|||
# build output
|
||||
dist
|
||||
app/renderer
|
||||
target
|
||||
bin/cli.*
|
||||
cache
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
# logs
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# optional dev config file and plugins directory
|
||||
hyper.json
|
||||
schema.json
|
||||
plugins
|
||||
|
||||
# other
|
||||
.next
|
||||
.DS_Store
|
||||
.vscode/*
|
||||
!.vscode/launch.json
|
||||
.idea
|
||||
|
|
|
|||
1
.husky/.gitignore
vendored
1
.husky/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
_
|
||||
|
|
@ -1 +0,0 @@
|
|||
yarn test
|
||||
|
|
@ -1 +0,0 @@
|
|||
20.11.0
|
||||
1
.nvmrc
1
.nvmrc
|
|
@ -1 +0,0 @@
|
|||
20.11.0
|
||||
42
.travis.yml
Normal file
42
.travis.yml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
osx_image: xcode7.3
|
||||
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: c
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
- os: linux
|
||||
env: CC=clang CXX=clang++ npm_config_clang=1
|
||||
compiler: clang
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- app/node_modules
|
||||
- $HOME/.electron
|
||||
- $HOME/.cache
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libgnome-keyring-dev
|
||||
- icnsutils
|
||||
|
||||
before_install:
|
||||
- mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([ "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
|
||||
|
||||
install:
|
||||
- nvm install 6
|
||||
- npm install electron-builder@next # force install next version to test electron-builder
|
||||
- npm install
|
||||
- npm prune
|
||||
|
||||
script:
|
||||
- npm run release
|
||||
|
||||
branches:
|
||||
except:
|
||||
- "/^v\\d+\\.\\d+\\.\\d+$/"
|
||||
22
.vscode/launch.json
vendored
22
.vscode/launch.json
vendored
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Hyper",
|
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
||||
"program": "${workspaceRoot}/target/index.js",
|
||||
"protocol": "inspector"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "cli",
|
||||
"runtimeExecutable": "node",
|
||||
"program": "${workspaceRoot}/bin/cli.js",
|
||||
"args": ["--help"],
|
||||
"protocol": "inspector"
|
||||
}
|
||||
]
|
||||
}
|
||||
148049
.yarn/releases/yarn-classic.cjs
vendored
148049
.yarn/releases/yarn-classic.cjs
vendored
File diff suppressed because one or more lines are too long
1
.yarnrc
1
.yarnrc
|
|
@ -1 +0,0 @@
|
|||
registry "https://registry.npmjs.org/"
|
||||
|
|
@ -1 +0,0 @@
|
|||
yarnPath: .yarn/releases/yarn-classic.cjs
|
||||
173
HISTORY.md
Normal file
173
HISTORY.md
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
|
||||
0.7.0 / 2016-07-25
|
||||
==================
|
||||
|
||||
* use `uuid` instead of `uid2` for session ids [@albinekb]
|
||||
* fix support for `mapTermsDispatch` [@albinekb]
|
||||
* implement `extend-info` for the custom `plist` [@lordgiotto]
|
||||
* index: prevent double sesson exit (#380) [@timneutkens]
|
||||
* add decorateEnv to the extensions API (#370) [@ekmartin]
|
||||
* reorganize dir structure and implement `electron-builder` [@rauchg]
|
||||
* move to the last term with cmd+9 (#261) [@ekmartin]
|
||||
* make sure scrollbar shim doesn't capture clicks [@rauchg]
|
||||
* support default width/height of browser window (#257) [@tamagokun]
|
||||
* add ctrl+tab/ctrl+shift+tab for tab switching (#367) [@NickChristensen]
|
||||
* add `TERM_PROGRAM` and `TERM_PROGRAM_VERSION` env vars (#350) [@tootallnate]
|
||||
* bump `electron-prebuilt` (#359) [@freebroccolo]
|
||||
* add middle click to close tab functionality (#286) [@itswil]
|
||||
* adds plugin hook for decorating the electron browser options (#310) [@danprince]
|
||||
* add support for multiple cursor shapes (#352) [@rpunkfu]
|
||||
* add LANG env variable (#354) [@TooTallNate]
|
||||
* improved linux support (#341) [@c0b41]
|
||||
* auto-updater: stop notifying and being annoying [@rauchg]
|
||||
* fix quit problem (#343) [@c0b41, @timneutkens]
|
||||
* allow the `color` config to be an object (#193) [@mike-engel]
|
||||
* remove $ from terminal commands in README (#130) [@Tyriar]
|
||||
* configurable cursor opacity (#76) [@hharnisc]
|
||||
* implement post push and post install hooks (#328) [@freebroccolo]
|
||||
* update rounded header radius (#333) [@blakeembrey]
|
||||
* disable linux autoupdate (#338) [@c0b41]
|
||||
* specify bash to run command in for editor opening (#314) [@kyleholzinger]
|
||||
* update dependencies (#319) [@freeboccolo]
|
||||
* add .editorconfig file (#320) [@freebroccolo]
|
||||
* fix linter issues (#321) [@freebroccolo]
|
||||
* add window zoom menu item (#325) [@marcbachmann]
|
||||
* disable pinch zoom functionality (#326) [@marcbachmann]
|
||||
* fix prop update logic for fontSmoothing (#302) [@mike-engel]
|
||||
* allow opening of files in webview (#305) [@cuth]
|
||||
* modified Info.plist generation to enable folder drop onto dock icon (#307) [@lordgiotto]
|
||||
* fix installing plugins that use `node-gyp` (#291) [@dfrankland]
|
||||
* dynamically change the `font-smoothing` pref (#205) [@mike-engel]
|
||||
* add cursor actions (#217) [@marcbachmann]
|
||||
* override the buggy hexToRGB implementation in hterm. (#272) [@mauro-oto]
|
||||
* add reducer to set cwd (#271) [@hharnisc]
|
||||
* add homebrew cask install method (#273, #356) [@ZakariaRidouh, @arnif]
|
||||
* do not rely on bash-style comments for pref opening (#279) [@mfpierre]
|
||||
* add support for a `registry` configuration field (#211) [@developit]
|
||||
* expose 'getWindows' and 'createWindow' to plugins (#248) [@CWSpear]
|
||||
* make preference-opening work on all shells (#267) [@szhu]
|
||||
* remove unused state variable (#268) [@marcbachmann]
|
||||
* remove unnecessary comment referencing use of !important due to aphrodite" (#223) [@conorhastings]
|
||||
* close window when last tab is exited (#263) [@ekmartin]
|
||||
* bring focus to main window when clicking preferences (#235) [@leo]
|
||||
* remove unnecessary event listener teardown on Term unmount (#242) [@developit]
|
||||
* make CMD + K work for all commands, even tail (#215) [@marcbachmann]
|
||||
* fix some documentation typos. (#212) [@mauro-oto]
|
||||
* add an option for a non-login shell to be run (#192) [@mike-engel, @cuth]
|
||||
* hide scrollbar when webview is active (#209) [@marcbachmann]
|
||||
|
||||
0.6.0 / 2016-07-17
|
||||
==================
|
||||
|
||||
* notification style improvements and link to release notes upon updates [@rauchg]
|
||||
* make `npm install` work more reliably (#172) [@marcbachmann]
|
||||
* fixing problems with alt key and special characters like å, ö and ä. (#201) [@teemuteemu]
|
||||
* change the version of eslint-config-standard from 5.3.1 to 5.3.5 (#166) [@6thmonth]
|
||||
* fixed an issue where the app icon was not showing up in Linux (#126) [@code-haven]
|
||||
* fixed typo (#152) [@radarhere]
|
||||
* icon typo fixed in about dialog (#146) [@akashnimare]
|
||||
* add a copy of the MIT license (#160) [@calinou]
|
||||
* fix notification message (#111) [@montogeek]
|
||||
* improved installation method (#104) [@amilajack]
|
||||
* initial travis ci support (#107) [@amilajack]
|
||||
* menu improvements (#185) [@sindresorhus]
|
||||
* provide hooks to open a new tab to the same directory (#174) [@hharnisc]
|
||||
* fix hypersolar plugin example, it does not exist (#179) [@montogeek]
|
||||
* fix onWindow hook (#180) [@dfrankland]
|
||||
|
||||
0.5.0 / 2016-07-16
|
||||
==================
|
||||
|
||||
* plugins: improve error handling and introduce `getDecoratedConfig` [@rauchg]
|
||||
* index: notify renderer of plugins changes to reload config [@rauchg]
|
||||
* index: allow plugin authors to change electron window settings [@rauchg]
|
||||
* index: expose `config` and `plugins` to plugin authors in electron process [@rauchg]
|
||||
* app: preserve class names with uglification [@rauchg]
|
||||
* config: reload config upon `plugins change` due to decorati [@rauchg]
|
||||
* app: expose `plugins` and `config` to window [@rauchg]
|
||||
* allow plugin authors to override styles by ditching !important [@rauchg]
|
||||
|
||||
0.4.5 / 2016-07-14
|
||||
==================
|
||||
|
||||
* performance improvements for url matching [@rauchg]
|
||||
* improve repaint performance for writes to the term [@rauchg]
|
||||
* fix issue with perf degradation related to title polling [@rauchg]
|
||||
* fix resizing when only one axis changed [@rauchg]
|
||||
|
||||
0.4.4 / 2016-07-14
|
||||
==================
|
||||
|
||||
* plugins: more graceful npm error
|
||||
|
||||
0.4.3 / 2016-07-14
|
||||
==================
|
||||
|
||||
* terms: improve write performance
|
||||
* remove unused import
|
||||
|
||||
0.4.2 / 2016-07-13
|
||||
==================
|
||||
|
||||
* fix close icon by copying static assets to build [@rauchg]
|
||||
|
||||
0.4.1 / 2016-07-13
|
||||
==================
|
||||
|
||||
* noop bump to test updates
|
||||
|
||||
0.4.0 / 2016-07-13
|
||||
==================
|
||||
|
||||
* implement extensible redux actions system [@rauchg]
|
||||
* add support for config (~/.hyperterm.js) [@rauchg, @nfcampos]
|
||||
* add support for plugins (~/.hyperterm_modules) [@rauchg]
|
||||
* improve menubar look [@leo, @rauchg]
|
||||
* beautiful default colors [@hharnisc, @dzannotti]
|
||||
* add close icon for tabs [@johanbrook]
|
||||
* add support for font size shortcuts [@jhaynie, @nfcampos]
|
||||
* add support for maximizing upon double click [@jhaynie]
|
||||
* add fallback fonts for linux and windows [@olliv]
|
||||
* improve menu items [@rauchg, @sindresorhus]
|
||||
* add proper auto updates system [@matiastucci, @rauchg]
|
||||
|
||||
0.3.1 / 2016-07-04
|
||||
==================
|
||||
|
||||
* implement most recent hterm with lots of bugfixes [@dbkaplun, @rauchg]
|
||||
|
||||
0.3.0 / 2016-07-04
|
||||
==================
|
||||
|
||||
* revamp the menu to be a lot more standard (#38) [@rauchg]
|
||||
* move menu into its own file and refactor [@rauchg]
|
||||
* add static icon, move icons to static folder [@rauchg]
|
||||
* add cross-platform font family settings (#26) [@OlliV, @rauchg]
|
||||
* remove `xterm.css` (no longer used, smaller build!) [@rauchg]
|
||||
* change font size with command shortcuts (#34) [@jhaynie]
|
||||
* implement a more reasonable update interval check frequency (#33) [@rauchg]
|
||||
* add standard behavior when you double click window (#32) [@jhaynie]
|
||||
|
||||
0.2.1 / 2016-07-03
|
||||
==================
|
||||
|
||||
* improvements to update checker
|
||||
|
||||
0.2.0 / 2016-07-03
|
||||
==================
|
||||
|
||||
* Implement hterm (#28) [@rauchg]
|
||||
* Fix "Download" link being clickable when hidden (#7) [@rauchg]
|
||||
* Jump to beginning of end at edges of tabs when moving sideways (#22) [@rauchg]
|
||||
* Make clear where to run `npm start` (#19) [@montogeek]
|
||||
* Add fullscreen menu item (#1) [@rauchg, @montogeek]
|
||||
* Improve README and scripts (#15) [@leo]
|
||||
* Add support for cmd+shift+[|] [@rauchg]
|
||||
* Add dev build instructions to README (#3) [@rauchg]
|
||||
* Make `ctrl+c` close <webview> instead of `cmd+w` (#2) [@rauchg]
|
||||
* Improve `zip` builds to not include nested directory [@rauchg]
|
||||
|
||||
0.1.0 / 2016-07-01
|
||||
==================
|
||||
|
||||
* initial release
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# MIT License
|
||||
|
||||
Copyright (c) 2018 Vercel, Inc.
|
||||
Copyright (c) 2016 Zeit, Inc. and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
210
PLUGINS.md
210
PLUGINS.md
|
|
@ -1,210 +0,0 @@
|
|||
# Plugin development
|
||||
|
||||
## Workflow
|
||||
|
||||
### Run Hyper in dev mode
|
||||
Hyper can be run in dev mode by cloning this repository and following the ["Contributing" section of our README](https://github.com/vercel/hyper#contribute).
|
||||
|
||||
In dev mode you'll get more ouput and access to React/Redux dev-tools in Electron.
|
||||
|
||||
Prerequisites and steps are described in the ["Contributing" section of our README](https://github.com/vercel/hyper#contribute).
|
||||
Be sure to use the `canary` branch.
|
||||
|
||||
### Create a dev config file
|
||||
Copy your config file `hyper.json` to the root of your cloned repository. Hyper, in dev mode, will use this copied config file. That means that you can continue to use your main installation of Hyper with your day-to-day configuration.
|
||||
After the first run, Hyper, in dev mode, will have created a new `plugins` directory in your repository directory.
|
||||
|
||||
### Setup your plugin
|
||||
Go to your recently created `<repository_root>/plugins/local` directory and create/clone your plugin repo. An even better method on macOS/Linux is to add a symlink to your plugin directory.
|
||||
|
||||
Edit your dev config file, and add your plugin name (directory name in your `local` directory) in the `localPlugins` array.
|
||||
```js
|
||||
module.exports = {
|
||||
config: {
|
||||
...
|
||||
},
|
||||
plugins: [],
|
||||
localPlugins: ['hyper-awesome-plugin'],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Running your plugin
|
||||
To load, your plugin should expose at least one API method. All possible methods are listed [here](https://github.com/vercel/hyper/blob/canary/app/plugins/extensions.ts).
|
||||
|
||||
After launching Hyper in dev mode, run `yarn run app`, it should log that your plugin has been correcty loaded: `Plugin hyper-awesome-plugin (0.1.0) loaded.`. Name and version printed are the ones in your plugins `package.json` file.
|
||||
|
||||
When you put a `console.log()` in your plugin code, it will be displayed in the Electron dev-tools, but only if it is located in a renderer method, like component decorators. If it is located in the Electron main process method, like the `onApp` handler, it will be displayed in your terminal where you ran `yarn run app` or in your VSCode console.
|
||||
|
||||
## Recipes
|
||||
Almost all available API methods can be found on https://hyper.is.
|
||||
If there's any missing, let us know or submit a PR to document it!
|
||||
|
||||
### Components
|
||||
You can decorate almost all Hyper components with a Higher-Order Component (HOC). To understand their architecture, the easiest way is to use React dev-tools to dig in to their hierarchy.
|
||||
|
||||
Multiple plugins can decorate the same Hyper component. Thus, `Component` passed as first argument to your decorator function could possibly not be an original Hyper component but a HOC of a previous plugin. If you need to retrieve a reference to a real Hyper component, you can pass down a `onDecorated` handler.
|
||||
```js
|
||||
exports.decorateTerms = (Terms, {React}) => {
|
||||
return class extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.terms = null;
|
||||
this.onDecorated = this.onDecorated.bind(this);
|
||||
}
|
||||
|
||||
onDecorated(terms) {
|
||||
this.terms = terms;
|
||||
// Don't forget to propagate it to HOC chain
|
||||
if (this.props.onDecorated) this.props.onDecorated(terms);
|
||||
}
|
||||
|
||||
render() {
|
||||
return React.createElement(
|
||||
Terms,
|
||||
Object.assign({}, this.props, {
|
||||
onDecorated: this.onDecorated
|
||||
})
|
||||
);
|
||||
// Or if you use JSX:
|
||||
// <Terms onDecorated={this.onDecorated} />
|
||||
}
|
||||
}
|
||||
```
|
||||
:warning: Note that you have to execute `this.props.onDecorated` to not break the handler chain. Without this, you could break other plugins that decorate the same component.
|
||||
|
||||
### Keymaps
|
||||
If you want to add some keymaps, you need to do 2 things:
|
||||
|
||||
#### Declare your key bindings
|
||||
Use the `decorateKeymaps` API handler to modify existing keymaps and add yours with the following format `command: hotkeys`.
|
||||
```js
|
||||
// Adding Keymaps
|
||||
exports.decorateKeymaps = keymaps => {
|
||||
const newKeymaps = {
|
||||
'pane:maximize': 'ctrl+shift+m',
|
||||
'pane:invert': 'ctrl+shift+i'
|
||||
}
|
||||
return Object.assign({}, keymaps, newKeymaps);
|
||||
}
|
||||
```
|
||||
The command name can be whatever you want, but the following is better to respect the default naming convention: `<context>:<action>`.
|
||||
Hotkeys are composed by [Mousetrap supported keys](https://craig.is/killing/mice#keys).
|
||||
|
||||
**Bonus feature**: if your command ends with `:prefix`, it would mean that you want to use this command with an additional digit to the command. Then Hyper will create all your commands under the hood. For example, this keymap `'pane:hide:prefix': 'ctrl+shift'` will automatically generate the following:
|
||||
```
|
||||
{
|
||||
'pane:hide:1': 'ctrl+shift+1',
|
||||
'pane:hide:2': 'ctrl+shift+2',
|
||||
...
|
||||
'pane:hide:8': 'ctrl+shift+8',
|
||||
'pane:hide:last': 'ctrl+shift+9'
|
||||
}
|
||||
```
|
||||
Notice that `9` has been replaced by `last` because most of the time this is handy if you have more than 9 items.
|
||||
|
||||
|
||||
#### Register a handler for your commands
|
||||
##### Renderer/Window
|
||||
Most of time, you'll want to execute some sort of handler in context of the renderer, like dispatching a Redux action.
|
||||
To trigger these handlers, you'll have to register them with the `registerCommands` Terms method.
|
||||
```js
|
||||
this.terms.registerCommands({
|
||||
'pane:maximize': e => {
|
||||
this.props.onMaximizePane();
|
||||
// e parameter is React key event
|
||||
e.preventDefault();
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Main process
|
||||
If there is no handler in the renderer for an existing command, an `rpc` message is emitted.
|
||||
If you want to execute a handler in main process you have to subscribe to a message, for example:
|
||||
```js
|
||||
rpc.on('command pane:snapshot', () => {
|
||||
/* Awesome snapshot feature */
|
||||
});
|
||||
```
|
||||
|
||||
### Menu
|
||||
Your plugin can expose a `decorateMenu` function to modify the Hyper menu template.
|
||||
Check the [Electron documentation](https://electronjs.org/docs/api/menu-item) for more details about the different menu item types/options available.
|
||||
|
||||
Be careful, a click handler will be executed on the main process. If you need to trigger a handler in the render process you need to use an `rpc` message like this:
|
||||
```js
|
||||
exports.decorateMenu = (menu) => {
|
||||
debug('decorateMenu');
|
||||
const isMac = process.platform === 'darwin';
|
||||
// menu label is different on mac
|
||||
const menuLabel = isMac ? 'Shell' : 'File';
|
||||
|
||||
return menu.map(menuCategory => {
|
||||
if (menuCategory.label !== menuLabel) {
|
||||
return menuItem;
|
||||
}
|
||||
return [
|
||||
...menuCategory,
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Clear all panes in all tabs',
|
||||
accelerator: 'ctrl+shift+y',
|
||||
click(item, focusedWindow) {
|
||||
// on macOS, menu item can clicked without or minized window
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('clear allPanes');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
/* Plugin needs to register a rpc handler on renderer side for example in a Terms HOC*/
|
||||
exports.decorateTerms = (Terms, { React }) => {
|
||||
return class extends React.Component {
|
||||
componentDidMount() {
|
||||
window.rpc.on('clear allPanes',() => {
|
||||
/* Awesome plugin feature */
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cursor
|
||||
If your plugin needs to know cursor position/size, it can decorate the Term component and pass a handler. This handler will be called with each cursor move while passing back all information about the cursor.
|
||||
```js
|
||||
exports.decorateTerm = (Term, { React, notify }) => {
|
||||
// Define and return our higher order component.
|
||||
return class extends React.Component {
|
||||
onCursorMove (cursorFrame) {
|
||||
// Don't forget to propagate it to HOC chain
|
||||
if (this.props.onCursorMove) this.props.onCursorMove(cursorFrame);
|
||||
|
||||
const { x, y, width, height, col, row } = cursorFrame;
|
||||
/* Awesome cursor feature */
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Require Electron
|
||||
Hyper doesn't provide a reference to electron. However plugins can directly require electron.
|
||||
|
||||
```js
|
||||
const electron = require('electron')
|
||||
// or
|
||||
const { dialog, Menu } = require('electron')
|
||||
```
|
||||
|
||||
This is needed in order to allow show/hide to have proper return of focus.
|
||||
|
||||
## Hyper v2 breaking changes
|
||||
Hyper v2 uses `xterm.js` instead of `hterm`. It means that PTY output renders now in a canvas element, not with a hackable DOM structure.
|
||||
For example, plugins can't use TermCSS in order to modify text or link styles anymore. It is now required to use available configuration params that are passed down to `xterm.js`.
|
||||
|
||||
If your plugin was deeply linked with the `hterm` API (even public methods), it certainly doesn't work anymore.
|
||||
|
||||
If your plugin needs some unavailable API to tweak `xterm.js`, please open an issue. We'll be happy to expose some existing `xterm.js` API or implement new ones.
|
||||
125
README.md
125
README.md
|
|
@ -1,121 +1,44 @@
|
|||
<p align="center">
|
||||
<img alt="hyper - modern web-based terminal" height=150 src="https://github.com/user-attachments/assets/3096f20a-8116-45ce-8c5e-0f1106107484">
|
||||
</p>
|
||||
# hyperterm
|
||||
|
||||
<p>
|
||||
<a aria-label="Vercel logo" href="https://vercel.com"><img
|
||||
src="https://img.shields.io/badge/MADE%20BY%20Vercel-000000.svg?style=for-the-badge&logo=vercel&labelColor=000000&logoWidth=20"
|
||||
/></a> <a aria-label="Quine logo" href="https://quineglobal.com"><img
|
||||
width="143" height="28" alt="forked-by-quine" src="https://github.com/user-attachments/assets/57decaa2-7d8c-4d13-ada7-ff6b964346f7"
|
||||
/></a>
|
||||
</p>
|
||||
[](https://zeit.chat/)
|
||||
|
||||
[](https://github.com/quine-global/hyper/actions/workflows/ci.yml)
|
||||

|
||||
|
||||
[](https://changelog.com/213)
|
||||
For downloads, documentation and the developer API head to: https://hyperterm.org
|
||||
|
||||
For more details, head to: https://hyper.is
|
||||
|
||||
## Project goals
|
||||
|
||||
The goal of the project is to create a beautiful and customizable experience for command-line interface users, built on open web standards. We have picked up where Vercel left off, and intend to first offer stability, followed by a more tailored experience. We will still support customizability, but stability of theming APIs is not a goal.
|
||||
|
||||
In the future, we anticipate the community will come up with innovative additions to enhance what could be the simplest, most powerful and well-tested interface for productivity.
|
||||
|
||||
## Usage
|
||||
|
||||
[Download the latest release!](https://hyper.is/#installation)
|
||||
|
||||
### Linux
|
||||
#### Arch and derivatives
|
||||
Hyper is available in the [AUR](https://aur.archlinux.org/packages/hyper/). Use an AUR [package manager](https://wiki.archlinux.org/index.php/AUR_helpers) e.g. [paru](https://github.com/Morganamilo/paru)
|
||||
|
||||
```sh
|
||||
paru -S hyper
|
||||
```
|
||||
|
||||
#### NixOS
|
||||
Hyper is available as [Nix package](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/hyper/default.nix), to install the app run this command:
|
||||
|
||||
```sh
|
||||
nix-env -i hyper
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
Use [Homebrew Cask](https://brew.sh) to download the app by running these commands:
|
||||
(NOTE: only on macOS) With [Homebrew](http://brew.sh/) and [Homebrew Cask](https://caskroom.github.io/) installed, you can run this command:
|
||||
|
||||
```bash
|
||||
brew update
|
||||
brew install --cask hyper
|
||||
brew cask update
|
||||
brew cask install hyperterm
|
||||
```
|
||||
|
||||
### Windows
|
||||
### Repositories
|
||||
|
||||
Use [chocolatey](https://chocolatey.org/) to install the app by running the following command (package information can be found [here](https://chocolatey.org/packages/hyper/)):
|
||||
|
||||
```bash
|
||||
choco install hyper
|
||||
```
|
||||
|
||||
**Note:** The version available on [Homebrew Cask](https://brew.sh), [Chocolatey](https://chocolatey.org), [Snapcraft](https://snapcraft.io/store) or the [AUR](https://aur.archlinux.org) may not be the latest. Please consider downloading it from [here](https://hyper.is/#installation) if that's the case.
|
||||
- Art: https://github.com/zeit/hyperterm-art
|
||||
- Website: https://github.com/zeit/hyperterm-website
|
||||
- Example extension: https://github.com/zeit/hyperpower
|
||||
|
||||
## Contribute
|
||||
|
||||
Regardless of the platform you are working on, you will need to have Yarn installed. If you have never installed Yarn before, you can find out how at: https://yarnpkg.com/en/docs/install.
|
||||
|
||||
1. Install necessary packages:
|
||||
* Windows
|
||||
- Be sure to run `yarn global add windows-build-tools` from an elevated prompt (as an administrator) to install `windows-build-tools`.
|
||||
* macOS
|
||||
- Once you have installed Yarn, you can skip this section!
|
||||
* Linux (You can see [here](https://en.wikipedia.org/wiki/List_of_Linux_distributions) what your Linux is based on.)
|
||||
- RPM-based
|
||||
+ `GraphicsMagick`
|
||||
+ `libicns-utils`
|
||||
+ `xz` (Installed by default on some distributions.)
|
||||
- Debian-based
|
||||
+ `graphicsmagick`
|
||||
+ `icnsutils`
|
||||
+ `xz-utils`
|
||||
2. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
3. Install the dependencies: `yarn`
|
||||
4. Build the code and watch for changes: `yarn run dev`
|
||||
5. To run `hyper`
|
||||
* `yarn run app` from another terminal tab/window/pane
|
||||
* If you are using **Visual Studio Code**, select `Launch Hyper` in debugger configuration to launch a new Hyper instance with debugger attached.
|
||||
* If you interrupt `yarn run dev`, you'll need to relaunch it each time you want to test something. Webpack will watch changes and will rebuild renderer code when needed (and only what have changed). You'll just have to relaunch electron by using yarn run app or VSCode launch task.
|
||||
|
||||
To make sure that your code works in the finished application, you can generate the binaries like this:
|
||||
To test a certain git tree, clone and then run:
|
||||
|
||||
```bash
|
||||
yarn run dist
|
||||
npm install
|
||||
npm run pack
|
||||
```
|
||||
|
||||
After that, you will see the binary in the `./dist` folder!
|
||||
then open the `./dist` folder to find the built binaries!
|
||||
|
||||
#### Known issues that can happen during development
|
||||
If you want to develop, run the above, and then you want to
|
||||
run webpack in `watch` mode:
|
||||
|
||||
##### Error building `node-pty`
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
If after building during development you get an alert dialog related to `node-pty` issues,
|
||||
make sure its build process is working correctly by running `yarn run rebuild-node-pty`.
|
||||
and to load the application simply run:
|
||||
|
||||
If you are on macOS, this typically is related to Xcode issues (like not having agreed
|
||||
to the Terms of Service by running `sudo xcodebuild` after a fresh Xcode installation).
|
||||
|
||||
##### Error with `C++` on macOS when running `yarn`
|
||||
|
||||
If you are getting compiler errors when running `yarn` add the environment variable `export CXX=clang++`
|
||||
|
||||
##### Error with `codesign` on macOS when running `yarn run dist`
|
||||
|
||||
If you have issues in the `codesign` step when running `yarn run dist` on macOS, you can temporarily disable code signing locally by setting
|
||||
`export CSC_IDENTITY_AUTO_DISCOVERY=false` for the current terminal session.
|
||||
|
||||
## Related Repositories
|
||||
|
||||
- [Website](https://github.com/vercel/hyper-site)
|
||||
- [Sample Extension](https://github.com/vercel/hyperpower)
|
||||
- [Sample Theme](https://github.com/vercel/hyperyellow)
|
||||
- [Awesome Hyper](https://github.com/bnb/awesome-hyper)
|
||||
```
|
||||
electron app/index.js
|
||||
```
|
||||
|
|
|
|||
2
app/.eslintignore
Normal file
2
app/.eslintignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
dist
|
||||
node_modules
|
||||
|
|
@ -1 +0,0 @@
|
|||
registry "https://registry.npmjs.org/"
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
import {EventEmitter} from 'events';
|
||||
|
||||
import fetch from 'electron-fetch';
|
||||
|
||||
class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
|
||||
updateURL!: string;
|
||||
quitAndInstall() {
|
||||
this.emitError('QuitAndInstall unimplemented');
|
||||
}
|
||||
getFeedURL() {
|
||||
return this.updateURL;
|
||||
}
|
||||
|
||||
setFeedURL(options: Electron.FeedURLOptions) {
|
||||
this.updateURL = options.url;
|
||||
}
|
||||
|
||||
checkForUpdates() {
|
||||
if (!this.updateURL) {
|
||||
return this.emitError('Update URL is not set');
|
||||
}
|
||||
this.emit('checking-for-update');
|
||||
|
||||
fetch(this.updateURL)
|
||||
.then((res) => {
|
||||
if (res.status === 204) {
|
||||
this.emit('update-not-available');
|
||||
return;
|
||||
}
|
||||
return res.json().then(({name, notes, pub_date}: {name: string; notes: string; pub_date: string}) => {
|
||||
// Only name is mandatory, needed to construct release URL.
|
||||
if (!name) {
|
||||
throw new Error('Malformed server response: release name is missing.');
|
||||
}
|
||||
const date = pub_date ? new Date(pub_date) : new Date();
|
||||
this.emit('update-available', {}, notes, name, date);
|
||||
});
|
||||
})
|
||||
.catch(this.emitError.bind(this));
|
||||
}
|
||||
|
||||
emitError(error: string | Error) {
|
||||
if (typeof error === 'string') {
|
||||
error = new Error(error);
|
||||
}
|
||||
this.emit('error', error);
|
||||
}
|
||||
}
|
||||
|
||||
const autoUpdaterLinux = new AutoUpdater();
|
||||
|
||||
export default autoUpdaterLinux;
|
||||
45
app/auto-updater.js
Normal file
45
app/auto-updater.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
const { autoUpdater } = require('electron');
|
||||
const { version } = require('./package');
|
||||
const notify = require('./notify'); // eslint-disable-line no-unused-vars
|
||||
const ms = require('ms');
|
||||
|
||||
const FEED_URL = 'https://hyperterm-updates.now.sh/update/osx';
|
||||
let isInit = false;
|
||||
|
||||
function init () {
|
||||
autoUpdater.on('error', (err, msg) => {
|
||||
console.error('Error fetching updates', msg + ' (' + err.stack + ')');
|
||||
});
|
||||
|
||||
autoUpdater.setFeedURL(`${FEED_URL}/${version}`);
|
||||
|
||||
setTimeout(() => {
|
||||
autoUpdater.checkForUpdates();
|
||||
}, ms('10s'));
|
||||
|
||||
setInterval(() => {
|
||||
autoUpdater.checkForUpdates();
|
||||
}, ms('5m'));
|
||||
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
module.exports = function (win) {
|
||||
if (!isInit) init();
|
||||
|
||||
const { rpc } = win;
|
||||
|
||||
const onupdate = (ev, releaseNotes, releaseName) => {
|
||||
rpc.emit('update available', { releaseNotes, releaseName });
|
||||
};
|
||||
|
||||
autoUpdater.on('update-downloaded', onupdate);
|
||||
|
||||
rpc.once('quit and install', () => {
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
win.on('close', () => {
|
||||
autoUpdater.removeListener('update-downloaded', onupdate);
|
||||
});
|
||||
};
|
||||
170
app/commands.ts
170
app/commands.ts
|
|
@ -1,170 +0,0 @@
|
|||
import {app, Menu} from 'electron';
|
||||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
import {openConfig, getConfig} from './config';
|
||||
import {updatePlugins} from './plugins';
|
||||
import {installCLI} from './utils/cli-install';
|
||||
import * as systemContextMenu from './utils/system-context-menu';
|
||||
|
||||
const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
|
||||
'window:new': () => {
|
||||
// If window is created on the same tick, it will consume event too
|
||||
setTimeout(app.createWindow, 0);
|
||||
},
|
||||
'tab:new': (focusedWindow) => {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('termgroup add req', {});
|
||||
} else {
|
||||
setTimeout(app.createWindow, 0);
|
||||
}
|
||||
},
|
||||
'pane:splitRight': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('split request vertical', {});
|
||||
},
|
||||
'pane:splitDown': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('split request horizontal', {});
|
||||
},
|
||||
'pane:close': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('termgroup close req');
|
||||
},
|
||||
'window:preferences': () => {
|
||||
void openConfig();
|
||||
},
|
||||
'editor:clearBuffer': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session clear req');
|
||||
},
|
||||
'editor:selectAll': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('term selectAll');
|
||||
},
|
||||
'plugins:update': () => {
|
||||
updatePlugins();
|
||||
},
|
||||
'window:reload': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('reload');
|
||||
},
|
||||
'window:reloadFull': (focusedWindow) => {
|
||||
focusedWindow?.reload();
|
||||
},
|
||||
'window:devtools': (focusedWindow) => {
|
||||
if (!focusedWindow) {
|
||||
return;
|
||||
}
|
||||
const webContents = focusedWindow.webContents;
|
||||
if (webContents.isDevToolsOpened()) {
|
||||
webContents.closeDevTools();
|
||||
} else {
|
||||
webContents.openDevTools({mode: 'detach'});
|
||||
}
|
||||
},
|
||||
'zoom:reset': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('reset fontSize req');
|
||||
},
|
||||
'zoom:in': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('increase fontSize req');
|
||||
},
|
||||
'zoom:out': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('decrease fontSize req');
|
||||
},
|
||||
'tab:prev': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('move left req');
|
||||
},
|
||||
'tab:next': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('move right req');
|
||||
},
|
||||
'pane:prev': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('prev pane req');
|
||||
},
|
||||
'pane:next': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('next pane req');
|
||||
},
|
||||
'editor:movePreviousWord': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session move word left req');
|
||||
},
|
||||
'editor:moveNextWord': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session move word right req');
|
||||
},
|
||||
'editor:moveBeginningLine': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session move line beginning req');
|
||||
},
|
||||
'editor:moveEndLine': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session move line end req');
|
||||
},
|
||||
'editor:deletePreviousWord': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session del word left req');
|
||||
},
|
||||
'editor:deleteNextWord': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session del word right req');
|
||||
},
|
||||
'editor:deleteBeginningLine': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session del line beginning req');
|
||||
},
|
||||
'editor:deleteEndLine': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session del line end req');
|
||||
},
|
||||
'editor:break': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session break req');
|
||||
},
|
||||
'editor:stop': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session stop req');
|
||||
},
|
||||
'editor:quit': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session quit req');
|
||||
},
|
||||
'editor:tmux': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session tmux req');
|
||||
},
|
||||
'editor:search': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session search');
|
||||
},
|
||||
'editor:search-close': (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('session search close');
|
||||
},
|
||||
'cli:install': () => {
|
||||
void installCLI(true);
|
||||
},
|
||||
'window:hamburgerMenu': () => {
|
||||
if (process.platform !== 'darwin' && ['', true].includes(getConfig().showHamburgerMenu)) {
|
||||
Menu.getApplicationMenu()!.popup({x: 25, y: 22});
|
||||
}
|
||||
},
|
||||
'systemContextMenu:add': () => {
|
||||
systemContextMenu.add();
|
||||
},
|
||||
'systemContextMenu:remove': () => {
|
||||
systemContextMenu.remove();
|
||||
},
|
||||
'window:toggleKeepOnTop': (focusedWindow) => {
|
||||
focusedWindow?.setAlwaysOnTop(!focusedWindow.isAlwaysOnTop());
|
||||
}
|
||||
};
|
||||
|
||||
//Special numeric command
|
||||
([1, 2, 3, 4, 5, 6, 7, 8, 'last'] as const).forEach((cmdIndex) => {
|
||||
const index = cmdIndex === 'last' ? cmdIndex : cmdIndex - 1;
|
||||
commands[`tab:jump:${cmdIndex}`] = (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('move jump req', index);
|
||||
};
|
||||
});
|
||||
|
||||
//Profile specific commands
|
||||
getConfig().profiles.forEach((profile) => {
|
||||
commands[`window:new:${profile.name}`] = () => {
|
||||
setTimeout(() => app.createWindow(undefined, undefined, profile.name), 0);
|
||||
};
|
||||
commands[`tab:new:${profile.name}`] = (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('termgroup add req', {profile: profile.name});
|
||||
};
|
||||
commands[`pane:splitRight:${profile.name}`] = (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('split request vertical', {profile: profile.name});
|
||||
};
|
||||
commands[`pane:splitDown:${profile.name}`] = (focusedWindow) => {
|
||||
focusedWindow?.rpc.emit('split request horizontal', {profile: profile.name});
|
||||
};
|
||||
});
|
||||
|
||||
export const execCommand = (command: string, focusedWindow?: BrowserWindow) => {
|
||||
const fn = commands[command];
|
||||
if (fn) {
|
||||
fn(focusedWindow);
|
||||
}
|
||||
};
|
||||
74
app/config-default.js
Normal file
74
app/config-default.js
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
module.exports = {
|
||||
config: {
|
||||
// default font size in pixels for all tabs
|
||||
fontSize: 12,
|
||||
|
||||
// font family with optional fallbacks
|
||||
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
|
||||
|
||||
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
|
||||
cursorColor: 'rgba(248,28,229,0.75)',
|
||||
|
||||
// `BEAM` for |, `UNDERLINE` for _, `BLOCK` for █
|
||||
cursorShape: 'BLOCK',
|
||||
|
||||
// color of the text
|
||||
foregroundColor: '#fff',
|
||||
|
||||
// terminal background color
|
||||
backgroundColor: '#000',
|
||||
|
||||
// border color (window, tabs)
|
||||
borderColor: '#333',
|
||||
|
||||
// custom css to embed in the main window
|
||||
css: '',
|
||||
|
||||
// custom css to embed in the terminal window
|
||||
termCSS: '',
|
||||
|
||||
// custom padding (css format, i.e.: `top right bottom left`)
|
||||
padding: '12px 14px',
|
||||
|
||||
// the full list. if you're going to provide the full color palette,
|
||||
// including the 6 x 6 color cubes and the grayscale map, just provide
|
||||
// an array here instead of a color map object
|
||||
colors: {
|
||||
black: '#000000',
|
||||
red: '#ff0000',
|
||||
green: '#33ff00',
|
||||
yellow: '#ffff00',
|
||||
blue: '#0066ff',
|
||||
magenta: '#cc00ff',
|
||||
cyan: '#00ffff',
|
||||
white: '#d0d0d0',
|
||||
lightBlack: '#808080',
|
||||
lightRed: '#ff0000',
|
||||
lightGreen: '#33ff00',
|
||||
lightYellow: '#ffff00',
|
||||
lightBlue: '#0066ff',
|
||||
lightMagenta: '#cc00ff',
|
||||
lightCyan: '#00ffff',
|
||||
lightWhite: '#ffffff'
|
||||
},
|
||||
|
||||
// the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
|
||||
// if left empty, your system's login shell will be used by default
|
||||
shell: ''
|
||||
|
||||
// for advanced config flags please refer to https://hyperterm.org/#cfg
|
||||
},
|
||||
|
||||
// a list of plugins to fetch and install from npm
|
||||
// format: [@org/]project[#version]
|
||||
// examples:
|
||||
// `hyperpower`
|
||||
// `@company/project`
|
||||
// `project#1.0.1`
|
||||
plugins: [],
|
||||
|
||||
// in development, you can create a directory under
|
||||
// `~/.hyperterm_plugins/local/` and include it here
|
||||
// to load it and avoid it being `npm install`ed
|
||||
localPlugins: []
|
||||
};
|
||||
86
app/config.js
Normal file
86
app/config.js
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
const { dialog } = require('electron');
|
||||
const { homedir } = require('os');
|
||||
const { resolve } = require('path');
|
||||
const { readFileSync, writeFileSync } = require('fs');
|
||||
const gaze = require('gaze');
|
||||
const vm = require('vm');
|
||||
const notify = require('./notify');
|
||||
|
||||
const path = resolve(homedir(), '.hyperterm.js');
|
||||
const watchers = [];
|
||||
|
||||
let cfg = {};
|
||||
|
||||
function watch () {
|
||||
gaze(path, function (err) {
|
||||
if (err) throw err;
|
||||
this.on('changed', () => {
|
||||
try {
|
||||
if (exec(readFileSync(path, 'utf8'))) {
|
||||
notify('HyperTerm configuration reloaded!');
|
||||
watchers.forEach((fn) => fn());
|
||||
}
|
||||
} catch (err) {
|
||||
dialog.showMessageBox({
|
||||
message: `An error occurred loading your configuration (${path}): ${err.message}`,
|
||||
buttons: ['Ok']
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let _str; // last script
|
||||
function exec (str) {
|
||||
if (str === _str) return false;
|
||||
_str = str;
|
||||
const script = new vm.Script(str);
|
||||
const module = {};
|
||||
script.runInNewContext({ module });
|
||||
if (!module.exports) {
|
||||
throw new Error('Error reading configuration: `module.exports` not set');
|
||||
}
|
||||
const _cfg = module.exports;
|
||||
if (!_cfg.config) {
|
||||
throw new Error('Error reading configuration: `config` key is missing');
|
||||
}
|
||||
_cfg.plugins = _cfg.plugins || [];
|
||||
_cfg.localPlugins = _cfg.localPlugins || [];
|
||||
cfg = _cfg;
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.subscribe = function (fn) {
|
||||
watchers.push(fn);
|
||||
return () => {
|
||||
watchers.splice(watchers.indexOf(fn), 1);
|
||||
};
|
||||
};
|
||||
|
||||
exports.init = function () {
|
||||
try {
|
||||
exec(readFileSync(path, 'utf8'));
|
||||
} catch (err) {
|
||||
console.log('read error', path, err.message);
|
||||
const defaultConfig = readFileSync(resolve(__dirname, 'config-default.js'));
|
||||
try {
|
||||
console.log('attempting to write default config to', path);
|
||||
exec(defaultConfig);
|
||||
writeFileSync(path, defaultConfig);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to write config to ${path}`);
|
||||
}
|
||||
}
|
||||
watch();
|
||||
};
|
||||
|
||||
exports.getConfig = function () {
|
||||
return cfg.config;
|
||||
};
|
||||
|
||||
exports.getPlugins = function () {
|
||||
return {
|
||||
plugins: cfg.plugins,
|
||||
localPlugins: cfg.localPlugins
|
||||
};
|
||||
};
|
||||
156
app/config.ts
156
app/config.ts
|
|
@ -1,156 +0,0 @@
|
|||
import {app} from 'electron';
|
||||
|
||||
import chokidar from 'chokidar';
|
||||
|
||||
import type {parsedConfig, configOptions} from '../typings/config';
|
||||
|
||||
import {_import, getDefaultConfig} from './config/import';
|
||||
import _openConfig from './config/open';
|
||||
import {cfgPath, cfgDir} from './config/paths';
|
||||
import notify from './notify';
|
||||
import {getColorMap} from './utils/colors';
|
||||
|
||||
const watchers: Function[] = [];
|
||||
let cfg: parsedConfig = {} as any;
|
||||
let _watcher: chokidar.FSWatcher;
|
||||
|
||||
export const getDeprecatedCSS = (config: configOptions) => {
|
||||
const deprecated: string[] = [];
|
||||
const deprecatedCSS = ['x-screen', 'x-row', 'cursor-node', '::selection'];
|
||||
deprecatedCSS.forEach((css) => {
|
||||
if (config.css?.includes(css) || config.termCSS?.includes(css)) {
|
||||
deprecated.push(css);
|
||||
}
|
||||
});
|
||||
return deprecated;
|
||||
};
|
||||
|
||||
const checkDeprecatedConfig = () => {
|
||||
if (!cfg.config) {
|
||||
return;
|
||||
}
|
||||
const deprecated = getDeprecatedCSS(cfg.config);
|
||||
if (deprecated.length === 0) {
|
||||
return;
|
||||
}
|
||||
const deprecatedStr = deprecated.join(', ');
|
||||
notify('Configuration warning', `Your configuration uses some deprecated CSS classes (${deprecatedStr})`);
|
||||
};
|
||||
|
||||
const _watch = () => {
|
||||
if (_watcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
const onChange = () => {
|
||||
// Need to wait 100ms to ensure that write is complete
|
||||
setTimeout(() => {
|
||||
cfg = _import();
|
||||
notify('Configuration updated', 'Hyper configuration reloaded!');
|
||||
watchers.forEach((fn) => {
|
||||
fn();
|
||||
});
|
||||
checkDeprecatedConfig();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
_watcher = chokidar.watch(cfgPath);
|
||||
_watcher.on('change', onChange);
|
||||
_watcher.on('error', (error) => {
|
||||
console.error('error watching config', error);
|
||||
});
|
||||
|
||||
app.on('before-quit', () => {
|
||||
if (Object.keys(_watcher.getWatched()).length > 0) {
|
||||
_watcher.close().catch((err) => {
|
||||
console.warn(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const subscribe = (fn: Function) => {
|
||||
watchers.push(fn);
|
||||
return () => {
|
||||
watchers.splice(watchers.indexOf(fn), 1);
|
||||
};
|
||||
};
|
||||
|
||||
export const getConfigDir = () => {
|
||||
// expose config directory to load plugin from the right place
|
||||
return cfgDir;
|
||||
};
|
||||
|
||||
export const getDefaultProfile = () => {
|
||||
return cfg.config.defaultProfile || cfg.config.profiles[0]?.name || 'default';
|
||||
};
|
||||
|
||||
// get config for the default profile, keeping it for backward compatibility
|
||||
export const getConfig = () => {
|
||||
return getProfileConfig(getDefaultProfile());
|
||||
};
|
||||
|
||||
export const getProfiles = () => {
|
||||
return cfg.config.profiles;
|
||||
};
|
||||
|
||||
export const getProfileConfig = (profileName: string): configOptions => {
|
||||
const {profiles, defaultProfile, ...baseConfig} = cfg.config;
|
||||
const profileConfig = profiles.find((p) => p.name === profileName)?.config || {};
|
||||
for (const key in profileConfig) {
|
||||
if (typeof baseConfig[key] === 'object' && !Array.isArray(baseConfig[key])) {
|
||||
baseConfig[key] = {...baseConfig[key], ...profileConfig[key]};
|
||||
} else {
|
||||
baseConfig[key] = profileConfig[key];
|
||||
}
|
||||
}
|
||||
return {...baseConfig, defaultProfile, profiles};
|
||||
};
|
||||
|
||||
export const openConfig = () => {
|
||||
return _openConfig();
|
||||
};
|
||||
|
||||
export const getPlugins = (): {plugins: string[]; localPlugins: string[]} => {
|
||||
return {
|
||||
plugins: cfg.plugins,
|
||||
localPlugins: cfg.localPlugins
|
||||
};
|
||||
};
|
||||
|
||||
export const getKeymaps = () => {
|
||||
return cfg.keymaps;
|
||||
};
|
||||
|
||||
export const setup = () => {
|
||||
cfg = _import();
|
||||
_watch();
|
||||
checkDeprecatedConfig();
|
||||
};
|
||||
|
||||
export {get as getWin, recordState as winRecord, defaults as windowDefaults} from './config/windows';
|
||||
|
||||
export const fixConfigDefaults = (decoratedConfig: configOptions) => {
|
||||
const defaultConfig = getDefaultConfig().config!;
|
||||
decoratedConfig.colors = getColorMap(decoratedConfig.colors) || {};
|
||||
// We must have default colors for xterm css.
|
||||
decoratedConfig.colors = {...defaultConfig.colors, ...decoratedConfig.colors};
|
||||
return decoratedConfig;
|
||||
};
|
||||
|
||||
export const htermConfigTranslate = (config: configOptions) => {
|
||||
const cssReplacements: Record<string, string> = {
|
||||
'x-screen x-row([ {.[])': '.xterm-rows > div$1',
|
||||
'.cursor-node([ {.[])': '.terminal-cursor$1',
|
||||
'::selection([ {.[])': '.terminal .xterm-selection div$1',
|
||||
'x-screen a([ {.[])': '.terminal a$1',
|
||||
'x-row a([ {.[])': '.terminal a$1'
|
||||
};
|
||||
Object.keys(cssReplacements).forEach((pattern) => {
|
||||
const searchvalue = new RegExp(pattern, 'g');
|
||||
const newvalue = cssReplacements[pattern];
|
||||
config.css = config.css?.replace(searchvalue, newvalue);
|
||||
config.termCSS = config.termCSS?.replace(searchvalue, newvalue);
|
||||
});
|
||||
return config;
|
||||
};
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
{
|
||||
"$schema": "./schema.json",
|
||||
"config": {
|
||||
"updateChannel": "stable",
|
||||
"fontSize": 12,
|
||||
"fontFamily": "Menlo, \"DejaVu Sans Mono\", Consolas, \"Lucida Console\", monospace",
|
||||
"fontWeight": "normal",
|
||||
"fontWeightBold": "bold",
|
||||
"lineHeight": 1,
|
||||
"letterSpacing": 0,
|
||||
"scrollback": 1000,
|
||||
"cursorColor": "rgba(248,28,229,0.8)",
|
||||
"cursorAccentColor": "#000",
|
||||
"cursorShape": "BLOCK",
|
||||
"cursorBlink": false,
|
||||
"foregroundColor": "#fff",
|
||||
"backgroundColor": "#000",
|
||||
"selectionColor": "rgba(248,28,229,0.3)",
|
||||
"borderColor": "#333",
|
||||
"css": "",
|
||||
"termCSS": "",
|
||||
"workingDirectory": "",
|
||||
"showHamburgerMenu": "",
|
||||
"showWindowControls": "",
|
||||
"padding": "12px 14px",
|
||||
"colors": {
|
||||
"black": "#000000",
|
||||
"red": "#C51E14",
|
||||
"green": "#1DC121",
|
||||
"yellow": "#C7C329",
|
||||
"blue": "#0A2FC4",
|
||||
"magenta": "#C839C5",
|
||||
"cyan": "#20C5C6",
|
||||
"white": "#C7C7C7",
|
||||
"lightBlack": "#686868",
|
||||
"lightRed": "#FD6F6B",
|
||||
"lightGreen": "#67F86F",
|
||||
"lightYellow": "#FFFA72",
|
||||
"lightBlue": "#6A76FB",
|
||||
"lightMagenta": "#FD7CFC",
|
||||
"lightCyan": "#68FDFE",
|
||||
"lightWhite": "#FFFFFF",
|
||||
"limeGreen": "#32CD32",
|
||||
"lightCoral": "#F08080"
|
||||
},
|
||||
"shell": "",
|
||||
"shellArgs": [
|
||||
"--login"
|
||||
],
|
||||
"env": {},
|
||||
"bell": "SOUND",
|
||||
"bellSound": null,
|
||||
"bellSoundURL": null,
|
||||
"copyOnSelect": false,
|
||||
"defaultSSHApp": true,
|
||||
"quickEdit": false,
|
||||
"macOptionSelectionMode": "vertical",
|
||||
"webGLRenderer": false,
|
||||
"webLinksActivationKey": "",
|
||||
"disableLigatures": true,
|
||||
"disableAutoUpdates": false,
|
||||
"autoUpdatePlugins": true,
|
||||
"preserveCWD": true,
|
||||
"screenReaderMode": false,
|
||||
"imageSupport": true,
|
||||
"defaultProfile": "default",
|
||||
"profiles": [
|
||||
{
|
||||
"name": "default",
|
||||
"config": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
"plugins": [],
|
||||
"localPlugins": [],
|
||||
"keymaps": {}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
import {readFileSync, mkdirpSync} from 'fs-extra';
|
||||
|
||||
import type {rawConfig} from '../../typings/config';
|
||||
import notify from '../notify';
|
||||
|
||||
import {_init} from './init';
|
||||
import {migrateHyper3Config} from './migrate';
|
||||
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';
|
||||
|
||||
let defaultConfig: rawConfig;
|
||||
|
||||
const _importConf = () => {
|
||||
// init plugin directories if not present
|
||||
mkdirpSync(plugs.base);
|
||||
mkdirpSync(plugs.local);
|
||||
|
||||
try {
|
||||
migrateHyper3Config();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
let defaultCfgRaw = '{}';
|
||||
try {
|
||||
defaultCfgRaw = readFileSync(defaultCfg, 'utf8');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
const _defaultCfg = JSON.parse(defaultCfgRaw) as rawConfig;
|
||||
|
||||
// Importing platform specific keymap
|
||||
let content = '{}';
|
||||
try {
|
||||
content = readFileSync(defaultPlatformKeyPath(), 'utf8');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
const mapping = JSON.parse(content) as Record<string, string | string[]>;
|
||||
_defaultCfg.keymaps = mapping;
|
||||
|
||||
// Import user config
|
||||
let userCfg: rawConfig;
|
||||
try {
|
||||
userCfg = JSON.parse(readFileSync(cfgPath, 'utf8'));
|
||||
} catch (err) {
|
||||
notify("Couldn't parse config file. Using default config instead.");
|
||||
userCfg = JSON.parse(defaultCfgRaw);
|
||||
}
|
||||
|
||||
return {userCfg, defaultCfg: _defaultCfg};
|
||||
};
|
||||
|
||||
export const _import = () => {
|
||||
const imported = _importConf();
|
||||
defaultConfig = imported.defaultCfg;
|
||||
const result = _init(imported.userCfg, imported.defaultCfg);
|
||||
return result;
|
||||
};
|
||||
|
||||
export const getDefaultConfig = () => {
|
||||
if (!defaultConfig) {
|
||||
defaultConfig = _importConf().defaultCfg;
|
||||
}
|
||||
return defaultConfig;
|
||||
};
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
import vm from 'vm';
|
||||
|
||||
import merge from 'lodash/merge';
|
||||
|
||||
import type {parsedConfig, rawConfig, configOptions} from '../../typings/config';
|
||||
import notify from '../notify';
|
||||
import mapKeys from '../utils/map-keys';
|
||||
|
||||
const _extract = (script?: vm.Script): Record<string, any> => {
|
||||
const module: Record<string, any> = {};
|
||||
script?.runInNewContext({module}, {displayErrors: true});
|
||||
if (!module.exports) {
|
||||
throw new Error('Error reading configuration: `module.exports` not set');
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return module.exports;
|
||||
};
|
||||
|
||||
const _syntaxValidation = (cfg: string) => {
|
||||
try {
|
||||
return new vm.Script(cfg, {filename: '.hyper.js'});
|
||||
} catch (_err) {
|
||||
const err = _err as {name: string};
|
||||
notify(`Error loading config: ${err.name}`, JSON.stringify(err), {error: err});
|
||||
}
|
||||
};
|
||||
|
||||
const _extractDefault = (cfg: string) => {
|
||||
return _extract(_syntaxValidation(cfg));
|
||||
};
|
||||
|
||||
// init config
|
||||
const _init = (userCfg: rawConfig, defaultCfg: rawConfig): parsedConfig => {
|
||||
return {
|
||||
config: (() => {
|
||||
if (userCfg?.config) {
|
||||
const conf = userCfg.config;
|
||||
conf.defaultProfile = conf.defaultProfile || 'default';
|
||||
conf.profiles = conf.profiles || [];
|
||||
conf.profiles = conf.profiles.length > 0 ? conf.profiles : [{name: 'default', config: {}}];
|
||||
conf.profiles = conf.profiles.map((p, i) => ({
|
||||
...p,
|
||||
name: p.name || `profile-${i + 1}`,
|
||||
config: p.config || {}
|
||||
}));
|
||||
if (!conf.profiles.map((p) => p.name).includes(conf.defaultProfile)) {
|
||||
conf.defaultProfile = conf.profiles[0].name;
|
||||
}
|
||||
return merge({}, defaultCfg.config, conf);
|
||||
} else {
|
||||
notify('Error reading configuration: `config` key is missing');
|
||||
return defaultCfg.config || ({} as configOptions);
|
||||
}
|
||||
})(),
|
||||
// Merging platform specific keymaps with user defined keymaps
|
||||
keymaps: mapKeys({...defaultCfg.keymaps, ...userCfg?.keymaps}),
|
||||
// Ignore undefined values in plugin and localPlugins array Issue #1862
|
||||
plugins: userCfg?.plugins?.filter(Boolean) || [],
|
||||
localPlugins: userCfg?.localPlugins?.filter(Boolean) || []
|
||||
};
|
||||
};
|
||||
|
||||
export {_init, _extractDefault};
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
import {dirname, resolve} from 'path';
|
||||
|
||||
import {builders, namedTypes} from 'ast-types';
|
||||
import type {ExpressionKind} from 'ast-types/lib/gen/kinds';
|
||||
import {copy, copySync, existsSync, readFileSync, writeFileSync} from 'fs-extra';
|
||||
import merge from 'lodash/merge';
|
||||
import {parse, prettyPrint} from 'recast';
|
||||
import * as babelParser from 'recast/parsers/babel';
|
||||
|
||||
import notify from '../notify';
|
||||
|
||||
import {_extractDefault} from './init';
|
||||
import {cfgDir, cfgPath, defaultCfg, legacyCfgPath, plugs, schemaFile, schemaPath} from './paths';
|
||||
|
||||
// function to remove all json serializable entries from an array expression
|
||||
function removeElements(node: namedTypes.ArrayExpression): namedTypes.ArrayExpression {
|
||||
const newElements = node.elements.filter((element) => {
|
||||
if (namedTypes.ObjectExpression.check(element)) {
|
||||
const newElement = removeProperties(element);
|
||||
if (newElement.properties.length === 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (namedTypes.ArrayExpression.check(element)) {
|
||||
const newElement = removeElements(element);
|
||||
if (newElement.elements.length === 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (namedTypes.Literal.check(element)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return {...node, elements: newElements};
|
||||
}
|
||||
|
||||
// function to remove all json serializable properties from an object expression
|
||||
function removeProperties(node: namedTypes.ObjectExpression): namedTypes.ObjectExpression {
|
||||
const newProperties = node.properties.filter((property) => {
|
||||
if (
|
||||
namedTypes.ObjectProperty.check(property) &&
|
||||
(namedTypes.Literal.check(property.key) || namedTypes.Identifier.check(property.key)) &&
|
||||
!property.computed
|
||||
) {
|
||||
if (namedTypes.ObjectExpression.check(property.value)) {
|
||||
const newValue = removeProperties(property.value);
|
||||
if (newValue.properties.length === 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (namedTypes.ArrayExpression.check(property.value)) {
|
||||
const newValue = removeElements(property.value);
|
||||
if (newValue.elements.length === 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (namedTypes.Literal.check(property.value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return {...node, properties: newProperties};
|
||||
}
|
||||
|
||||
export function configToPlugin(code: string): string {
|
||||
const ast: namedTypes.File = parse(code, {
|
||||
parser: babelParser
|
||||
});
|
||||
const statements = ast.program.body;
|
||||
let moduleExportsNode: namedTypes.AssignmentExpression | null = null;
|
||||
let configNode: ExpressionKind | null = null;
|
||||
|
||||
for (const statement of statements) {
|
||||
if (namedTypes.ExpressionStatement.check(statement)) {
|
||||
const expression = statement.expression;
|
||||
if (
|
||||
namedTypes.AssignmentExpression.check(expression) &&
|
||||
expression.operator === '=' &&
|
||||
namedTypes.MemberExpression.check(expression.left) &&
|
||||
namedTypes.Identifier.check(expression.left.object) &&
|
||||
expression.left.object.name === 'module' &&
|
||||
namedTypes.Identifier.check(expression.left.property) &&
|
||||
expression.left.property.name === 'exports'
|
||||
) {
|
||||
moduleExportsNode = expression;
|
||||
if (namedTypes.ObjectExpression.check(expression.right)) {
|
||||
const properties = expression.right.properties;
|
||||
for (const property of properties) {
|
||||
if (
|
||||
namedTypes.ObjectProperty.check(property) &&
|
||||
namedTypes.Identifier.check(property.key) &&
|
||||
property.key.name === 'config'
|
||||
) {
|
||||
configNode = property.value as ExpressionKind;
|
||||
if (namedTypes.ObjectExpression.check(property.value)) {
|
||||
configNode = removeProperties(property.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
configNode = builders.memberExpression(moduleExportsNode.right, builders.identifier('config'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!moduleExportsNode) {
|
||||
console.log('No module.exports found in config');
|
||||
return '';
|
||||
}
|
||||
if (!configNode) {
|
||||
console.log('No config field found in module.exports');
|
||||
return '';
|
||||
}
|
||||
if (namedTypes.ObjectExpression.check(configNode) && configNode.properties.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
moduleExportsNode.right = builders.objectExpression([
|
||||
builders.property(
|
||||
'init',
|
||||
builders.identifier('decorateConfig'),
|
||||
builders.arrowFunctionExpression(
|
||||
[builders.identifier('_config')],
|
||||
builders.callExpression(
|
||||
builders.memberExpression(builders.identifier('Object'), builders.identifier('assign')),
|
||||
[builders.objectExpression([]), builders.identifier('_config'), configNode]
|
||||
)
|
||||
)
|
||||
)
|
||||
]);
|
||||
|
||||
return prettyPrint(ast, {tabWidth: 2}).code;
|
||||
}
|
||||
|
||||
export const _write = (path: string, data: string) => {
|
||||
// This method will take text formatted as Unix line endings and transform it
|
||||
// to text formatted with DOS line endings. We do this because the default
|
||||
// text editor on Windows (notepad) doesn't Deal with LF files. Still. In 2017.
|
||||
const crlfify = (str: string) => {
|
||||
return str.replace(/\r?\n/g, '\r\n');
|
||||
};
|
||||
const format = process.platform === 'win32' ? crlfify(data.toString()) : data;
|
||||
writeFileSync(path, format, 'utf8');
|
||||
};
|
||||
|
||||
// Migrate Hyper3 config to Hyper4 but only if the user hasn't manually
|
||||
// touched the new config and if the old config is not a symlink
|
||||
export const migrateHyper3Config = () => {
|
||||
copy(schemaPath, resolve(cfgDir, schemaFile), (err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
if (existsSync(cfgPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!existsSync(legacyCfgPath)) {
|
||||
copySync(defaultCfg, cfgPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Migrate
|
||||
copySync(resolve(dirname(legacyCfgPath), '.hyper_plugins', 'local'), plugs.local);
|
||||
|
||||
const defaultCfgData = JSON.parse(readFileSync(defaultCfg, 'utf8'));
|
||||
let newCfgData;
|
||||
try {
|
||||
const legacyCfgRaw = readFileSync(legacyCfgPath, 'utf8');
|
||||
const legacyCfgData = _extractDefault(legacyCfgRaw);
|
||||
newCfgData = merge({}, defaultCfgData, legacyCfgData);
|
||||
|
||||
const pluginCode = configToPlugin(legacyCfgRaw);
|
||||
if (pluginCode) {
|
||||
const pluginPath = resolve(plugs.local, 'migrated-hyper3-config.js');
|
||||
newCfgData.localPlugins = ['migrated-hyper3-config', ...(newCfgData.localPlugins || [])];
|
||||
_write(pluginPath, pluginCode);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
notify(
|
||||
'Hyper 4',
|
||||
`Failed to migrate your config from Hyper 3.\nDefault config will be created instead at ${cfgPath}`
|
||||
);
|
||||
newCfgData = defaultCfgData;
|
||||
}
|
||||
_write(cfgPath, JSON.stringify(newCfgData, null, 2));
|
||||
|
||||
notify('Hyper 4', `Settings location and format has changed to ${cfgPath}`);
|
||||
};
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
import {exec} from 'child_process';
|
||||
|
||||
import {shell} from 'electron';
|
||||
|
||||
import * as Registry from 'native-reg';
|
||||
|
||||
import {cfgPath} from './paths';
|
||||
|
||||
const getUserChoiceKey = () => {
|
||||
try {
|
||||
// Load FileExts keys for .js files
|
||||
const fileExtsKeys = Registry.openKey(
|
||||
Registry.HKCU,
|
||||
'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.js',
|
||||
Registry.Access.READ
|
||||
);
|
||||
const keys = fileExtsKeys ? Registry.enumKeyNames(fileExtsKeys) : [];
|
||||
Registry.closeKey(fileExtsKeys);
|
||||
|
||||
// Find UserChoice key
|
||||
const userChoice = keys.find((k) => k.endsWith('UserChoice'));
|
||||
return userChoice
|
||||
? `Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.js\\${userChoice}`
|
||||
: userChoice;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const hasDefaultSet = () => {
|
||||
const userChoice = getUserChoiceKey();
|
||||
if (!userChoice) return false;
|
||||
|
||||
try {
|
||||
// Load key values
|
||||
const userChoiceKey = Registry.openKey(Registry.HKCU, userChoice, Registry.Access.READ)!;
|
||||
const values: string[] = Registry.enumValueNames(userChoiceKey).map(
|
||||
(x) => (Registry.queryValue(userChoiceKey, x) as string) || ''
|
||||
);
|
||||
Registry.closeKey(userChoiceKey);
|
||||
|
||||
// Look for default program
|
||||
const hasDefaultProgramConfigured = values.every(
|
||||
(value) => value && typeof value === 'string' && !value.includes('WScript.exe') && !value.includes('JSFile')
|
||||
);
|
||||
|
||||
return hasDefaultProgramConfigured;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// This mimics shell.openItem, true if it worked, false if not.
|
||||
const openNotepad = (file: string) =>
|
||||
new Promise<boolean>((resolve) => {
|
||||
exec(`start notepad.exe ${file}`, (error) => {
|
||||
resolve(!error);
|
||||
});
|
||||
});
|
||||
|
||||
const openConfig = () => {
|
||||
// Windows opens .js files with WScript.exe by default
|
||||
// If the user hasn't set up an editor for .js files, we fallback to notepad.
|
||||
if (process.platform === 'win32') {
|
||||
try {
|
||||
if (hasDefaultSet()) {
|
||||
return shell.openPath(cfgPath).then((error) => error === '');
|
||||
}
|
||||
console.warn('No default app set for .js files, using notepad.exe fallback');
|
||||
} catch (err) {
|
||||
console.error('Open config with default app error:', err);
|
||||
}
|
||||
return openNotepad(cfgPath);
|
||||
}
|
||||
return shell.openPath(cfgPath).then((error) => error === '');
|
||||
};
|
||||
|
||||
export default openConfig;
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
// This module exports paths, names, and other metadata that is referenced
|
||||
import {statSync} from 'fs';
|
||||
import {homedir} from 'os';
|
||||
import {resolve, join} from 'path';
|
||||
|
||||
import {app} from 'electron';
|
||||
|
||||
import isDev from 'electron-is-dev';
|
||||
|
||||
const cfgFile = 'hyper.json';
|
||||
const defaultCfgFile = 'config-default.json';
|
||||
const schemaFile = 'schema.json';
|
||||
const homeDirectory = homedir();
|
||||
|
||||
// If the user defines XDG_CONFIG_HOME they definitely want their config there,
|
||||
// otherwise use the home directory in linux/mac and userdata in windows
|
||||
let cfgDir = process.env.XDG_CONFIG_HOME
|
||||
? join(process.env.XDG_CONFIG_HOME, 'Hyper')
|
||||
: process.platform === 'win32'
|
||||
? app.getPath('userData')
|
||||
: join(homeDirectory, '.config', 'Hyper');
|
||||
|
||||
const legacyCfgPath = join(
|
||||
process.env.XDG_CONFIG_HOME !== undefined
|
||||
? join(process.env.XDG_CONFIG_HOME, 'hyper')
|
||||
: process.platform == 'win32'
|
||||
? app.getPath('userData')
|
||||
: homedir(),
|
||||
'.hyper.js'
|
||||
);
|
||||
|
||||
let cfgPath = join(cfgDir, cfgFile);
|
||||
const schemaPath = resolve(__dirname, schemaFile);
|
||||
|
||||
const devDir = resolve(__dirname, '../..');
|
||||
const devCfg = join(devDir, cfgFile);
|
||||
const defaultCfg = resolve(__dirname, defaultCfgFile);
|
||||
|
||||
if (isDev) {
|
||||
// if a local config file exists, use it
|
||||
try {
|
||||
statSync(devCfg);
|
||||
cfgPath = devCfg;
|
||||
cfgDir = devDir;
|
||||
console.log('using config file:', cfgPath);
|
||||
} catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
const plugins = resolve(cfgDir, 'plugins');
|
||||
const plugs = {
|
||||
base: plugins,
|
||||
local: resolve(plugins, 'local'),
|
||||
cache: resolve(plugins, 'cache')
|
||||
};
|
||||
const yarn = resolve(__dirname, '../../bin/yarn-standalone.js');
|
||||
const cliScriptPath = resolve(__dirname, '../../bin/hyper');
|
||||
const cliLinkPath = '/usr/local/bin/hyper';
|
||||
|
||||
const icon = resolve(__dirname, '../static/icon96x96.png');
|
||||
|
||||
const keymapPath = resolve(__dirname, '../keymaps');
|
||||
const darwinKeys = join(keymapPath, 'darwin.json');
|
||||
const win32Keys = join(keymapPath, 'win32.json');
|
||||
const linuxKeys = join(keymapPath, 'linux.json');
|
||||
|
||||
const defaultPlatformKeyPath = () => {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return darwinKeys;
|
||||
case 'win32':
|
||||
return win32Keys;
|
||||
case 'linux':
|
||||
return linuxKeys;
|
||||
default:
|
||||
return darwinKeys;
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
cfgDir,
|
||||
cfgPath,
|
||||
legacyCfgPath,
|
||||
cfgFile,
|
||||
defaultCfg,
|
||||
icon,
|
||||
defaultPlatformKeyPath,
|
||||
plugs,
|
||||
yarn,
|
||||
cliScriptPath,
|
||||
cliLinkPath,
|
||||
homeDirectory,
|
||||
schemaFile,
|
||||
schemaPath
|
||||
};
|
||||
|
|
@ -1,756 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"FontWeight": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"100",
|
||||
"200",
|
||||
"300",
|
||||
"400",
|
||||
"500",
|
||||
"600",
|
||||
"700",
|
||||
"800",
|
||||
"900",
|
||||
"bold",
|
||||
"normal"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"description": "A string or number representing text font weight."
|
||||
},
|
||||
"Partial<profileConfigOptions>": {
|
||||
"properties": {
|
||||
"backgroundColor": {
|
||||
"description": "terminal background color\n\nopacity is only supported on macOS",
|
||||
"type": "string"
|
||||
},
|
||||
"bell": {
|
||||
"description": "Supported Options:\n1. 'SOUND' -> Enables the bell as a sound\n2. false: turns off the bell",
|
||||
"enum": [
|
||||
"SOUND",
|
||||
false
|
||||
]
|
||||
},
|
||||
"bellSound": {
|
||||
"description": "base64 encoded string of the sound file to use for the bell\nif null, the default bell will be used",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"bellSoundURL": {
|
||||
"description": "An absolute file path to a sound file on the machine.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"borderColor": {
|
||||
"description": "border color (window, tabs)",
|
||||
"type": "string"
|
||||
},
|
||||
"colors": {
|
||||
"description": "the full list. if you're going to provide the full color palette,\nincluding the 6 x 6 color cubes and the grayscale map, just provide\nan array here instead of a color map object",
|
||||
"properties": {
|
||||
"black": {
|
||||
"type": "string"
|
||||
},
|
||||
"blue": {
|
||||
"type": "string"
|
||||
},
|
||||
"cyan": {
|
||||
"type": "string"
|
||||
},
|
||||
"green": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightBlack": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightBlue": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightCyan": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightGreen": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightMagenta": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightRed": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightWhite": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightYellow": {
|
||||
"type": "string"
|
||||
},
|
||||
"magenta": {
|
||||
"type": "string"
|
||||
},
|
||||
"red": {
|
||||
"type": "string"
|
||||
},
|
||||
"white": {
|
||||
"type": "string"
|
||||
},
|
||||
"yellow": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"black",
|
||||
"blue",
|
||||
"cyan",
|
||||
"green",
|
||||
"lightBlack",
|
||||
"lightBlue",
|
||||
"lightCyan",
|
||||
"lightGreen",
|
||||
"lightMagenta",
|
||||
"lightRed",
|
||||
"lightWhite",
|
||||
"lightYellow",
|
||||
"magenta",
|
||||
"red",
|
||||
"white",
|
||||
"yellow"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"copyOnSelect": {
|
||||
"description": "if `true` selected text will automatically be copied to the clipboard",
|
||||
"type": "boolean"
|
||||
},
|
||||
"css": {
|
||||
"description": "custom CSS to embed in the main window",
|
||||
"type": "string"
|
||||
},
|
||||
"cursorAccentColor": {
|
||||
"description": "terminal text color under BLOCK cursor",
|
||||
"type": "string"
|
||||
},
|
||||
"cursorBlink": {
|
||||
"description": "set to `true` for blinking cursor",
|
||||
"type": "boolean"
|
||||
},
|
||||
"cursorColor": {
|
||||
"description": "terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)",
|
||||
"type": "string"
|
||||
},
|
||||
"cursorShape": {
|
||||
"description": "`'BEAM'` for |, `'UNDERLINE'` for _, `'BLOCK'` for █",
|
||||
"enum": [
|
||||
"BEAM",
|
||||
"BLOCK",
|
||||
"UNDERLINE"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"disableLigatures": {
|
||||
"description": "if `false` Hyper will use ligatures provided by some fonts",
|
||||
"type": "boolean"
|
||||
},
|
||||
"env": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "for environment variables",
|
||||
"type": "object"
|
||||
},
|
||||
"fontFamily": {
|
||||
"description": "font family with optional fallbacks",
|
||||
"type": "string"
|
||||
},
|
||||
"fontSize": {
|
||||
"description": "default font size in pixels for all tabs",
|
||||
"type": "number"
|
||||
},
|
||||
"fontWeight": {
|
||||
"$ref": "#/definitions/FontWeight",
|
||||
"description": "default font weight eg:'normal', '400', 'bold'"
|
||||
},
|
||||
"fontWeightBold": {
|
||||
"$ref": "#/definitions/FontWeight",
|
||||
"description": "font weight for bold characters eg:'normal', '600', 'bold'"
|
||||
},
|
||||
"foregroundColor": {
|
||||
"description": "color of the text",
|
||||
"type": "string"
|
||||
},
|
||||
"imageSupport": {
|
||||
"description": "Whether to enable Sixel and iTerm2 inline image protocol support or not.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"letterSpacing": {
|
||||
"description": "letter spacing as a relative unit",
|
||||
"type": "number"
|
||||
},
|
||||
"lineHeight": {
|
||||
"description": "line height as a relative unit",
|
||||
"type": "number"
|
||||
},
|
||||
"macOptionSelectionMode": {
|
||||
"description": "choose either `'vertical'`, if you want the column mode when Option key is hold during selection (Default)\nor `'force'`, if you want to force selection regardless of whether the terminal is in mouse events mode\n(inside tmux or vim with mouse mode enabled for example).",
|
||||
"type": "string"
|
||||
},
|
||||
"modifierKeys": {
|
||||
"properties": {
|
||||
"altIsMeta": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"cmdIsMeta": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"altIsMeta",
|
||||
"cmdIsMeta"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"padding": {
|
||||
"description": "custom padding (CSS format, i.e.: `top right bottom left` or `top horizontal bottom` or `vertical horizontal` or `all`)",
|
||||
"type": "string"
|
||||
},
|
||||
"preserveCWD": {
|
||||
"description": "set to true to preserve working directory when creating splits or tabs",
|
||||
"type": "boolean"
|
||||
},
|
||||
"quickEdit": {
|
||||
"description": "if `true` on right click selected text will be copied or pasted if no\nselection is present (`true` by default on Windows and disables the context menu feature)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"screenReaderMode": {
|
||||
"description": "set to true to enable screen reading apps (like NVDA) to read the contents of the terminal",
|
||||
"type": "boolean"
|
||||
},
|
||||
"scrollback": {
|
||||
"type": "number"
|
||||
},
|
||||
"selectionColor": {
|
||||
"description": "terminal selection color",
|
||||
"type": "string"
|
||||
},
|
||||
"shell": {
|
||||
"description": "the shell to run when spawning a new session (e.g. /usr/local/bin/fish)\nif left empty, your system's login shell will be used by default\n\nWindows\n- Make sure to use a full path if the binary name doesn't work\n- Remove `--login` in shellArgs\n\nWindows Subsystem for Linux (WSL) - previously Bash on Windows\n- Example: `C:\\\\Windows\\\\System32\\\\wsl.exe`\n\nGit-bash on Windows\n- Example: `C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe`\n\nPowerShell on Windows\n- Example: `C:\\\\WINDOWS\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`\n\nCygwin\n- Example: `C:\\\\cygwin64\\\\bin\\\\bash.exe`\n\nGit Bash\n- Example: `C:\\\\Program Files\\\\Git\\\\git-cmd.exe`\nThen Add `--command=usr/bin/bash.exe` to shellArgs",
|
||||
"type": "string"
|
||||
},
|
||||
"shellArgs": {
|
||||
"description": "for setting shell arguments (e.g. for using interactive shellArgs: `['-i']`)\nby default `['--login']` will be used",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"showHamburgerMenu": {
|
||||
"description": "if you're using a Linux setup which show native menus, set to false\n\ndefault: `true` on Linux, `true` on Windows, ignored on macOS",
|
||||
"enum": [
|
||||
"",
|
||||
false,
|
||||
true
|
||||
]
|
||||
},
|
||||
"showWindowControls": {
|
||||
"description": "set to `false` if you want to hide the minimize, maximize and close buttons\n\nadditionally, set to `'left'` if you want them on the left, like in Ubuntu\n\ndefault: `true` on Windows and Linux, ignored on macOS",
|
||||
"enum": [
|
||||
"",
|
||||
false,
|
||||
"left",
|
||||
true
|
||||
]
|
||||
},
|
||||
"termCSS": {
|
||||
"description": "custom CSS to embed in the terminal window",
|
||||
"type": "string"
|
||||
},
|
||||
"uiFontFamily": {
|
||||
"type": "string"
|
||||
},
|
||||
"webGLRenderer": {
|
||||
"description": "Whether to use the WebGL renderer. Set it to false to use canvas-based\nrendering (slower, but supports transparent backgrounds)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"webLinksActivationKey": {
|
||||
"description": "keypress required for weblink activation: [ctrl | alt | meta | shift]",
|
||||
"enum": [
|
||||
"",
|
||||
"alt",
|
||||
"ctrl",
|
||||
"meta",
|
||||
"shift"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"windowSize": {
|
||||
"description": "Initial window size in pixels",
|
||||
"items": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"maxItems": 2,
|
||||
"minItems": 2,
|
||||
"type": "array"
|
||||
},
|
||||
"workingDirectory": {
|
||||
"description": "set custom startup directory (must be an absolute path)",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"configOptions": {
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"autoUpdatePlugins": {
|
||||
"description": "if `true` (default), Hyper will update plugins every 5 hours\nyou can also set it to a custom time e.g. `1d` or `2h`",
|
||||
"type": [
|
||||
"string",
|
||||
"boolean"
|
||||
]
|
||||
},
|
||||
"defaultSSHApp": {
|
||||
"description": "if `true` hyper will be set as the default protocol client for SSH",
|
||||
"type": "boolean"
|
||||
},
|
||||
"disableAutoUpdates": {
|
||||
"description": "if `true` hyper will not check for updates",
|
||||
"type": "boolean"
|
||||
},
|
||||
"updateChannel": {
|
||||
"description": "choose either `'stable'` for receiving highly polished, or `'canary'` for less polished but more frequent updates",
|
||||
"enum": [
|
||||
"canary",
|
||||
"stable"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"useConpty": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"autoUpdatePlugins",
|
||||
"defaultSSHApp",
|
||||
"disableAutoUpdates",
|
||||
"updateChannel"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"backgroundColor": {
|
||||
"description": "terminal background color\n\nopacity is only supported on macOS",
|
||||
"type": "string"
|
||||
},
|
||||
"bell": {
|
||||
"description": "Supported Options:\n1. 'SOUND' -> Enables the bell as a sound\n2. false: turns off the bell",
|
||||
"enum": [
|
||||
"SOUND",
|
||||
false
|
||||
]
|
||||
},
|
||||
"bellSound": {
|
||||
"description": "base64 encoded string of the sound file to use for the bell\nif null, the default bell will be used",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"bellSoundURL": {
|
||||
"description": "An absolute file path to a sound file on the machine.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"borderColor": {
|
||||
"description": "border color (window, tabs)",
|
||||
"type": "string"
|
||||
},
|
||||
"colors": {
|
||||
"description": "the full list. if you're going to provide the full color palette,\nincluding the 6 x 6 color cubes and the grayscale map, just provide\nan array here instead of a color map object",
|
||||
"properties": {
|
||||
"black": {
|
||||
"type": "string"
|
||||
},
|
||||
"blue": {
|
||||
"type": "string"
|
||||
},
|
||||
"cyan": {
|
||||
"type": "string"
|
||||
},
|
||||
"green": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightBlack": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightBlue": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightCyan": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightGreen": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightMagenta": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightRed": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightWhite": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightYellow": {
|
||||
"type": "string"
|
||||
},
|
||||
"magenta": {
|
||||
"type": "string"
|
||||
},
|
||||
"red": {
|
||||
"type": "string"
|
||||
},
|
||||
"white": {
|
||||
"type": "string"
|
||||
},
|
||||
"yellow": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"black",
|
||||
"blue",
|
||||
"cyan",
|
||||
"green",
|
||||
"lightBlack",
|
||||
"lightBlue",
|
||||
"lightCyan",
|
||||
"lightGreen",
|
||||
"lightMagenta",
|
||||
"lightRed",
|
||||
"lightWhite",
|
||||
"lightYellow",
|
||||
"magenta",
|
||||
"red",
|
||||
"white",
|
||||
"yellow"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"copyOnSelect": {
|
||||
"description": "if `true` selected text will automatically be copied to the clipboard",
|
||||
"type": "boolean"
|
||||
},
|
||||
"css": {
|
||||
"description": "custom CSS to embed in the main window",
|
||||
"type": "string"
|
||||
},
|
||||
"cursorAccentColor": {
|
||||
"description": "terminal text color under BLOCK cursor",
|
||||
"type": "string"
|
||||
},
|
||||
"cursorBlink": {
|
||||
"description": "set to `true` for blinking cursor",
|
||||
"type": "boolean"
|
||||
},
|
||||
"cursorColor": {
|
||||
"description": "terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)",
|
||||
"type": "string"
|
||||
},
|
||||
"cursorShape": {
|
||||
"description": "`'BEAM'` for |, `'UNDERLINE'` for _, `'BLOCK'` for █",
|
||||
"enum": [
|
||||
"BEAM",
|
||||
"BLOCK",
|
||||
"UNDERLINE"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"disableLigatures": {
|
||||
"description": "if `false` Hyper will use ligatures provided by some fonts",
|
||||
"type": "boolean"
|
||||
},
|
||||
"env": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "for environment variables",
|
||||
"type": "object"
|
||||
},
|
||||
"fontFamily": {
|
||||
"description": "font family with optional fallbacks",
|
||||
"type": "string"
|
||||
},
|
||||
"fontSize": {
|
||||
"description": "default font size in pixels for all tabs",
|
||||
"type": "number"
|
||||
},
|
||||
"fontWeight": {
|
||||
"$ref": "#/definitions/FontWeight",
|
||||
"description": "default font weight eg:'normal', '400', 'bold'"
|
||||
},
|
||||
"fontWeightBold": {
|
||||
"$ref": "#/definitions/FontWeight",
|
||||
"description": "font weight for bold characters eg:'normal', '600', 'bold'"
|
||||
},
|
||||
"foregroundColor": {
|
||||
"description": "color of the text",
|
||||
"type": "string"
|
||||
},
|
||||
"imageSupport": {
|
||||
"description": "Whether to enable Sixel and iTerm2 inline image protocol support or not.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"letterSpacing": {
|
||||
"description": "letter spacing as a relative unit",
|
||||
"type": "number"
|
||||
},
|
||||
"lineHeight": {
|
||||
"description": "line height as a relative unit",
|
||||
"type": "number"
|
||||
},
|
||||
"macOptionSelectionMode": {
|
||||
"description": "choose either `'vertical'`, if you want the column mode when Option key is hold during selection (Default)\nor `'force'`, if you want to force selection regardless of whether the terminal is in mouse events mode\n(inside tmux or vim with mouse mode enabled for example).",
|
||||
"type": "string"
|
||||
},
|
||||
"modifierKeys": {
|
||||
"properties": {
|
||||
"altIsMeta": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"cmdIsMeta": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"altIsMeta",
|
||||
"cmdIsMeta"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"padding": {
|
||||
"description": "custom padding (CSS format, i.e.: `top right bottom left` or `top horizontal bottom` or `vertical horizontal` or `all`)",
|
||||
"type": "string"
|
||||
},
|
||||
"preserveCWD": {
|
||||
"description": "set to true to preserve working directory when creating splits or tabs",
|
||||
"type": "boolean"
|
||||
},
|
||||
"quickEdit": {
|
||||
"description": "if `true` on right click selected text will be copied or pasted if no\nselection is present (`true` by default on Windows and disables the context menu feature)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"screenReaderMode": {
|
||||
"description": "set to true to enable screen reading apps (like NVDA) to read the contents of the terminal",
|
||||
"type": "boolean"
|
||||
},
|
||||
"scrollback": {
|
||||
"type": "number"
|
||||
},
|
||||
"selectionColor": {
|
||||
"description": "terminal selection color",
|
||||
"type": "string"
|
||||
},
|
||||
"shell": {
|
||||
"description": "the shell to run when spawning a new session (e.g. /usr/local/bin/fish)\nif left empty, your system's login shell will be used by default\n\nWindows\n- Make sure to use a full path if the binary name doesn't work\n- Remove `--login` in shellArgs\n\nWindows Subsystem for Linux (WSL) - previously Bash on Windows\n- Example: `C:\\\\Windows\\\\System32\\\\wsl.exe`\n\nGit-bash on Windows\n- Example: `C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe`\n\nPowerShell on Windows\n- Example: `C:\\\\WINDOWS\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`\n\nCygwin\n- Example: `C:\\\\cygwin64\\\\bin\\\\bash.exe`\n\nGit Bash\n- Example: `C:\\\\Program Files\\\\Git\\\\git-cmd.exe`\nThen Add `--command=usr/bin/bash.exe` to shellArgs",
|
||||
"type": "string"
|
||||
},
|
||||
"shellArgs": {
|
||||
"description": "for setting shell arguments (e.g. for using interactive shellArgs: `['-i']`)\nby default `['--login']` will be used",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"showHamburgerMenu": {
|
||||
"description": "if you're using a Linux setup which show native menus, set to false\n\ndefault: `true` on Linux, `true` on Windows, ignored on macOS",
|
||||
"enum": [
|
||||
"",
|
||||
false,
|
||||
true
|
||||
]
|
||||
},
|
||||
"showWindowControls": {
|
||||
"description": "set to `false` if you want to hide the minimize, maximize and close buttons\n\nadditionally, set to `'left'` if you want them on the left, like in Ubuntu\n\ndefault: `true` on Windows and Linux, ignored on macOS",
|
||||
"enum": [
|
||||
"",
|
||||
false,
|
||||
"left",
|
||||
true
|
||||
]
|
||||
},
|
||||
"termCSS": {
|
||||
"description": "custom CSS to embed in the terminal window",
|
||||
"type": "string"
|
||||
},
|
||||
"uiFontFamily": {
|
||||
"type": "string"
|
||||
},
|
||||
"webGLRenderer": {
|
||||
"description": "Whether to use the WebGL renderer. Set it to false to use canvas-based\nrendering (slower, but supports transparent backgrounds)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"webLinksActivationKey": {
|
||||
"description": "keypress required for weblink activation: [ctrl | alt | meta | shift]",
|
||||
"enum": [
|
||||
"",
|
||||
"alt",
|
||||
"ctrl",
|
||||
"meta",
|
||||
"shift"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"windowSize": {
|
||||
"description": "Initial window size in pixels",
|
||||
"items": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"maxItems": 2,
|
||||
"minItems": 2,
|
||||
"type": "array"
|
||||
},
|
||||
"workingDirectory": {
|
||||
"description": "set custom startup directory (must be an absolute path)",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"backgroundColor",
|
||||
"bell",
|
||||
"bellSound",
|
||||
"bellSoundURL",
|
||||
"borderColor",
|
||||
"colors",
|
||||
"copyOnSelect",
|
||||
"css",
|
||||
"cursorAccentColor",
|
||||
"cursorBlink",
|
||||
"cursorColor",
|
||||
"cursorShape",
|
||||
"disableLigatures",
|
||||
"env",
|
||||
"fontFamily",
|
||||
"fontSize",
|
||||
"fontWeight",
|
||||
"fontWeightBold",
|
||||
"foregroundColor",
|
||||
"imageSupport",
|
||||
"letterSpacing",
|
||||
"lineHeight",
|
||||
"macOptionSelectionMode",
|
||||
"padding",
|
||||
"preserveCWD",
|
||||
"quickEdit",
|
||||
"screenReaderMode",
|
||||
"scrollback",
|
||||
"selectionColor",
|
||||
"shell",
|
||||
"shellArgs",
|
||||
"showHamburgerMenu",
|
||||
"showWindowControls",
|
||||
"termCSS",
|
||||
"webGLRenderer",
|
||||
"webLinksActivationKey",
|
||||
"workingDirectory"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"defaultProfile": {
|
||||
"description": "The default profile name to use when launching a new session",
|
||||
"type": "string"
|
||||
},
|
||||
"profiles": {
|
||||
"description": "A list of profiles to use",
|
||||
"items": {
|
||||
"properties": {
|
||||
"config": {
|
||||
"$ref": "#/definitions/Partial<profileConfigOptions>",
|
||||
"description": "Specify all the options you want to override for each profile.\nOptions set here override the defaults set in the root."
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config",
|
||||
"name"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"defaultProfile",
|
||||
"profiles"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"config": {
|
||||
"$ref": "#/definitions/configOptions"
|
||||
},
|
||||
"keymaps": {
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": "Example\n'window:devtools': 'cmd+alt+o',",
|
||||
"type": "object"
|
||||
},
|
||||
"localPlugins": {
|
||||
"description": "in development, you can create a directory under\n`plugins/local/` and include it here\nto load it and avoid it being `npm install`ed",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"plugins": {
|
||||
"description": "a list of plugins to fetch and install from npm\nformat: [@org/]project[#version]\nexamples:\n `hyperpower`\n `@company/project`\n `project#1.0.1`",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
import Config from 'electron-store';
|
||||
|
||||
export const defaults = {
|
||||
windowPosition: [50, 50] as [number, number],
|
||||
windowSize: [540, 380] as [number, number]
|
||||
};
|
||||
|
||||
// local storage
|
||||
const cfg = new Config({defaults});
|
||||
|
||||
export function get() {
|
||||
const position = cfg.get('windowPosition', defaults.windowPosition);
|
||||
const size = cfg.get('windowSize', defaults.windowSize);
|
||||
return {position, size};
|
||||
}
|
||||
export function recordState(win: BrowserWindow) {
|
||||
cfg.set('windowPosition', win.getPosition());
|
||||
cfg.set('windowSize', win.getSize());
|
||||
}
|
||||
|
|
@ -1,38 +1,26 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hyper</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="initial-scale=1.0">
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'">
|
||||
|
||||
<title>HyperTerm</title>
|
||||
<meta name="viewport" content="initial-scale=1.0" />
|
||||
<style>
|
||||
body {
|
||||
color: #fff;
|
||||
-webkit-backface-visibility: hidden;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-rendering: optimizeLegibility;
|
||||
text-rendering: geometricPrecision;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (min-resolution: 2dppx) {
|
||||
* {
|
||||
text-rendering: geometricPrecision;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="mount"></div>
|
||||
|
||||
<script>start = performance.now();</script>
|
||||
<script src="renderer/bundle.js"></script>
|
||||
<script src="dist/bundle.js"></script>
|
||||
<script>console.log('total init time', performance.now() - start);</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
255
app/index.js
Normal file
255
app/index.js
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
const { app, BrowserWindow, shell, Menu } = require('electron');
|
||||
const createRPC = require('./rpc');
|
||||
const createMenu = require('./menu');
|
||||
const uuid = require('uuid');
|
||||
const { resolve } = require('path');
|
||||
const isDev = require('electron-is-dev');
|
||||
const AutoUpdater = require('./auto-updater');
|
||||
const toHex = require('convert-css-color-name-to-hex');
|
||||
|
||||
// set up config
|
||||
const config = require('./config');
|
||||
config.init();
|
||||
const plugins = require('./plugins');
|
||||
const Session = require('./session');
|
||||
|
||||
const windowSet = new Set([]);
|
||||
|
||||
// expose to plugins
|
||||
app.config = config;
|
||||
app.plugins = plugins;
|
||||
app.getWindows = () => new Set([...windowSet]); // return a clone
|
||||
|
||||
if (isDev) {
|
||||
console.log('running in dev mode');
|
||||
} else {
|
||||
console.log('running in prod mode');
|
||||
}
|
||||
|
||||
const url = 'file://' + resolve(
|
||||
isDev ? __dirname : app.getAppPath(),
|
||||
'index.html'
|
||||
);
|
||||
|
||||
console.log('electron will open', url);
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('ready', () => {
|
||||
function createWindow (fn) {
|
||||
const cfg = plugins.getDecoratedConfig();
|
||||
const [width, height] = cfg.windowSize || [540, 380];
|
||||
|
||||
const browserDefaults = {
|
||||
width,
|
||||
height,
|
||||
minHeight: 190,
|
||||
minWidth: 370,
|
||||
titleBarStyle: 'hidden-inset',
|
||||
title: 'HyperTerm',
|
||||
backgroundColor: toHex(cfg.backgroundColor || '#000'),
|
||||
transparent: true,
|
||||
icon: resolve(__dirname, 'static/icon.png'),
|
||||
// we only want to show when the prompt
|
||||
// is ready for user input
|
||||
show: process.env.HYPERTERM_DEBUG || isDev
|
||||
};
|
||||
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
|
||||
|
||||
const win = new BrowserWindow(browserOptions);
|
||||
|
||||
windowSet.add(win);
|
||||
win.loadURL(url);
|
||||
|
||||
const rpc = createRPC(win);
|
||||
const sessions = new Map();
|
||||
|
||||
// config changes
|
||||
const cfgUnsubscribe = config.subscribe(() => {
|
||||
win.webContents.send('config change');
|
||||
});
|
||||
|
||||
rpc.on('init', () => {
|
||||
win.show();
|
||||
if (fn) fn(win);
|
||||
|
||||
// auto updates
|
||||
if (!isDev && process.platform !== 'linux') {
|
||||
AutoUpdater(win);
|
||||
} else {
|
||||
console.log('ignoring auto updates during dev');
|
||||
}
|
||||
});
|
||||
|
||||
rpc.on('new', ({ rows = 40, cols = 100, cwd = process.env.HOME }) => {
|
||||
const shell = cfg.shell;
|
||||
|
||||
initSession({ rows, cols, cwd, shell }, (uid, session) => {
|
||||
sessions.set(uid, session);
|
||||
rpc.emit('session add', {
|
||||
uid,
|
||||
shell: session.shell,
|
||||
pid: session.pty.pid
|
||||
});
|
||||
|
||||
session.on('data', (data) => {
|
||||
rpc.emit('session data', { uid, data });
|
||||
});
|
||||
|
||||
session.on('title', (title) => {
|
||||
rpc.emit('session title', { uid, title });
|
||||
});
|
||||
|
||||
session.on('exit', () => {
|
||||
rpc.emit('session exit', { uid });
|
||||
sessions.delete(uid);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: this goes away when we are able to poll
|
||||
// for the title ourseleves, instead of relying
|
||||
// on Session and focus/blur to subscribe
|
||||
rpc.on('focus', ({ uid }) => {
|
||||
const session = sessions.get(uid);
|
||||
|
||||
if (session) {
|
||||
session.focus();
|
||||
} else {
|
||||
console.log('session not found by', uid);
|
||||
}
|
||||
});
|
||||
|
||||
rpc.on('blur', ({ uid }) => {
|
||||
const session = sessions.get(uid);
|
||||
|
||||
if (session) {
|
||||
session.blur();
|
||||
} else {
|
||||
console.log('session not found by', uid);
|
||||
}
|
||||
});
|
||||
|
||||
rpc.on('exit', ({ uid }) => {
|
||||
const session = sessions.get(uid);
|
||||
|
||||
if (session) {
|
||||
session.exit();
|
||||
} else {
|
||||
console.log('session not found by', uid);
|
||||
}
|
||||
});
|
||||
|
||||
rpc.on('unmaximize', () => {
|
||||
win.unmaximize();
|
||||
});
|
||||
|
||||
rpc.on('maximize', () => {
|
||||
win.maximize();
|
||||
});
|
||||
|
||||
rpc.on('resize', ({ cols, rows }) => {
|
||||
sessions.forEach((session) => {
|
||||
session.resize({ cols, rows });
|
||||
});
|
||||
});
|
||||
|
||||
rpc.on('data', ({ uid, data }) => {
|
||||
sessions.get(uid).write(data);
|
||||
});
|
||||
|
||||
rpc.on('open external', ({ url }) => {
|
||||
shell.openExternal(url);
|
||||
});
|
||||
|
||||
rpc.win.on('move', () => {
|
||||
rpc.emit('move');
|
||||
});
|
||||
|
||||
const deleteSessions = () => {
|
||||
sessions.forEach((session, key) => {
|
||||
session.removeAllListeners();
|
||||
session.destroy();
|
||||
sessions.delete(key);
|
||||
});
|
||||
};
|
||||
|
||||
// we reset the rpc channel only upon
|
||||
// subsequent refreshes (ie: F5)
|
||||
let i = 0;
|
||||
win.webContents.on('did-navigate', () => {
|
||||
if (i++) {
|
||||
deleteSessions();
|
||||
}
|
||||
});
|
||||
|
||||
// expose internals to extension authors
|
||||
win.rpc = rpc;
|
||||
win.sessions = sessions;
|
||||
|
||||
const load = () => {
|
||||
plugins.onWindow(win);
|
||||
};
|
||||
|
||||
// load plugins
|
||||
load();
|
||||
|
||||
const pluginsUnsubscribe = plugins.subscribe((err) => {
|
||||
if (!err) {
|
||||
load();
|
||||
win.webContents.send('plugins change');
|
||||
}
|
||||
});
|
||||
|
||||
// the window can be closed by the browser process itself
|
||||
win.on('close', () => {
|
||||
windowSet.delete(win);
|
||||
rpc.destroy();
|
||||
deleteSessions();
|
||||
cfgUnsubscribe();
|
||||
pluginsUnsubscribe();
|
||||
});
|
||||
}
|
||||
|
||||
// when opening create a new window
|
||||
createWindow();
|
||||
|
||||
// expose to plugins
|
||||
app.createWindow = createWindow;
|
||||
|
||||
// mac only. when the dock icon is clicked
|
||||
// and we don't have any active windows open,
|
||||
// we open one
|
||||
app.on('activate', () => {
|
||||
if (!windowSet.size) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
const setupMenu = () => {
|
||||
const tpl = plugins.decorateMenu(createMenu({
|
||||
createWindow,
|
||||
updatePlugins: () => {
|
||||
plugins.updatePlugins({ force: true });
|
||||
}
|
||||
}));
|
||||
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate(tpl));
|
||||
};
|
||||
|
||||
const load = () => {
|
||||
plugins.onApp(app);
|
||||
setupMenu();
|
||||
};
|
||||
|
||||
load();
|
||||
plugins.subscribe(load);
|
||||
});
|
||||
|
||||
function initSession (opts, fn) {
|
||||
fn(uuid.v4(), new Session(opts));
|
||||
}
|
||||
247
app/index.ts
247
app/index.ts
|
|
@ -1,247 +0,0 @@
|
|||
// eslint-disable-next-line import/order
|
||||
import {cfgPath} from './config/paths';
|
||||
|
||||
// Print diagnostic information for a few arguments instead of running Hyper.
|
||||
if (['--help', '-v', '--version'].includes(process.argv[1])) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const {version} = require('./package');
|
||||
console.log(`Hyper version ${version}`);
|
||||
console.log('Hyper does not accept any command line arguments. Please modify the config file instead.');
|
||||
console.log(`Hyper configuration file located at: ${cfgPath}`);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
// Enable remote module
|
||||
// eslint-disable-next-line import/order
|
||||
import {initialize as remoteInitialize} from '@electron/remote/main';
|
||||
remoteInitialize();
|
||||
|
||||
// set up config
|
||||
// eslint-disable-next-line import/order
|
||||
import * as config from './config';
|
||||
config.setup();
|
||||
|
||||
// Native
|
||||
import {resolve} from 'path';
|
||||
|
||||
// Packages
|
||||
import {app, BrowserWindow, Menu, screen} from 'electron';
|
||||
|
||||
import isDev from 'electron-is-dev';
|
||||
import {gitDescribe} from 'git-describe';
|
||||
import parseUrl from 'parse-url';
|
||||
|
||||
import * as AppMenu from './menus/menu';
|
||||
import * as plugins from './plugins';
|
||||
import {newWindow} from './ui/window';
|
||||
import {installCLI} from './utils/cli-install';
|
||||
import * as windowUtils from './utils/window-utils';
|
||||
|
||||
const windowSet = new Set<BrowserWindow>([]);
|
||||
|
||||
// expose to plugins
|
||||
app.config = config;
|
||||
app.plugins = plugins;
|
||||
app.getWindows = () => new Set([...windowSet]); // return a clone
|
||||
|
||||
// function to retrieve the last focused window in windowSet;
|
||||
// added to app object in order to expose it to plugins.
|
||||
app.getLastFocusedWindow = () => {
|
||||
if (!windowSet.size) {
|
||||
return null;
|
||||
}
|
||||
return Array.from(windowSet).reduce((lastWindow, win) => {
|
||||
return win.focusTime > lastWindow.focusTime ? win : lastWindow;
|
||||
});
|
||||
};
|
||||
|
||||
console.log('Disabling Chromium GPU blacklist');
|
||||
app.commandLine.appendSwitch('ignore-gpu-blacklist');
|
||||
|
||||
if (isDev) {
|
||||
console.log('running in dev mode');
|
||||
|
||||
// Override default appVersion which is set from package.json
|
||||
gitDescribe({customArguments: ['--tags']}, (error: any, gitInfo: {raw: string}) => {
|
||||
if (!error) {
|
||||
app.setVersion(gitInfo.raw);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('running in prod mode');
|
||||
}
|
||||
|
||||
const url = `file://${resolve(isDev ? __dirname : app.getAppPath(), 'index.html')}`;
|
||||
console.log('electron will open', url);
|
||||
|
||||
async function installDevExtensions(isDev_: boolean) {
|
||||
if (!isDev_) {
|
||||
return [];
|
||||
}
|
||||
const {default: installer, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS} = await import('electron-devtools-installer');
|
||||
|
||||
const extensions = [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS];
|
||||
const forceDownload = Boolean(process.env.UPGRADE_EXTENSIONS);
|
||||
|
||||
return Promise.all(
|
||||
extensions.map((extension) => installer(extension, {forceDownload, loadExtensionOptions: {allowFileAccess: true}}))
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
app.on('ready', () =>
|
||||
installDevExtensions(isDev)
|
||||
.then(() => {
|
||||
function createWindow(
|
||||
fn?: (win: BrowserWindow) => void,
|
||||
options: {size?: [number, number]; position?: [number, number]} = {},
|
||||
profileName: string = config.getDefaultProfile()
|
||||
) {
|
||||
const cfg = plugins.getDecoratedConfig(profileName);
|
||||
|
||||
const winSet = config.getWin();
|
||||
let [startX, startY] = winSet.position;
|
||||
|
||||
const [width, height] = options.size ? options.size : cfg.windowSize || winSet.size;
|
||||
|
||||
const winPos = options.position;
|
||||
|
||||
// Open the new window roughly the height of the header away from the
|
||||
// previous window. This also ensures in multi monitor setups that the
|
||||
// new terminal is on the correct screen.
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow() || app.getLastFocusedWindow();
|
||||
// In case of options defaults position and size, we should ignore the focusedWindow.
|
||||
if (winPos !== undefined) {
|
||||
[startX, startY] = winPos;
|
||||
} else if (focusedWindow) {
|
||||
const points = focusedWindow.getPosition();
|
||||
const currentScreen = screen.getDisplayNearestPoint({
|
||||
x: points[0],
|
||||
y: points[1]
|
||||
});
|
||||
|
||||
const biggestX = points[0] + 100 + width - currentScreen.bounds.x;
|
||||
const biggestY = points[1] + 100 + height - currentScreen.bounds.y;
|
||||
|
||||
if (biggestX > currentScreen.size.width) {
|
||||
startX = 50;
|
||||
} else {
|
||||
startX = points[0] + 34;
|
||||
}
|
||||
if (biggestY > currentScreen.size.height) {
|
||||
startY = 50;
|
||||
} else {
|
||||
startY = points[1] + 34;
|
||||
}
|
||||
}
|
||||
|
||||
if (!windowUtils.positionIsValid([startX, startY])) {
|
||||
[startX, startY] = config.windowDefaults.windowPosition;
|
||||
}
|
||||
|
||||
const hwin = newWindow({width, height, x: startX, y: startY}, cfg, fn, profileName);
|
||||
windowSet.add(hwin);
|
||||
void hwin.loadURL(url);
|
||||
|
||||
hwin.once('ready-to-show', () => {
|
||||
hwin.show();
|
||||
});
|
||||
|
||||
// the window can be closed by the browser process itself
|
||||
hwin.on('close', () => {
|
||||
hwin.clean();
|
||||
windowSet.delete(hwin);
|
||||
});
|
||||
|
||||
return hwin;
|
||||
}
|
||||
|
||||
// when opening create a new window
|
||||
createWindow();
|
||||
|
||||
// expose to plugins
|
||||
app.createWindow = createWindow;
|
||||
|
||||
// mac only. when the dock icon is clicked
|
||||
// and we don't have any active windows open,
|
||||
// we open one
|
||||
app.on('activate', () => {
|
||||
if (!windowSet.size) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
const makeMenu = () => {
|
||||
const menu = plugins.decorateMenu(AppMenu.createMenu(createWindow, plugins.getLoadedPluginVersions));
|
||||
|
||||
// If we're on Mac make a Dock Menu
|
||||
if (process.platform === 'darwin') {
|
||||
const dockMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'New Window',
|
||||
click() {
|
||||
createWindow();
|
||||
}
|
||||
}
|
||||
]);
|
||||
app.dock?.setMenu(dockMenu);
|
||||
}
|
||||
|
||||
Menu.setApplicationMenu(AppMenu.buildMenu(menu));
|
||||
};
|
||||
|
||||
plugins.onApp(app);
|
||||
makeMenu();
|
||||
plugins.subscribe(plugins.onApp.bind(undefined, app));
|
||||
config.subscribe(makeMenu);
|
||||
if (!isDev) {
|
||||
// check if should be set/removed as default ssh protocol client
|
||||
if (config.getConfig().defaultSSHApp && !app.isDefaultProtocolClient('ssh')) {
|
||||
console.log('Setting Hyper as default client for ssh:// protocol');
|
||||
app.setAsDefaultProtocolClient('ssh');
|
||||
} else if (!config.getConfig().defaultSSHApp && app.isDefaultProtocolClient('ssh')) {
|
||||
console.log('Removing Hyper from default client for ssh:// protocol');
|
||||
app.removeAsDefaultProtocolClient('ssh');
|
||||
}
|
||||
void installCLI(false);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error while loading devtools extensions', err);
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Get last focused BrowserWindow or create new if none and callback
|
||||
* @param callback Function to call with the BrowserWindow
|
||||
*/
|
||||
function GetWindow(callback: (win: BrowserWindow) => void) {
|
||||
const lastWindow = app.getLastFocusedWindow();
|
||||
if (lastWindow) {
|
||||
callback(lastWindow);
|
||||
} else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) {
|
||||
app.createWindow(callback);
|
||||
} else {
|
||||
// If createWindow doesn't exist yet ('ready' event was not fired),
|
||||
// sets his callback to an app.windowCallback property.
|
||||
app.windowCallback = callback;
|
||||
}
|
||||
}
|
||||
|
||||
app.on('open-file', (_event, path) => {
|
||||
GetWindow((win: BrowserWindow) => {
|
||||
win.rpc.emit('open file', {path});
|
||||
});
|
||||
});
|
||||
|
||||
app.on('open-url', (_event, sshUrl) => {
|
||||
GetWindow((win: BrowserWindow) => {
|
||||
win.rpc.emit('open ssh', parseUrl(sshUrl));
|
||||
});
|
||||
});
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"window:devtools": "command+alt+i",
|
||||
"window:reload": "command+shift+r",
|
||||
"window:reloadFull": "command+shift+f5",
|
||||
"window:preferences": "command+,",
|
||||
"zoom:reset": "command+0",
|
||||
"zoom:in": [
|
||||
"command+plus",
|
||||
"command+="
|
||||
],
|
||||
"zoom:out": "command+-",
|
||||
"window:new": "command+n",
|
||||
"window:minimize": "command+m",
|
||||
"window:zoom": "ctrl+alt+command+m",
|
||||
"window:toggleFullScreen": "command+ctrl+f",
|
||||
"window:close": "command+shift+w",
|
||||
"tab:new": "command+t",
|
||||
"tab:next": [
|
||||
"command+shift+]",
|
||||
"command+shift+right",
|
||||
"command+alt+right",
|
||||
"ctrl+tab"
|
||||
],
|
||||
"tab:prev": [
|
||||
"command+shift+[",
|
||||
"command+shift+left",
|
||||
"command+alt+left",
|
||||
"ctrl+shift+tab"
|
||||
],
|
||||
"tab:jump:prefix": "command",
|
||||
"pane:next": "command+]",
|
||||
"pane:prev": "command+[",
|
||||
"pane:splitRight": "command+d",
|
||||
"pane:splitDown": "command+shift+d",
|
||||
"pane:close": "command+w",
|
||||
"editor:undo": "command+z",
|
||||
"editor:redo": "command+y",
|
||||
"editor:cut": "command+x",
|
||||
"editor:copy": "command+c",
|
||||
"editor:paste": "command+v",
|
||||
"editor:selectAll": "command+a",
|
||||
"editor:search": "command+f",
|
||||
"editor:search-close": "esc",
|
||||
"editor:movePreviousWord": "alt+left",
|
||||
"editor:moveNextWord": "alt+right",
|
||||
"editor:moveBeginningLine": "command+left",
|
||||
"editor:moveEndLine": "command+right",
|
||||
"editor:deletePreviousWord": "alt+backspace",
|
||||
"editor:deleteNextWord": "alt+delete",
|
||||
"editor:deleteBeginningLine": "command+backspace",
|
||||
"editor:deleteEndLine": "command+delete",
|
||||
"editor:clearBuffer": "command+k",
|
||||
"editor:break": "ctrl+c",
|
||||
"plugins:update": "command+shift+u"
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
{
|
||||
"window:devtools": "ctrl+shift+i",
|
||||
"window:reload": "ctrl+shift+r",
|
||||
"window:reloadFull": "ctrl+shift+f5",
|
||||
"window:preferences": "ctrl+,",
|
||||
"window:hamburgerMenu": "alt+f",
|
||||
"zoom:reset": "ctrl+0",
|
||||
"zoom:in": "ctrl+=",
|
||||
"zoom:out": "ctrl+-",
|
||||
"window:new": "ctrl+shift+n",
|
||||
"window:minimize": "ctrl+shift+m",
|
||||
"window:zoom": "ctrl+shift+alt+m",
|
||||
"window:toggleFullScreen": "f11",
|
||||
"window:close": "ctrl+shift+q",
|
||||
"tab:new": "ctrl+shift+t",
|
||||
"tab:next": [
|
||||
"ctrl+shift+]",
|
||||
"ctrl+shift+right",
|
||||
"ctrl+alt+right",
|
||||
"ctrl+tab"
|
||||
],
|
||||
"tab:prev": [
|
||||
"ctrl+shift+[",
|
||||
"ctrl+shift+left",
|
||||
"ctrl+alt+left",
|
||||
"ctrl+shift+tab"
|
||||
],
|
||||
"tab:jump:prefix": "ctrl",
|
||||
"pane:next": "ctrl+pageup",
|
||||
"pane:prev": "ctrl+pagedown",
|
||||
"pane:splitRight": "ctrl+shift+d",
|
||||
"pane:splitDown": "ctrl+shift+e",
|
||||
"pane:close": "ctrl+shift+w",
|
||||
"editor:undo": "ctrl+shift+z",
|
||||
"editor:redo": "ctrl+shift+y",
|
||||
"editor:cut": "ctrl+shift+x",
|
||||
"editor:copy": "ctrl+shift+c",
|
||||
"editor:paste": "ctrl+shift+v",
|
||||
"editor:selectAll": "ctrl+shift+a",
|
||||
"editor:search": "ctrl+shift+f",
|
||||
"editor:search-close": "esc",
|
||||
"editor:movePreviousWord": "ctrl+left",
|
||||
"editor:moveNextWord": "ctrl+right",
|
||||
"editor:moveBeginningLine": "home",
|
||||
"editor:moveEndLine": "end",
|
||||
"editor:deletePreviousWord": "ctrl+backspace",
|
||||
"editor:deleteNextWord": "ctrl+del",
|
||||
"editor:deleteBeginningLine": "ctrl+home",
|
||||
"editor:deleteEndLine": "ctrl+end",
|
||||
"editor:clearBuffer": "ctrl+shift+k",
|
||||
"editor:break": "ctrl+c",
|
||||
"plugins:update": "ctrl+shift+u"
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
"window:devtools": "ctrl+shift+i",
|
||||
"window:reload": "ctrl+shift+r",
|
||||
"window:reloadFull": "ctrl+shift+f5",
|
||||
"window:preferences": "ctrl+,",
|
||||
"window:hamburgerMenu": "alt+f",
|
||||
"zoom:reset": "ctrl+0",
|
||||
"zoom:in": "ctrl+=",
|
||||
"zoom:out": "ctrl+-",
|
||||
"window:new": "ctrl+shift+n",
|
||||
"window:minimize": "ctrl+shift+m",
|
||||
"window:zoom": "ctrl+shift+alt+m",
|
||||
"window:toggleFullScreen": "f11",
|
||||
"window:close": [
|
||||
"ctrl+shift+q",
|
||||
"alt+f4"
|
||||
],
|
||||
"tab:new": "ctrl+shift+t",
|
||||
"tab:next": [
|
||||
"ctrl+tab"
|
||||
],
|
||||
"tab:prev": [
|
||||
"ctrl+shift+tab"
|
||||
],
|
||||
"tab:jump:prefix": "ctrl",
|
||||
"pane:next": "ctrl+pageup",
|
||||
"pane:prev": "ctrl+pagedown",
|
||||
"pane:splitRight": "ctrl+shift+d",
|
||||
"pane:splitDown": "ctrl+shift+e",
|
||||
"pane:close": "ctrl+shift+w",
|
||||
"editor:undo": "ctrl+shift+z",
|
||||
"editor:redo": "ctrl+shift+y",
|
||||
"editor:cut": "ctrl+shift+x",
|
||||
"editor:copy": "ctrl+shift+c",
|
||||
"editor:paste": "ctrl+shift+v",
|
||||
"editor:selectAll": "ctrl+shift+a",
|
||||
"editor:search": "ctrl+shift+f",
|
||||
"editor:search-close": "esc",
|
||||
"editor:movePreviousWord": "",
|
||||
"editor:moveNextWord": "",
|
||||
"editor:moveBeginningLine": "Home",
|
||||
"editor:moveEndLine": "End",
|
||||
"editor:deletePreviousWord": "ctrl+backspace",
|
||||
"editor:deleteNextWord": "ctrl+del",
|
||||
"editor:deleteBeginningLine": "ctrl+home",
|
||||
"editor:deleteEndLine": "ctrl+end",
|
||||
"editor:clearBuffer": "ctrl+shift+k",
|
||||
"editor:break": "ctrl+c",
|
||||
"plugins:update": "ctrl+shift+u"
|
||||
}
|
||||
297
app/menu.js
Normal file
297
app/menu.js
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
const os = require('os');
|
||||
const path = require('path');
|
||||
const { app, shell, dialog } = require('electron');
|
||||
const appName = app.getName();
|
||||
|
||||
// based on and inspired by
|
||||
// https://github.com/sindresorhus/anatine/blob/master/menu.js
|
||||
|
||||
module.exports = function createMenu ({ createWindow, updatePlugins }) {
|
||||
return [
|
||||
{
|
||||
label: 'Application',
|
||||
submenu: [
|
||||
{
|
||||
role: 'about'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Preferences...',
|
||||
accelerator: 'Cmd+,',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('preferences');
|
||||
} else {
|
||||
createWindow(win => win.rpc.emit('preferences'));
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'services',
|
||||
submenu: []
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'hide'
|
||||
},
|
||||
{
|
||||
role: 'hideothers'
|
||||
},
|
||||
{
|
||||
role: 'unhide'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'quit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Shell',
|
||||
submenu: [
|
||||
{
|
||||
label: 'New Window',
|
||||
accelerator: 'CmdOrCtrl+N',
|
||||
click (item, focusedWindow) {
|
||||
createWindow();
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'New Tab',
|
||||
accelerator: 'CmdOrCtrl+T',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('session add req');
|
||||
} else {
|
||||
createWindow();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'CmdOrCtrl+W',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('session close req');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Close Terminal Window',
|
||||
role: 'close',
|
||||
accelerator: 'CmdOrCtrl+Shift+W'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{
|
||||
role: 'undo'
|
||||
},
|
||||
{
|
||||
role: 'redo'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'cut'
|
||||
},
|
||||
{
|
||||
role: 'copy'
|
||||
},
|
||||
{
|
||||
role: 'paste'
|
||||
},
|
||||
{
|
||||
role: 'selectall'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Clear',
|
||||
accelerator: 'CmdOrCtrl+K',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('session clear req');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('reload');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Full Reload',
|
||||
accelerator: 'CmdOrCtrl+Shift+R',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.webContents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Actual Size',
|
||||
accelerator: 'CmdOrCtrl+0',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('reset fontSize req');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom In',
|
||||
accelerator: 'CmdOrCtrl+plus',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('increase fontSize req');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom Out',
|
||||
accelerator: 'CmdOrCtrl+-',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('decrease fontSize req');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Plugins',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Update All Now',
|
||||
accelerator: 'CmdOrCtrl+Shift+U',
|
||||
click () {
|
||||
updatePlugins();
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Window',
|
||||
submenu: [
|
||||
{
|
||||
role: 'minimize'
|
||||
},
|
||||
{
|
||||
role: 'zoom'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Show Previous Tab',
|
||||
accelerator: 'CmdOrCtrl+Option+Left',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('move left req');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Show Next Tab',
|
||||
accelerator: 'CmdOrCtrl+Option+Right',
|
||||
click (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('move right req');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'front'
|
||||
},
|
||||
{
|
||||
role: 'togglefullscreen'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: `${appName} Website`,
|
||||
click () {
|
||||
shell.openExternal('https://hyperterm.now.sh');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Report an Issue...',
|
||||
click () {
|
||||
const body = `
|
||||
<!-- Please succinctly describe your issue and steps to reproduce it. -->
|
||||
|
||||
-
|
||||
|
||||
${app.getName()} ${app.getVersion()}
|
||||
Electron ${process.versions.electron}
|
||||
${process.platform} ${process.arch} ${os.release()}`;
|
||||
|
||||
shell.openExternal(`https://github.com/zeit/hyperterm/issues/new?body=${encodeURIComponent(body)}`);
|
||||
}
|
||||
},
|
||||
...(
|
||||
'darwin' !== process.platform
|
||||
? [
|
||||
{ type: 'separator' },
|
||||
{
|
||||
role: 'about',
|
||||
click () {
|
||||
dialog.showMessageBox({
|
||||
title: `About ${appName}`,
|
||||
message: `${appName} ${app.getVersion()}`,
|
||||
detail: 'Created by Guillermo Rauch',
|
||||
icon: path.join(__dirname, 'static/icon.png'),
|
||||
buttons: []
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
: []
|
||||
)
|
||||
]
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
// Packages
|
||||
import {app, dialog, Menu} from 'electron';
|
||||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
// Utilities
|
||||
import {execCommand} from '../commands';
|
||||
import {getConfig} from '../config';
|
||||
import {icon} from '../config/paths';
|
||||
import {getDecoratedKeymaps} from '../plugins';
|
||||
import {getRendererTypes} from '../utils/renderer-utils';
|
||||
|
||||
import darwinMenu from './menus/darwin';
|
||||
import editMenu from './menus/edit';
|
||||
import helpMenu from './menus/help';
|
||||
import shellMenu from './menus/shell';
|
||||
import toolsMenu from './menus/tools';
|
||||
import viewMenu from './menus/view';
|
||||
import windowMenu from './menus/window';
|
||||
|
||||
const appName = app.name;
|
||||
const appVersion = app.getVersion();
|
||||
|
||||
let menu_: Menu;
|
||||
|
||||
export const createMenu = (
|
||||
createWindow: (fn?: (win: BrowserWindow) => void, options?: Record<string, any>) => BrowserWindow,
|
||||
getLoadedPluginVersions: () => {name: string; version: string}[]
|
||||
) => {
|
||||
const config = getConfig();
|
||||
// We take only first shortcut in array for each command
|
||||
const allCommandKeys = getDecoratedKeymaps();
|
||||
const commandKeys = Object.keys(allCommandKeys).reduce((result: Record<string, string>, command) => {
|
||||
result[command] = allCommandKeys[command][0];
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
let updateChannel = 'stable';
|
||||
|
||||
if (config?.updateChannel && config.updateChannel === 'canary') {
|
||||
updateChannel = 'canary';
|
||||
}
|
||||
|
||||
const showAbout = () => {
|
||||
const loadedPlugins = getLoadedPluginVersions();
|
||||
const pluginList =
|
||||
loadedPlugins.length === 0 ? 'none' : loadedPlugins.map((plugin) => `\n ${plugin.name} (${plugin.version})`);
|
||||
|
||||
const rendererCounts = Object.values(getRendererTypes()).reduce((acc: Record<string, number>, type) => {
|
||||
acc[type] = acc[type] ? acc[type] + 1 : 1;
|
||||
return acc;
|
||||
}, {});
|
||||
const renderers = Object.entries(rendererCounts)
|
||||
.map(([type, count]) => type + (count > 1 ? ` (${count})` : ''))
|
||||
.join(', ');
|
||||
|
||||
void dialog.showMessageBox({
|
||||
title: `About ${appName}`,
|
||||
message: `${appName} ${appVersion} (${updateChannel})`,
|
||||
detail: `
|
||||
Renderers: ${renderers}
|
||||
Plugins: ${pluginList}
|
||||
|
||||
Maintained by QUINE Global
|
||||
Copyright © 2025
|
||||
|
||||
Created by Guillermo Rauch
|
||||
Copyright © 2022 Vercel, Inc.
|
||||
`
|
||||
.split('\n')
|
||||
.map((z) => z.trim())
|
||||
.join('\n'),
|
||||
buttons: [],
|
||||
icon: icon as any
|
||||
});
|
||||
};
|
||||
const menu = [
|
||||
...(process.platform === 'darwin' ? [darwinMenu(commandKeys, execCommand, showAbout)] : []),
|
||||
shellMenu(
|
||||
commandKeys,
|
||||
(command, focusedWindow) => execCommand(command, focusedWindow as BrowserWindow | undefined),
|
||||
getConfig().profiles.map((p) => p.name)
|
||||
),
|
||||
editMenu(commandKeys, execCommand),
|
||||
viewMenu(commandKeys, execCommand),
|
||||
toolsMenu(commandKeys, execCommand),
|
||||
windowMenu(commandKeys, execCommand),
|
||||
helpMenu(commandKeys, showAbout)
|
||||
];
|
||||
|
||||
return menu;
|
||||
};
|
||||
|
||||
export const buildMenu = (template: Electron.MenuItemConstructorOptions[]): Electron.Menu => {
|
||||
menu_ = Menu.buildFromTemplate(template);
|
||||
return menu_;
|
||||
};
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
// This menu label is overrided by OSX to be the appName
|
||||
// The label is set to appName here so it matches actual behavior
|
||||
import {app} from 'electron';
|
||||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const darwinMenu = (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void,
|
||||
showAbout: () => void
|
||||
): MenuItemConstructorOptions => {
|
||||
return {
|
||||
label: `${app.name}`,
|
||||
submenu: [
|
||||
{
|
||||
label: 'About Hyper',
|
||||
click() {
|
||||
showAbout();
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Preferences...',
|
||||
accelerator: commandKeys['window:preferences'],
|
||||
click() {
|
||||
execCommand('window:preferences');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'services',
|
||||
submenu: []
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'hide'
|
||||
},
|
||||
{
|
||||
role: 'hideOthers'
|
||||
},
|
||||
{
|
||||
role: 'unhide'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'quit'
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default darwinMenu;
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const editMenu = (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
) => {
|
||||
const submenu: MenuItemConstructorOptions[] = [
|
||||
{
|
||||
label: 'Undo',
|
||||
accelerator: commandKeys['editor:undo'],
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
label: 'Redo',
|
||||
accelerator: commandKeys['editor:redo'],
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Cut',
|
||||
accelerator: commandKeys['editor:cut'],
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
role: 'copy',
|
||||
command: 'editor:copy',
|
||||
accelerator: commandKeys['editor:copy'],
|
||||
registerAccelerator: true
|
||||
} as any,
|
||||
{
|
||||
role: 'paste',
|
||||
accelerator: commandKeys['editor:paste'],
|
||||
registerAccelerator: true
|
||||
},
|
||||
{
|
||||
label: 'Select All',
|
||||
accelerator: commandKeys['editor:selectAll'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:selectAll', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Move to...',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Previous word',
|
||||
accelerator: commandKeys['editor:movePreviousWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:movePreviousWord', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next word',
|
||||
accelerator: commandKeys['editor:moveNextWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:moveNextWord', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line beginning',
|
||||
accelerator: commandKeys['editor:moveBeginningLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:moveBeginningLine', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line end',
|
||||
accelerator: commandKeys['editor:moveEndLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:moveEndLine', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Delete...',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Previous word',
|
||||
accelerator: commandKeys['editor:deletePreviousWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deletePreviousWord', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next word',
|
||||
accelerator: commandKeys['editor:deleteNextWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deleteNextWord', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line beginning',
|
||||
accelerator: commandKeys['editor:deleteBeginningLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deleteBeginningLine', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line end',
|
||||
accelerator: commandKeys['editor:deleteEndLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deleteEndLine', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Clear Buffer',
|
||||
accelerator: commandKeys['editor:clearBuffer'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:clearBuffer', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Search',
|
||||
accelerator: commandKeys['editor:search'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:search', focusedWindow as BrowserWindow | undefined);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
submenu.push(
|
||||
{type: 'separator'},
|
||||
{
|
||||
label: 'Preferences...',
|
||||
accelerator: commandKeys['window:preferences'],
|
||||
click() {
|
||||
execCommand('window:preferences');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
label: 'Edit',
|
||||
submenu
|
||||
};
|
||||
};
|
||||
|
||||
export default editMenu;
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
import {release} from 'os';
|
||||
|
||||
import {app, shell, dialog, clipboard} from 'electron';
|
||||
import type {MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
import {getConfig, getPlugins} from '../../config';
|
||||
import {version} from '../../package.json';
|
||||
|
||||
const {arch, env, platform, versions} = process;
|
||||
|
||||
const helpMenu = (commands: Record<string, string>, showAbout: () => void): MenuItemConstructorOptions => {
|
||||
const submenu: MenuItemConstructorOptions[] = [
|
||||
{
|
||||
label: `${app.name} Website`,
|
||||
click() {
|
||||
void shell.openExternal('https://hyper.is');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Report Issue',
|
||||
click(menuItem, focusedWindow) {
|
||||
const body = `<!--
|
||||
Hi there! Thank you for discovering and submitting an issue.
|
||||
Before you submit this; let's make sure of a few things.
|
||||
Please make sure the following boxes are ✅ if they are correct.
|
||||
If not, please try and fulfil these first.
|
||||
-->
|
||||
<!-- 👉 Checked checkbox should look like this: [x] -->
|
||||
- [ ] Your Hyper.app version is **${version}**. Please verify you're using the [latest](https://github.com/vercel/hyper/releases/latest) Hyper.app version
|
||||
- [ ] I have searched the [issues](https://github.com/vercel/hyper/issues) of this repo and believe that this is not a duplicate
|
||||
---
|
||||
- **Any relevant information from devtools?** _(CMD+OPTION+I on macOS, CTRL+SHIFT+I elsewhere)_:
|
||||
<!-- 👉 Replace with info if applicable, or N/A -->
|
||||
|
||||
- **Is the issue reproducible in vanilla Hyper.app?**
|
||||
<!-- 👉 Replace with info if applicable, or Is Vanilla. (Vanilla means Hyper.app without any add-ons or extras. Straight out of the box.) -->
|
||||
|
||||
## Issue
|
||||
<!-- 👉 Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
<!-- hyper.json config -->
|
||||
- **${app.name} version**: ${env.TERM_PROGRAM_VERSION} "${app.getVersion()}"
|
||||
- **OS ARCH VERSION:** ${platform} ${arch} ${release()}
|
||||
- **Electron:** ${versions.electron} **LANG:** ${env.LANG}
|
||||
- **SHELL:** ${env.SHELL} **TERM:** ${env.TERM}
|
||||
<details><summary><strong>hyper.json contents</strong></summary>
|
||||
|
||||
\`\`\`json
|
||||
${JSON.stringify(getConfig(), null, 2)}
|
||||
\`\`\`
|
||||
</details>
|
||||
<details><summary><strong>plugins</strong></summary>
|
||||
|
||||
\`\`\`json
|
||||
${JSON.stringify(getPlugins(), null, 2)}
|
||||
\`\`\`
|
||||
</details>`;
|
||||
|
||||
const issueURL = `https://github.com/quine-global/hyper/issues/new?body=${encodeURIComponent(body)}`;
|
||||
const copyAndSend = () => {
|
||||
clipboard.writeText(body);
|
||||
void shell.openExternal(
|
||||
`https://github.com/quine-global/hyper/issues/new?body=${encodeURIComponent(
|
||||
'<!-- We have written the needed data into your clipboard because it was too large to send. ' +
|
||||
'Please paste. -->\n'
|
||||
)}`
|
||||
);
|
||||
};
|
||||
if (!focusedWindow) {
|
||||
copyAndSend();
|
||||
} else if (issueURL.length > 6144) {
|
||||
void dialog
|
||||
.showMessageBox(focusedWindow, {
|
||||
message:
|
||||
'There is too much data to send to GitHub directly. The data will be copied to the clipboard, ' +
|
||||
'please paste it into the GitHub issue page that will open.',
|
||||
type: 'warning',
|
||||
buttons: ['OK', 'Cancel']
|
||||
})
|
||||
.then((result) => {
|
||||
if (result.response === 0) {
|
||||
copyAndSend();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
void shell.openExternal(issueURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
submenu.push(
|
||||
{type: 'separator'},
|
||||
{
|
||||
label: 'About Hyper',
|
||||
click() {
|
||||
showAbout();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return {
|
||||
role: 'help',
|
||||
submenu
|
||||
};
|
||||
};
|
||||
|
||||
export default helpMenu;
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const shellMenu = (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BaseWindow) => void,
|
||||
profiles: string[]
|
||||
): MenuItemConstructorOptions => {
|
||||
const isMac = process.platform === 'darwin';
|
||||
|
||||
return {
|
||||
label: isMac ? 'Shell' : 'File',
|
||||
submenu: [
|
||||
{
|
||||
label: 'New Tab',
|
||||
accelerator: commandKeys['tab:new'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('tab:new', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'New Window',
|
||||
accelerator: commandKeys['window:new'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('window:new', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Split Down',
|
||||
accelerator: commandKeys['pane:splitDown'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('pane:splitDown', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Split Right',
|
||||
accelerator: commandKeys['pane:splitRight'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('pane:splitRight', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
...profiles.map(
|
||||
(profile): MenuItemConstructorOptions => ({
|
||||
label: profile,
|
||||
submenu: [
|
||||
{
|
||||
label: 'New Tab',
|
||||
accelerator: commandKeys[`tab:new:${profile}`],
|
||||
click(item, focusedWindow) {
|
||||
execCommand(`tab:new:${profile}`, focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'New Window',
|
||||
accelerator: commandKeys[`window:new:${profile}`],
|
||||
click(item, focusedWindow) {
|
||||
execCommand(`window:new:${profile}`, focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Split Down',
|
||||
accelerator: commandKeys[`pane:splitDown:${profile}`],
|
||||
click(item, focusedWindow) {
|
||||
execCommand(`pane:splitDown:${profile}`, focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Split Right',
|
||||
accelerator: commandKeys[`pane:splitRight:${profile}`],
|
||||
click(item, focusedWindow) {
|
||||
execCommand(`pane:splitRight:${profile}`, focusedWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
),
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: commandKeys['pane:close'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('pane:close', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: isMac ? 'Close Window' : 'Quit',
|
||||
role: 'close',
|
||||
accelerator: commandKeys['window:close']
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default shellMenu;
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const toolsMenu = (
|
||||
commands: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
return {
|
||||
label: 'Tools',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Update plugins',
|
||||
accelerator: commands['plugins:update'],
|
||||
click() {
|
||||
execCommand('plugins:update');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Install Hyper CLI command in PATH',
|
||||
click() {
|
||||
execCommand('cli:install');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
...(process.platform === 'win32'
|
||||
? <MenuItemConstructorOptions[]>[
|
||||
{
|
||||
label: 'Add Hyper to system context menu',
|
||||
click() {
|
||||
execCommand('systemContextMenu:add');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Remove Hyper from system context menu',
|
||||
click() {
|
||||
execCommand('systemContextMenu:remove');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default toolsMenu;
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const viewMenu = (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
return {
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: commandKeys['window:reload'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('window:reload', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Full Reload',
|
||||
accelerator: commandKeys['window:reloadFull'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('window:reloadFull', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Developer Tools',
|
||||
accelerator: commandKeys['window:devtools'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('window:devtools', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Reset Zoom Level',
|
||||
accelerator: commandKeys['zoom:reset'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('zoom:reset', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom In',
|
||||
accelerator: commandKeys['zoom:in'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('zoom:in', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom Out',
|
||||
accelerator: commandKeys['zoom:out'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('zoom:out', focusedWindow as BrowserWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default viewMenu;
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const windowMenu = (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
// Generating tab:jump array
|
||||
const tabJump: MenuItemConstructorOptions[] = [];
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
// 9 is a special number because it means 'last'
|
||||
const label = i === 9 ? 'Last' : `${i}`;
|
||||
tabJump.push({
|
||||
label,
|
||||
accelerator: commandKeys[`tab:jump:${label.toLowerCase()}`]
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
role: 'window',
|
||||
submenu: [
|
||||
{
|
||||
role: 'minimize',
|
||||
accelerator: commandKeys['window:minimize']
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
// It's the same thing as clicking the green traffc-light on macOS
|
||||
role: 'zoom',
|
||||
accelerator: commandKeys['window:zoom']
|
||||
},
|
||||
{
|
||||
label: 'Select Tab',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Previous',
|
||||
accelerator: commandKeys['tab:prev'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('tab:prev', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next',
|
||||
accelerator: commandKeys['tab:next'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('tab:next', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
...tabJump
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Select Pane',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Previous',
|
||||
accelerator: commandKeys['pane:prev'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('pane:prev', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next',
|
||||
accelerator: commandKeys['pane:next'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('pane:next', focusedWindow as BrowserWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'front'
|
||||
},
|
||||
{
|
||||
label: 'Toggle Always on Top',
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('window:toggleKeepOnTop', focusedWindow as BrowserWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
role: 'togglefullscreen',
|
||||
accelerator: commandKeys['window:toggleFullScreen']
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default windowMenu;
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
import fetch from 'electron-fetch';
|
||||
import ms from 'ms';
|
||||
|
||||
import {version} from './package.json';
|
||||
|
||||
const NEWS_URL = 'https://hyper-news.now.sh';
|
||||
|
||||
export default function fetchNotifications(win: BrowserWindow) {
|
||||
const {rpc} = win;
|
||||
const retry = (err?: Error) => {
|
||||
setTimeout(() => fetchNotifications(win), ms('30m'));
|
||||
if (err) {
|
||||
console.error('Notification messages fetch error', err.stack);
|
||||
}
|
||||
};
|
||||
console.log('Checking for notification messages');
|
||||
fetch(NEWS_URL, {
|
||||
headers: {
|
||||
'X-Hyper-Version': version,
|
||||
'X-Hyper-Platform': process.platform
|
||||
}
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
const message: {text: string; url: string; dismissable: boolean} | '' = data.message || '';
|
||||
if (typeof message !== 'object' && message !== '') {
|
||||
throw new Error('Bad response');
|
||||
}
|
||||
if (message === '') {
|
||||
console.log('No matching notification messages');
|
||||
} else {
|
||||
rpc.emit('add notification', message);
|
||||
}
|
||||
|
||||
retry();
|
||||
})
|
||||
.catch(retry);
|
||||
}
|
||||
5
app/notify.html
Normal file
5
app/notify.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
require('electron').ipcRenderer.on('notification', (ev, { title, body }) => {
|
||||
new Notification(title, { body });
|
||||
});
|
||||
</script>
|
||||
41
app/notify.js
Normal file
41
app/notify.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const isDev = require('electron-is-dev');
|
||||
const { resolve } = require('path');
|
||||
|
||||
let win;
|
||||
|
||||
// the hack of all hacks
|
||||
// electron doesn't have a built in notification thing,
|
||||
// so we launch a window on which we can use the
|
||||
// HTML5 `Notification` API :'(
|
||||
|
||||
let buffer = [];
|
||||
|
||||
app.on('ready', () => {
|
||||
const win_ = new BrowserWindow({
|
||||
show: false
|
||||
});
|
||||
const url = 'file://' + resolve(
|
||||
isDev ? __dirname : app.getAppPath(),
|
||||
'notify.html'
|
||||
);
|
||||
win_.loadURL(url);
|
||||
win_.webContents.on('dom-ready', () => {
|
||||
win = win_;
|
||||
buffer.forEach(([title, body]) => {
|
||||
notify(title, body);
|
||||
});
|
||||
buffer = null;
|
||||
});
|
||||
});
|
||||
|
||||
function notify (title, body) {
|
||||
console.log(`[Notification] ${title}: ${body}`);
|
||||
if (win) {
|
||||
win.webContents.send('notification', { title, body });
|
||||
} else {
|
||||
buffer.push([title, body]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = notify;
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import {app, Notification} from 'electron';
|
||||
|
||||
import {icon} from './config/paths';
|
||||
|
||||
export default function notify(title: string, body = '', details: {error?: any} = {}) {
|
||||
console.log(`[Notification] ${title}: ${body}`);
|
||||
if (details.error) {
|
||||
console.error(details.error);
|
||||
}
|
||||
if (app.isReady()) {
|
||||
_createNotification(title, body);
|
||||
} else {
|
||||
app.on('ready', () => {
|
||||
_createNotification(title, body);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const _createNotification = (title: string, body: string) => {
|
||||
new Notification({title, body, ...(process.platform === 'linux' && {icon})}).show();
|
||||
};
|
||||
|
|
@ -1,51 +1,40 @@
|
|||
{
|
||||
"name": "hyper",
|
||||
"productName": "Hyper",
|
||||
"description": "A terminal built on web technologies",
|
||||
"version": "4.0.0-q-canary.8",
|
||||
"name": "hyperterm",
|
||||
"productName": "HyperTerm",
|
||||
"version": "0.7.0",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "ZEIT, Inc.",
|
||||
"email": "team@zeit.co"
|
||||
},
|
||||
"repository": "quine-global/hyper",
|
||||
"scripts": {
|
||||
"postinstall": "npx patch-package"
|
||||
},
|
||||
"author": "rauchg",
|
||||
"repository": "zeit/hyperterm",
|
||||
"description": "HTML/JS/CSS Terminal",
|
||||
"dependencies": {
|
||||
"@babel/parser": "7.27.0",
|
||||
"@electron/remote": "2.1.2",
|
||||
"ast-types": "^0.16.1",
|
||||
"async-retry": "1.3.3",
|
||||
"chokidar": "^3.6.0",
|
||||
"color": "4.2.3",
|
||||
"child_pty": "3.0.1",
|
||||
"convert-css-color-name-to-hex": "0.1.1",
|
||||
"default-shell": "1.0.1",
|
||||
"electron-devtools-installer": "3.2.1",
|
||||
"electron-fetch": "1.9.1",
|
||||
"electron-is-dev": "2.0.0",
|
||||
"electron-store": "8.2.0",
|
||||
"fs-extra": "11.3.0",
|
||||
"git-describe": "4.1.1",
|
||||
"lodash": "4.17.21",
|
||||
"ms": "2.1.3",
|
||||
"native-process-working-directory": "^1.0.2",
|
||||
"node-pty": "1.1.0-beta33",
|
||||
"os-locale": "5.0.0",
|
||||
"parse-url": "9.2.0",
|
||||
"queue": "6.0.2",
|
||||
"quine-electron-drag-click": "2.0.0",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"recast": "0.23.11",
|
||||
"semver": "7.7.1",
|
||||
"shell-env": "3.0.1",
|
||||
"sudo-prompt": "^9.2.1",
|
||||
"uuid": "10.0.0"
|
||||
"electron-config": "0.2.1",
|
||||
"electron-is-dev": "0.1.1",
|
||||
"gaze": "1.1.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"ms": "0.7.1",
|
||||
"shell-env": "0.1.2",
|
||||
"uuid": "2.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"native-reg": "1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-gyp": "^10.2.0"
|
||||
"eslintConfig": {
|
||||
"extends": "standard",
|
||||
"rules": {
|
||||
"yoda": 0,
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
],
|
||||
"no-unused-vars": 2,
|
||||
"no-extra-semi": 2,
|
||||
"semi-spacing": [
|
||||
2,
|
||||
{
|
||||
"before": false,
|
||||
"after": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
319
app/plugins.js
Normal file
319
app/plugins.js
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
const { app, dialog } = require('electron');
|
||||
const { homedir } = require('os');
|
||||
const { resolve, basename } = require('path');
|
||||
const { writeFileSync } = require('fs');
|
||||
const config = require('./config');
|
||||
const { sync: mkdirpSync } = require('mkdirp');
|
||||
const { exec } = require('child_process');
|
||||
const Config = require('electron-config');
|
||||
const ms = require('ms');
|
||||
const notify = require('./notify');
|
||||
const shellEnv = require('shell-env');
|
||||
|
||||
// local storage
|
||||
const cache = new Config();
|
||||
|
||||
// modules path
|
||||
const path = resolve(homedir(), '.hyperterm_plugins');
|
||||
const localPath = resolve(homedir(), '.hyperterm_plugins', 'local');
|
||||
const availableExtensions = new Set([
|
||||
'onApp', 'onWindow', 'onUnload', 'middleware',
|
||||
'reduceUI', 'reduceSessions', 'decorateMenu',
|
||||
'decorateTerm', 'decorateHyperTerm', 'decorateTab',
|
||||
'decorateNotification', 'decorateNotifications',
|
||||
'decorateTabs', 'decorateConfig', 'decorateEnv'
|
||||
]);
|
||||
|
||||
// init plugin directories if not present
|
||||
mkdirpSync(path);
|
||||
mkdirpSync(localPath);
|
||||
|
||||
// caches
|
||||
let plugins = config.getPlugins();
|
||||
let paths = getPaths(plugins);
|
||||
let id = getId(plugins);
|
||||
let modules = requirePlugins();
|
||||
|
||||
function getId (plugins_) {
|
||||
return JSON.stringify(plugins_);
|
||||
}
|
||||
|
||||
const watchers = [];
|
||||
|
||||
// we listen on configuration updates to trigger
|
||||
// plugin installation
|
||||
config.subscribe(() => {
|
||||
const plugins_ = config.getPlugins();
|
||||
if (plugins !== plugins_) {
|
||||
const id_ = getId(plugins_);
|
||||
if (id !== id_) {
|
||||
id = id_;
|
||||
plugins = plugins_;
|
||||
updatePlugins();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let updating = false;
|
||||
|
||||
function updatePlugins ({ force = false } = {}) {
|
||||
if (updating) return notify('Plugin update in progress');
|
||||
updating = true;
|
||||
syncPackageJSON();
|
||||
const id_ = id;
|
||||
install((err) => {
|
||||
updating = false;
|
||||
|
||||
if (err) {
|
||||
console.error(err.stack);
|
||||
if (/not a recognized/.test(err.message) || /command not found/.test(err.message)) {
|
||||
notify(
|
||||
'Error updating plugins.',
|
||||
'We could not find the `npm` command. Make sure it\'s in $PATH'
|
||||
);
|
||||
} else {
|
||||
notify(
|
||||
'Error updating plugins.',
|
||||
'Check `~/.hyperterm_plugins/npm-debug.log` for more information.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// flag successful plugin update
|
||||
cache.set('plugins', id_);
|
||||
|
||||
// cache paths
|
||||
paths = getPaths(plugins);
|
||||
|
||||
// clear require cache
|
||||
clearCache();
|
||||
|
||||
// cache modules
|
||||
modules = requirePlugins();
|
||||
|
||||
const loaded = modules.length;
|
||||
const total = paths.plugins.length + paths.localPlugins.length;
|
||||
const pluginVersions = JSON.stringify(getPluginVersions());
|
||||
const changed = cache.get('plugin-versions') !== pluginVersions && loaded === total;
|
||||
cache.set('plugin-versions', pluginVersions);
|
||||
|
||||
// notify watchers
|
||||
if (force || changed) {
|
||||
if (changed) {
|
||||
notify(
|
||||
'Plugins Updated',
|
||||
'Restart the app or hot-reload with "View" > "Reload" to enjoy the updates!'
|
||||
);
|
||||
} else {
|
||||
notify(
|
||||
'Plugins Updated',
|
||||
'No changes!'
|
||||
);
|
||||
}
|
||||
watchers.forEach((fn) => fn(err, { force }));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getPluginVersions () {
|
||||
const paths_ = paths.plugins.concat(paths.localPlugins);
|
||||
return paths_.map((path) => {
|
||||
let version = null;
|
||||
try {
|
||||
version = require(resolve(path, 'package.json')).version;
|
||||
} catch (err) { }
|
||||
return [
|
||||
basename(path),
|
||||
version
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
function clearCache (mod) {
|
||||
// trigger unload hooks
|
||||
modules.forEach((mod) => {
|
||||
if (mod.onUnload) mod.onUnload(app);
|
||||
});
|
||||
|
||||
// clear require cache
|
||||
for (const entry in require.cache) {
|
||||
if (entry.indexOf(path) === 0 || entry.indexOf(localPath) === 0) {
|
||||
delete require.cache[entry];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.updatePlugins = updatePlugins;
|
||||
|
||||
// we schedule the initial plugins update
|
||||
// a bit after the user launches the terminal
|
||||
// to prevent slowness
|
||||
if (cache.get('plugins') !== id || process.env.HYPERTERM_FORCE_UPDATE) {
|
||||
// install immediately if the user changed plugins
|
||||
console.log('plugins have changed / not init, scheduling plugins installation');
|
||||
setTimeout(() => {
|
||||
updatePlugins();
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// otherwise update plugins every 5 hours
|
||||
setInterval(updatePlugins, ms('5h'));
|
||||
|
||||
function syncPackageJSON () {
|
||||
const dependencies = toDependencies(plugins);
|
||||
const pkg = {
|
||||
name: 'hyperterm-plugins',
|
||||
description: 'Auto-generated from `~/.hyperterm.js`!',
|
||||
private: true,
|
||||
version: '0.0.1',
|
||||
repository: 'zeit/hyperterm',
|
||||
license: 'MIT',
|
||||
homepage: 'https://hyperterm.org',
|
||||
dependencies
|
||||
};
|
||||
|
||||
const file = resolve(path, 'package.json');
|
||||
try {
|
||||
writeFileSync(file, JSON.stringify(pkg, null, 2));
|
||||
} catch (err) {
|
||||
alert(`An error occurred writing to ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
function alert (message) {
|
||||
dialog.showMessageBox({
|
||||
message,
|
||||
buttons: ['Ok']
|
||||
});
|
||||
}
|
||||
|
||||
function toDependencies (plugins) {
|
||||
const obj = {};
|
||||
plugins.plugins.forEach((plugin) => {
|
||||
const pieces = plugin.split('#');
|
||||
obj[pieces[0]] = null == pieces[1] ? 'latest' : pieces[1];
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
function install (fn) {
|
||||
shellEnv().then((env) => {
|
||||
let registry = exports.getDecoratedConfig().npmRegistry;
|
||||
if (registry) env.NPM_CONFIG_REGISTRY = registry;
|
||||
env.npm_config_runtime = 'electron';
|
||||
env.npm_config_target = '1.2.8';
|
||||
env.npm_config_disturl = 'https://atom.io/download/atom-shell';
|
||||
exec('npm prune && npm install --ignore-scripts --production', {
|
||||
cwd: path,
|
||||
env: env
|
||||
}, (err, stdout, stderr) => {
|
||||
if (err) return fn(err);
|
||||
fn(null);
|
||||
});
|
||||
}).catch(fn);
|
||||
}
|
||||
|
||||
exports.subscribe = function (fn) {
|
||||
watchers.push(fn);
|
||||
return () => {
|
||||
watchers.splice(watchers.indexOf(fn), 1);
|
||||
};
|
||||
};
|
||||
|
||||
function getPaths () {
|
||||
return {
|
||||
plugins: plugins.plugins.map((name) => {
|
||||
return resolve(path, 'node_modules', name.split('#')[0]);
|
||||
}),
|
||||
localPlugins: plugins.localPlugins.map((name) => {
|
||||
return resolve(localPath, name);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
// expose to renderer
|
||||
exports.getPaths = getPaths;
|
||||
|
||||
// get paths from renderer
|
||||
exports.getBasePaths = function () {
|
||||
return { path, localPath };
|
||||
};
|
||||
|
||||
function requirePlugins () {
|
||||
const { plugins, localPlugins } = paths;
|
||||
|
||||
const load = (path) => {
|
||||
let mod;
|
||||
try {
|
||||
mod = require(path);
|
||||
const exposed = mod && Object.keys(mod).some(key => availableExtensions.has(key));
|
||||
if (!exposed) {
|
||||
notify('Plugin error!', `Plugin "${basename(path)}" does not expose any ` +
|
||||
'HyperTerm extension API methods');
|
||||
return;
|
||||
}
|
||||
|
||||
// populate the name for internal errors here
|
||||
mod._name = basename(path);
|
||||
|
||||
return mod;
|
||||
} catch (err) {
|
||||
notify('Plugin error!', `Plugin "${basename(path)}" failed to load (${err.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
return plugins.map(load)
|
||||
.concat(localPlugins.map(load))
|
||||
.filter(v => !!v);
|
||||
}
|
||||
|
||||
exports.onApp = function (app) {
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.onApp) {
|
||||
plugin.onApp(app);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.onWindow = function (win) {
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.onWindow) {
|
||||
plugin.onWindow(win);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// decorates the base object by calling plugin[key]
|
||||
// for all the available plugins
|
||||
function decorateObject (base, key) {
|
||||
let decorated = base;
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin[key]) {
|
||||
const res = plugin[key](decorated);
|
||||
if (res && 'object' === typeof res) {
|
||||
decorated = res;
|
||||
} else {
|
||||
notify('Plugin error!', `"${plugin._name}": invalid return type for \`${key}\``);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return decorated;
|
||||
}
|
||||
|
||||
exports.decorateMenu = function (tpl) {
|
||||
return decorateObject(tpl, 'decorateMenu');
|
||||
};
|
||||
|
||||
exports.getDecoratedEnv = function (baseEnv) {
|
||||
return decorateObject(baseEnv, 'decorateEnv');
|
||||
};
|
||||
|
||||
exports.getDecoratedConfig = function () {
|
||||
const baseConfig = config.getConfig();
|
||||
return decorateObject(baseConfig, 'decorateConfig');
|
||||
};
|
||||
|
||||
exports.getDecoratedBrowserOptions = function (defaults) {
|
||||
return decorateObject(defaults, 'decorateBrowserOptions');
|
||||
};
|
||||
480
app/plugins.ts
480
app/plugins.ts
|
|
@ -1,480 +0,0 @@
|
|||
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
import {exec, execFile} from 'child_process';
|
||||
import {writeFileSync} from 'fs';
|
||||
import {resolve, basename} from 'path';
|
||||
import {promisify} from 'util';
|
||||
|
||||
import {app, dialog, ipcMain as _ipcMain} from 'electron';
|
||||
import type {BrowserWindow, App, MenuItemConstructorOptions} from 'electron';
|
||||
import React from 'react';
|
||||
|
||||
import Config from 'electron-store';
|
||||
import ms from 'ms';
|
||||
import ReactDom from 'react-dom';
|
||||
|
||||
import type {IpcMainWithCommands} from '../typings/common';
|
||||
import type {configOptions} from '../typings/config';
|
||||
|
||||
import * as config from './config';
|
||||
import {plugs} from './config/paths';
|
||||
import notify from './notify';
|
||||
import {availableExtensions} from './plugins/extensions';
|
||||
import {install} from './plugins/install';
|
||||
import mapKeys from './utils/map-keys';
|
||||
|
||||
// local storage
|
||||
const cache = new Config();
|
||||
|
||||
const path = plugs.base;
|
||||
const localPath = plugs.local;
|
||||
|
||||
patchModuleLoad();
|
||||
|
||||
// caches
|
||||
let plugins = config.getPlugins();
|
||||
let paths = getPaths();
|
||||
let id = getId(plugins);
|
||||
let modules = requirePlugins();
|
||||
|
||||
function getId(plugins_: any) {
|
||||
return JSON.stringify(plugins_);
|
||||
}
|
||||
|
||||
const watchers: Function[] = [];
|
||||
|
||||
// we listen on configuration updates to trigger
|
||||
// plugin installation
|
||||
config.subscribe(() => {
|
||||
const plugins_ = config.getPlugins();
|
||||
if (plugins !== plugins_) {
|
||||
const id_ = getId(plugins_);
|
||||
if (id !== id_) {
|
||||
id = id_;
|
||||
plugins = plugins_;
|
||||
updatePlugins();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// patching Module._load
|
||||
// so plugins can `require` them without needing their own version
|
||||
// https://github.com/vercel/hyper/issues/619
|
||||
function patchModuleLoad() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Module = require('module');
|
||||
const originalLoad = Module._load;
|
||||
Module._load = function _load(modulePath: string) {
|
||||
// PLEASE NOTE: Code changes here, also need to be changed in
|
||||
// lib/utils/plugins.js
|
||||
switch (modulePath) {
|
||||
case 'react':
|
||||
// DEPRECATED
|
||||
return React;
|
||||
case 'react-dom':
|
||||
// DEPRECATED
|
||||
return ReactDom;
|
||||
case 'hyper/component':
|
||||
// DEPRECATED
|
||||
return React.PureComponent;
|
||||
// These return Object, since they work differently on the backend, than on the frontend.
|
||||
// Still needs to be here, to prevent errors, while loading plugins.
|
||||
case 'hyper/Notification':
|
||||
case 'hyper/notify':
|
||||
case 'hyper/decorate':
|
||||
return Object;
|
||||
default:
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
return originalLoad.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function checkDeprecatedExtendKeymaps() {
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.extendKeymaps) {
|
||||
notify('Plugin warning!', `"${plugin._name}" use deprecated "extendKeymaps" handler`);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let updating = false;
|
||||
|
||||
function updatePlugins({force = false} = {}) {
|
||||
if (updating) {
|
||||
return notify('Plugin update in progress');
|
||||
}
|
||||
updating = true;
|
||||
syncPackageJSON();
|
||||
const id_ = id;
|
||||
install((err) => {
|
||||
updating = false;
|
||||
|
||||
if (err) {
|
||||
notify('Error updating plugins.', err, {error: err});
|
||||
} else {
|
||||
// flag successful plugin update
|
||||
cache.set('hyper.plugins', id_);
|
||||
|
||||
// cache paths
|
||||
paths = getPaths();
|
||||
|
||||
// clear require cache
|
||||
clearCache();
|
||||
|
||||
// cache modules
|
||||
modules = requirePlugins();
|
||||
|
||||
const loaded = modules.length;
|
||||
const total = paths.plugins.length + paths.localPlugins.length;
|
||||
const pluginVersions = JSON.stringify(getPluginVersions());
|
||||
const changed = cache.get('hyper.plugin-versions') !== pluginVersions && loaded === total;
|
||||
cache.set('hyper.plugin-versions', pluginVersions);
|
||||
|
||||
// notify watchers
|
||||
watchers.forEach((fn) => {
|
||||
fn(err, {force});
|
||||
});
|
||||
|
||||
if (force || changed) {
|
||||
if (changed) {
|
||||
notify('Plugins Updated', 'Restart the app or hot-reload with "View" > "Reload" to enjoy the updates!');
|
||||
} else {
|
||||
notify('Plugins Updated', 'No changes!');
|
||||
}
|
||||
checkDeprecatedExtendKeymaps();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getPluginVersions() {
|
||||
const paths_ = paths.plugins.concat(paths.localPlugins);
|
||||
return paths_.map((path_) => {
|
||||
let version: string | null = null;
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
version = require(resolve(path_, 'package.json')).version;
|
||||
//eslint-disable-next-line no-empty
|
||||
} catch (err) {}
|
||||
return [basename(path_), version];
|
||||
});
|
||||
}
|
||||
|
||||
function clearCache() {
|
||||
// trigger unload hooks
|
||||
modules.forEach((mod) => {
|
||||
if (mod.onUnload) {
|
||||
mod.onUnload(app);
|
||||
}
|
||||
});
|
||||
|
||||
// clear require cache
|
||||
for (const entry in require.cache) {
|
||||
if (entry.indexOf(path) === 0 || entry.indexOf(localPath) === 0) {
|
||||
delete require.cache[entry];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {updatePlugins};
|
||||
|
||||
export const getLoadedPluginVersions = () => {
|
||||
return modules.map((mod) => ({name: mod._name, version: mod._version}));
|
||||
};
|
||||
|
||||
// we schedule the initial plugins update
|
||||
// a bit after the user launches the terminal
|
||||
// to prevent slowness
|
||||
if (cache.get('hyper.plugins') !== id || process.env.HYPER_FORCE_UPDATE) {
|
||||
// install immediately if the user changed plugins
|
||||
console.log('plugins have changed / not init, scheduling plugins installation');
|
||||
setTimeout(() => {
|
||||
updatePlugins();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
(() => {
|
||||
const baseConfig = config.getConfig();
|
||||
if (baseConfig['autoUpdatePlugins']) {
|
||||
// otherwise update plugins every 5 hours
|
||||
setInterval(updatePlugins, ms(baseConfig['autoUpdatePlugins'] === true ? '5h' : baseConfig['autoUpdatePlugins']));
|
||||
}
|
||||
})();
|
||||
|
||||
function syncPackageJSON() {
|
||||
const dependencies = toDependencies(plugins);
|
||||
const pkg = {
|
||||
name: 'hyper-plugins',
|
||||
description: 'Auto-generated from `hyper.json`!',
|
||||
private: true,
|
||||
version: '0.0.1',
|
||||
repository: 'quine-global/hyper',
|
||||
license: 'MIT',
|
||||
homepage: 'https://hyper.is',
|
||||
dependencies
|
||||
};
|
||||
|
||||
const file = resolve(path, 'package.json');
|
||||
try {
|
||||
writeFileSync(file, JSON.stringify(pkg, null, 2));
|
||||
} catch (err) {
|
||||
alert(`An error occurred writing to ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
function alert(message: string) {
|
||||
void dialog.showMessageBox({
|
||||
message,
|
||||
buttons: ['Ok']
|
||||
});
|
||||
}
|
||||
|
||||
function toDependencies(plugins_: {plugins: string[]}) {
|
||||
const obj: Record<string, string> = {};
|
||||
plugins_.plugins.forEach((plugin) => {
|
||||
const regex = /.(@|#)/;
|
||||
const match = regex.exec(plugin);
|
||||
|
||||
if (match) {
|
||||
const index = match.index + 1;
|
||||
const pieces: string[] = [];
|
||||
|
||||
pieces[0] = plugin.substring(0, index);
|
||||
pieces[1] = plugin.substring(index + 1, plugin.length);
|
||||
obj[pieces[0]] = pieces[1];
|
||||
} else {
|
||||
obj[plugin] = 'latest';
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
export const subscribe = (fn: Function) => {
|
||||
watchers.push(fn);
|
||||
return () => {
|
||||
watchers.splice(watchers.indexOf(fn), 1);
|
||||
};
|
||||
};
|
||||
|
||||
function getPaths() {
|
||||
return {
|
||||
plugins: plugins.plugins.map((name) => {
|
||||
return resolve(path, 'node_modules', name.split('#')[0]);
|
||||
}),
|
||||
localPlugins: plugins.localPlugins.map((name) => {
|
||||
return resolve(localPath, name);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
// expose to renderer
|
||||
export {getPaths};
|
||||
|
||||
// get paths from renderer
|
||||
export const getBasePaths = () => {
|
||||
return {path, localPath};
|
||||
};
|
||||
|
||||
function requirePlugins(): any[] {
|
||||
const {plugins: plugins_, localPlugins} = paths;
|
||||
|
||||
const load = (path_: string) => {
|
||||
let mod: Record<string, any>;
|
||||
try {
|
||||
mod = require(path_);
|
||||
const exposed = mod && Object.keys(mod).some((key) => availableExtensions.has(key));
|
||||
if (!exposed) {
|
||||
notify('Plugin error!', `${`Plugin "${basename(path_)}" does not expose any `}Hyper extension API methods`);
|
||||
return;
|
||||
}
|
||||
|
||||
// populate the name for internal errors here
|
||||
mod._name = basename(path_);
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
mod._version = require(resolve(path_, 'package.json')).version;
|
||||
} catch (err) {
|
||||
console.warn(`No package.json found in ${path_}`);
|
||||
}
|
||||
console.log(`Plugin ${mod._name} (${mod._version}) loaded.`);
|
||||
|
||||
return mod;
|
||||
} catch (_err) {
|
||||
const err = _err as {code: string; message: string};
|
||||
if (err.code === 'MODULE_NOT_FOUND') {
|
||||
console.warn(`Plugin error while loading "${basename(path_)}" (${path_}): ${err.message}`);
|
||||
} else {
|
||||
notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`, {error: err});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
...localPlugins.filter((p) => basename(p) === 'migrated-hyper3-config'),
|
||||
...plugins_,
|
||||
...localPlugins.filter((p) => basename(p) !== 'migrated-hyper3-config')
|
||||
]
|
||||
.map(load)
|
||||
.filter((v): v is Record<string, any> => Boolean(v));
|
||||
}
|
||||
|
||||
export const onApp = (app_: App) => {
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.onApp) {
|
||||
try {
|
||||
plugin.onApp(app_);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const onWindowClass = (win: BrowserWindow) => {
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.onWindowClass) {
|
||||
try {
|
||||
plugin.onWindowClass(win);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const onWindow = (win: BrowserWindow) => {
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.onWindow) {
|
||||
try {
|
||||
plugin.onWindow(win);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// decorates the base entity by calling plugin[key]
|
||||
// for all the available plugins
|
||||
function decorateEntity(base: any, key: string, type: 'object' | 'function') {
|
||||
let decorated = base;
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin[key]) {
|
||||
let res;
|
||||
try {
|
||||
res = plugin[key](decorated);
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" when decorating ${key}`, {error: e});
|
||||
return;
|
||||
}
|
||||
if (res && (!type || typeof res === type)) {
|
||||
decorated = res;
|
||||
} else {
|
||||
notify('Plugin error!', `"${plugin._name}": invalid return type for \`${key}\``);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return decorated;
|
||||
}
|
||||
|
||||
function decorateObject<T>(base: T, key: string): T {
|
||||
return decorateEntity(base, key, 'object');
|
||||
}
|
||||
|
||||
function decorateClass(base: any, key: string) {
|
||||
return decorateEntity(base, key, 'function');
|
||||
}
|
||||
|
||||
export const getDeprecatedConfig = () => {
|
||||
const deprecated: Record<string, {css: string[]}> = {};
|
||||
const baseConfig = config.getConfig();
|
||||
modules.forEach((plugin) => {
|
||||
if (!plugin.decorateConfig) {
|
||||
return;
|
||||
}
|
||||
// We need to clone config in case of plugin modifies config directly.
|
||||
let configTmp: configOptions;
|
||||
try {
|
||||
configTmp = plugin.decorateConfig(JSON.parse(JSON.stringify(baseConfig)));
|
||||
} catch (e) {
|
||||
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||
error: e
|
||||
});
|
||||
return;
|
||||
}
|
||||
const pluginCSSDeprecated = config.getDeprecatedCSS(configTmp);
|
||||
if (pluginCSSDeprecated.length === 0) {
|
||||
return;
|
||||
}
|
||||
deprecated[plugin._name] = {css: pluginCSSDeprecated};
|
||||
});
|
||||
return deprecated;
|
||||
};
|
||||
|
||||
export const decorateMenu = (tpl: MenuItemConstructorOptions[]) => {
|
||||
return decorateObject(tpl, 'decorateMenu');
|
||||
};
|
||||
|
||||
export const getDecoratedEnv = (baseEnv: Record<string, string>) => {
|
||||
return decorateObject(baseEnv, 'decorateEnv');
|
||||
};
|
||||
|
||||
export const getDecoratedConfig = (profile: string) => {
|
||||
const baseConfig = config.getProfileConfig(profile);
|
||||
const decoratedConfig = decorateObject(baseConfig, 'decorateConfig');
|
||||
const fixedConfig = config.fixConfigDefaults(decoratedConfig);
|
||||
const translatedConfig = config.htermConfigTranslate(fixedConfig);
|
||||
return translatedConfig;
|
||||
};
|
||||
|
||||
export const getDecoratedKeymaps = () => {
|
||||
const baseKeymaps = config.getKeymaps();
|
||||
// Ensure that all keys are in an array and don't use deprecated key combination`
|
||||
const decoratedKeymaps = mapKeys(decorateObject(baseKeymaps, 'decorateKeymaps'));
|
||||
return decoratedKeymaps;
|
||||
};
|
||||
|
||||
export const getDecoratedBrowserOptions = <T>(defaults: T): T => {
|
||||
return decorateObject(defaults, 'decorateBrowserOptions');
|
||||
};
|
||||
|
||||
export const decorateWindowClass = <T>(defaults: T): T => {
|
||||
return decorateObject(defaults, 'decorateWindowClass');
|
||||
};
|
||||
|
||||
export const decorateSessionOptions = <T>(defaults: T): T => {
|
||||
return decorateObject(defaults, 'decorateSessionOptions');
|
||||
};
|
||||
|
||||
export const decorateSessionClass = <T>(Session: T): T => {
|
||||
return decorateClass(Session, 'decorateSessionClass');
|
||||
};
|
||||
|
||||
export {toDependencies as _toDependencies};
|
||||
|
||||
const ipcMain = _ipcMain as IpcMainWithCommands;
|
||||
|
||||
ipcMain.handle('child_process.exec', (event, command, options) => {
|
||||
return promisify(exec)(command, options);
|
||||
});
|
||||
|
||||
ipcMain.handle('child_process.execFile', (event, file, args, options) => {
|
||||
return promisify(execFile)(file, args, options);
|
||||
});
|
||||
|
||||
ipcMain.handle('getLoadedPluginVersions', () => getLoadedPluginVersions());
|
||||
ipcMain.handle('getPaths', () => getPaths());
|
||||
ipcMain.handle('getBasePaths', () => getBasePaths());
|
||||
ipcMain.handle('getDeprecatedConfig', () => getDeprecatedConfig());
|
||||
ipcMain.handle('getDecoratedConfig', (e, profile) => getDecoratedConfig(profile));
|
||||
ipcMain.handle('getDecoratedKeymaps', () => getDecoratedKeymaps());
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
export const availableExtensions = new Set([
|
||||
'onApp',
|
||||
'onWindowClass',
|
||||
'decorateWindowClass',
|
||||
'onWindow',
|
||||
'onRendererWindow',
|
||||
'onUnload',
|
||||
'decorateSessionClass',
|
||||
'decorateSessionOptions',
|
||||
'middleware',
|
||||
'reduceUI',
|
||||
'reduceSessions',
|
||||
'reduceTermGroups',
|
||||
'decorateBrowserOptions',
|
||||
'decorateMenu',
|
||||
'decorateTerm',
|
||||
'decorateHyper',
|
||||
'decorateHyperTerm', // for backwards compatibility with hyperterm
|
||||
'decorateHeader',
|
||||
'decorateTerms',
|
||||
'decorateTab',
|
||||
'decorateNotification',
|
||||
'decorateNotifications',
|
||||
'decorateTabs',
|
||||
'decorateConfig',
|
||||
'decorateKeymaps',
|
||||
'decorateEnv',
|
||||
'decorateTermGroup',
|
||||
'decorateSplitPane',
|
||||
'getTermProps',
|
||||
'getTabProps',
|
||||
'getTabsProps',
|
||||
'getTermGroupProps',
|
||||
'mapHyperTermState',
|
||||
'mapTermsState',
|
||||
'mapHeaderState',
|
||||
'mapNotificationsState',
|
||||
'mapHyperTermDispatch',
|
||||
'mapTermsDispatch',
|
||||
'mapHeaderDispatch',
|
||||
'mapNotificationsDispatch'
|
||||
]);
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
import cp from 'child_process';
|
||||
|
||||
import ms from 'ms';
|
||||
import queue from 'queue';
|
||||
|
||||
import {yarn, plugs} from '../config/paths';
|
||||
|
||||
export const install = (fn: (err: string | null) => void) => {
|
||||
const spawnQueue = queue({concurrency: 1});
|
||||
function yarnFn(args: string[], cb: (err: string | null) => void) {
|
||||
const env = {
|
||||
NODE_ENV: 'production',
|
||||
ELECTRON_RUN_AS_NODE: 'true'
|
||||
};
|
||||
spawnQueue.push((end) => {
|
||||
const cmd = [process.execPath, yarn].concat(args).join(' ');
|
||||
console.log('Launching yarn:', cmd);
|
||||
|
||||
cp.execFile(
|
||||
process.execPath,
|
||||
[yarn].concat(args),
|
||||
{
|
||||
cwd: plugs.base,
|
||||
env,
|
||||
timeout: ms('5m'),
|
||||
maxBuffer: 1024 * 1024
|
||||
},
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
cb(stderr);
|
||||
} else {
|
||||
cb(null);
|
||||
}
|
||||
end?.();
|
||||
spawnQueue.start();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
spawnQueue.start();
|
||||
}
|
||||
|
||||
yarnFn(['install', '--no-emoji', '--no-lockfile', '--cache-folder', plugs.cache], (err) => {
|
||||
if (err) {
|
||||
return fn(err);
|
||||
}
|
||||
fn(null);
|
||||
});
|
||||
};
|
||||
70
app/rpc.js
Normal file
70
app/rpc.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
const { EventEmitter } = require('events');
|
||||
const { ipcMain } = require('electron');
|
||||
const uuid = require('uuid');
|
||||
|
||||
class Server {
|
||||
|
||||
constructor (win) {
|
||||
this.win = win;
|
||||
this.ipcListener = this.ipcListener.bind(this);
|
||||
this.emitter = new EventEmitter();
|
||||
|
||||
if (this.destroyed) return;
|
||||
|
||||
const uid = uuid.v4();
|
||||
this.id = uid;
|
||||
|
||||
ipcMain.on(uid, this.ipcListener);
|
||||
|
||||
// we intentionally subscribe to `on` instead of `once`
|
||||
// to support reloading the window and re-initializing
|
||||
// the channel
|
||||
this.wc.on('did-finish-load', () => {
|
||||
this.wc.send('init', uid);
|
||||
});
|
||||
}
|
||||
|
||||
get wc () {
|
||||
return this.win.webContents;
|
||||
}
|
||||
|
||||
ipcListener (event, { ev, data }) {
|
||||
this.emitter.emit(ev, data);
|
||||
}
|
||||
|
||||
emit (ch, data) {
|
||||
this.wc.send(this.id, { ch, data });
|
||||
}
|
||||
|
||||
on (ev, fn) {
|
||||
this.emitter.on(ev, fn);
|
||||
}
|
||||
|
||||
once (ev, fn) {
|
||||
this.emitter.once(ev, fn);
|
||||
}
|
||||
|
||||
removeListener (ev, fn) {
|
||||
this.emitter.removeListener(ev, fn);
|
||||
}
|
||||
|
||||
removeAllListeners () {
|
||||
this.emitter.removeAllListeners();
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.removeAllListeners();
|
||||
this.wc.removeAllListeners();
|
||||
if (this.id) {
|
||||
ipcMain.removeListener(this.id, this.ipcListener);
|
||||
} else {
|
||||
// mark for `genUid` in constructor
|
||||
this.destroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = function createRPC (win) {
|
||||
return new Server(win);
|
||||
};
|
||||
83
app/rpc.ts
83
app/rpc.ts
|
|
@ -1,83 +0,0 @@
|
|||
import {EventEmitter} from 'events';
|
||||
|
||||
import {ipcMain} from 'electron';
|
||||
import type {BrowserWindow, IpcMainEvent} from 'electron';
|
||||
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
|
||||
import type {TypedEmitter, MainEvents, RendererEvents, FilterNever} from '../typings/common';
|
||||
|
||||
export class Server {
|
||||
emitter: TypedEmitter<MainEvents>;
|
||||
destroyed = false;
|
||||
win: BrowserWindow;
|
||||
id!: string;
|
||||
|
||||
constructor(win: BrowserWindow) {
|
||||
this.emitter = new EventEmitter();
|
||||
this.win = win;
|
||||
this.emit = this.emit.bind(this);
|
||||
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uid = uuidv4();
|
||||
this.id = uid;
|
||||
|
||||
ipcMain.on(uid, this.ipcListener);
|
||||
|
||||
// we intentionally subscribe to `on` instead of `once`
|
||||
// to support reloading the window and re-initializing
|
||||
// the channel
|
||||
this.wc.on('did-finish-load', () => {
|
||||
this.wc.send('init', uid, win.profileName);
|
||||
});
|
||||
}
|
||||
|
||||
get wc() {
|
||||
return this.win.webContents;
|
||||
}
|
||||
|
||||
ipcListener = <U extends keyof MainEvents>(event: IpcMainEvent, {ev, data}: {ev: U; data: MainEvents[U]}) =>
|
||||
this.emitter.emit(ev, data);
|
||||
|
||||
on = <U extends keyof MainEvents>(ev: U, fn: (arg0: MainEvents[U]) => void) => {
|
||||
this.emitter.on(ev, fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
once = <U extends keyof MainEvents>(ev: U, fn: (arg0: MainEvents[U]) => void) => {
|
||||
this.emitter.once(ev, fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
emit<U extends Exclude<keyof RendererEvents, FilterNever<RendererEvents>>>(ch: U): boolean;
|
||||
emit<U extends FilterNever<RendererEvents>>(ch: U, data: RendererEvents[U]): boolean;
|
||||
emit<U extends keyof RendererEvents>(ch: U, data?: RendererEvents[U]) {
|
||||
// This check is needed because data-batching can cause extra data to be
|
||||
// emitted after the window has already closed
|
||||
if (!this.win.isDestroyed()) {
|
||||
this.wc.send(this.id, {ch, data});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.emitter.removeAllListeners();
|
||||
this.wc.removeAllListeners();
|
||||
if (this.id) {
|
||||
ipcMain.removeListener(this.id, this.ipcListener);
|
||||
} else {
|
||||
// mark for `genUid` in constructor
|
||||
this.destroyed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const createRPC = (win: BrowserWindow) => {
|
||||
return new Server(win);
|
||||
};
|
||||
|
||||
export default createRPC;
|
||||
126
app/session.js
Normal file
126
app/session.js
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
const { app } = require('electron');
|
||||
const { EventEmitter } = require('events');
|
||||
const { exec } = require('child_process');
|
||||
const defaultShell = require('default-shell');
|
||||
const { getDecoratedEnv } = require('./plugins');
|
||||
const { productName, version } = require('./package');
|
||||
|
||||
let spawn;
|
||||
try {
|
||||
spawn = require('child_pty').spawn;
|
||||
} catch (err) {
|
||||
console.error(
|
||||
'A native module failed to load. Typically this means ' +
|
||||
'you installed the modules incorrectly.\n Use `scripts/install.sh` ' +
|
||||
'to trigger the installation.\n ' +
|
||||
'More information: https://github.com/zeit/hyperterm/issues/72'
|
||||
);
|
||||
}
|
||||
|
||||
const TITLE_POLL_INTERVAL = 500;
|
||||
|
||||
module.exports = class Session extends EventEmitter {
|
||||
|
||||
constructor ({ rows, cols: columns, cwd, shell }) {
|
||||
super();
|
||||
const baseEnv = Object.assign({}, process.env, {
|
||||
LANG: app.getLocale().replace('-', '_'),
|
||||
TERM: 'xterm-256color',
|
||||
TERM_PROGRAM: productName,
|
||||
TERM_PROGRAM_VERSION: version
|
||||
});
|
||||
|
||||
this.pty = spawn(shell || defaultShell, ['--login'], {
|
||||
columns,
|
||||
rows,
|
||||
cwd,
|
||||
env: getDecoratedEnv(baseEnv)
|
||||
});
|
||||
|
||||
this.pty.stdout.on('data', (data) => {
|
||||
this.emit('data', data.toString('utf8'));
|
||||
});
|
||||
|
||||
this.pty.on('exit', () => {
|
||||
if (!this.ended) {
|
||||
this.ended = true;
|
||||
this.emit('exit');
|
||||
}
|
||||
});
|
||||
|
||||
this.shell = shell || defaultShell;
|
||||
this.getTitle();
|
||||
}
|
||||
|
||||
focus () {
|
||||
this.subscribed = true;
|
||||
this.getTitle();
|
||||
}
|
||||
|
||||
blur () {
|
||||
this.subscribed = false;
|
||||
clearTimeout(this.titlePoll);
|
||||
}
|
||||
|
||||
getTitle () {
|
||||
if ('win32' === process.platform) return;
|
||||
if (this.fetching) return;
|
||||
this.fetching = true;
|
||||
|
||||
let tty = this.pty.stdout.ttyname;
|
||||
tty = tty.replace(/^\/dev\/tty/, '');
|
||||
|
||||
// try to exclude grep from the results
|
||||
// by grepping for `[s]001` instead of `s001`
|
||||
tty = `[${tty[0]}]${tty.substr(1)}`;
|
||||
|
||||
// TODO: limit the concurrency of how many processes we run?
|
||||
// TODO: only tested on mac
|
||||
exec(`ps uxac | grep ${tty} | head -n 1`, (err, out) => {
|
||||
this.fetching = false;
|
||||
if (this.ended) return;
|
||||
if (err) return;
|
||||
let title = out.split(' ').pop();
|
||||
if (title) {
|
||||
title = title.replace(/^\(/, '');
|
||||
title = title.replace(/\)?\n$/, '');
|
||||
if (title !== this.lastTitle) {
|
||||
this.emit('title', title);
|
||||
this.lastTitle = title;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.subscribed) {
|
||||
this.titlePoll = setTimeout(() => this.getTitle(), TITLE_POLL_INTERVAL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exit () {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
write (data) {
|
||||
this.pty.stdin.write(data);
|
||||
}
|
||||
|
||||
resize ({ cols: columns, rows }) {
|
||||
try {
|
||||
this.pty.stdout.resize({ columns, rows });
|
||||
} catch (err) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
}
|
||||
|
||||
destroy () {
|
||||
try {
|
||||
this.pty.kill('SIGHUP');
|
||||
} catch (err) {
|
||||
console.error('exit error', err.stack);
|
||||
}
|
||||
this.emit('exit');
|
||||
this.ended = true;
|
||||
this.blur();
|
||||
}
|
||||
|
||||
};
|
||||
263
app/session.ts
263
app/session.ts
|
|
@ -1,263 +0,0 @@
|
|||
import {EventEmitter} from 'events';
|
||||
import {dirname} from 'path';
|
||||
import {StringDecoder} from 'string_decoder';
|
||||
|
||||
import defaultShell from 'default-shell';
|
||||
import type {IPty, IWindowsPtyForkOptions, spawn as npSpawn} from 'node-pty';
|
||||
import osLocale from 'os-locale';
|
||||
import shellEnv from 'shell-env';
|
||||
|
||||
import * as config from './config';
|
||||
import {cliScriptPath} from './config/paths';
|
||||
import {productName, version} from './package.json';
|
||||
import {getDecoratedEnv} from './plugins';
|
||||
import {getFallBackShellConfig} from './utils/shell-fallback';
|
||||
|
||||
const createNodePtyError = () =>
|
||||
new Error(
|
||||
'`node-pty` failed to load. Typically this means that it was built incorrectly. Please check the `readme.md` to more info.'
|
||||
);
|
||||
|
||||
let spawn: typeof npSpawn;
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
spawn = require('node-pty').spawn;
|
||||
} catch (err) {
|
||||
throw createNodePtyError();
|
||||
}
|
||||
|
||||
const useConpty = config.getConfig().useConpty;
|
||||
|
||||
// Max duration to batch session data before sending it to the renderer process.
|
||||
const BATCH_DURATION_MS = 16;
|
||||
|
||||
// Max size of a session data batch. Note that this value can be exceeded by ~4k
|
||||
// (chunk sizes seem to be 4k at the most)
|
||||
const BATCH_MAX_SIZE = 200 * 1024;
|
||||
|
||||
// Data coming from the pty is sent to the renderer process for further
|
||||
// vt parsing and rendering. This class batches data to minimize the number of
|
||||
// IPC calls. It also reduces GC pressure and CPU cost: each chunk is prefixed
|
||||
// with the window ID which is then stripped on the renderer process and this
|
||||
// overhead is reduced with batching.
|
||||
class DataBatcher extends EventEmitter {
|
||||
uid: string;
|
||||
decoder: StringDecoder;
|
||||
data!: string;
|
||||
timeout!: NodeJS.Timeout | null;
|
||||
constructor(uid: string) {
|
||||
super();
|
||||
this.uid = uid;
|
||||
this.decoder = new StringDecoder('utf8');
|
||||
|
||||
this.reset();
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.data = this.uid;
|
||||
this.timeout = null;
|
||||
}
|
||||
|
||||
write(chunk: Buffer | string) {
|
||||
if (this.data.length + chunk.length >= BATCH_MAX_SIZE) {
|
||||
// We've reached the max batch size. Flush it and start another one
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
}
|
||||
this.flush();
|
||||
}
|
||||
|
||||
this.data += typeof chunk === 'string' ? chunk : this.decoder.write(chunk);
|
||||
|
||||
if (!this.timeout) {
|
||||
this.timeout = setTimeout(() => this.flush(), BATCH_DURATION_MS);
|
||||
}
|
||||
}
|
||||
|
||||
flush() {
|
||||
// Reset before emitting to allow for potential reentrancy
|
||||
const data = this.data;
|
||||
this.reset();
|
||||
|
||||
this.emit('flush', data);
|
||||
}
|
||||
}
|
||||
|
||||
interface SessionOptions {
|
||||
uid: string;
|
||||
rows?: number;
|
||||
cols?: number;
|
||||
cwd?: string;
|
||||
shell?: string;
|
||||
shellArgs?: string[];
|
||||
profile: string;
|
||||
}
|
||||
export default class Session extends EventEmitter {
|
||||
pty: IPty | null;
|
||||
batcher: DataBatcher | null;
|
||||
shell: string | null;
|
||||
ended: boolean;
|
||||
initTimestamp: number;
|
||||
profile!: string;
|
||||
constructor(options: SessionOptions) {
|
||||
super();
|
||||
this.pty = null;
|
||||
this.batcher = null;
|
||||
this.shell = null;
|
||||
this.ended = false;
|
||||
this.initTimestamp = new Date().getTime();
|
||||
this.init(options);
|
||||
}
|
||||
|
||||
init({uid, rows, cols, cwd, shell: _shell, shellArgs: _shellArgs, profile}: SessionOptions) {
|
||||
this.profile = profile;
|
||||
const envFromConfig = config.getProfileConfig(profile).env || {};
|
||||
const defaultShellArgs = ['--login'];
|
||||
|
||||
const shell = _shell || defaultShell;
|
||||
const shellArgs = _shellArgs || defaultShellArgs;
|
||||
|
||||
const cleanEnv =
|
||||
process.env['APPIMAGE'] && process.env['APPDIR'] ? shellEnv.sync(_shell || defaultShell) : process.env;
|
||||
const baseEnv: Record<string, string> = {
|
||||
...cleanEnv,
|
||||
LANG: `${osLocale.sync().replace(/-/, '_')}.UTF-8`,
|
||||
TERM: 'xterm-256color',
|
||||
COLORTERM: 'truecolor',
|
||||
TERM_PROGRAM: productName,
|
||||
TERM_PROGRAM_VERSION: version,
|
||||
...envFromConfig
|
||||
};
|
||||
// path to AppImage mount point is added to PATH environment variable automatically
|
||||
// which conflicts with the cli
|
||||
if (baseEnv['APPIMAGE'] && baseEnv['APPDIR']) {
|
||||
baseEnv['PATH'] = [dirname(cliScriptPath)]
|
||||
.concat((baseEnv['PATH'] || '').split(':').filter((val) => !val.startsWith(baseEnv['APPDIR'])))
|
||||
.join(':');
|
||||
}
|
||||
|
||||
// Electron has a default value for process.env.GOOGLE_API_KEY
|
||||
// We don't want to leak this to the shell
|
||||
// See https://github.com/vercel/hyper/issues/696
|
||||
if (baseEnv.GOOGLE_API_KEY && process.env.GOOGLE_API_KEY === baseEnv.GOOGLE_API_KEY) {
|
||||
delete baseEnv.GOOGLE_API_KEY;
|
||||
}
|
||||
|
||||
const options: IWindowsPtyForkOptions = {
|
||||
cols,
|
||||
rows,
|
||||
cwd,
|
||||
env: getDecoratedEnv(baseEnv)
|
||||
};
|
||||
|
||||
// if config do not set the useConpty, it will be judged by the node-pty
|
||||
if (typeof useConpty === 'boolean') {
|
||||
options.useConpty = useConpty;
|
||||
}
|
||||
|
||||
try {
|
||||
this.pty = spawn(shell, shellArgs, options);
|
||||
} catch (_err) {
|
||||
const err = _err as {message: string};
|
||||
if (/is not a function/.test(err.message)) {
|
||||
throw createNodePtyError();
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
this.batcher = new DataBatcher(uid);
|
||||
this.pty.onData((chunk) => {
|
||||
if (this.ended) {
|
||||
return;
|
||||
}
|
||||
this.batcher?.write(chunk);
|
||||
});
|
||||
|
||||
this.batcher.on('flush', (data: string) => {
|
||||
this.emit('data', data);
|
||||
});
|
||||
|
||||
this.pty.onExit((e) => {
|
||||
if (!this.ended) {
|
||||
// fall back to default shell config if the shell exits within 1 sec with non zero exit code
|
||||
// this will inform users in case there are errors in the config instead of instant exit
|
||||
const runDuration = new Date().getTime() - this.initTimestamp;
|
||||
if (e.exitCode > 0 && runDuration < 1000) {
|
||||
const fallBackShellConfig = getFallBackShellConfig(shell, shellArgs, defaultShell, defaultShellArgs);
|
||||
if (fallBackShellConfig) {
|
||||
const msg = `
|
||||
shell exited in ${runDuration} ms with exit code ${e.exitCode}
|
||||
please check the shell config: ${JSON.stringify({shell, shellArgs}, undefined, 2)}
|
||||
using fallback shell config: ${JSON.stringify(fallBackShellConfig, undefined, 2)}
|
||||
`;
|
||||
console.warn(msg);
|
||||
this.batcher?.write(msg.replace(/\n/g, '\r\n'));
|
||||
this.init({
|
||||
uid,
|
||||
rows,
|
||||
cols,
|
||||
cwd,
|
||||
shell: fallBackShellConfig.shell,
|
||||
shellArgs: fallBackShellConfig.shellArgs,
|
||||
profile
|
||||
});
|
||||
} else {
|
||||
const msg = `
|
||||
shell exited in ${runDuration} ms with exit code ${e.exitCode}
|
||||
No fallback available, please check the shell config.
|
||||
`;
|
||||
console.warn(msg);
|
||||
this.batcher?.write(msg.replace(/\n/g, '\r\n'));
|
||||
}
|
||||
} else {
|
||||
this.ended = true;
|
||||
this.emit('exit');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.shell = shell;
|
||||
}
|
||||
|
||||
exit() {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
write(data: string) {
|
||||
if (this.pty) {
|
||||
this.pty.write(data);
|
||||
} else {
|
||||
console.warn('Warning: Attempted to write to a session with no pty');
|
||||
}
|
||||
}
|
||||
|
||||
resize({cols, rows}: {cols: number; rows: number}) {
|
||||
if (this.pty) {
|
||||
try {
|
||||
this.pty.resize(cols, rows);
|
||||
} catch (_err) {
|
||||
const err = _err as {stack: any};
|
||||
console.error(err.stack);
|
||||
}
|
||||
} else {
|
||||
console.warn('Warning: Attempted to resize a session with no pty');
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.pty) {
|
||||
try {
|
||||
this.pty.kill();
|
||||
} catch (_err) {
|
||||
const err = _err as {stack: any};
|
||||
console.error('exit error', err.stack);
|
||||
}
|
||||
} else {
|
||||
console.warn('Warning: Attempted to destroy a session with no pty');
|
||||
}
|
||||
this.emit('exit');
|
||||
this.ended = true;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.7 KiB |
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"extends": "../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationDir": "../dist/tmp/appdts/",
|
||||
"outDir": "../target/",
|
||||
"composite": true,
|
||||
"noImplicitAny": false
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"./package.json",
|
||||
"../typings/extend-electron.d.ts",
|
||||
"../typings/ext-modules.d.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"../dist/**/*",
|
||||
"../target/**/*"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
import type {MenuItemConstructorOptions, BrowserWindow} from 'electron';
|
||||
|
||||
import {execCommand} from '../commands';
|
||||
import {getProfiles} from '../config';
|
||||
import editMenu from '../menus/menus/edit';
|
||||
import shellMenu from '../menus/menus/shell';
|
||||
import {getDecoratedKeymaps} from '../plugins';
|
||||
|
||||
const separator: MenuItemConstructorOptions = {type: 'separator'};
|
||||
|
||||
const getCommandKeys = (keymaps: Record<string, string[]>): Record<string, string> =>
|
||||
Object.keys(keymaps).reduce((commandKeys: Record<string, string>, command) => {
|
||||
return Object.assign(commandKeys, {
|
||||
[command]: keymaps[command][0]
|
||||
});
|
||||
}, {});
|
||||
|
||||
// only display cut/copy when there's a cursor selection
|
||||
const filterCutCopy = (selection: string, menuItem: MenuItemConstructorOptions) => {
|
||||
if (/^cut$|^copy$/.test(menuItem.role!) && !selection) {
|
||||
return;
|
||||
}
|
||||
return menuItem;
|
||||
};
|
||||
|
||||
const contextMenuTemplate = (
|
||||
createWindow: (fn?: (win: BrowserWindow) => void, options?: Record<string, any>) => BrowserWindow,
|
||||
selection: string
|
||||
) => {
|
||||
const commandKeys = getCommandKeys(getDecoratedKeymaps());
|
||||
const _shell = shellMenu(
|
||||
commandKeys,
|
||||
(command, focusedWindow) => execCommand(command, focusedWindow as BrowserWindow | undefined),
|
||||
getProfiles().map((p) => p.name)
|
||||
).submenu as MenuItemConstructorOptions[];
|
||||
const _edit = editMenu(commandKeys, execCommand).submenu.filter(filterCutCopy.bind(null, selection));
|
||||
return _edit
|
||||
.concat(separator, _shell)
|
||||
.filter((menuItem) => !Object.prototype.hasOwnProperty.call(menuItem, 'enabled') || menuItem.enabled);
|
||||
};
|
||||
|
||||
export default contextMenuTemplate;
|
||||
376
app/ui/window.ts
376
app/ui/window.ts
|
|
@ -1,376 +0,0 @@
|
|||
import {existsSync} from 'fs';
|
||||
import {isAbsolute, normalize, sep} from 'path';
|
||||
import {URL, fileURLToPath} from 'url';
|
||||
|
||||
import {app, BrowserWindow, shell, Menu} from 'electron';
|
||||
import type {BrowserWindowConstructorOptions} from 'electron';
|
||||
|
||||
import {enable as remoteEnable} from '@electron/remote/main';
|
||||
import isDev from 'electron-is-dev';
|
||||
import {getWorkingDirectoryFromPID} from 'native-process-working-directory';
|
||||
import electronDragClick from 'quine-electron-drag-click';
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
|
||||
import type {sessionExtraOptions} from '../../typings/common';
|
||||
import type {configOptions} from '../../typings/config';
|
||||
import {execCommand} from '../commands';
|
||||
import {getDefaultProfile} from '../config';
|
||||
import {icon, homeDirectory} from '../config/paths';
|
||||
import fetchNotifications from '../notifications';
|
||||
import notify from '../notify';
|
||||
import {decorateSessionOptions, decorateSessionClass} from '../plugins';
|
||||
import createRPC from '../rpc';
|
||||
import Session from '../session';
|
||||
import updater from '../updater';
|
||||
import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
|
||||
import toElectronBackgroundColor from '../utils/to-electron-background-color';
|
||||
|
||||
import contextMenuTemplate from './contextmenu';
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
electronDragClick();
|
||||
}
|
||||
|
||||
export function newWindow(
|
||||
options_: BrowserWindowConstructorOptions,
|
||||
cfg: configOptions,
|
||||
fn?: (win: BrowserWindow) => void,
|
||||
profileName: string = getDefaultProfile()
|
||||
): BrowserWindow {
|
||||
const classOpts = Object.assign({uid: uuidv4()});
|
||||
app.plugins.decorateWindowClass(classOpts);
|
||||
|
||||
const winOpts: BrowserWindowConstructorOptions = {
|
||||
minWidth: 370,
|
||||
minHeight: 190,
|
||||
backgroundColor: toElectronBackgroundColor(cfg.backgroundColor || '#000'),
|
||||
titleBarStyle: 'hiddenInset',
|
||||
title: 'Hyper.app',
|
||||
// we want to go frameless on Windows and Linux
|
||||
frame: process.platform === 'darwin',
|
||||
transparent: process.platform === 'darwin',
|
||||
icon,
|
||||
show: Boolean(process.env.HYPER_DEBUG || process.env.HYPERTERM_DEBUG || isDev),
|
||||
acceptFirstMouse: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
navigateOnDragDrop: true,
|
||||
contextIsolation: false
|
||||
},
|
||||
...options_
|
||||
};
|
||||
const window = new BrowserWindow(app.plugins.getDecoratedBrowserOptions(winOpts));
|
||||
|
||||
window.profileName = profileName;
|
||||
|
||||
// Enable remote module on this window
|
||||
remoteEnable(window.webContents);
|
||||
|
||||
window.uid = classOpts.uid;
|
||||
|
||||
app.plugins.onWindowClass(window);
|
||||
window.uid = classOpts.uid;
|
||||
|
||||
const rpc = createRPC(window);
|
||||
const sessions = new Map<string, Session>();
|
||||
|
||||
const updateBackgroundColor = () => {
|
||||
const cfg_ = app.plugins.getDecoratedConfig(profileName);
|
||||
window.setBackgroundColor(toElectronBackgroundColor(cfg_.backgroundColor || '#000'));
|
||||
};
|
||||
|
||||
// config changes
|
||||
const cfgUnsubscribe = app.config.subscribe(() => {
|
||||
const cfg_ = app.plugins.getDecoratedConfig(profileName);
|
||||
|
||||
// notify renderer
|
||||
window.webContents.send('config change');
|
||||
|
||||
// notify user that shell changes require new sessions
|
||||
if (cfg_.shell !== cfg.shell || JSON.stringify(cfg_.shellArgs) !== JSON.stringify(cfg.shellArgs)) {
|
||||
notify('Shell configuration changed!', 'Open a new tab or window to start using the new shell');
|
||||
}
|
||||
|
||||
// update background color if necessary
|
||||
updateBackgroundColor();
|
||||
|
||||
cfg = cfg_;
|
||||
});
|
||||
|
||||
rpc.on('init', () => {
|
||||
window.show();
|
||||
updateBackgroundColor();
|
||||
|
||||
// If no callback is passed to createWindow,
|
||||
// a new session will be created by default.
|
||||
if (!fn) {
|
||||
fn = (win: BrowserWindow) => {
|
||||
win.rpc.emit('termgroup add req', {});
|
||||
};
|
||||
}
|
||||
|
||||
// app.windowCallback is the createWindow callback
|
||||
// that can be set before the 'ready' app event
|
||||
// and createWindow definition. It's executed in place of
|
||||
// the callback passed as parameter, and deleted right after.
|
||||
(app.windowCallback || fn)(window);
|
||||
app.windowCallback = undefined;
|
||||
fetchNotifications(window);
|
||||
// auto updates
|
||||
if (!isDev) {
|
||||
updater(window);
|
||||
} else {
|
||||
console.log('ignoring auto updates during dev');
|
||||
}
|
||||
});
|
||||
|
||||
function createSession(extraOptions: sessionExtraOptions = {}) {
|
||||
const uid = uuidv4();
|
||||
const extraOptionsFiltered: sessionExtraOptions = {};
|
||||
Object.keys(extraOptions).forEach((key) => {
|
||||
if (extraOptions[key] !== undefined) extraOptionsFiltered[key] = extraOptions[key];
|
||||
});
|
||||
|
||||
const profile = extraOptionsFiltered.profile || profileName;
|
||||
const activeSession = extraOptionsFiltered.activeUid ? sessions.get(extraOptionsFiltered.activeUid) : undefined;
|
||||
let cwd = '';
|
||||
if (cfg.preserveCWD !== false && activeSession && activeSession.profile === profile) {
|
||||
const activePID = activeSession.pty?.pid;
|
||||
if (activePID !== undefined) {
|
||||
try {
|
||||
cwd = getWorkingDirectoryFromPID(activePID) || '';
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
cwd = cwd && isAbsolute(cwd) && existsSync(cwd) ? cwd : '';
|
||||
}
|
||||
|
||||
const profileCfg = app.plugins.getDecoratedConfig(profile);
|
||||
|
||||
// set working directory
|
||||
let argPath = process.argv[1];
|
||||
if (argPath && process.platform === 'win32') {
|
||||
if (/[a-zA-Z]:"/.test(argPath)) {
|
||||
argPath = argPath.replace('"', sep);
|
||||
}
|
||||
argPath = normalize(argPath + sep);
|
||||
}
|
||||
let workingDirectory = homeDirectory;
|
||||
if (argPath && isAbsolute(argPath)) {
|
||||
workingDirectory = argPath;
|
||||
} else if (profileCfg.workingDirectory && isAbsolute(profileCfg.workingDirectory)) {
|
||||
workingDirectory = profileCfg.workingDirectory;
|
||||
}
|
||||
|
||||
// remove the rows and cols, the wrong value of them will break layout when init create
|
||||
const defaultOptions = Object.assign(
|
||||
{
|
||||
cwd: cwd || workingDirectory,
|
||||
splitDirection: undefined,
|
||||
shell: profileCfg.shell,
|
||||
shellArgs: profileCfg.shellArgs && Array.from(profileCfg.shellArgs)
|
||||
},
|
||||
extraOptionsFiltered,
|
||||
{
|
||||
profile: extraOptionsFiltered.profile || profileName,
|
||||
uid
|
||||
}
|
||||
);
|
||||
const options = decorateSessionOptions(defaultOptions);
|
||||
const DecoratedSession = decorateSessionClass(Session);
|
||||
const session = new DecoratedSession(options);
|
||||
sessions.set(uid, session);
|
||||
return {session, options};
|
||||
}
|
||||
|
||||
rpc.on('new', (extraOptions) => {
|
||||
const {session, options} = createSession(extraOptions);
|
||||
|
||||
sessions.set(options.uid, session);
|
||||
rpc.emit('session add', {
|
||||
rows: options.rows,
|
||||
cols: options.cols,
|
||||
uid: options.uid,
|
||||
splitDirection: options.splitDirection,
|
||||
shell: session.shell,
|
||||
pid: session.pty ? session.pty.pid : null,
|
||||
activeUid: options.activeUid ?? undefined,
|
||||
profile: options.profile
|
||||
});
|
||||
|
||||
session.on('data', (data: string) => {
|
||||
rpc.emit('session data', data);
|
||||
});
|
||||
|
||||
session.on('exit', () => {
|
||||
rpc.emit('session exit', {uid: options.uid});
|
||||
unsetRendererType(options.uid);
|
||||
sessions.delete(options.uid);
|
||||
});
|
||||
});
|
||||
|
||||
rpc.on('exit', ({uid}) => {
|
||||
const session = sessions.get(uid);
|
||||
if (session) {
|
||||
session.exit();
|
||||
}
|
||||
});
|
||||
rpc.on('unmaximize', () => {
|
||||
window.unmaximize();
|
||||
});
|
||||
rpc.on('maximize', () => {
|
||||
window.maximize();
|
||||
});
|
||||
rpc.on('minimize', () => {
|
||||
window.minimize();
|
||||
});
|
||||
rpc.on('resize', ({uid, cols, rows}) => {
|
||||
const session = sessions.get(uid);
|
||||
if (session) {
|
||||
session.resize({cols, rows});
|
||||
}
|
||||
});
|
||||
rpc.on('data', ({uid, data, escaped}) => {
|
||||
const session = uid && sessions.get(uid);
|
||||
if (session) {
|
||||
if (escaped) {
|
||||
const escapedData = session.shell?.endsWith('cmd.exe')
|
||||
? `"${data}"` // This is how cmd.exe does it
|
||||
: `'${data.replace(/'/g, `'\\''`)}'`; // Inside a single-quoted string nothing is interpreted
|
||||
|
||||
session.write(escapedData);
|
||||
} else {
|
||||
session.write(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
rpc.on('info renderer', ({uid, type}) => {
|
||||
// Used in the "About" dialog
|
||||
setRendererType(uid, type);
|
||||
});
|
||||
rpc.on('open external', ({url}) => {
|
||||
void shell.openExternal(url);
|
||||
});
|
||||
rpc.on('open context menu', (selection) => {
|
||||
const {createWindow} = app;
|
||||
Menu.buildFromTemplate(contextMenuTemplate(createWindow, selection)).popup({window});
|
||||
});
|
||||
rpc.on('open hamburger menu', ({x, y}) => {
|
||||
Menu.getApplicationMenu()!.popup({x: Math.ceil(x), y: Math.ceil(y)});
|
||||
});
|
||||
// Same deal as above, grabbing the window titlebar when the window
|
||||
// is maximized on Windows results in unmaximize, without hitting any
|
||||
// app buttons
|
||||
const onGeometryChange = () => rpc.emit('windowGeometry change', {isMaximized: window.isMaximized()});
|
||||
window.on('maximize', onGeometryChange);
|
||||
window.on('unmaximize', onGeometryChange);
|
||||
window.on('minimize', onGeometryChange);
|
||||
window.on('restore', onGeometryChange);
|
||||
|
||||
window.on('move', () => {
|
||||
const position = window.getPosition();
|
||||
rpc.emit('move', {bounds: {x: position[0], y: position[1]}});
|
||||
});
|
||||
rpc.on('close', () => {
|
||||
window.close();
|
||||
});
|
||||
rpc.on('command', (command) => {
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
execCommand(command, focusedWindow!);
|
||||
});
|
||||
// pass on the full screen events from the window to react
|
||||
rpc.win.on('enter-full-screen', () => {
|
||||
rpc.emit('enter full screen');
|
||||
});
|
||||
rpc.win.on('leave-full-screen', () => {
|
||||
rpc.emit('leave full screen');
|
||||
});
|
||||
const deleteSessions = () => {
|
||||
sessions.forEach((session, key) => {
|
||||
session.removeAllListeners();
|
||||
session.destroy();
|
||||
sessions.delete(key);
|
||||
});
|
||||
};
|
||||
// we reset the rpc channel only upon
|
||||
// subsequent refreshes (ie: F5)
|
||||
let i = 0;
|
||||
window.webContents.on('did-navigate', () => {
|
||||
if (i++) {
|
||||
deleteSessions();
|
||||
}
|
||||
});
|
||||
|
||||
const handleDroppedURL = (url: string) => {
|
||||
const protocol = typeof url === 'string' && new URL(url).protocol;
|
||||
if (protocol === 'file:') {
|
||||
const path = fileURLToPath(url);
|
||||
return {uid: null, data: path, escaped: true};
|
||||
} else if (protocol === 'http:' || protocol === 'https:') {
|
||||
return {uid: null, data: url};
|
||||
}
|
||||
};
|
||||
|
||||
// If file is dropped onto the terminal window, navigate and new-window events are prevented
|
||||
// and it's path is added to active session.
|
||||
window.webContents.on('will-navigate', (event, url) => {
|
||||
const data = handleDroppedURL(url);
|
||||
if (data) {
|
||||
event.preventDefault();
|
||||
rpc.emit('session data send', data);
|
||||
}
|
||||
});
|
||||
window.webContents.setWindowOpenHandler(({url}) => {
|
||||
const data = handleDroppedURL(url);
|
||||
if (data) {
|
||||
rpc.emit('session data send', data);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
return {action: 'allow'};
|
||||
});
|
||||
|
||||
// expose internals to extension authors
|
||||
window.rpc = rpc;
|
||||
window.sessions = sessions;
|
||||
|
||||
const load = () => {
|
||||
app.plugins.onWindow(window);
|
||||
};
|
||||
|
||||
// load plugins
|
||||
load();
|
||||
|
||||
const pluginsUnsubscribe = app.plugins.subscribe((err: any) => {
|
||||
if (!err) {
|
||||
load();
|
||||
window.webContents.send('plugins change');
|
||||
updateBackgroundColor();
|
||||
}
|
||||
});
|
||||
|
||||
// Keep track of focus time of every window, to figure out
|
||||
// which one of the existing window is the last focused.
|
||||
// Works nicely even if a window is closed and removed.
|
||||
const updateFocusTime = () => {
|
||||
window.focusTime = process.uptime();
|
||||
};
|
||||
|
||||
window.on('focus', () => {
|
||||
updateFocusTime();
|
||||
});
|
||||
|
||||
// the window can be closed by the browser process itself
|
||||
window.clean = () => {
|
||||
app.config.winRecord(window);
|
||||
rpc.destroy();
|
||||
deleteSessions();
|
||||
cfgUnsubscribe();
|
||||
pluginsUnsubscribe();
|
||||
};
|
||||
// Ensure focusTime is set on window open. The focus event doesn't
|
||||
// fire from the dock (see bug #583)
|
||||
updateFocusTime();
|
||||
|
||||
return window;
|
||||
}
|
||||
134
app/updater.ts
134
app/updater.ts
|
|
@ -1,134 +0,0 @@
|
|||
// Packages
|
||||
import electron, {app} from 'electron';
|
||||
import type {BrowserWindow, AutoUpdater as OriginalAutoUpdater} from 'electron';
|
||||
|
||||
import retry from 'async-retry';
|
||||
import ms from 'ms';
|
||||
|
||||
// Utilities
|
||||
import autoUpdaterLinux from './auto-updater-linux';
|
||||
import {getDefaultProfile} from './config';
|
||||
import {version} from './package.json';
|
||||
import {getDecoratedConfig} from './plugins';
|
||||
|
||||
// Necessary due to typescript not handling overloads well
|
||||
type AutoUpdaterEvent =
|
||||
| 'error'
|
||||
| 'checking-for-update'
|
||||
| 'before-quit-for-update'
|
||||
| 'update-downloaded'
|
||||
| 'update-available'
|
||||
| 'update-not-available';
|
||||
|
||||
interface AutoUpdater extends OriginalAutoUpdater {
|
||||
on(event: AutoUpdaterEvent, listener: Function): this;
|
||||
removeListener(event: AutoUpdaterEvent, listener: Function): this;
|
||||
}
|
||||
|
||||
const {platform} = process;
|
||||
const isLinux = platform === 'linux';
|
||||
|
||||
const autoUpdater: AutoUpdater = isLinux ? autoUpdaterLinux : electron.autoUpdater;
|
||||
|
||||
const getDecoratedConfigWithRetry = async () => {
|
||||
return await retry(() => {
|
||||
const content = getDecoratedConfig(getDefaultProfile());
|
||||
if (!content) {
|
||||
throw new Error('No config content loaded');
|
||||
}
|
||||
return content;
|
||||
});
|
||||
};
|
||||
|
||||
const checkForUpdates = async () => {
|
||||
const config = await getDecoratedConfigWithRetry();
|
||||
if (!config.disableAutoUpdates) {
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
};
|
||||
|
||||
let isInit = false;
|
||||
// Default to the "stable" update channel
|
||||
let canaryUpdates = false;
|
||||
|
||||
const buildFeedUrl = (canary: boolean, currentVersion: string) => {
|
||||
const updatePrefix = canary ? 'releases-canary' : 'releases';
|
||||
const archSuffix = process.arch === 'arm64' || app.runningUnderARM64Translation ? '_arm64' : '';
|
||||
return `https://${updatePrefix}.hyper.is/update/${isLinux ? 'deb' : platform}${archSuffix}/${currentVersion}`;
|
||||
};
|
||||
|
||||
const isCanary = (updateChannel: string) => updateChannel === 'canary';
|
||||
|
||||
async function init() {
|
||||
autoUpdater.on('error', (err) => {
|
||||
console.error('Error fetching updates', `${err.message} (${err.stack})`);
|
||||
});
|
||||
|
||||
const config = await getDecoratedConfigWithRetry();
|
||||
|
||||
// If defined in the config, switch to the "canary" channel
|
||||
if (config.updateChannel && isCanary(config.updateChannel)) {
|
||||
canaryUpdates = true;
|
||||
}
|
||||
|
||||
const feedURL = buildFeedUrl(canaryUpdates, version);
|
||||
|
||||
autoUpdater.setFeedURL({url: feedURL});
|
||||
|
||||
setTimeout(() => {
|
||||
void checkForUpdates();
|
||||
}, ms('10s'));
|
||||
|
||||
setInterval(() => {
|
||||
void checkForUpdates();
|
||||
}, ms('30m'));
|
||||
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
const updater = (win: BrowserWindow) => {
|
||||
if (!isInit) {
|
||||
void init();
|
||||
}
|
||||
|
||||
const {rpc} = win;
|
||||
|
||||
const onupdate = (ev: Event, releaseNotes: string, releaseName: string, date: Date, updateUrl: string) => {
|
||||
const releaseUrl = updateUrl || `https://github.com/quine-global/hyper/releases/tag/${releaseName}`;
|
||||
rpc.emit('update available', {releaseNotes, releaseName, releaseUrl, canInstall: !isLinux});
|
||||
};
|
||||
|
||||
if (isLinux) {
|
||||
autoUpdater.on('update-available', onupdate);
|
||||
} else {
|
||||
autoUpdater.on('update-downloaded', onupdate);
|
||||
}
|
||||
|
||||
rpc.once('quit and install', () => {
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
app.config.subscribe(async () => {
|
||||
const {updateChannel} = await getDecoratedConfigWithRetry();
|
||||
const newUpdateIsCanary = isCanary(updateChannel);
|
||||
|
||||
if (newUpdateIsCanary !== canaryUpdates) {
|
||||
const feedURL = buildFeedUrl(newUpdateIsCanary, version);
|
||||
|
||||
autoUpdater.setFeedURL({url: feedURL});
|
||||
void checkForUpdates();
|
||||
|
||||
canaryUpdates = newUpdateIsCanary;
|
||||
}
|
||||
});
|
||||
|
||||
win.on('close', () => {
|
||||
if (isLinux) {
|
||||
autoUpdater.removeListener('update-available', onupdate);
|
||||
} else {
|
||||
autoUpdater.removeListener('update-downloaded', onupdate);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default updater;
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
import {existsSync, readlink, symlink} from 'fs';
|
||||
import path from 'path';
|
||||
import {promisify} from 'util';
|
||||
|
||||
import {clipboard, dialog} from 'electron';
|
||||
|
||||
import {mkdirpSync} from 'fs-extra';
|
||||
import * as Registry from 'native-reg';
|
||||
import type {ValueType} from 'native-reg';
|
||||
import sudoPrompt from 'sudo-prompt';
|
||||
|
||||
import {cliScriptPath, cliLinkPath} from '../config/paths';
|
||||
import notify from '../notify';
|
||||
|
||||
const readLink = promisify(readlink);
|
||||
const symLink = promisify(symlink);
|
||||
const sudoExec = promisify(sudoPrompt.exec);
|
||||
|
||||
const checkInstall = () => {
|
||||
return readLink(cliLinkPath)
|
||||
.then((link) => link === cliScriptPath)
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
return false;
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
const addSymlink = async (silent: boolean) => {
|
||||
try {
|
||||
const isInstalled = await checkInstall();
|
||||
if (isInstalled) {
|
||||
console.log('Hyper CLI already in PATH');
|
||||
return;
|
||||
}
|
||||
console.log('Linking HyperCLI');
|
||||
if (!existsSync(path.dirname(cliLinkPath))) {
|
||||
try {
|
||||
mkdirpSync(path.dirname(cliLinkPath));
|
||||
} catch (err) {
|
||||
throw `Failed to create directory ${path.dirname(cliLinkPath)} - ${err}`;
|
||||
}
|
||||
}
|
||||
await symLink(cliScriptPath, cliLinkPath);
|
||||
} catch (_err) {
|
||||
const err = _err as {code: string};
|
||||
// 'EINVAL' is returned by readlink,
|
||||
// 'EEXIST' is returned by symlink
|
||||
let error =
|
||||
err.code === 'EEXIST' || err.code === 'EINVAL'
|
||||
? `File already exists: ${cliLinkPath}`
|
||||
: `Symlink creation failed: ${err.code}`;
|
||||
// Need sudo access to create symlink
|
||||
if (err.code === 'EACCES' && !silent) {
|
||||
const result = await dialog.showMessageBox({
|
||||
message: `You need to grant elevated privileges to add Hyper CLI to PATH
|
||||
Or you can run
|
||||
sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`,
|
||||
type: 'info',
|
||||
buttons: ['OK', 'Copy Command', 'Cancel']
|
||||
});
|
||||
if (result.response === 0) {
|
||||
try {
|
||||
await sudoExec(`ln -sf "${cliScriptPath}" "${cliLinkPath}"`, {name: 'Hyper'});
|
||||
return;
|
||||
} catch (_error) {
|
||||
error = (_error as any[])[0];
|
||||
}
|
||||
} else if (result.response === 1) {
|
||||
clipboard.writeText(`sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`);
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const addBinToUserPath = () => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
try {
|
||||
const envKey = Registry.openKey(Registry.HKCU, 'Environment', Registry.Access.ALL_ACCESS)!;
|
||||
|
||||
// C:\Users\<user>\AppData\Local\Programs\hyper\resources\bin
|
||||
const binPath = path.dirname(cliScriptPath);
|
||||
// C:\Users\<user>\AppData\Local\hyper
|
||||
const oldPath = path.resolve(process.env.LOCALAPPDATA!, 'hyper');
|
||||
|
||||
const items = Registry.enumValueNames(envKey);
|
||||
const pathItem = items.find((item) => item.toUpperCase() === 'PATH');
|
||||
const pathItemName = pathItem || 'PATH';
|
||||
|
||||
let newPathValue = binPath;
|
||||
let type: ValueType = Registry.ValueType.SZ;
|
||||
if (pathItem) {
|
||||
type = Registry.queryValueRaw(envKey, pathItem)!.type;
|
||||
if (type !== Registry.ValueType.SZ && type !== Registry.ValueType.EXPAND_SZ) {
|
||||
reject(`Registry key type is ${type}`);
|
||||
return;
|
||||
}
|
||||
const value = Registry.queryValue(envKey, pathItem) as string;
|
||||
let pathParts = value.split(';');
|
||||
const existingPath = pathParts.includes(binPath);
|
||||
const existingOldPath = pathParts.some((pathPart) => pathPart.startsWith(oldPath));
|
||||
if (existingPath && !existingOldPath) {
|
||||
console.log('Hyper CLI already in PATH');
|
||||
Registry.closeKey(envKey);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// Because nsis install path is different from squirrel we need to remove old path if present
|
||||
// and add current path if absent
|
||||
if (existingOldPath) pathParts = pathParts.filter((pathPart) => !pathPart.startsWith(oldPath));
|
||||
if (!pathParts.includes(binPath)) pathParts.push(binPath);
|
||||
newPathValue = pathParts.join(';');
|
||||
}
|
||||
console.log('Adding HyperCLI path (registry)');
|
||||
Registry.setValueRaw(envKey, pathItemName, type, Registry.formatString(newPathValue));
|
||||
Registry.closeKey(envKey);
|
||||
resolve();
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const logNotify = (withNotification: boolean, title: string, body: string, details?: {error?: any}) => {
|
||||
console.log(title, body, details);
|
||||
withNotification && notify(title, body, details);
|
||||
};
|
||||
|
||||
export const installCLI = async (withNotification: boolean) => {
|
||||
if (process.platform === 'win32') {
|
||||
try {
|
||||
await addBinToUserPath();
|
||||
logNotify(
|
||||
withNotification,
|
||||
'Hyper CLI installed',
|
||||
'You may need to restart your computer to complete this installation process.'
|
||||
);
|
||||
} catch (err) {
|
||||
logNotify(withNotification, 'Hyper CLI installation failed', `Failed to add Hyper CLI path to user PATH ${err}`);
|
||||
}
|
||||
} else if (process.platform === 'darwin' || process.platform === 'linux') {
|
||||
// AppImages are mounted on run at a temporary path, don't create symlink
|
||||
if (process.env['APPIMAGE']) {
|
||||
console.log('Skipping CLI symlink creation as it is an AppImage install');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await addSymlink(!withNotification);
|
||||
logNotify(withNotification, 'Hyper CLI installed', `Symlink created at ${cliLinkPath}`);
|
||||
} catch (error) {
|
||||
logNotify(withNotification, 'Hyper CLI installation failed', `${error}`);
|
||||
}
|
||||
} else {
|
||||
logNotify(withNotification, 'Hyper CLI installation failed', `Unsupported platform ${process.platform}`);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
const colorList = [
|
||||
'black',
|
||||
'red',
|
||||
'green',
|
||||
'yellow',
|
||||
'blue',
|
||||
'magenta',
|
||||
'cyan',
|
||||
'white',
|
||||
'lightBlack',
|
||||
'lightRed',
|
||||
'lightGreen',
|
||||
'lightYellow',
|
||||
'lightBlue',
|
||||
'lightMagenta',
|
||||
'lightCyan',
|
||||
'lightWhite',
|
||||
'colorCubes',
|
||||
'grayscale'
|
||||
];
|
||||
|
||||
export const getColorMap: {
|
||||
<T>(colors: T): T extends (infer U)[] ? {[k: string]: U} : T;
|
||||
} = (colors) => {
|
||||
if (!Array.isArray(colors)) {
|
||||
return colors;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return colors.reduce((result, color, index) => {
|
||||
if (index < colorList.length) {
|
||||
result[colorList[index]] = color;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
const generatePrefixedCommand = (command: string, shortcuts: string[]) => {
|
||||
const result: Record<string, string[]> = {};
|
||||
const baseCmd = command.replace(/:prefix$/, '');
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
// 9 is a special number because it means 'last'
|
||||
const index = i === 9 ? 'last' : i;
|
||||
const prefixedShortcuts = shortcuts.map((shortcut) => `${shortcut}+${i}`);
|
||||
result[`${baseCmd}:${index}`] = prefixedShortcuts;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const mapKeys = (config: Record<string, string[] | string>) => {
|
||||
return Object.keys(config).reduce((keymap: Record<string, string[]>, command: string) => {
|
||||
if (!command) {
|
||||
return keymap;
|
||||
}
|
||||
// We can have different keys for a same command.
|
||||
const _shortcuts = config[command];
|
||||
const shortcuts = Array.isArray(_shortcuts) ? _shortcuts : [_shortcuts];
|
||||
const fixedShortcuts: string[] = [];
|
||||
shortcuts.forEach((shortcut) => {
|
||||
let newShortcut = shortcut;
|
||||
if (newShortcut.indexOf('cmd') !== -1) {
|
||||
// Mousetrap use `command` and not `cmd`
|
||||
console.warn('Your config use deprecated `cmd` in key combination. Please use `command` instead.');
|
||||
newShortcut = newShortcut.replace('cmd', 'command');
|
||||
}
|
||||
fixedShortcuts.push(newShortcut);
|
||||
});
|
||||
|
||||
if (command.endsWith(':prefix')) {
|
||||
return Object.assign(keymap, generatePrefixedCommand(command, fixedShortcuts));
|
||||
}
|
||||
|
||||
keymap[command] = fixedShortcuts;
|
||||
|
||||
return keymap;
|
||||
}, {});
|
||||
};
|
||||
|
||||
export default mapKeys;
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
const rendererTypes: Record<string, string> = {};
|
||||
|
||||
function getRendererTypes() {
|
||||
return rendererTypes;
|
||||
}
|
||||
|
||||
function setRendererType(uid: string, type: string) {
|
||||
rendererTypes[uid] = type;
|
||||
}
|
||||
|
||||
function unsetRendererType(uid: string) {
|
||||
delete rendererTypes[uid];
|
||||
}
|
||||
|
||||
export {getRendererTypes, setRendererType, unsetRendererType};
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
export const getFallBackShellConfig = (
|
||||
shell: string,
|
||||
shellArgs: string[],
|
||||
defaultShell: string,
|
||||
defaultShellArgs: string[]
|
||||
): {
|
||||
shell: string;
|
||||
shellArgs: string[];
|
||||
} | null => {
|
||||
if (shellArgs.length > 0) {
|
||||
return {
|
||||
shell,
|
||||
shellArgs: []
|
||||
};
|
||||
}
|
||||
|
||||
if (shell != defaultShell) {
|
||||
return {
|
||||
shell: defaultShell,
|
||||
shellArgs: defaultShellArgs
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
import * as Registry from 'native-reg';
|
||||
import type {HKEY} from 'native-reg';
|
||||
|
||||
const appPath = `"${process.execPath}"`;
|
||||
const regKeys = [
|
||||
`Software\\Classes\\Directory\\Background\\shell\\Hyper`,
|
||||
`Software\\Classes\\Directory\\shell\\Hyper`,
|
||||
`Software\\Classes\\Drive\\shell\\Hyper`
|
||||
];
|
||||
const regParts = [
|
||||
{key: 'command', name: '', value: `${appPath} "%V"`},
|
||||
{name: '', value: 'Open &Hyper here'},
|
||||
{name: 'Icon', value: `${appPath}`}
|
||||
];
|
||||
|
||||
function addValues(hyperKey: HKEY, commandKey: HKEY) {
|
||||
try {
|
||||
Registry.setValueSZ(hyperKey, regParts[1].name, regParts[1].value);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
try {
|
||||
Registry.setValueSZ(hyperKey, regParts[2].name, regParts[2].value);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
try {
|
||||
Registry.setValueSZ(commandKey, regParts[0].name, regParts[0].value);
|
||||
} catch (err_) {
|
||||
console.error(err_);
|
||||
}
|
||||
}
|
||||
|
||||
export const add = () => {
|
||||
regKeys.forEach((regKey) => {
|
||||
try {
|
||||
const hyperKey =
|
||||
Registry.openKey(Registry.HKCU, regKey, Registry.Access.ALL_ACCESS) ||
|
||||
Registry.createKey(Registry.HKCU, regKey, Registry.Access.ALL_ACCESS);
|
||||
const commandKey =
|
||||
Registry.openKey(Registry.HKCU, `${regKey}\\${regParts[0].key}`, Registry.Access.ALL_ACCESS) ||
|
||||
Registry.createKey(Registry.HKCU, `${regKey}\\${regParts[0].key}`, Registry.Access.ALL_ACCESS);
|
||||
addValues(hyperKey, commandKey);
|
||||
Registry.closeKey(hyperKey);
|
||||
Registry.closeKey(commandKey);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const remove = () => {
|
||||
regKeys.forEach((regKey) => {
|
||||
try {
|
||||
Registry.deleteTree(Registry.HKCU, regKey);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
// Packages
|
||||
import Color from 'color';
|
||||
|
||||
// returns a background color that's in hex
|
||||
// format including the alpha channel (e.g.: `#00000050`)
|
||||
// input can be any css value (rgb, hsl, string…)
|
||||
const toElectronBackgroundColor = (bgColor: string) => {
|
||||
const color = Color(bgColor);
|
||||
|
||||
if (color.alpha() === 1) {
|
||||
return color.hex().toString();
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/11019879/1202488
|
||||
const alphaHex = Math.round(color.alpha() * 255).toString(16);
|
||||
return `#${alphaHex}${color.hex().toString().slice(1)}`;
|
||||
};
|
||||
|
||||
export default toElectronBackgroundColor;
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import electron from 'electron';
|
||||
|
||||
export function positionIsValid(position: [number, number]) {
|
||||
const displays = electron.screen.getAllDisplays();
|
||||
const [x, y] = position;
|
||||
|
||||
return displays.some(({workArea}) => {
|
||||
return x >= workArea.x && x <= workArea.x + workArea.width && y >= workArea.y && y <= workArea.y + workArea.height;
|
||||
});
|
||||
}
|
||||
1620
app/yarn.lock
1620
app/yarn.lock
File diff suppressed because it is too large
Load diff
|
|
@ -1,61 +1,8 @@
|
|||
<svg display="none" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<symbol id="close-tab" viewBox="0 0 24 24">
|
||||
<title>close tab</title>
|
||||
<symbol id="close" viewBox="0 0 24 24">
|
||||
<title>close</title>
|
||||
<g><path d='M13.1919001,11.9997324 L23.7528721,22.5607045 C24.0822321,22.8904941 24.0822321,23.4241533 23.7528721,23.7526581 C23.4235121,24.0824473 22.8898521,24.0824473 22.5609201,23.7526581 L11.999948,13.1916857 L1.43897601,23.7526581 C1.109612,24.0824473 0.575952002,24.0824473 0.247020001,23.7526581 C-0.0823400003,23.4237253 -0.0823400003,22.8900657 0.247020001,22.5607045 L10.80842,11.9997324 L0.247020001,1.43961681 C-0.0823400003,1.110684 -0.0823400003,0.576168002 0.247020001,0.247663201 C0.576384002,-0.0825544003 1.11004,-0.0825544003 1.43897601,0.247663201 L11.999948,10.8082072 L22.5609201,0.247663201 C22.8902801,-0.0825544003 23.4239401,-0.0825544003 23.7528721,0.247663201 C24.0822321,0.576596002 24.0822321,1.111112 23.7528721,1.43961681 L13.1919001,11.9997324 L13.1919001,11.9997324 L13.1919001,11.9997324 Z'></path></g>
|
||||
</symbol>
|
||||
<symbol id="hamburger-menu" viewBox="0 0 10 10">
|
||||
<title>hamburger menu</title>
|
||||
<rect y="0.5" width="10" height="1" fill="currentColor"/>
|
||||
<rect y="4.5" width="10" height="1" fill="currentColor"/>
|
||||
<rect y="8.5" width="10" height="1" fill="currentColor"/>
|
||||
</symbol>
|
||||
<symbol id="minimize-window" viewBox="0 0 10 10">
|
||||
<title>minimize window</title>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<polygon points="0 0 10 0 10 10 0 10"/>
|
||||
<path stroke="currentColor" d="M9.5,5 L0.5,5" stroke-linecap="square"/>
|
||||
</g>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<polygon points="0 0 10 0 10 10 0 10"/>
|
||||
<rect width="10" height="1" y="4.5" fill="currentColor"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<symbol id="maximize-window" viewBox="0 0 10 10">
|
||||
<title>maximize window</title>
|
||||
<defs>
|
||||
<polygon id="maximize-window-a" points="0 0 10 0 10 10 0 10"/>
|
||||
<mask id="maximize-window-b" width="10" height="10" x="0" y="0">
|
||||
<use xlink:href="#maximize-window-a"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<polygon fill="none" points="0 0 10 0 10 10 0 10"/>
|
||||
<use stroke="currentColor" stroke-width="2" mask="url(#maximize-window-b)" xlink:href="#maximize-window-a"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<symbol id="restore-window" viewBox="0 0 10.2 10.2">
|
||||
<title>restore window</title>
|
||||
<defs>
|
||||
<mask id="restore-window-b" width="10.2" height="10.2" x="0" y="0">
|
||||
<use xlink:href="#restore-window-a"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<path fill="currentColor"
|
||||
d='M2.1,0v2H0v8.1h8.2v-2h2V0H2.1z M7.2,9.2H1.1V3h6.1V9.2z M9.2,7.1h-1V2H3.1V1h6.1V7.1z' />
|
||||
<use stroke="currentColor" xlink:href="#restore-window-a"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<symbol id="close-window" viewBox="0 0 10 10">
|
||||
<title>close window</title>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g stroke="currentColor" transform="translate(.25 .25)" stroke-linecap="square">
|
||||
<path d="M0.5,0.5 L9,9"/>
|
||||
<path d="M0.5,0.5 L9,9" transform="matrix(-1 0 0 1 9.5 0)"/>
|
||||
</g>
|
||||
<polygon points="0 0 10 0 10 10 0 10"/>
|
||||
</g>
|
||||
</symbol>
|
||||
</defs>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 1 KiB |
|
|
@ -1,9 +0,0 @@
|
|||
module.exports = {
|
||||
files: ['test/*'],
|
||||
extensions: ['ts'],
|
||||
require: ['ts-node/register/transpile-only'],
|
||||
timeout: '2m',
|
||||
verbose: true,
|
||||
// Due to permissions issues, Windows needs cache turned off
|
||||
cache: false
|
||||
};
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
module.exports = {
|
||||
files: ['test/unit/*'],
|
||||
extensions: ['ts'],
|
||||
require: ['ts-node/register/transpile-only'],
|
||||
verbose: true,
|
||||
// Due to permissions issues, Windows needs cache turned off
|
||||
cache: false
|
||||
};
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"presets": [
|
||||
"@babel/react",
|
||||
"@babel/typescript"
|
||||
],
|
||||
"plugins": [
|
||||
[
|
||||
"styled-jsx/babel",
|
||||
{
|
||||
"vendorPrefixes": false
|
||||
}
|
||||
],
|
||||
"@babel/plugin-proposal-numeric-separator",
|
||||
"@babel/proposal-class-properties",
|
||||
"@babel/proposal-object-rest-spread",
|
||||
"@babel/plugin-proposal-optional-chaining"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fsPromises = require('fs/promises');
|
||||
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.mkdirSync(pathToElectron, { recursive: true });
|
||||
fs.copyFileSync(pathToBlob, path.join(pathToElectron, snapshotFileName));
|
||||
fs.copyFileSync(pathToBlobV8, path.join(pathToElectron, v8ContextFileName));
|
||||
}
|
||||
|
||||
function getPathToElectron() {
|
||||
const electronPath = require.resolve('electron');
|
||||
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return path.resolve(
|
||||
electronPath,
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources'
|
||||
);
|
||||
case 'win32':
|
||||
case 'linux':
|
||||
return path.resolve(electronPath, '..', '..', '..', 'dist');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getV8ContextFileName(archToCopy) {
|
||||
return `snapshot_blob.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);
|
||||
useLoaderScriptFix(context);
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// copied and modified from https://github.com/gergof/electron-builder-sandbox-fix/blob/master/lib/index.js
|
||||
// copied and modified from https://github.com/Adamant-im/adamant-im/blob/7b20272a717833ffb0b49b034ab9974118fc59ec/scripts/electron/sandboxFix.js
|
||||
|
||||
const useLoaderScriptFix = async (params) => {
|
||||
if (params.electronPlatformName !== 'linux') {
|
||||
// this fix is only required on linux
|
||||
return
|
||||
}
|
||||
|
||||
const executable = path.join(params.appOutDir, params.packager.executableName)
|
||||
|
||||
const loaderScript = `#!/usr/bin/env bash
|
||||
set -u
|
||||
SCRIPT_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
||||
exec "$SCRIPT_DIR/${params.packager.executableName}.bin" "--no-sandbox" "$@"
|
||||
`
|
||||
|
||||
try {
|
||||
await fsPromises.rename(executable, executable + '.bin')
|
||||
await fsPromises.writeFile(executable, loaderScript)
|
||||
await fsPromises.chmod(executable, 0o755)
|
||||
} catch (e) {
|
||||
console.error('failed to create loader for sandbox fix: ' + e.message)
|
||||
throw new Error('Failed to create loader for sandbox fix')
|
||||
}
|
||||
|
||||
console.log('sandbox fix successfully applied')
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
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'];
|
||||
|
||||
const archMap = {
|
||||
x64: 'x86_64',
|
||||
arm64: 'arm64'
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const npmConfigArch = process.env.npm_config_arch;
|
||||
if (!npmConfigArch) {
|
||||
throw new Error('env var npm_config_arch is not specified')
|
||||
}
|
||||
|
||||
|
||||
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/${npmConfigArch}`;
|
||||
await mkdirp(outputBlobPath);
|
||||
|
||||
let mksnapshotBinPath
|
||||
if (process.platform === 'win32') {
|
||||
mksnapshotBinPath =
|
||||
require.resolve(
|
||||
path.join("electron-mksnapshot", "bin", "mksnapshot.exe")
|
||||
);
|
||||
} else {
|
||||
mksnapshotBinPath =
|
||||
require.resolve(
|
||||
path.join("electron-mksnapshot", "bin", "mksnapshot")
|
||||
);
|
||||
}
|
||||
|
||||
mksnapshotBinPath = path.dirname(mksnapshotBinPath);
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const startupBlobPath = path.join(outputBlobPath, 'snapshot_blob.bin');
|
||||
|
||||
console.log(`Generating startup blob in "${outputBlobPath}"`);
|
||||
const res = childProcess.execFileSync(
|
||||
require.resolve(`electron-mksnapshot/bin/mksnapshot${process.platform === 'win32' ? '.exe' : ''}`),
|
||||
[
|
||||
'--startup-src=' + snapshotScriptPath,
|
||||
'--startup-blob=' + startupBlobPath,
|
||||
`--target-arch=${archMap[process.env.npm_config_arch]}`,
|
||||
//'--v8-context-snapshot=' + v8SnapshotPath
|
||||
]
|
||||
);
|
||||
console.log('result:', res.toString())
|
||||
}
|
||||
|
||||
main().catch((err) => console.error(err));
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
exports.default = async function notarizing(context) {
|
||||
|
||||
const { electronPlatformName, appOutDir } = context;
|
||||
if (electronPlatformName !== "darwin" || !process.env.APPLE_ID || !process.env.APPLE_PASSWORD) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { notarize } = await import('@electron/notarize');
|
||||
|
||||
const appName = context.packager.appInfo.productFilename;
|
||||
return await notarize({
|
||||
appBundleId: "com.quineglobal.hyper",
|
||||
appPath: `${appOutDir}/${appName}.app`,
|
||||
appleId: process.env.APPLE_ID,
|
||||
appleIdPassword: process.env.APPLE_PASSWORD
|
||||
});
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,31 +0,0 @@
|
|||
require('color-convert');
|
||||
require('color-string');
|
||||
require('columnify');
|
||||
require('lodash');
|
||||
require('ms');
|
||||
require('normalize-url');
|
||||
require('parse-url');
|
||||
require('php-escape-shell');
|
||||
require('plist');
|
||||
require('redux-thunk');
|
||||
require('redux');
|
||||
require('reselect');
|
||||
require('seamless-immutable');
|
||||
require('stylis');
|
||||
require('@xterm/addon-unicode11');
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
if (false) {
|
||||
require('args');
|
||||
require('mousetrap');
|
||||
require('open');
|
||||
require('react-dom');
|
||||
require('react-redux');
|
||||
require('react');
|
||||
require('@xterm/addon-fit');
|
||||
require('@xterm/addon-image');
|
||||
require('@xterm/addon-search');
|
||||
require('@xterm/addon-web-links');
|
||||
require('@xterm/addon-webgl');
|
||||
require('@xterm/addon-canvas');
|
||||
require('@xterm/xterm');
|
||||
}
|
||||
147315
bin/yarn-standalone.js
147315
bin/yarn-standalone.js
File diff suppressed because one or more lines are too long
34
build/Info.plist
Normal file
34
build/Info.plist
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Folders</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>public.folder</string>
|
||||
<string>com.apple.bundle</string>
|
||||
<string>com.apple.package</string>
|
||||
<string>com.apple.resolvable</string>
|
||||
</array>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Alternate</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>UnixExecutables</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Shell</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>public.unix-executable</string>
|
||||
</array>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Alternate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
BIN
build/canary.ico
BIN
build/canary.ico
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue