mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Compare commits
No commits in common. "canary" and "v3.1.1" have entirely different histories.
152 changed files with 8343 additions and 160359 deletions
|
|
@ -9,6 +9,4 @@ assets
|
|||
website
|
||||
bin
|
||||
dist
|
||||
target
|
||||
cache
|
||||
schema.json
|
||||
target
|
||||
104
.eslintrc.json
104
.eslintrc.json
|
|
@ -3,9 +3,7 @@
|
|||
"react",
|
||||
"prettier",
|
||||
"@typescript-eslint",
|
||||
"eslint-comments",
|
||||
"lodash",
|
||||
"import"
|
||||
"eslint-comments"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
|
|
@ -15,6 +13,7 @@
|
|||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
|
|
@ -34,11 +33,7 @@
|
|||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
},
|
||||
"import/resolver": {
|
||||
"typescript": {}
|
||||
},
|
||||
"import/internal-regex": "^(electron|react)$"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"func-names": [
|
||||
|
|
@ -62,21 +57,34 @@
|
|||
"bracketSpacing": false,
|
||||
"semi": true,
|
||||
"useTabs": false,
|
||||
"bracketSameLine": false
|
||||
"jsxBracketSameLine": false
|
||||
}
|
||||
],
|
||||
"eslint-comments/no-unused-disable": "error",
|
||||
"react/no-unknown-property":[
|
||||
"error",
|
||||
{
|
||||
"ignore": [
|
||||
"jsx",
|
||||
"global"
|
||||
]
|
||||
}
|
||||
]
|
||||
"eslint-comments/no-unused-disable": "error"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"app/config/config-default.js",
|
||||
".hyper.js"
|
||||
],
|
||||
"rules": {
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": false,
|
||||
"semi": true,
|
||||
"useTabs": false,
|
||||
"parser": "babel",
|
||||
"jsxBracketSameLine": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"**.ts",
|
||||
|
|
@ -98,63 +106,7 @@
|
|||
"@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"
|
||||
"@typescript-eslint/restrict-template-expressions": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -26,7 +26,7 @@ assignees: ''
|
|||
|
||||
- **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 -->
|
||||
- **Link of a [Gist](https://gist.github.com/) with the contents of your .hyper.js**: <!-- 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.) -->
|
||||
|
||||
|
|
|
|||
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
|
||||
#
|
||||
25
.github/dependabot.yml
vendored
25
.github/dependabot.yml
vendored
|
|
@ -5,33 +5,10 @@ updates:
|
|||
schedule:
|
||||
interval: weekly
|
||||
time: '11:00'
|
||||
open-pull-requests-limit: 30
|
||||
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'
|
||||
|
|
|
|||
9
.github/pull_request_template.md
vendored
9
.github/pull_request_template.md
vendored
|
|
@ -1 +1,8 @@
|
|||
<!-- Please check `Allow edits from maintainers`. Thanks! -->
|
||||
<!-- Hi there! Thanks for submitting a PR! We're excited to see what you've got for us.
|
||||
|
||||
- To help whoever reviews your PR, it'd be extremely helpful for you to list whether your PR is ready to be merged,
|
||||
If there's anything left to do and if there are any related PRs
|
||||
- It'd also be extremely helpful to enable us to update your PR incase we need to rebase or what-not by checking `Allow edits from maintainers`
|
||||
- If your PR changes some API, please make a PR for hyper website too: https://github.com/vercel/hyper-site.
|
||||
|
||||
Thanks, again! -->
|
||||
|
|
|
|||
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
|
||||
10
.github/workflows/codeql-analysis.yml
vendored
10
.github/workflows/codeql-analysis.yml
vendored
|
|
@ -35,11 +35,11 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
|
|
@ -50,10 +50,10 @@ jobs:
|
|||
# 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
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ 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
|
||||
|
|
@ -64,4 +64,4 @@ jobs:
|
|||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
|
|
|||
79
.github/workflows/nodejs.yml
vendored
Normal file
79
.github/workflows/nodejs.yml
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
name: Node CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- canary
|
||||
pull_request:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x]
|
||||
os:
|
||||
- macos-11.0
|
||||
- ubuntu-18.04
|
||||
- windows-latest
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install
|
||||
run: yarn install
|
||||
- name: Test
|
||||
run: yarn run test
|
||||
- name: Getting Build Icon
|
||||
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 (pr)
|
||||
if: github.event_name == 'pull_request'
|
||||
run: yarn run dist --publish=never
|
||||
- name: Build (push)
|
||||
if: github.event_name == 'push'
|
||||
run: yarn run dist
|
||||
env:
|
||||
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 }}
|
||||
- name: Test Spectron
|
||||
if: runner.os != 'Linux'
|
||||
run: yarn run test:spectron
|
||||
- name: Archive Spectron test screenshot
|
||||
if: runner.os != 'Linux'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: spectron
|
||||
path: dist/tmp/*.png
|
||||
- name: Archive Build Artifacts
|
||||
uses: LabhanshAgrawal/upload-artifact@v3
|
||||
with:
|
||||
path: |
|
||||
dist/*.dmg
|
||||
dist/*.snap
|
||||
dist/*.AppImage
|
||||
dist/*.deb
|
||||
dist/*.rpm
|
||||
dist/*.exe
|
||||
- name: Save the pr number in an artifact
|
||||
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@v2
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
name: pr_num
|
||||
path: ./pr_num.txt
|
||||
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
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
name: Comment e2e test screenshots on PR
|
||||
name: Comment spectron screenshots on PR
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Node CI']
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
e2e_comment:
|
||||
spectron_comment:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
steps:
|
||||
|
|
@ -14,14 +14,14 @@ jobs:
|
|||
WORKFLOW_RUN_INFO: ${{ toJSON(github.event.workflow_run) }}
|
||||
run: echo "$WORKFLOW_RUN_INFO"
|
||||
- name: Download Artifacts
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
uses: dawidd6/action-download-artifact@v2.11.0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
workflow: nodejs.yml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: e2e
|
||||
name: spectron
|
||||
- name: Get PR number
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
uses: dawidd6/action-download-artifact@v2.11.0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
workflow: nodejs.yml
|
||||
|
|
@ -29,14 +29,14 @@ jobs:
|
|||
name: pr_num
|
||||
- name: Read the pr_num file
|
||||
id: pr_num_reader
|
||||
uses: juliangruber/read-file-action@v1.1.7
|
||||
uses: juliangruber/read-file-action@v1.0.0
|
||||
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
|
||||
uses: devicons/public-upload-to-imgur@v2.2.1
|
||||
with:
|
||||
path: ./*.png
|
||||
client_id: ${{ secrets.IMGUR_CLIENT_ID }}
|
||||
|
|
@ -46,18 +46,11 @@ jobs:
|
|||
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}
|
||||
Thank you for contributing to Hyper!
|
||||
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 }}
|
||||
body: ${{ format(env.MESSAGE, env.IMG_MARKDOWN) }}
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -3,7 +3,6 @@ dist
|
|||
app/renderer
|
||||
target
|
||||
bin/cli.*
|
||||
cache
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
|
@ -13,9 +12,8 @@ npm-debug.log
|
|||
yarn-error.log
|
||||
|
||||
# optional dev config file and plugins directory
|
||||
hyper.json
|
||||
schema.json
|
||||
plugins
|
||||
.hyper.js
|
||||
.hyper_plugins
|
||||
|
||||
.DS_Store
|
||||
.vscode/*
|
||||
|
|
|
|||
3
.husky/pre-push
Normal file → Executable file
3
.husky/pre-push
Normal file → Executable file
|
|
@ -1 +1,4 @@
|
|||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn test
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
20.11.0
|
||||
1
.nvmrc
1
.nvmrc
|
|
@ -1 +0,0 @@
|
|||
20.11.0
|
||||
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 +0,0 @@
|
|||
yarnPath: .yarn/releases/yarn-classic.cjs
|
||||
|
|
@ -11,11 +11,11 @@ Prerequisites and steps are described in the ["Contributing" section of our READ
|
|||
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.
|
||||
Copy your config file `.hyper.js` 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 `.hyper_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.
|
||||
Go to your recently created `<repository_root>/.hyper_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
|
||||
|
|
|
|||
26
README.md
26
README.md
|
|
@ -1,24 +1,19 @@
|
|||

|
||||
|
||||
<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>
|
||||
|
||||
<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://github.com/quine-global/hyper/actions/workflows/ci.yml)
|
||||
|
||||
<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>
|
||||
</p>
|
||||
|
||||
[](https://github.com/vercel/hyper/actions?query=workflow%3A%22Node+CI%22+branch%3Acanary+event%3Apush)
|
||||
[](https://changelog.com/213)
|
||||
|
||||
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.
|
||||
The goal of the project is to create a beautiful and extensible experience for command-line interface users, built on open web standards. In the beginning, our focus will be primarily around speed, stability and the development of the correct API for extension authors.
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -104,7 +99,7 @@ make sure its build process is working correctly by running `yarn run rebuild-no
|
|||
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`
|
||||
##### Error with `c++` on macOS when running `yarn`
|
||||
|
||||
If you are getting compiler errors when running `yarn` add the environment variable `export CXX=clang++`
|
||||
|
||||
|
|
@ -115,6 +110,7 @@ If you have issues in the `codesign` step when running `yarn run dist` on macOS,
|
|||
|
||||
## Related Repositories
|
||||
|
||||
- [Art](https://github.com/vercel/art/tree/master/hyper)
|
||||
- [Website](https://github.com/vercel/hyper-site)
|
||||
- [Sample Extension](https://github.com/vercel/hyperpower)
|
||||
- [Sample Theme](https://github.com/vercel/hyperyellow)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import {EventEmitter} from 'events';
|
||||
|
||||
import fetch from 'electron-fetch';
|
||||
import {EventEmitter} from 'events';
|
||||
|
||||
class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
|
||||
updateURL!: string;
|
||||
|
|
@ -27,12 +26,13 @@ class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
|
|||
this.emit('update-not-available');
|
||||
return;
|
||||
}
|
||||
return res.json().then(({name, notes, pub_date}: {name: string; notes: string; pub_date: string}) => {
|
||||
return res.json().then(({name, notes, pub_date}) => {
|
||||
// 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();
|
||||
// If `null` is passed to Date constructor, current time will be used. This doesn't work with `undefined`
|
||||
const date = new Date(pub_date || null);
|
||||
this.emit('update-available', {}, notes, name, date);
|
||||
});
|
||||
})
|
||||
|
|
@ -47,6 +47,4 @@ class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
const autoUpdaterLinux = new AutoUpdater();
|
||||
|
||||
export default autoUpdaterLinux;
|
||||
export default new AutoUpdater();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {app, Menu} from 'electron';
|
||||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
import {app, Menu, BrowserWindow} from 'electron';
|
||||
import {openConfig, getConfig} from './config';
|
||||
import {updatePlugins} from './plugins';
|
||||
import {installCLI} from './utils/cli-install';
|
||||
|
|
@ -146,22 +144,6 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
|
|||
};
|
||||
});
|
||||
|
||||
//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) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
import {app} from 'electron';
|
||||
|
||||
import chokidar from 'chokidar';
|
||||
|
||||
import type {parsedConfig, configOptions} from '../typings/config';
|
||||
|
||||
import notify from './notify';
|
||||
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';
|
||||
import {parsedConfig, configOptions} from '../lib/config';
|
||||
import {app} from 'electron';
|
||||
|
||||
const watchers: Function[] = [];
|
||||
let cfg: parsedConfig = {} as any;
|
||||
|
|
@ -60,11 +57,17 @@ const _watch = () => {
|
|||
console.error('error watching config', error);
|
||||
});
|
||||
|
||||
app.on('before-quit', () => {
|
||||
app.on('before-quit', (e) => {
|
||||
if (Object.keys(_watcher.getWatched()).length > 0) {
|
||||
_watcher.close().catch((err) => {
|
||||
console.warn(err);
|
||||
});
|
||||
e.preventDefault();
|
||||
_watcher
|
||||
.close()
|
||||
.catch((err) => {
|
||||
console.warn(err);
|
||||
})
|
||||
.finally(() => {
|
||||
app.quit();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -81,30 +84,8 @@ export const getConfigDir = () => {
|
|||
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};
|
||||
return cfg.config;
|
||||
};
|
||||
|
||||
export const openConfig = () => {
|
||||
|
|
|
|||
180
app/config/config-default.js
Normal file
180
app/config/config-default.js
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
// Future versions of Hyper may add additional config options,
|
||||
// which will not automatically be merged into this file.
|
||||
// See https://hyper.is#cfg for all currently supported options.
|
||||
|
||||
module.exports = {
|
||||
config: {
|
||||
// choose either `'stable'` for receiving highly polished,
|
||||
// or `'canary'` for less polished but more frequent updates
|
||||
updateChannel: 'stable',
|
||||
|
||||
// default font size in pixels for all tabs
|
||||
fontSize: 12,
|
||||
|
||||
// font family with optional fallbacks
|
||||
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
|
||||
|
||||
// default font weight: 'normal' or 'bold'
|
||||
fontWeight: 'normal',
|
||||
|
||||
// font weight for bold characters: 'normal' or 'bold'
|
||||
fontWeightBold: 'bold',
|
||||
|
||||
// line height as a relative unit
|
||||
lineHeight: 1,
|
||||
|
||||
// letter spacing as a relative unit
|
||||
letterSpacing: 0,
|
||||
|
||||
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
|
||||
cursorColor: 'rgba(248,28,229,0.8)',
|
||||
|
||||
// terminal text color under BLOCK cursor
|
||||
cursorAccentColor: '#000',
|
||||
|
||||
// `'BEAM'` for |, `'UNDERLINE'` for _, `'BLOCK'` for █
|
||||
cursorShape: 'BLOCK',
|
||||
|
||||
// set to `true` (without backticks and without quotes) for blinking cursor
|
||||
cursorBlink: false,
|
||||
|
||||
// color of the text
|
||||
foregroundColor: '#fff',
|
||||
|
||||
// terminal background color
|
||||
// opacity is only supported on macOS
|
||||
backgroundColor: '#000',
|
||||
|
||||
// terminal selection color
|
||||
selectionColor: 'rgba(248,28,229,0.3)',
|
||||
|
||||
// border color (window, tabs)
|
||||
borderColor: '#333',
|
||||
|
||||
// custom CSS to embed in the main window
|
||||
css: '',
|
||||
|
||||
// custom CSS to embed in the terminal window
|
||||
termCSS: '',
|
||||
|
||||
// set custom startup directory (must be an absolute path)
|
||||
workingDirectory: '',
|
||||
|
||||
// if you're using a Linux setup which show native menus, set to false
|
||||
// default: `true` on Linux, `true` on Windows, ignored on macOS
|
||||
showHamburgerMenu: '',
|
||||
|
||||
// set to `false` (without backticks and without quotes) if you want to hide the minimize, maximize and close buttons
|
||||
// additionally, set to `'left'` if you want them on the left, like in Ubuntu
|
||||
// default: `true` (without backticks and without quotes) on Windows and Linux, ignored on macOS
|
||||
showWindowControls: '',
|
||||
|
||||
// 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: '#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',
|
||||
},
|
||||
|
||||
// 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
|
||||
//
|
||||
// Windows
|
||||
// - Make sure to use a full path if the binary name doesn't work
|
||||
// - Remove `--login` in shellArgs
|
||||
//
|
||||
// Windows Subsystem for Linux (WSL) - previously Bash on Windows
|
||||
// - Example: `C:\\Windows\\System32\\wsl.exe`
|
||||
//
|
||||
// Git-bash on Windows
|
||||
// - Example: `C:\\Program Files\\Git\\bin\\bash.exe`
|
||||
//
|
||||
// PowerShell on Windows
|
||||
// - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
|
||||
//
|
||||
// Cygwin
|
||||
// - Example: `C:\\cygwin64\\bin\\bash.exe`
|
||||
shell: '',
|
||||
|
||||
// for setting shell arguments (i.e. for using interactive shellArgs: `['-i']`)
|
||||
// by default `['--login']` will be used
|
||||
shellArgs: ['--login'],
|
||||
|
||||
// for environment variables
|
||||
env: {},
|
||||
|
||||
// Supported Options:
|
||||
// 1. 'SOUND' -> Enables the bell as a sound
|
||||
// 2. false: turns off the bell
|
||||
bell: 'SOUND',
|
||||
|
||||
// An absolute file path to a sound file on the machine.
|
||||
// bellSoundURL: '/path/to/sound/file',
|
||||
|
||||
// if `true` (without backticks and without quotes), selected text will automatically be copied to the clipboard
|
||||
copyOnSelect: false,
|
||||
|
||||
// if `true` (without backticks and without quotes), hyper will be set as the default protocol client for SSH
|
||||
defaultSSHApp: true,
|
||||
|
||||
// if `true` (without backticks and without quotes), on right click selected text will be copied or pasted if no
|
||||
// selection is present (`true` by default on Windows and disables the context menu feature)
|
||||
quickEdit: false,
|
||||
|
||||
// choose either `'vertical'`, if you want the column mode when Option key is hold during selection (Default)
|
||||
// or `'force'`, if you want to force selection regardless of whether the terminal is in mouse events mode
|
||||
// (inside tmux or vim with mouse mode enabled for example).
|
||||
macOptionSelectionMode: 'vertical',
|
||||
|
||||
// Whether to use the WebGL renderer. Set it to false to use canvas-based
|
||||
// rendering (slower, but supports transparent backgrounds)
|
||||
webGLRenderer: false,
|
||||
|
||||
// keypress required for weblink activation: [ctrl|alt|meta|shift]
|
||||
// todo: does not pick up config changes automatically, need to restart terminal :/
|
||||
webLinksActivationKey: '',
|
||||
|
||||
// if `false` (without backticks and without quotes), Hyper will use ligatures provided by some fonts
|
||||
disableLigatures: true,
|
||||
|
||||
// for advanced config flags please refer to https://hyper.is/#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
|
||||
// `~/.hyper_plugins/local/` and include it here
|
||||
// to load it and avoid it being `npm install`ed
|
||||
localPlugins: [],
|
||||
|
||||
keymaps: {
|
||||
// Example
|
||||
// 'window:devtools': 'cmd+alt+o',
|
||||
},
|
||||
};
|
||||
|
|
@ -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,32 +1,100 @@
|
|||
import {readFileSync, mkdirpSync} from 'fs-extra';
|
||||
|
||||
import type {rawConfig} from '../../typings/config';
|
||||
import {moveSync, copySync, existsSync, writeFileSync, readFileSync, lstatSync} from 'fs-extra';
|
||||
import {sync as mkdirpSync} from 'mkdirp';
|
||||
import {defaultCfg, cfgPath, legacyCfgPath, plugs, defaultPlatformKeyPath} from './paths';
|
||||
import {_init, _extractDefault} from './init';
|
||||
import notify from '../notify';
|
||||
|
||||
import {_init} from './init';
|
||||
import {migrateHyper3Config} from './migrate';
|
||||
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';
|
||||
import {rawConfig} from '../../lib/config';
|
||||
|
||||
let defaultConfig: rawConfig;
|
||||
|
||||
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');
|
||||
};
|
||||
|
||||
// Saves a file as backup by appending '.backup' or '.backup2', '.backup3', etc.
|
||||
// so as to not override any existing files
|
||||
const saveAsBackup = (src: string) => {
|
||||
let attempt = 1;
|
||||
while (attempt < 100) {
|
||||
const backupPath = `${src}.backup${attempt === 1 ? '' : attempt}`;
|
||||
if (!existsSync(backupPath)) {
|
||||
moveSync(src, backupPath);
|
||||
return backupPath;
|
||||
}
|
||||
attempt++;
|
||||
}
|
||||
throw new Error('Failed to create backup for config file. Too many backups');
|
||||
};
|
||||
|
||||
// Migrate Hyper2 config to Hyper3 but only if the user hasn't manually
|
||||
// touched the new config and if the old config is not a symlink
|
||||
const migrateHyper2Config = () => {
|
||||
if (cfgPath === legacyCfgPath) {
|
||||
// No need to migrate
|
||||
return;
|
||||
}
|
||||
if (!existsSync(legacyCfgPath)) {
|
||||
// Already migrated or user never used Hyper 2
|
||||
return;
|
||||
}
|
||||
const existsNew = existsSync(cfgPath);
|
||||
if (lstatSync(legacyCfgPath).isSymbolicLink() || (existsNew && lstatSync(cfgPath).isSymbolicLink())) {
|
||||
// One of the files is a symlink, there could be a number of complications
|
||||
// in this case so let's avoid those and not do automatic migration
|
||||
return;
|
||||
}
|
||||
|
||||
if (existsNew) {
|
||||
const cfg1 = readFileSync(defaultCfg, 'utf8').replace(/\r|\n/g, '');
|
||||
const cfg2 = readFileSync(cfgPath, 'utf8').replace(/\r|\n/g, '');
|
||||
const hasNewConfigBeenTouched = cfg1 !== cfg2;
|
||||
if (hasNewConfigBeenTouched) {
|
||||
// Assume the user has migrated manually but rename old config to .backup so
|
||||
// we don't keep trying to migrate on every launch
|
||||
const backupPath = saveAsBackup(legacyCfgPath);
|
||||
notify(
|
||||
'Hyper 3',
|
||||
`Settings location has changed to ${cfgPath}.\nWe've backed up your old Hyper config to ${backupPath}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate
|
||||
copySync(legacyCfgPath, cfgPath);
|
||||
saveAsBackup(legacyCfgPath);
|
||||
|
||||
notify(
|
||||
'Hyper 3',
|
||||
`Settings location has changed to ${cfgPath}.\nWe've automatically migrated your existing config!\nPlease restart Hyper now`
|
||||
);
|
||||
};
|
||||
|
||||
const _importConf = () => {
|
||||
// init plugin directories if not present
|
||||
mkdirpSync(plugs.base);
|
||||
mkdirpSync(plugs.local);
|
||||
|
||||
try {
|
||||
migrateHyper3Config();
|
||||
migrateHyper2Config();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
let defaultCfgRaw = '{}';
|
||||
let defaultCfgRaw = '';
|
||||
try {
|
||||
defaultCfgRaw = readFileSync(defaultCfg, 'utf8');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
const _defaultCfg = JSON.parse(defaultCfgRaw) as rawConfig;
|
||||
const _defaultCfg = _extractDefault(defaultCfgRaw) as rawConfig;
|
||||
|
||||
// Importing platform specific keymap
|
||||
let content = '{}';
|
||||
|
|
@ -39,12 +107,12 @@ const _importConf = () => {
|
|||
_defaultCfg.keymaps = mapping;
|
||||
|
||||
// Import user config
|
||||
let userCfg: rawConfig;
|
||||
let userCfg: string;
|
||||
try {
|
||||
userCfg = JSON.parse(readFileSync(cfgPath, 'utf8'));
|
||||
userCfg = readFileSync(cfgPath, 'utf8');
|
||||
} catch (err) {
|
||||
notify("Couldn't parse config file. Using default config instead.");
|
||||
userCfg = JSON.parse(defaultCfgRaw);
|
||||
_write(cfgPath, defaultCfgRaw);
|
||||
userCfg = defaultCfgRaw;
|
||||
}
|
||||
|
||||
return {userCfg, defaultCfg: _defaultCfg};
|
||||
|
|
@ -53,7 +121,7 @@ const _importConf = () => {
|
|||
export const _import = () => {
|
||||
const imported = _importConf();
|
||||
defaultConfig = imported.defaultCfg;
|
||||
const result = _init(imported.userCfg, imported.defaultCfg);
|
||||
const result = _init(imported);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
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';
|
||||
import {parsedConfig, rawConfig, configOptions} from '../../lib/config';
|
||||
|
||||
const _extract = (script?: vm.Script): Record<string, any> => {
|
||||
const module: Record<string, any> = {};
|
||||
script?.runInNewContext({module}, {displayErrors: true});
|
||||
script?.runInNewContext({module});
|
||||
if (!module.exports) {
|
||||
throw new Error('Error reading configuration: `module.exports` not set');
|
||||
}
|
||||
|
|
@ -18,10 +15,9 @@ const _extract = (script?: vm.Script): Record<string, any> => {
|
|||
|
||||
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});
|
||||
return new vm.Script(cfg, {filename: '.hyper.js', displayErrors: true});
|
||||
} catch (err) {
|
||||
notify(`Error loading config: ${err.name}`, `${err}`, {error: err});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -30,33 +26,23 @@ const _extractDefault = (cfg: string) => {
|
|||
};
|
||||
|
||||
// init config
|
||||
const _init = (userCfg: rawConfig, defaultCfg: rawConfig): parsedConfig => {
|
||||
const _init = (cfg: {userCfg: string; defaultCfg: rawConfig}): parsedConfig => {
|
||||
const script = _syntaxValidation(cfg.userCfg);
|
||||
const _cfg = script && (_extract(script) as rawConfig);
|
||||
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);
|
||||
if (_cfg?.config) {
|
||||
return _cfg.config;
|
||||
} else {
|
||||
notify('Error reading configuration: `config` key is missing');
|
||||
return defaultCfg.config || ({} as configOptions);
|
||||
return cfg.defaultCfg.config || ({} as configOptions);
|
||||
}
|
||||
})(),
|
||||
// Merging platform specific keymaps with user defined keymaps
|
||||
keymaps: mapKeys({...defaultCfg.keymaps, ...userCfg?.keymaps}),
|
||||
keymaps: mapKeys({...cfg.defaultCfg.keymaps, ..._cfg?.keymaps}),
|
||||
// Ignore undefined values in plugin and localPlugins array Issue #1862
|
||||
plugins: userCfg?.plugins?.filter(Boolean) || [],
|
||||
localPlugins: userCfg?.localPlugins?.filter(Boolean) || []
|
||||
plugins: (_cfg?.plugins && _cfg.plugins.filter(Boolean)) || [],
|
||||
localPlugins: (_cfg?.localPlugins && _cfg.localPlugins.filter(Boolean)) || []
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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,10 +1,7 @@
|
|||
import {exec} from 'child_process';
|
||||
|
||||
import {shell} from 'electron';
|
||||
|
||||
import * as Registry from 'native-reg';
|
||||
|
||||
import {cfgPath} from './paths';
|
||||
import * as Registry from 'native-reg';
|
||||
import {exec} from 'child_process';
|
||||
|
||||
const getUserChoiceKey = () => {
|
||||
try {
|
||||
|
|
@ -60,7 +57,7 @@ const openNotepad = (file: string) =>
|
|||
});
|
||||
});
|
||||
|
||||
const openConfig = () => {
|
||||
export default () => {
|
||||
// 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') {
|
||||
|
|
@ -76,5 +73,3 @@ const openConfig = () => {
|
|||
}
|
||||
return shell.openPath(cfgPath).then((error) => error === '');
|
||||
};
|
||||
|
||||
export default openConfig;
|
||||
|
|
|
|||
|
|
@ -1,36 +1,26 @@
|
|||
// 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 {statSync} from 'fs';
|
||||
import {resolve, join} from 'path';
|
||||
import isDev from 'electron-is-dev';
|
||||
|
||||
const cfgFile = 'hyper.json';
|
||||
const defaultCfgFile = 'config-default.json';
|
||||
const schemaFile = 'schema.json';
|
||||
const cfgFile = '.hyper.js';
|
||||
const defaultCfgFile = 'config-default.js';
|
||||
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(
|
||||
const applicationDirectory =
|
||||
process.env.XDG_CONFIG_HOME !== undefined
|
||||
? join(process.env.XDG_CONFIG_HOME, 'hyper')
|
||||
: process.platform == 'win32'
|
||||
? app.getPath('userData')
|
||||
: homedir(),
|
||||
'.hyper.js'
|
||||
);
|
||||
? app.getPath('userData')
|
||||
: homedir();
|
||||
|
||||
let cfgPath = join(cfgDir, cfgFile);
|
||||
const schemaPath = resolve(__dirname, schemaFile);
|
||||
let cfgDir = applicationDirectory;
|
||||
let cfgPath = join(applicationDirectory, cfgFile);
|
||||
const legacyCfgPath = join(homeDirectory, cfgFile); // Hyper 2 config location
|
||||
|
||||
const devDir = resolve(__dirname, '../..');
|
||||
const devCfg = join(devDir, cfgFile);
|
||||
|
|
@ -48,8 +38,10 @@ if (isDev) {
|
|||
}
|
||||
}
|
||||
|
||||
const plugins = resolve(cfgDir, 'plugins');
|
||||
const plugins = resolve(cfgDir, '.hyper_plugins');
|
||||
const plugs = {
|
||||
legacyBase: resolve(homeDirectory, '.hyper_plugins'),
|
||||
legacyLocal: resolve(homeDirectory, '.hyper_plugins', 'local'),
|
||||
base: plugins,
|
||||
local: resolve(plugins, 'local'),
|
||||
cache: resolve(plugins, 'cache')
|
||||
|
|
@ -90,7 +82,5 @@ export {
|
|||
yarn,
|
||||
cliScriptPath,
|
||||
cliLinkPath,
|
||||
homeDirectory,
|
||||
schemaFile,
|
||||
schemaPath
|
||||
homeDirectory
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,6 +1,5 @@
|
|||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
import Config from 'electron-store';
|
||||
import {BrowserWindow} from 'electron';
|
||||
|
||||
export const defaults = {
|
||||
windowPosition: [50, 50] as [number, number],
|
||||
|
|
|
|||
8
app/ext-modules.d.ts
vendored
Normal file
8
app/ext-modules.d.ts
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
declare module 'git-describe' {
|
||||
export function gitDescribe(...args: any[]): void;
|
||||
}
|
||||
|
||||
declare module 'default-shell' {
|
||||
const val: string;
|
||||
export default val;
|
||||
}
|
||||
25
app/extend-electron.d.ts
vendored
Normal file
25
app/extend-electron.d.ts
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import type {Server} from './rpc';
|
||||
|
||||
declare module 'electron' {
|
||||
interface App {
|
||||
config: typeof import('./config');
|
||||
plugins: typeof import('./plugins');
|
||||
getWindows: () => Set<BrowserWindow>;
|
||||
getLastFocusedWindow: () => BrowserWindow | null;
|
||||
windowCallback?: (win: BrowserWindow) => void;
|
||||
createWindow: (
|
||||
fn?: (win: BrowserWindow) => void,
|
||||
options?: {size?: [number, number]; position?: [number, number]}
|
||||
) => BrowserWindow;
|
||||
setVersion: (version: string) => void;
|
||||
}
|
||||
|
||||
// type Server = import('./rpc').Server;
|
||||
interface BrowserWindow {
|
||||
uid: string;
|
||||
sessions: Map<any, any>;
|
||||
focusTime: number;
|
||||
clean: () => void;
|
||||
rpc: Server;
|
||||
}
|
||||
}
|
||||
1
app/index.d.ts
vendored
Normal file
1
app/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
// Dummy file, required by tsc
|
||||
57
app/index.ts
57
app/index.ts
|
|
@ -1,40 +1,30 @@
|
|||
// 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');
|
||||
const configLocation = process.platform === 'win32' ? `${process.env.userprofile}\\.hyper.js` : '~/.hyper.js';
|
||||
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}`);
|
||||
console.log(`Hyper configuration file located at: ${configLocation}`);
|
||||
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 {app, BrowserWindow, Menu} from 'electron';
|
||||
import {gitDescribe} from 'git-describe';
|
||||
import parseUrl from 'parse-url';
|
||||
import isDev from 'electron-is-dev';
|
||||
import * as config from './config';
|
||||
|
||||
// set up config
|
||||
config.setup();
|
||||
|
||||
import * as AppMenu from './menus/menu';
|
||||
import * as plugins from './plugins';
|
||||
import {newWindow} from './ui/window';
|
||||
import {installCLI} from './utils/cli-install';
|
||||
import * as AppMenu from './menus/menu';
|
||||
import {newWindow} from './ui/window';
|
||||
import * as windowUtils from './utils/window-utils';
|
||||
|
||||
const windowSet = new Set<BrowserWindow>([]);
|
||||
|
|
@ -62,7 +52,7 @@ 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}) => {
|
||||
gitDescribe({customArguments: ['--tags']}, (error: any, gitInfo: any) => {
|
||||
if (!error) {
|
||||
app.setVersion(gitInfo.raw);
|
||||
}
|
||||
|
|
@ -78,13 +68,15 @@ async function installDevExtensions(isDev_: boolean) {
|
|||
if (!isDev_) {
|
||||
return [];
|
||||
}
|
||||
const {default: installer, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS} = await import('electron-devtools-installer');
|
||||
const installer = await import('electron-devtools-installer');
|
||||
|
||||
const extensions = [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS];
|
||||
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'] as const;
|
||||
const forceDownload = Boolean(process.env.UPGRADE_EXTENSIONS);
|
||||
|
||||
return Promise.all(
|
||||
extensions.map((extension) => installer(extension, {forceDownload, loadExtensionOptions: {allowFileAccess: true}}))
|
||||
extensions.map((name) =>
|
||||
installer.default(installer[name], {forceDownload, loadExtensionOptions: {allowFileAccess: true}})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -94,15 +86,16 @@ app.on('ready', () =>
|
|||
.then(() => {
|
||||
function createWindow(
|
||||
fn?: (win: BrowserWindow) => void,
|
||||
options: {size?: [number, number]; position?: [number, number]} = {},
|
||||
profileName: string = config.getDefaultProfile()
|
||||
options: {size?: [number, number]; position?: [number, number]} = {}
|
||||
) {
|
||||
const cfg = plugins.getDecoratedConfig(profileName);
|
||||
const cfg = plugins.getDecoratedConfig();
|
||||
|
||||
const winSet = config.getWin();
|
||||
let [startX, startY] = winSet.position;
|
||||
|
||||
const [width, height] = options.size ? options.size : cfg.windowSize || winSet.size;
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const {screen} = require('electron');
|
||||
|
||||
const winPos = options.position;
|
||||
|
||||
|
|
@ -139,14 +132,10 @@ app.on('ready', () =>
|
|||
[startX, startY] = config.windowDefaults.windowPosition;
|
||||
}
|
||||
|
||||
const hwin = newWindow({width, height, x: startX, y: startY}, cfg, fn, profileName);
|
||||
const hwin = newWindow({width, height, x: startX, y: startY}, cfg, fn);
|
||||
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();
|
||||
|
|
@ -190,7 +179,7 @@ app.on('ready', () =>
|
|||
}
|
||||
}
|
||||
]);
|
||||
app.dock?.setMenu(dockMenu);
|
||||
app.dock.setMenu(dockMenu);
|
||||
}
|
||||
|
||||
Menu.setApplicationMenu(AppMenu.buildMenu(menu));
|
||||
|
|
@ -242,6 +231,6 @@ app.on('open-file', (_event, path) => {
|
|||
|
||||
app.on('open-url', (_event, sshUrl) => {
|
||||
GetWindow((win: BrowserWindow) => {
|
||||
win.rpc.emit('open ssh', parseUrl(sshUrl));
|
||||
win.rpc.emit('open ssh', sshUrl);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"window:reload": "ctrl+shift+r",
|
||||
"window:reloadFull": "ctrl+shift+f5",
|
||||
"window:preferences": "ctrl+,",
|
||||
"window:hamburgerMenu": "alt+f",
|
||||
"window:hamburgerMenu": "alt",
|
||||
"zoom:reset": "ctrl+0",
|
||||
"zoom:in": "ctrl+=",
|
||||
"zoom:out": "ctrl+-",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"window:reload": "ctrl+shift+r",
|
||||
"window:reloadFull": "ctrl+shift+f5",
|
||||
"window:preferences": "ctrl+,",
|
||||
"window:hamburgerMenu": "alt+f",
|
||||
"window:hamburgerMenu": "alt",
|
||||
"zoom:reset": "ctrl+0",
|
||||
"zoom:in": "ctrl+=",
|
||||
"zoom:out": "ctrl+-",
|
||||
|
|
@ -16,12 +16,6 @@
|
|||
"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",
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
// Packages
|
||||
import {app, dialog, Menu} from 'electron';
|
||||
import type {BrowserWindow} from 'electron';
|
||||
import {app, dialog, Menu, 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 shellMenu from './menus/shell';
|
||||
import editMenu from './menus/edit';
|
||||
import toolsMenu from './menus/tools';
|
||||
import windowMenu from './menus/window';
|
||||
import helpMenu from './menus/help';
|
||||
import darwinMenu from './menus/darwin';
|
||||
import {getDecoratedKeymaps} from '../plugins';
|
||||
import {execCommand} from '../commands';
|
||||
import {getRendererTypes} from '../utils/renderer-utils';
|
||||
|
||||
const appName = app.name;
|
||||
const appVersion = app.getVersion();
|
||||
|
|
@ -56,30 +54,14 @@ export const createMenu = (
|
|||
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'),
|
||||
detail: `Renderers: ${renderers}\nPlugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2020 Vercel, Inc.`,
|
||||
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)
|
||||
),
|
||||
shellMenu(commandKeys, execCommand),
|
||||
editMenu(commandKeys, execCommand),
|
||||
viewMenu(commandKeys, execCommand),
|
||||
toolsMenu(commandKeys, execCommand),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// 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';
|
||||
import {app, BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const darwinMenu = (
|
||||
export default (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void,
|
||||
showAbout: () => void
|
||||
|
|
@ -55,5 +54,3 @@ const darwinMenu = (
|
|||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default darwinMenu;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const editMenu = (
|
||||
export default (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
) => {
|
||||
|
|
@ -31,14 +31,13 @@ const editMenu = (
|
|||
} as any,
|
||||
{
|
||||
role: 'paste',
|
||||
accelerator: commandKeys['editor:paste'],
|
||||
registerAccelerator: true
|
||||
accelerator: commandKeys['editor:paste']
|
||||
},
|
||||
{
|
||||
label: 'Select All',
|
||||
accelerator: commandKeys['editor:selectAll'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:selectAll', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:selectAll', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -51,28 +50,28 @@ const editMenu = (
|
|||
label: 'Previous word',
|
||||
accelerator: commandKeys['editor:movePreviousWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:movePreviousWord', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:movePreviousWord', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next word',
|
||||
accelerator: commandKeys['editor:moveNextWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:moveNextWord', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:moveNextWord', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line beginning',
|
||||
accelerator: commandKeys['editor:moveBeginningLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:moveBeginningLine', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:moveBeginningLine', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line end',
|
||||
accelerator: commandKeys['editor:moveEndLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:moveEndLine', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:moveEndLine', focusedWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -84,28 +83,28 @@ const editMenu = (
|
|||
label: 'Previous word',
|
||||
accelerator: commandKeys['editor:deletePreviousWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deletePreviousWord', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:deletePreviousWord', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next word',
|
||||
accelerator: commandKeys['editor:deleteNextWord'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deleteNextWord', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:deleteNextWord', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line beginning',
|
||||
accelerator: commandKeys['editor:deleteBeginningLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deleteBeginningLine', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:deleteBeginningLine', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Line end',
|
||||
accelerator: commandKeys['editor:deleteEndLine'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:deleteEndLine', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:deleteEndLine', focusedWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -117,14 +116,14 @@ const editMenu = (
|
|||
label: 'Clear Buffer',
|
||||
accelerator: commandKeys['editor:clearBuffer'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:clearBuffer', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:clearBuffer', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Search',
|
||||
accelerator: commandKeys['editor:search'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('editor:search', focusedWindow as BrowserWindow | undefined);
|
||||
execCommand('editor:search', focusedWindow);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
@ -147,5 +146,3 @@ const editMenu = (
|
|||
submenu
|
||||
};
|
||||
};
|
||||
|
||||
export default editMenu;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
import {release} from 'os';
|
||||
|
||||
import {app, shell, dialog, clipboard} from 'electron';
|
||||
import type {MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
import {app, shell, MenuItemConstructorOptions, dialog, clipboard} from 'electron';
|
||||
import {getConfig, getPlugins} from '../../config';
|
||||
const {arch, env, platform, versions} = process;
|
||||
import {version} from '../../package.json';
|
||||
|
||||
const {arch, env, platform, versions} = process;
|
||||
|
||||
const helpMenu = (commands: Record<string, string>, showAbout: () => void): MenuItemConstructorOptions => {
|
||||
export default (commands: Record<string, string>, showAbout: () => void): MenuItemConstructorOptions => {
|
||||
const submenu: MenuItemConstructorOptions[] = [
|
||||
{
|
||||
label: `${app.name} Website`,
|
||||
|
|
@ -26,7 +22,7 @@ const helpMenu = (commands: Record<string, string>, showAbout: () => void): Menu
|
|||
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
|
||||
- [ ] Your Hyper.app version is **${version}**. Please verify your 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)_:
|
||||
|
|
@ -43,12 +39,12 @@ const helpMenu = (commands: Record<string, string>, showAbout: () => void): Menu
|
|||
|
||||
|
||||
---
|
||||
<!-- hyper.json config -->
|
||||
<!-- ~/.hyper.js 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>
|
||||
<details><summary><strong>.hyper.js contents</strong></summary>
|
||||
|
||||
\`\`\`json
|
||||
${JSON.stringify(getConfig(), null, 2)}
|
||||
|
|
@ -61,11 +57,11 @@ ${JSON.stringify(getPlugins(), null, 2)}
|
|||
\`\`\`
|
||||
</details>`;
|
||||
|
||||
const issueURL = `https://github.com/quine-global/hyper/issues/new?body=${encodeURIComponent(body)}`;
|
||||
const issueURL = `https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent(body)}`;
|
||||
const copyAndSend = () => {
|
||||
clipboard.writeText(body);
|
||||
void shell.openExternal(
|
||||
`https://github.com/quine-global/hyper/issues/new?body=${encodeURIComponent(
|
||||
`https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent(
|
||||
'<!-- We have written the needed data into your clipboard because it was too large to send. ' +
|
||||
'Please paste. -->\n'
|
||||
)}`
|
||||
|
|
@ -110,5 +106,3 @@ ${JSON.stringify(getPlugins(), null, 2)}
|
|||
submenu
|
||||
};
|
||||
};
|
||||
|
||||
export default helpMenu;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const shellMenu = (
|
||||
export default (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BaseWindow) => void,
|
||||
profiles: string[]
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
const isMac = process.platform === 'darwin';
|
||||
|
||||
|
|
@ -44,47 +43,6 @@ const shellMenu = (
|
|||
{
|
||||
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'],
|
||||
|
|
@ -100,5 +58,3 @@ const shellMenu = (
|
|||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default shellMenu;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const toolsMenu = (
|
||||
export default (
|
||||
commands: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
|
|
@ -45,5 +45,3 @@ const toolsMenu = (
|
|||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default toolsMenu;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const viewMenu = (
|
||||
export default (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
|
|
@ -11,21 +11,21 @@ const viewMenu = (
|
|||
label: 'Reload',
|
||||
accelerator: commandKeys['window:reload'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('window:reload', focusedWindow as BrowserWindow);
|
||||
execCommand('window:reload', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Full Reload',
|
||||
accelerator: commandKeys['window:reloadFull'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('window:reloadFull', focusedWindow as BrowserWindow);
|
||||
execCommand('window:reloadFull', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Developer Tools',
|
||||
accelerator: commandKeys['window:devtools'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('window:devtools', focusedWindow as BrowserWindow);
|
||||
execCommand('window:devtools', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -35,25 +35,23 @@ const viewMenu = (
|
|||
label: 'Reset Zoom Level',
|
||||
accelerator: commandKeys['zoom:reset'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('zoom:reset', focusedWindow as BrowserWindow);
|
||||
execCommand('zoom:reset', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom In',
|
||||
accelerator: commandKeys['zoom:in'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('zoom:in', focusedWindow as BrowserWindow);
|
||||
execCommand('zoom:in', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom Out',
|
||||
accelerator: commandKeys['zoom:out'],
|
||||
click(item, focusedWindow) {
|
||||
execCommand('zoom:out', focusedWindow as BrowserWindow);
|
||||
execCommand('zoom:out', focusedWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default viewMenu;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||
|
||||
const windowMenu = (
|
||||
export default (
|
||||
commandKeys: Record<string, string>,
|
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||
): MenuItemConstructorOptions => {
|
||||
// Generating tab:jump array
|
||||
const tabJump: MenuItemConstructorOptions[] = [];
|
||||
const tabJump = [];
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
// 9 is a special number because it means 'last'
|
||||
const label = i === 9 ? 'Last' : `${i}`;
|
||||
|
|
@ -37,14 +37,14 @@ const windowMenu = (
|
|||
label: 'Previous',
|
||||
accelerator: commandKeys['tab:prev'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('tab:prev', focusedWindow as BrowserWindow);
|
||||
execCommand('tab:prev', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next',
|
||||
accelerator: commandKeys['tab:next'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('tab:next', focusedWindow as BrowserWindow);
|
||||
execCommand('tab:next', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -63,14 +63,14 @@ const windowMenu = (
|
|||
label: 'Previous',
|
||||
accelerator: commandKeys['pane:prev'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('pane:prev', focusedWindow as BrowserWindow);
|
||||
execCommand('pane:prev', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Next',
|
||||
accelerator: commandKeys['pane:next'],
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('pane:next', focusedWindow as BrowserWindow);
|
||||
execCommand('pane:next', focusedWindow);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -84,7 +84,7 @@ const windowMenu = (
|
|||
{
|
||||
label: 'Toggle Always on Top',
|
||||
click: (item, focusedWindow) => {
|
||||
execCommand('window:toggleKeepOnTop', focusedWindow as BrowserWindow);
|
||||
execCommand('window:toggleKeepOnTop', focusedWindow);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -94,5 +94,3 @@ const windowMenu = (
|
|||
]
|
||||
};
|
||||
};
|
||||
|
||||
export default windowMenu;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import type {BrowserWindow} from 'electron';
|
||||
|
||||
import fetch from 'electron-fetch';
|
||||
import ms from 'ms';
|
||||
|
||||
import fetch from 'electron-fetch';
|
||||
import {version} from './package.json';
|
||||
import {BrowserWindow} from 'electron';
|
||||
|
||||
const NEWS_URL = 'https://hyper-news.now.sh';
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ export default function fetchNotifications(win: BrowserWindow) {
|
|||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
const message: {text: string; url: string; dismissable: boolean} | '' = data.message || '';
|
||||
const {message} = data || {};
|
||||
if (typeof message !== 'object' && message !== '') {
|
||||
throw new Error('Bad response');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import {app, Notification} from 'electron';
|
||||
|
||||
import {icon} from './config/paths';
|
||||
|
||||
export default function notify(title: string, body = '', details: {error?: any} = {}) {
|
||||
|
|
|
|||
|
|
@ -2,50 +2,41 @@
|
|||
"name": "hyper",
|
||||
"productName": "Hyper",
|
||||
"description": "A terminal built on web technologies",
|
||||
"version": "4.0.0-q-canary.8",
|
||||
"version": "3.1.0-canary.6",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "ZEIT, Inc.",
|
||||
"email": "team@zeit.co"
|
||||
},
|
||||
"repository": "quine-global/hyper",
|
||||
"scripts": {
|
||||
"postinstall": "npx patch-package"
|
||||
},
|
||||
"repository": "zeit/hyper",
|
||||
"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",
|
||||
"async-retry": "1.3.1",
|
||||
"chokidar": "^3.5.2",
|
||||
"color": "3.1.3",
|
||||
"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-fetch": "1.7.3",
|
||||
"electron-is-dev": "2.0.0",
|
||||
"electron-store": "8.2.0",
|
||||
"fs-extra": "11.3.0",
|
||||
"git-describe": "4.1.1",
|
||||
"electron-store": "8.0.0",
|
||||
"file-uri-to-path": "2.0.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"git-describe": "4.0.4",
|
||||
"lodash": "4.17.21",
|
||||
"mkdirp": "1.0.4",
|
||||
"ms": "2.1.3",
|
||||
"native-process-working-directory": "^1.0.2",
|
||||
"node-pty": "1.1.0-beta33",
|
||||
"node-pty": "0.10.1",
|
||||
"os-locale": "5.0.0",
|
||||
"parse-url": "9.2.0",
|
||||
"parse-url": "5.0.7",
|
||||
"pify": "5.0.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",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"semver": "7.3.5",
|
||||
"shell-env": "3.0.1",
|
||||
"sudo-prompt": "^9.2.1",
|
||||
"uuid": "10.0.0"
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"native-reg": "1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-gyp": "^10.2.0"
|
||||
"native-reg": "0.3.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,20 @@
|
|||
/* 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 {app, dialog, BrowserWindow, App} from 'electron';
|
||||
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 {writeFileSync} from 'fs';
|
||||
import Config from 'electron-store';
|
||||
import ms from 'ms';
|
||||
import React from 'react';
|
||||
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 {plugs} from './config/paths';
|
||||
import mapKeys from './utils/map-keys';
|
||||
import {configOptions} from '../lib/config';
|
||||
|
||||
// local storage
|
||||
const cache = new Config();
|
||||
|
|
@ -208,10 +200,10 @@ function syncPackageJSON() {
|
|||
const dependencies = toDependencies(plugins);
|
||||
const pkg = {
|
||||
name: 'hyper-plugins',
|
||||
description: 'Auto-generated from `hyper.json`!',
|
||||
description: 'Auto-generated from `~/.hyper.js`!',
|
||||
private: true,
|
||||
version: '0.0.1',
|
||||
repository: 'quine-global/hyper',
|
||||
repository: 'vercel/hyper',
|
||||
license: 'MIT',
|
||||
homepage: 'https://hyper.is',
|
||||
dependencies
|
||||
|
|
@ -240,7 +232,7 @@ function toDependencies(plugins_: {plugins: string[]}) {
|
|||
|
||||
if (match) {
|
||||
const index = match.index + 1;
|
||||
const pieces: string[] = [];
|
||||
const pieces = [];
|
||||
|
||||
pieces[0] = plugin.substring(0, index);
|
||||
pieces[1] = plugin.substring(index + 1, plugin.length);
|
||||
|
|
@ -282,7 +274,7 @@ function requirePlugins(): any[] {
|
|||
const {plugins: plugins_, localPlugins} = paths;
|
||||
|
||||
const load = (path_: string) => {
|
||||
let mod: Record<string, any>;
|
||||
let mod: any;
|
||||
try {
|
||||
mod = require(path_);
|
||||
const exposed = mod && Object.keys(mod).some((key) => availableExtensions.has(key));
|
||||
|
|
@ -302,8 +294,7 @@ function requirePlugins(): any[] {
|
|||
console.log(`Plugin ${mod._name} (${mod._version}) loaded.`);
|
||||
|
||||
return mod;
|
||||
} catch (_err) {
|
||||
const err = _err as {code: string; message: string};
|
||||
} catch (err) {
|
||||
if (err.code === 'MODULE_NOT_FOUND') {
|
||||
console.warn(`Plugin error while loading "${basename(path_)}" (${path_}): ${err.message}`);
|
||||
} else {
|
||||
|
|
@ -312,13 +303,10 @@ function requirePlugins(): any[] {
|
|||
}
|
||||
};
|
||||
|
||||
return [
|
||||
...localPlugins.filter((p) => basename(p) === 'migrated-hyper3-config'),
|
||||
...plugins_,
|
||||
...localPlugins.filter((p) => basename(p) !== 'migrated-hyper3-config')
|
||||
]
|
||||
return plugins_
|
||||
.map(load)
|
||||
.filter((v): v is Record<string, any> => Boolean(v));
|
||||
.concat(localPlugins.map(load))
|
||||
.filter((v) => Boolean(v));
|
||||
}
|
||||
|
||||
export const onApp = (app_: App) => {
|
||||
|
|
@ -421,7 +409,7 @@ export const getDeprecatedConfig = () => {
|
|||
return deprecated;
|
||||
};
|
||||
|
||||
export const decorateMenu = (tpl: MenuItemConstructorOptions[]) => {
|
||||
export const decorateMenu = (tpl: any) => {
|
||||
return decorateObject(tpl, 'decorateMenu');
|
||||
};
|
||||
|
||||
|
|
@ -429,8 +417,8 @@ export const getDecoratedEnv = (baseEnv: Record<string, string>) => {
|
|||
return decorateObject(baseEnv, 'decorateEnv');
|
||||
};
|
||||
|
||||
export const getDecoratedConfig = (profile: string) => {
|
||||
const baseConfig = config.getProfileConfig(profile);
|
||||
export const getDecoratedConfig = () => {
|
||||
const baseConfig = config.getConfig();
|
||||
const decoratedConfig = decorateObject(baseConfig, 'decorateConfig');
|
||||
const fixedConfig = config.fixConfigDefaults(decoratedConfig);
|
||||
const translatedConfig = config.htermConfigTranslate(fixedConfig);
|
||||
|
|
@ -461,20 +449,3 @@ export const decorateSessionClass = <T>(Session: T): T => {
|
|||
};
|
||||
|
||||
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,8 +1,6 @@
|
|||
import cp from 'child_process';
|
||||
|
||||
import ms from 'ms';
|
||||
import queue from 'queue';
|
||||
|
||||
import ms from 'ms';
|
||||
import {yarn, plugs} from '../config/paths';
|
||||
|
||||
export const install = (fn: (err: string | null) => void) => {
|
||||
|
|
|
|||
46
app/rpc.ts
46
app/rpc.ts
|
|
@ -1,22 +1,15 @@
|
|||
import {EventEmitter} from 'events';
|
||||
|
||||
import {ipcMain} from 'electron';
|
||||
import type {BrowserWindow, IpcMainEvent} from 'electron';
|
||||
|
||||
import {ipcMain, BrowserWindow} from 'electron';
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
|
||||
import type {TypedEmitter, MainEvents, RendererEvents, FilterNever} from '../typings/common';
|
||||
|
||||
export class Server {
|
||||
emitter: TypedEmitter<MainEvents>;
|
||||
export class Server extends EventEmitter {
|
||||
destroyed = false;
|
||||
win: BrowserWindow;
|
||||
id!: string;
|
||||
|
||||
constructor(win: BrowserWindow) {
|
||||
this.emitter = new EventEmitter();
|
||||
super();
|
||||
this.win = win;
|
||||
this.emit = this.emit.bind(this);
|
||||
this.ipcListener = this.ipcListener.bind(this);
|
||||
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
|
|
@ -25,13 +18,14 @@ export class Server {
|
|||
const uid = uuidv4();
|
||||
this.id = uid;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
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);
|
||||
this.wc.send('init', uid);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -39,35 +33,23 @@ export class Server {
|
|||
return this.win.webContents;
|
||||
}
|
||||
|
||||
ipcListener = <U extends keyof MainEvents>(event: IpcMainEvent, {ev, data}: {ev: U; data: MainEvents[U]}) =>
|
||||
this.emitter.emit(ev, data);
|
||||
ipcListener(event: any, {ev, data}: {ev: string; data: any}) {
|
||||
super.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]) {
|
||||
emit(ch: string, data: any = {}): any {
|
||||
// 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.removeAllListeners();
|
||||
this.wc.removeAllListeners();
|
||||
if (this.id) {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
ipcMain.removeListener(this.id, this.ipcListener);
|
||||
} else {
|
||||
// mark for `genUid` in constructor
|
||||
|
|
@ -76,8 +58,6 @@ export class Server {
|
|||
}
|
||||
}
|
||||
|
||||
const createRPC = (win: BrowserWindow) => {
|
||||
export default (win: BrowserWindow) => {
|
||||
return new Server(win);
|
||||
};
|
||||
|
||||
export default createRPC;
|
||||
|
|
|
|||
112
app/session.ts
112
app/session.ts
|
|
@ -1,17 +1,12 @@
|
|||
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';
|
||||
import {productName, version} from './package.json';
|
||||
import * as config from './config';
|
||||
import {IPty, IWindowsPtyForkOptions, spawn as npSpawn} from 'node-pty';
|
||||
import {cliScriptPath} from './config/paths';
|
||||
import {dirname} from 'path';
|
||||
|
||||
const createNodePtyError = () =>
|
||||
new Error(
|
||||
|
|
@ -26,6 +21,7 @@ try {
|
|||
throw createNodePtyError();
|
||||
}
|
||||
|
||||
const envFromConfig = config.getConfig().env || {};
|
||||
const useConpty = config.getConfig().useConpty;
|
||||
|
||||
// Max duration to batch session data before sending it to the renderer process.
|
||||
|
|
@ -58,7 +54,7 @@ class DataBatcher extends EventEmitter {
|
|||
this.timeout = null;
|
||||
}
|
||||
|
||||
write(chunk: Buffer | string) {
|
||||
write(chunk: Buffer) {
|
||||
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) {
|
||||
|
|
@ -68,7 +64,7 @@ class DataBatcher extends EventEmitter {
|
|||
this.flush();
|
||||
}
|
||||
|
||||
this.data += typeof chunk === 'string' ? chunk : this.decoder.write(chunk);
|
||||
this.data += this.decoder.write(chunk);
|
||||
|
||||
if (!this.timeout) {
|
||||
this.timeout = setTimeout(() => this.flush(), BATCH_DURATION_MS);
|
||||
|
|
@ -86,12 +82,11 @@ class DataBatcher extends EventEmitter {
|
|||
|
||||
interface SessionOptions {
|
||||
uid: string;
|
||||
rows?: number;
|
||||
cols?: number;
|
||||
cwd?: string;
|
||||
shell?: string;
|
||||
shellArgs?: string[];
|
||||
profile: string;
|
||||
rows: number;
|
||||
cols: number;
|
||||
cwd: string;
|
||||
shell: string;
|
||||
shellArgs: string[];
|
||||
}
|
||||
export default class Session extends EventEmitter {
|
||||
pty: IPty | null;
|
||||
|
|
@ -99,7 +94,6 @@ export default class Session extends EventEmitter {
|
|||
shell: string | null;
|
||||
ended: boolean;
|
||||
initTimestamp: number;
|
||||
profile!: string;
|
||||
constructor(options: SessionOptions) {
|
||||
super();
|
||||
this.pty = null;
|
||||
|
|
@ -110,25 +104,22 @@ export default class Session extends EventEmitter {
|
|||
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'];
|
||||
init({uid, rows, cols: columns, cwd, shell: _shell, shellArgs: _shellArgs}: SessionOptions) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const osLocale = require('os-locale') as typeof import('os-locale');
|
||||
const baseEnv = Object.assign(
|
||||
{},
|
||||
process.env,
|
||||
{
|
||||
LANG: `${osLocale.sync().replace(/-/, '_')}.UTF-8`,
|
||||
TERM: 'xterm-256color',
|
||||
COLORTERM: 'truecolor',
|
||||
TERM_PROGRAM: productName,
|
||||
TERM_PROGRAM_VERSION: version
|
||||
},
|
||||
envFromConfig
|
||||
);
|
||||
|
||||
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']) {
|
||||
|
|
@ -144,8 +135,10 @@ export default class Session extends EventEmitter {
|
|||
delete baseEnv.GOOGLE_API_KEY;
|
||||
}
|
||||
|
||||
const defaultShellArgs = ['--login'];
|
||||
|
||||
const options: IWindowsPtyForkOptions = {
|
||||
cols,
|
||||
cols: columns,
|
||||
rows,
|
||||
cwd,
|
||||
env: getDecoratedEnv(baseEnv)
|
||||
|
|
@ -156,10 +149,12 @@ export default class Session extends EventEmitter {
|
|||
options.useConpty = useConpty;
|
||||
}
|
||||
|
||||
const shell = _shell || defaultShell;
|
||||
const shellArgs = _shellArgs || defaultShellArgs;
|
||||
|
||||
try {
|
||||
this.pty = spawn(shell, shellArgs, options);
|
||||
} catch (_err) {
|
||||
const err = _err as {message: string};
|
||||
} catch (err) {
|
||||
if (/is not a function/.test(err.message)) {
|
||||
throw createNodePtyError();
|
||||
} else {
|
||||
|
|
@ -172,7 +167,7 @@ export default class Session extends EventEmitter {
|
|||
if (this.ended) {
|
||||
return;
|
||||
}
|
||||
this.batcher?.write(chunk);
|
||||
this.batcher?.write(chunk as any);
|
||||
});
|
||||
|
||||
this.batcher.on('flush', (data: string) => {
|
||||
|
|
@ -185,32 +180,15 @@ export default class Session extends EventEmitter {
|
|||
// 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 = `
|
||||
const defaultShellConfig = {shell: defaultShell, shellArgs: defaultShellArgs};
|
||||
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)}
|
||||
fallback to default shell config: ${JSON.stringify(defaultShellConfig, 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'));
|
||||
}
|
||||
console.warn(msg);
|
||||
this.batcher?.write(msg.replace(/\n/g, '\r\n') as any);
|
||||
this.init({uid, rows, cols: columns, cwd, ...defaultShellConfig});
|
||||
} else {
|
||||
this.ended = true;
|
||||
this.emit('exit');
|
||||
|
|
@ -237,8 +215,7 @@ No fallback available, please check the shell config.
|
|||
if (this.pty) {
|
||||
try {
|
||||
this.pty.resize(cols, rows);
|
||||
} catch (_err) {
|
||||
const err = _err as {stack: any};
|
||||
} catch (err) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -250,8 +227,7 @@ No fallback available, please check the shell config.
|
|||
if (this.pty) {
|
||||
try {
|
||||
this.pty.kill();
|
||||
} catch (_err) {
|
||||
const err = _err as {stack: any};
|
||||
} catch (err) {
|
||||
console.error('exit error', err.stack);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,11 @@
|
|||
{
|
||||
"extends": "../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationDir": "../dist/tmp/appdts/",
|
||||
"outDir": "../target/",
|
||||
"composite": true,
|
||||
"noImplicitAny": false
|
||||
"outDir": "../target/"
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"./package.json",
|
||||
"../typings/extend-electron.d.ts",
|
||||
"../typings/ext-modules.d.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"../dist/**/*",
|
||||
"../target/**/*"
|
||||
"./package.json"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
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 {execCommand} from '../commands';
|
||||
import {getDecoratedKeymaps} from '../plugins';
|
||||
|
||||
import {MenuItemConstructorOptions, BrowserWindow} from 'electron';
|
||||
const separator: MenuItemConstructorOptions = {type: 'separator'};
|
||||
|
||||
const getCommandKeys = (keymaps: Record<string, string[]>): Record<string, string> =>
|
||||
|
|
@ -23,20 +20,14 @@ const filterCutCopy = (selection: string, menuItem: MenuItemConstructorOptions)
|
|||
return menuItem;
|
||||
};
|
||||
|
||||
const contextMenuTemplate = (
|
||||
export default (
|
||||
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 _shell = shellMenu(commandKeys, execCommand).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;
|
||||
|
|
|
|||
178
app/ui/window.ts
178
app/ui/window.ts
|
|
@ -1,41 +1,25 @@
|
|||
import {existsSync} from 'fs';
|
||||
import {app, BrowserWindow, shell, Menu, BrowserWindowConstructorOptions} from 'electron';
|
||||
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 {parse as parseUrl} from 'url';
|
||||
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 fileUriToPath from 'file-uri-to-path';
|
||||
import isDev from 'electron-is-dev';
|
||||
import updater from '../updater';
|
||||
import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
|
||||
import toElectronBackgroundColor from '../utils/to-electron-background-color';
|
||||
|
||||
import {icon, homeDirectory} from '../config/paths';
|
||||
import createRPC from '../rpc';
|
||||
import notify from '../notify';
|
||||
import fetchNotifications from '../notifications';
|
||||
import Session from '../session';
|
||||
import contextMenuTemplate from './contextmenu';
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
electronDragClick();
|
||||
}
|
||||
import {execCommand} from '../commands';
|
||||
import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
|
||||
import {decorateSessionOptions, decorateSessionClass} from '../plugins';
|
||||
|
||||
export function newWindow(
|
||||
options_: BrowserWindowConstructorOptions,
|
||||
cfg: configOptions,
|
||||
fn?: (win: BrowserWindow) => void,
|
||||
profileName: string = getDefaultProfile()
|
||||
cfg: any,
|
||||
fn?: (win: BrowserWindow) => void
|
||||
): BrowserWindow {
|
||||
const classOpts = Object.assign({uid: uuidv4()});
|
||||
app.plugins.decorateWindowClass(classOpts);
|
||||
|
|
@ -55,17 +39,12 @@ export function newWindow(
|
|||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
navigateOnDragDrop: true,
|
||||
enableRemoteModule: 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);
|
||||
|
|
@ -75,13 +54,28 @@ export function newWindow(
|
|||
const sessions = new Map<string, Session>();
|
||||
|
||||
const updateBackgroundColor = () => {
|
||||
const cfg_ = app.plugins.getDecoratedConfig(profileName);
|
||||
const cfg_ = app.plugins.getDecoratedConfig();
|
||||
window.setBackgroundColor(toElectronBackgroundColor(cfg_.backgroundColor || '#000'));
|
||||
};
|
||||
|
||||
// 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 (cfg.workingDirectory && isAbsolute(cfg.workingDirectory)) {
|
||||
workingDirectory = cfg.workingDirectory;
|
||||
}
|
||||
|
||||
// config changes
|
||||
const cfgUnsubscribe = app.config.subscribe(() => {
|
||||
const cfg_ = app.plugins.getDecoratedConfig(profileName);
|
||||
const cfg_ = app.plugins.getDecoratedConfig();
|
||||
|
||||
// notify renderer
|
||||
window.webContents.send('config change');
|
||||
|
|
@ -124,58 +118,23 @@ export function newWindow(
|
|||
}
|
||||
});
|
||||
|
||||
function createSession(extraOptions: sessionExtraOptions = {}) {
|
||||
function createSession(extraOptions: any = {}) {
|
||||
const uid = uuidv4();
|
||||
const extraOptionsFiltered: sessionExtraOptions = {};
|
||||
const extraOptionsFiltered: any = {};
|
||||
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,
|
||||
cwd: workingDirectory,
|
||||
splitDirection: undefined,
|
||||
shell: profileCfg.shell,
|
||||
shellArgs: profileCfg.shellArgs && Array.from(profileCfg.shellArgs)
|
||||
shell: cfg.shell,
|
||||
shellArgs: cfg.shellArgs && Array.from(cfg.shellArgs)
|
||||
},
|
||||
extraOptionsFiltered,
|
||||
{
|
||||
profile: extraOptionsFiltered.profile || profileName,
|
||||
uid
|
||||
}
|
||||
{uid}
|
||||
);
|
||||
const options = decorateSessionOptions(defaultOptions);
|
||||
const DecoratedSession = decorateSessionClass(Session);
|
||||
|
|
@ -195,8 +154,7 @@ export function newWindow(
|
|||
splitDirection: options.splitDirection,
|
||||
shell: session.shell,
|
||||
pid: session.pty ? session.pty.pid : null,
|
||||
activeUid: options.activeUid ?? undefined,
|
||||
profile: options.profile
|
||||
activeUid: options.activeUid
|
||||
});
|
||||
|
||||
session.on('data', (data: string) => {
|
||||
|
|
@ -231,8 +189,8 @@ export function newWindow(
|
|||
session.resize({cols, rows});
|
||||
}
|
||||
});
|
||||
rpc.on('data', ({uid, data, escaped}) => {
|
||||
const session = uid && sessions.get(uid);
|
||||
rpc.on('data', ({uid, data, escaped}: {uid: string; data: string; escaped: boolean}) => {
|
||||
const session = sessions.get(uid);
|
||||
if (session) {
|
||||
if (escaped) {
|
||||
const escapedData = session.shell?.endsWith('cmd.exe')
|
||||
|
|
@ -262,12 +220,11 @@ export function newWindow(
|
|||
// 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);
|
||||
|
||||
for (const ev of ['maximize', 'unmaximize', 'minimize', 'restore'] as any) {
|
||||
window.on(ev, () => {
|
||||
rpc.emit('windowGeometry change', {});
|
||||
});
|
||||
}
|
||||
window.on('move', () => {
|
||||
const position = window.getPosition();
|
||||
rpc.emit('move', {bounds: {x: position[0], y: position[1]}});
|
||||
|
|
@ -281,10 +238,10 @@ export function newWindow(
|
|||
});
|
||||
// pass on the full screen events from the window to react
|
||||
rpc.win.on('enter-full-screen', () => {
|
||||
rpc.emit('enter full screen');
|
||||
rpc.emit('enter full screen', {});
|
||||
});
|
||||
rpc.win.on('leave-full-screen', () => {
|
||||
rpc.emit('leave full screen');
|
||||
rpc.emit('leave full screen', {});
|
||||
});
|
||||
const deleteSessions = () => {
|
||||
sessions.forEach((session, key) => {
|
||||
|
|
@ -302,32 +259,29 @@ export function newWindow(
|
|||
}
|
||||
});
|
||||
|
||||
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.
|
||||
// If file is dropped onto the terminal window, navigate event is prevented
|
||||
// and his path is added to active session.
|
||||
window.webContents.on('will-navigate', (event, url) => {
|
||||
const data = handleDroppedURL(url);
|
||||
if (data) {
|
||||
const protocol = typeof url === 'string' && parseUrl(url).protocol;
|
||||
if (protocol === 'file:') {
|
||||
event.preventDefault();
|
||||
rpc.emit('session data send', data);
|
||||
|
||||
const path = fileUriToPath(url);
|
||||
|
||||
rpc.emit('session data send', {data: path, escaped: true});
|
||||
} else if (protocol === 'http:' || protocol === 'https:') {
|
||||
event.preventDefault();
|
||||
rpc.emit('session data send', {data: url});
|
||||
}
|
||||
});
|
||||
window.webContents.setWindowOpenHandler(({url}) => {
|
||||
const data = handleDroppedURL(url);
|
||||
if (data) {
|
||||
rpc.emit('session data send', data);
|
||||
return {action: 'deny'};
|
||||
|
||||
// xterm makes link clickable
|
||||
window.webContents.on('new-window', (event, url) => {
|
||||
const protocol = typeof url === 'string' && parseUrl(url).protocol;
|
||||
if (protocol === 'http:' || protocol === 'https:') {
|
||||
event.preventDefault();
|
||||
void shell.openExternal(url);
|
||||
}
|
||||
return {action: 'allow'};
|
||||
});
|
||||
|
||||
// expose internals to extension authors
|
||||
|
|
|
|||
|
|
@ -1,60 +1,25 @@
|
|||
// Packages
|
||||
import electron, {app} from 'electron';
|
||||
import type {BrowserWindow, AutoUpdater as OriginalAutoUpdater} from 'electron';
|
||||
|
||||
import retry from 'async-retry';
|
||||
import electron, {app, BrowserWindow, AutoUpdater} from 'electron';
|
||||
import ms from 'ms';
|
||||
import retry from 'async-retry';
|
||||
|
||||
// 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;
|
||||
}
|
||||
import autoUpdaterLinux from './auto-updater-linux';
|
||||
|
||||
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}`;
|
||||
return `https://${updatePrefix}.hyper.is/update/${isLinux ? 'deb' : platform}/${currentVersion}`;
|
||||
};
|
||||
|
||||
const isCanary = (updateChannel: string) => updateChannel === 'canary';
|
||||
|
|
@ -64,7 +29,15 @@ async function init() {
|
|||
console.error('Error fetching updates', `${err.message} (${err.stack})`);
|
||||
});
|
||||
|
||||
const config = await getDecoratedConfigWithRetry();
|
||||
const config = await retry(() => {
|
||||
const content = getDecoratedConfig();
|
||||
|
||||
if (!content) {
|
||||
throw new Error('No config content loaded');
|
||||
}
|
||||
|
||||
return content;
|
||||
});
|
||||
|
||||
// If defined in the config, switch to the "canary" channel
|
||||
if (config.updateChannel && isCanary(config.updateChannel)) {
|
||||
|
|
@ -76,59 +49,58 @@ async function init() {
|
|||
autoUpdater.setFeedURL({url: feedURL});
|
||||
|
||||
setTimeout(() => {
|
||||
void checkForUpdates();
|
||||
autoUpdater.checkForUpdates();
|
||||
}, ms('10s'));
|
||||
|
||||
setInterval(() => {
|
||||
void checkForUpdates();
|
||||
autoUpdater.checkForUpdates();
|
||||
}, ms('30m'));
|
||||
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
const updater = (win: BrowserWindow) => {
|
||||
export default (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});
|
||||
const onupdate = (
|
||||
ev: Event,
|
||||
releaseNotes: string,
|
||||
releaseName: string,
|
||||
date: Date,
|
||||
updateUrl: string,
|
||||
onQuitAndInstall: any
|
||||
) => {
|
||||
const releaseUrl = updateUrl || `https://github.com/vercel/hyper/releases/tag/${releaseName}`;
|
||||
rpc.emit('update available', {releaseNotes, releaseName, releaseUrl, canInstall: !!onQuitAndInstall});
|
||||
};
|
||||
|
||||
if (isLinux) {
|
||||
autoUpdater.on('update-available', onupdate);
|
||||
} else {
|
||||
autoUpdater.on('update-downloaded', onupdate);
|
||||
}
|
||||
const eventName: any = isLinux ? 'update-available' : 'update-downloaded';
|
||||
|
||||
autoUpdater.on(eventName, onupdate);
|
||||
|
||||
rpc.once('quit and install', () => {
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
|
||||
app.config.subscribe(async () => {
|
||||
const {updateChannel} = await getDecoratedConfigWithRetry();
|
||||
app.config.subscribe(() => {
|
||||
const {updateChannel} = app.plugins.getDecoratedConfig();
|
||||
const newUpdateIsCanary = isCanary(updateChannel);
|
||||
|
||||
if (newUpdateIsCanary !== canaryUpdates) {
|
||||
const feedURL = buildFeedUrl(newUpdateIsCanary, version);
|
||||
|
||||
autoUpdater.setFeedURL({url: feedURL});
|
||||
void checkForUpdates();
|
||||
autoUpdater.checkForUpdates();
|
||||
|
||||
canaryUpdates = newUpdateIsCanary;
|
||||
}
|
||||
});
|
||||
|
||||
win.on('close', () => {
|
||||
if (isLinux) {
|
||||
autoUpdater.removeListener('update-available', onupdate);
|
||||
} else {
|
||||
autoUpdater.removeListener('update-downloaded', onupdate);
|
||||
}
|
||||
autoUpdater.removeListener(eventName, onupdate);
|
||||
});
|
||||
};
|
||||
|
||||
export default updater;
|
||||
|
|
|
|||
|
|
@ -1,23 +1,20 @@
|
|||
import {existsSync, readlink, symlink} from 'fs';
|
||||
import pify from 'pify';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {promisify} from 'util';
|
||||
|
||||
import {clipboard, dialog} from 'electron';
|
||||
|
||||
import {mkdirpSync} from 'fs-extra';
|
||||
import notify from '../notify';
|
||||
import {cliScriptPath, cliLinkPath} from '../config/paths';
|
||||
import * as Registry from 'native-reg';
|
||||
import type {ValueType} from 'native-reg';
|
||||
import sudoPrompt from 'sudo-prompt';
|
||||
import {clipboard, dialog} from 'electron';
|
||||
import {mkdirpSync} from 'fs-extra';
|
||||
|
||||
import {cliScriptPath, cliLinkPath} from '../config/paths';
|
||||
import notify from '../notify';
|
||||
|
||||
const readLink = promisify(readlink);
|
||||
const symLink = promisify(symlink);
|
||||
const sudoExec = promisify(sudoPrompt.exec);
|
||||
const readlink = pify(fs.readlink);
|
||||
const symlink = pify(fs.symlink);
|
||||
const sudoExec = pify(sudoPrompt.exec, {multiArgs: true});
|
||||
|
||||
const checkInstall = () => {
|
||||
return readLink(cliLinkPath)
|
||||
return readlink(cliLinkPath)
|
||||
.then((link) => link === cliScriptPath)
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
|
|
@ -35,16 +32,15 @@ const addSymlink = async (silent: boolean) => {
|
|||
return;
|
||||
}
|
||||
console.log('Linking HyperCLI');
|
||||
if (!existsSync(path.dirname(cliLinkPath))) {
|
||||
if (!fs.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};
|
||||
await symlink(cliScriptPath, cliLinkPath);
|
||||
} catch (err) {
|
||||
// 'EINVAL' is returned by readlink,
|
||||
// 'EEXIST' is returned by symlink
|
||||
let error =
|
||||
|
|
@ -65,7 +61,7 @@ sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`,
|
|||
await sudoExec(`ln -sf "${cliScriptPath}" "${cliLinkPath}"`, {name: 'Hyper'});
|
||||
return;
|
||||
} catch (_error) {
|
||||
error = (_error as any[])[0];
|
||||
error = _error[0];
|
||||
}
|
||||
} else if (result.response === 1) {
|
||||
clipboard.writeText(`sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const generatePrefixedCommand = (command: string, shortcuts: string[]) => {
|
|||
return result;
|
||||
};
|
||||
|
||||
const mapKeys = (config: Record<string, string[] | string>) => {
|
||||
export default (config: Record<string, string[] | string>) => {
|
||||
return Object.keys(config).reduce((keymap: Record<string, string[]>, command: string) => {
|
||||
if (!command) {
|
||||
return keymap;
|
||||
|
|
@ -39,5 +39,3 @@ const mapKeys = (config: Record<string, string[] | string>) => {
|
|||
return keymap;
|
||||
}, {});
|
||||
};
|
||||
|
||||
export default mapKeys;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
@ -9,7 +9,7 @@ const regKeys = [
|
|||
];
|
||||
const regParts = [
|
||||
{key: 'command', name: '', value: `${appPath} "%V"`},
|
||||
{name: '', value: 'Open &Hyper here'},
|
||||
{name: '', value: 'Open Hyper here'},
|
||||
{name: 'Icon', value: `${appPath}`}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ 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) => {
|
||||
export default (bgColor: string) => {
|
||||
const color = Color(bgColor);
|
||||
|
||||
if (color.alpha() === 1) {
|
||||
|
|
@ -13,7 +13,5 @@ const toElectronBackgroundColor = (bgColor: string) => {
|
|||
|
||||
// http://stackoverflow.com/a/11019879/1202488
|
||||
const alphaHex = Math.round(color.alpha() * 255).toString(16);
|
||||
return `#${alphaHex}${color.hex().toString().slice(1)}`;
|
||||
return `#${alphaHex}${color.hex().toString().substr(1)}`;
|
||||
};
|
||||
|
||||
export default toElectronBackgroundColor;
|
||||
|
|
|
|||
1299
app/yarn.lock
1299
app/yarn.lock
File diff suppressed because it is too large
Load diff
29
assets/search-icons.svg
Normal file
29
assets/search-icons.svg
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<symbol id="left-arrow" viewBox="0 0 10 10">
|
||||
<title>left arrow</title>
|
||||
<g stroke-linecap="round">
|
||||
<line x1="0.5" y1="5" x2="8.5" y2="5" stroke="#000" />
|
||||
<line x1="0.5" y1="5" x2="3.5" y2="2" stroke="#000" />
|
||||
<line x1="0.5" y1="5" x2="3.5" y2="8" stroke="#000" />
|
||||
</g>
|
||||
</symbol>
|
||||
<symbol id="right-arrow" viewBox="0 0 10 10">
|
||||
<title>right arrow</title>
|
||||
<g stroke-linecap="round">
|
||||
<line x1="1.5" y1="5" x2="9.5" y2="5" stroke="#000" />
|
||||
<line x1="9.5" y1="5" x2="6.5" y2="2" stroke="#000" />
|
||||
<line x1="9.5" y1="5" x2="6.5" y2="8" stroke="#000" />
|
||||
</g>
|
||||
</symbol>
|
||||
<symbol id="cancel" viewBox="0 0 10 10">
|
||||
<title>cancel</title>
|
||||
<g stroke-linecap="round">
|
||||
<line x1="5" y1="5" x2="8" y2="8" stroke="#000" />
|
||||
<line x1="5" y1="5" x2="8" y2="2" stroke="#000" />
|
||||
<line x1="5" y1="5" x2="2" y2="2" stroke="#000" />
|
||||
<line x1="5" y1="5" x2="2" y2="8" stroke="#000" />
|
||||
</g>
|
||||
</symbol>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.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
|
||||
};
|
||||
10
ava-spectron.config.js
Normal file
10
ava-spectron.config.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export default {
|
||||
files: ['test/*'],
|
||||
babel: {
|
||||
compileEnhancements: false,
|
||||
compileAsTests: ['**/testUtils/**/*']
|
||||
},
|
||||
extensions: ['ts'],
|
||||
require: ['ts-node/register/transpile-only'],
|
||||
timeout: '30s'
|
||||
};
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
module.exports = {
|
||||
export default {
|
||||
files: ['test/unit/*'],
|
||||
babel: {
|
||||
compileEnhancements: false,
|
||||
compileAsTests: ['**/testUtils/**/*']
|
||||
},
|
||||
extensions: ['ts'],
|
||||
require: ['ts-node/register/transpile-only'],
|
||||
verbose: true,
|
||||
// Due to permissions issues, Windows needs cache turned off
|
||||
cache: false
|
||||
require: ['ts-node/register/transpile-only']
|
||||
};
|
||||
|
|
|
|||
88
bin/cp-snapshot.js
vendored
88
bin/cp-snapshot.js
vendored
|
|
@ -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')
|
||||
}
|
||||
84
bin/mk-snapshot.js
vendored
84
bin/mk-snapshot.js
vendored
|
|
@ -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));
|
||||
17
bin/notarize.js
vendored
17
bin/notarize.js
vendored
|
|
@ -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
|
||||
});
|
||||
};
|
||||
31
bin/snapshot-libs.js
vendored
31
bin/snapshot-libs.js
vendored
|
|
@ -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');
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.automation.apple-events</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.camera</key>
|
||||
<true/>
|
||||
<key>com.apple.security.personal-information.addressbook</key>
|
||||
<true/>
|
||||
<key>com.apple.security.personal-information.calendars</key>
|
||||
<true/>
|
||||
<key>com.apple.security.personal-information.location</key>
|
||||
<true/>
|
||||
<key>com.apple.security.personal-information.photos-library</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -1,27 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.65.2/resources/darwin/bin/code.sh
|
||||
# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/darwin/bin/code.sh
|
||||
|
||||
# TODO: bash is deprecated on macOS and will be removed.
|
||||
# Port this to /bin/sh or /bin/zsh
|
||||
|
||||
function app_realpath() {
|
||||
SOURCE=$1
|
||||
while [ -h "$SOURCE" ]; do
|
||||
DIR=$(dirname "$SOURCE")
|
||||
SOURCE=$(readlink "$SOURCE")
|
||||
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
|
||||
done
|
||||
SOURCE_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
echo "${SOURCE_DIR%%"${SOURCE_DIR#*.app}"}"
|
||||
}
|
||||
|
||||
APP_PATH="$(app_realpath "${BASH_SOURCE[0]}")"
|
||||
if [ -z "$APP_PATH" ]; then
|
||||
echo "Unable to determine app path from symlink : ${BASH_SOURCE[0]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONTENTS="$APP_PATH/Contents"
|
||||
function realpath() { /usr/bin/python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
|
||||
CONTENTS="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")"
|
||||
ELECTRON="$CONTENTS/MacOS/Hyper"
|
||||
CLI="$CONTENTS/Resources/bin/cli.js"
|
||||
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
!macro customInstall
|
||||
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\Hyper" "" "Open &Hyper here"
|
||||
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\Hyper" "Icon" `"$appExe"`
|
||||
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\Hyper\command" "" `"$appExe" "%V"`
|
||||
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\Hyper" "" "Open Hyper here"
|
||||
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\Hyper" "Icon" "$appExe"
|
||||
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\Hyper\command" "" `$appExe "%V"`
|
||||
|
||||
WriteRegStr HKCU "Software\Classes\Directory\shell\Hyper" "" "Open &Hyper here"
|
||||
WriteRegStr HKCU "Software\Classes\Directory\shell\Hyper" "Icon" `"$appExe"`
|
||||
WriteRegStr HKCU "Software\Classes\Directory\shell\Hyper\command" "" `"$appExe" "%V"`
|
||||
WriteRegStr HKCU "Software\Classes\Directory\shell\Hyper" "" "Open Hyper here"
|
||||
WriteRegStr HKCU "Software\Classes\Directory\shell\Hyper" "Icon" "$appExe"
|
||||
WriteRegStr HKCU "Software\Classes\Directory\shell\Hyper\command" "" `$appExe "%V"`
|
||||
|
||||
WriteRegStr HKCU "Software\Classes\Drive\shell\Hyper" "" "Open &Hyper here"
|
||||
WriteRegStr HKCU "Software\Classes\Drive\shell\Hyper" "Icon" `"$appExe"`
|
||||
WriteRegStr HKCU "Software\Classes\Drive\shell\Hyper\command" "" `"$appExe" "%V"`
|
||||
WriteRegStr HKCU "Software\Classes\Drive\shell\Hyper" "" "Open Hyper here"
|
||||
WriteRegStr HKCU "Software\Classes\Drive\shell\Hyper" "Icon" "$appExe"
|
||||
WriteRegStr HKCU "Software\Classes\Drive\shell\Hyper\command" "" `$appExe "%V"`
|
||||
!macroend
|
||||
|
||||
!macro customUnInstall
|
||||
|
|
@ -25,4 +25,4 @@
|
|||
!macro customInit
|
||||
IfFileExists $LOCALAPPDATA\Hyper\Update.exe 0 +2
|
||||
nsExec::Exec '"$LOCALAPPDATA\Hyper\Update.exe" --uninstall -s'
|
||||
!macroend
|
||||
!macroend
|
||||
87
cli/api.ts
87
cli/api.ts
|
|
@ -2,27 +2,28 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import got from 'got';
|
||||
import registryUrlModule from 'registry-url';
|
||||
|
||||
const registryUrl = registryUrlModule();
|
||||
import pify from 'pify';
|
||||
import * as recast from 'recast';
|
||||
import path from 'path';
|
||||
|
||||
// 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
|
||||
const applicationDirectory = process.env.XDG_CONFIG_HOME
|
||||
? path.join(process.env.XDG_CONFIG_HOME, 'Hyper')
|
||||
: process.platform === 'win32'
|
||||
const applicationDirectory =
|
||||
process.env.XDG_CONFIG_HOME !== undefined
|
||||
? path.join(process.env.XDG_CONFIG_HOME, 'hyper')
|
||||
: process.platform == 'win32'
|
||||
? path.join(process.env.APPDATA!, 'Hyper')
|
||||
: path.join(os.homedir(), '.config', 'Hyper');
|
||||
: os.homedir();
|
||||
|
||||
const devConfigFileName = path.join(__dirname, `../hyper.json`);
|
||||
const devConfigFileName = path.join(__dirname, `../.hyper.js`);
|
||||
|
||||
const fileName =
|
||||
process.env.NODE_ENV !== 'production' && fs.existsSync(devConfigFileName)
|
||||
? devConfigFileName
|
||||
: path.join(applicationDirectory, 'hyper.json');
|
||||
: path.join(applicationDirectory, '.hyper.js');
|
||||
|
||||
/**
|
||||
* We need to make sure the file reading and parsing is lazy so that failure to
|
||||
|
|
@ -32,7 +33,7 @@ const fileName =
|
|||
function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
||||
let hasResult = false;
|
||||
let result: any;
|
||||
return ((...args: Parameters<T>) => {
|
||||
return ((...args: any[]) => {
|
||||
if (!hasResult) {
|
||||
result = fn(...args);
|
||||
hasResult = true;
|
||||
|
|
@ -42,12 +43,33 @@ function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
|||
}
|
||||
|
||||
const getFileContents = memoize(() => {
|
||||
return fs.readFileSync(fileName, 'utf8');
|
||||
try {
|
||||
return fs.readFileSync(fileName, 'utf8');
|
||||
} catch (err) {
|
||||
if (err.code !== 'ENOENT') {
|
||||
// ENOENT === !exists()
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const getParsedFile = memoize(() => JSON.parse(getFileContents()));
|
||||
const getParsedFile = memoize(() => recast.parse(getFileContents()!));
|
||||
|
||||
const getPluginsByKey = (key: string): any[] => getParsedFile()[key] || [];
|
||||
const getProperties = memoize(
|
||||
(): any[] =>
|
||||
((getParsedFile()?.program?.body as any[]) || []).find(
|
||||
(bodyItem) =>
|
||||
bodyItem.type === 'ExpressionStatement' &&
|
||||
bodyItem.expression.type === 'AssignmentExpression' &&
|
||||
bodyItem.expression.left.object.name === 'module' &&
|
||||
bodyItem.expression.left.property.name === 'exports' &&
|
||||
bodyItem.expression.right.type === 'ObjectExpression'
|
||||
)?.expression?.right?.properties || []
|
||||
);
|
||||
|
||||
const getPluginsByKey = (key: string): any[] =>
|
||||
getProperties().find((property) => property?.key?.name === key)?.value?.elements || [];
|
||||
|
||||
const getPlugins = memoize(() => {
|
||||
return getPluginsByKey('plugins');
|
||||
|
|
@ -64,13 +86,13 @@ function exists() {
|
|||
function isInstalled(plugin: string, locally?: boolean) {
|
||||
const array = locally ? getLocalPlugins() : getPlugins();
|
||||
if (array && Array.isArray(array)) {
|
||||
return array.includes(plugin);
|
||||
return array.some((entry) => entry.value === plugin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save(config: any) {
|
||||
return fs.writeFileSync(fileName, JSON.stringify(config, null, 2), 'utf8');
|
||||
function save() {
|
||||
return pify(fs.writeFile)(fileName, recast.print(getParsedFile()).code, 'utf8');
|
||||
}
|
||||
|
||||
function getPackageName(plugin: string) {
|
||||
|
|
@ -86,15 +108,13 @@ function getPackageName(plugin: string) {
|
|||
|
||||
function existsOnNpm(plugin: string) {
|
||||
const name = getPackageName(plugin);
|
||||
return got
|
||||
.get<any>(registryUrl + name.toLowerCase(), {timeout: {request: 10000}, responseType: 'json'})
|
||||
.then((res) => {
|
||||
if (!res.body.versions) {
|
||||
return Promise.reject(res);
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
});
|
||||
return got.get<any>(registryUrl + name.toLowerCase(), {timeout: 10000, responseType: 'json'}).then((res) => {
|
||||
if (!res.body.versions) {
|
||||
return Promise.reject(res);
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function install(plugin: string, locally?: boolean) {
|
||||
|
|
@ -112,25 +132,26 @@ function install(plugin: string, locally?: boolean) {
|
|||
return Promise.reject(`${plugin} is already installed`);
|
||||
}
|
||||
|
||||
const config = getParsedFile();
|
||||
config[locally ? 'localPlugins' : 'plugins'] = [...array, plugin];
|
||||
save(config);
|
||||
array.push(recast.types.builders.literal(plugin));
|
||||
return save();
|
||||
});
|
||||
}
|
||||
|
||||
async function uninstall(plugin: string) {
|
||||
function uninstall(plugin: string) {
|
||||
if (!isInstalled(plugin)) {
|
||||
return Promise.reject(`${plugin} is not installed`);
|
||||
}
|
||||
|
||||
const config = getParsedFile();
|
||||
config.plugins = getPlugins().filter((p) => p !== plugin);
|
||||
save(config);
|
||||
const index = getPlugins().findIndex((entry) => entry.value === plugin);
|
||||
getPlugins().splice(index, 1);
|
||||
return save();
|
||||
}
|
||||
|
||||
function list() {
|
||||
if (getPlugins().length > 0) {
|
||||
return getPlugins().join('\n');
|
||||
return getPlugins()
|
||||
.map((plugin) => plugin.value)
|
||||
.join('\n');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
57
cli/index.ts
57
cli/index.ts
|
|
@ -1,20 +1,16 @@
|
|||
// This is a CLI tool, using console is OK
|
||||
/* eslint no-console: 0 */
|
||||
import {spawn, exec} from 'child_process';
|
||||
import type {SpawnOptions} from 'child_process';
|
||||
import {existsSync} from 'fs';
|
||||
import {spawn, exec, SpawnOptions} from 'child_process';
|
||||
import {isAbsolute, resolve} from 'path';
|
||||
import {promisify} from 'util';
|
||||
|
||||
import {existsSync} from 'fs';
|
||||
import {version} from '../app/package.json';
|
||||
import pify from 'pify';
|
||||
import args from 'args';
|
||||
import chalk from 'chalk';
|
||||
import _columnify from 'columnify';
|
||||
import got from 'got';
|
||||
import open from 'open';
|
||||
import columnify from 'columnify';
|
||||
import got from 'got';
|
||||
import ora from 'ora';
|
||||
|
||||
import {version} from '../app/package.json';
|
||||
|
||||
import * as api from './api';
|
||||
|
||||
let commandPromise: Promise<void> | undefined;
|
||||
|
|
@ -36,22 +32,6 @@ const checkConfig = () => {
|
|||
process.exit(1);
|
||||
};
|
||||
|
||||
const columnify = (data: {name: string; description: string}[]) => {
|
||||
const maxNameLength = Math.max(...data.map((entry) => entry.name.length), 0);
|
||||
const descriptionWidth = process.stdout.columns - maxNameLength - 1;
|
||||
return _columnify(data, {
|
||||
showHeaders: false,
|
||||
config: {
|
||||
description: {
|
||||
maxWidth: descriptionWidth
|
||||
},
|
||||
name: {
|
||||
dataTransform: (nameValue) => chalk.green(nameValue)
|
||||
}
|
||||
}
|
||||
}).replace(/\s+$/gm, ''); // remove padding from the end of all lines
|
||||
};
|
||||
|
||||
args.command(
|
||||
'install',
|
||||
'Install a plugin',
|
||||
|
|
@ -77,7 +57,7 @@ args.command(
|
|||
commandPromise = api
|
||||
.uninstall(pluginName)
|
||||
.then(() => console.log(chalk.green(`${pluginName} uninstalled successfully!`)))
|
||||
.catch((err) => console.error(chalk.red(err)));
|
||||
.catch((err) => console.log(chalk.red(err)));
|
||||
},
|
||||
['u', 'rm', 'remove']
|
||||
);
|
||||
|
|
@ -112,6 +92,12 @@ const lsRemote = (pattern?: string) => {
|
|||
entries.map(({name, description}) => {
|
||||
return {name, description};
|
||||
})
|
||||
)
|
||||
.then((entries) =>
|
||||
entries.map((entry) => {
|
||||
entry.name = chalk.green(entry.name);
|
||||
return entry;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -130,8 +116,9 @@ args.command(
|
|||
console.error(`${chalk.red('Try')} ${chalk.green('hyper ls-remote')}`);
|
||||
process.exit(1);
|
||||
} else {
|
||||
const msg = columnify(entries);
|
||||
let msg = columnify(entries);
|
||||
spinner.succeed();
|
||||
msg = msg.substring(msg.indexOf('\n') + 1); // remove header
|
||||
console.log(msg);
|
||||
}
|
||||
})
|
||||
|
|
@ -151,8 +138,10 @@ args.command(
|
|||
|
||||
commandPromise = lsRemote()
|
||||
.then((entries) => {
|
||||
const msg = columnify(entries);
|
||||
let msg = columnify(entries);
|
||||
|
||||
spinner.succeed();
|
||||
msg = msg.substring(msg.indexOf('\n') + 1); // remove header
|
||||
console.log(msg);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -195,10 +184,8 @@ const main = (argv: string[]) => {
|
|||
version: false,
|
||||
mri: {
|
||||
boolean: ['v', 'verbose']
|
||||
},
|
||||
mainColor: 'yellow',
|
||||
subColor: 'dim'
|
||||
});
|
||||
}
|
||||
} as any);
|
||||
|
||||
if (commandPromise) {
|
||||
return commandPromise;
|
||||
|
|
@ -234,11 +221,11 @@ const main = (argv: string[]) => {
|
|||
options['stdio'] = 'ignore';
|
||||
if (process.platform === 'darwin') {
|
||||
//Use `open` to prevent multiple Hyper process
|
||||
const cmd = `open -b com.quineglobal.hyper ${args_}`;
|
||||
const cmd = `open -b co.zeit.hyper ${args_}`;
|
||||
const opts = {
|
||||
env
|
||||
};
|
||||
return promisify(exec)(cmd, opts);
|
||||
return pify(exec)(cmd, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/electron-builder",
|
||||
"extends": "electron-builder.json",
|
||||
"afterSign": null,
|
||||
"npmRebuild": false
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"appId": "com.quineglobal.hyper",
|
||||
"afterSign": "./bin/notarize.js",
|
||||
"afterPack": "./bin/cp-snapshot.js",
|
||||
"$schema": "http://json.schemastore.org/electron-builder",
|
||||
"appId": "co.zeit.hyper",
|
||||
"directories": {
|
||||
"app": "target"
|
||||
},
|
||||
|
|
@ -16,27 +15,43 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"artifactName": "${productName}-${version}-${arch}.${ext}",
|
||||
"linux": {
|
||||
"category": "TerminalEmulator",
|
||||
"target": [
|
||||
"deb",
|
||||
"AppImage",
|
||||
"snap",
|
||||
"pacman"
|
||||
{
|
||||
"target": "deb",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "AppImage",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "rpm",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "snap",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"win": {
|
||||
"target": {
|
||||
"target": "nsis",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
"signtoolOptions": {
|
||||
"timeStampServer": "http://timestamp.comodoca.com"
|
||||
}
|
||||
"target": [
|
||||
"nsis"
|
||||
],
|
||||
"rfc3161TimeStampServer": "http://timestamp.comodoca.com"
|
||||
},
|
||||
"nsis": {
|
||||
"include": "build/win/installer.nsh",
|
||||
|
|
@ -54,8 +69,6 @@
|
|||
},
|
||||
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
|
||||
"category": "public.app-category.developer-tools",
|
||||
"entitlements": "./build/mac/entitlements.plist",
|
||||
"entitlementsInherit": "./build/mac/entitlements.plist",
|
||||
"extendInfo": {
|
||||
"CFBundleDocumentTypes": [
|
||||
{
|
||||
|
|
@ -103,6 +116,9 @@
|
|||
"compression": "bzip2",
|
||||
"afterInstall": "./build/linux/after-install.tpl"
|
||||
},
|
||||
"rpm": {
|
||||
"afterInstall": "./build/linux/after-install.tpl"
|
||||
},
|
||||
"snap": {
|
||||
"confinement": "classic",
|
||||
"publish": "github"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type {configOptions} from '../../typings/config';
|
||||
import {CONFIG_LOAD, CONFIG_RELOAD} from '../../typings/constants/config';
|
||||
import type {HyperActions} from '../../typings/hyper';
|
||||
import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config';
|
||||
import {HyperActions} from '../hyper';
|
||||
import {configOptions} from '../config';
|
||||
|
||||
export function loadConfig(config: configOptions): HyperActions {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import {CLOSE_TAB, CHANGE_TAB} from '../../typings/constants/tabs';
|
||||
import {CLOSE_TAB, CHANGE_TAB} from '../constants/tabs';
|
||||
import {
|
||||
UI_WINDOW_MAXIMIZE,
|
||||
UI_WINDOW_UNMAXIMIZE,
|
||||
UI_OPEN_HAMBURGER_MENU,
|
||||
UI_WINDOW_MINIMIZE,
|
||||
UI_WINDOW_CLOSE
|
||||
} from '../../typings/constants/ui';
|
||||
import type {HyperDispatch} from '../../typings/hyper';
|
||||
} from '../constants/ui';
|
||||
import rpc from '../rpc';
|
||||
|
||||
import {userExitTermGroup, setActiveGroup} from './term-groups';
|
||||
import {HyperDispatch} from '../hyper';
|
||||
|
||||
export function closeTab(uid: string) {
|
||||
return (dispatch: HyperDispatch) => {
|
||||
|
|
@ -40,7 +39,7 @@ export function maximize() {
|
|||
dispatch({
|
||||
type: UI_WINDOW_MAXIMIZE,
|
||||
effect() {
|
||||
rpc.emit('maximize');
|
||||
rpc.emit('maximize', null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -51,7 +50,7 @@ export function unmaximize() {
|
|||
dispatch({
|
||||
type: UI_WINDOW_UNMAXIMIZE,
|
||||
effect() {
|
||||
rpc.emit('unmaximize');
|
||||
rpc.emit('unmaximize', null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -73,7 +72,7 @@ export function minimize() {
|
|||
dispatch({
|
||||
type: UI_WINDOW_MINIMIZE,
|
||||
effect() {
|
||||
rpc.emit('minimize');
|
||||
rpc.emit('minimize', null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -84,7 +83,7 @@ export function close() {
|
|||
dispatch({
|
||||
type: UI_WINDOW_CLOSE,
|
||||
effect() {
|
||||
rpc.emit('close');
|
||||
rpc.emit('close', null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {INIT} from '../../typings/constants';
|
||||
import type {HyperDispatch} from '../../typings/hyper';
|
||||
import rpc from '../rpc';
|
||||
import {INIT} from '../constants';
|
||||
import {HyperDispatch} from '../hyper';
|
||||
|
||||
export default function init() {
|
||||
return (dispatch: HyperDispatch) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../../typings/constants/notifications';
|
||||
import type {HyperActions} from '../../typings/hyper';
|
||||
import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../constants/notifications';
|
||||
import {HyperActions} from '../hyper';
|
||||
|
||||
export function dismissNotification(id: string): HyperActions {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import type {Session} from '../../typings/common';
|
||||
import rpc from '../rpc';
|
||||
import {keys} from '../utils/object';
|
||||
import findBySession from '../utils/term-groups';
|
||||
import {
|
||||
SESSION_ADD,
|
||||
SESSION_RESIZE,
|
||||
|
|
@ -11,14 +13,12 @@ import {
|
|||
SESSION_CLEAR_ACTIVE,
|
||||
SESSION_USER_DATA,
|
||||
SESSION_SET_XTERM_TITLE,
|
||||
SESSION_SEARCH
|
||||
} from '../../typings/constants/sessions';
|
||||
import type {HyperState, HyperDispatch, HyperActions} from '../../typings/hyper';
|
||||
import rpc from '../rpc';
|
||||
import {keys} from '../utils/object';
|
||||
import findBySession from '../utils/term-groups';
|
||||
SESSION_SEARCH,
|
||||
SESSION_SEARCH_CLOSE
|
||||
} from '../constants/sessions';
|
||||
import {HyperState, session, HyperDispatch, HyperActions} from '../hyper';
|
||||
|
||||
export function addSession({uid, shell, pid, cols = null, rows = null, splitDirection, activeUid, profile}: Session) {
|
||||
export function addSession({uid, shell, pid, cols, rows, splitDirection, activeUid}: session) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
const {sessions} = getState();
|
||||
const now = Date.now();
|
||||
|
|
@ -31,20 +31,20 @@ export function addSession({uid, shell, pid, cols = null, rows = null, splitDire
|
|||
rows,
|
||||
splitDirection,
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid,
|
||||
now,
|
||||
profile
|
||||
now
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function requestSession(profile: string | undefined) {
|
||||
export function requestSession() {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
dispatch({
|
||||
type: SESSION_REQUEST,
|
||||
effect: () => {
|
||||
const {ui} = getState();
|
||||
const {cwd} = ui;
|
||||
rpc.emit('new', {cwd, profile});
|
||||
// the cols and rows from preview session maybe not accurate. so remove.
|
||||
const {/*cols, rows,*/ cwd} = ui;
|
||||
rpc.emit('new', {cwd});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -135,13 +135,12 @@ export function resizeSession(uid: string, cols: number, rows: number) {
|
|||
};
|
||||
}
|
||||
|
||||
export function openSearch(uid?: string) {
|
||||
export function onSearch(uid?: string) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
const targetUid = uid || getState().sessions.activeUid!;
|
||||
dispatch({
|
||||
type: SESSION_SEARCH,
|
||||
uid: targetUid,
|
||||
value: new Date()
|
||||
uid: targetUid
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
@ -151,9 +150,8 @@ export function closeSearch(uid?: string, keyEvent?: any) {
|
|||
const targetUid = uid || getState().sessions.activeUid!;
|
||||
if (getState().sessions.sessions[targetUid]?.search) {
|
||||
dispatch({
|
||||
type: SESSION_SEARCH,
|
||||
uid: targetUid,
|
||||
value: null
|
||||
type: SESSION_SEARCH_CLOSE,
|
||||
uid: targetUid
|
||||
});
|
||||
} else {
|
||||
if (keyEvent) {
|
||||
|
|
@ -163,7 +161,7 @@ export function closeSearch(uid?: string, keyEvent?: any) {
|
|||
};
|
||||
}
|
||||
|
||||
export function sendSessionData(uid: string | null, data: string, escaped?: boolean) {
|
||||
export function sendSessionData(uid: string | null, data: any, escaped?: boolean | null) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
dispatch({
|
||||
type: SESSION_USER_DATA,
|
||||
|
|
|
|||
|
|
@ -1,32 +1,28 @@
|
|||
import {SESSION_REQUEST} from '../../typings/constants/sessions';
|
||||
import rpc from '../rpc';
|
||||
import {
|
||||
DIRECTION,
|
||||
TERM_GROUP_RESIZE,
|
||||
TERM_GROUP_REQUEST,
|
||||
TERM_GROUP_EXIT,
|
||||
TERM_GROUP_EXIT_ACTIVE
|
||||
} from '../../typings/constants/term-groups';
|
||||
import type {ITermState, ITermGroup, HyperState, HyperDispatch, HyperActions} from '../../typings/hyper';
|
||||
import rpc from '../rpc';
|
||||
import {getRootGroups} from '../selectors';
|
||||
} from '../constants/term-groups';
|
||||
import {SESSION_REQUEST} from '../constants/sessions';
|
||||
import findBySession from '../utils/term-groups';
|
||||
|
||||
import {getRootGroups} from '../selectors';
|
||||
import {setActiveSession, ptyExitSession, userExitSession} from './sessions';
|
||||
import {ITermState, ITermGroup, HyperState, HyperDispatch, HyperActions} from '../hyper';
|
||||
|
||||
function requestSplit(direction: 'VERTICAL' | 'HORIZONTAL') {
|
||||
return (_activeUid: string | undefined, _profile: string | undefined) =>
|
||||
return (activeUid: string) =>
|
||||
(dispatch: HyperDispatch, getState: () => HyperState): void => {
|
||||
dispatch({
|
||||
type: SESSION_REQUEST,
|
||||
effect: () => {
|
||||
const {ui, sessions} = getState();
|
||||
const activeUid = _activeUid ? _activeUid : sessions.activeUid;
|
||||
const profile = _profile ? _profile : activeUid ? sessions.sessions[activeUid].profile : window.profileName;
|
||||
rpc.emit('new', {
|
||||
splitDirection: direction,
|
||||
cwd: ui.cwd,
|
||||
activeUid,
|
||||
profile
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -44,20 +40,17 @@ export function resizeTermGroup(uid: string, sizes: number[]): HyperActions {
|
|||
};
|
||||
}
|
||||
|
||||
export function requestTermGroup(_activeUid: string | undefined, _profile: string | undefined) {
|
||||
export function requestTermGroup(activeUid: string) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
dispatch({
|
||||
type: TERM_GROUP_REQUEST,
|
||||
effect: () => {
|
||||
const {ui, sessions} = getState();
|
||||
const {ui} = getState();
|
||||
const {cwd} = ui;
|
||||
const activeUid = _activeUid ? _activeUid : sessions.activeUid;
|
||||
const profile = _profile ? _profile : activeUid ? sessions.sessions[activeUid].profile : window.profileName;
|
||||
rpc.emit('new', {
|
||||
isNewGroup: true,
|
||||
cwd,
|
||||
activeUid,
|
||||
profile
|
||||
activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import {stat} from 'fs';
|
||||
import type {Stats} from 'fs';
|
||||
|
||||
import type parseUrl from 'parse-url';
|
||||
import {php_escapeshellcmd as escapeShellCmd} from 'php-escape-shell';
|
||||
|
||||
import {isExecutable} from '../utils/file';
|
||||
import {getRootGroups} from '../selectors';
|
||||
import findBySession from '../utils/term-groups';
|
||||
import notify from '../utils/notify';
|
||||
import rpc from '../rpc';
|
||||
import {requestSession, sendSessionData, setActiveSession} from './sessions';
|
||||
import {
|
||||
UI_FONT_SIZE_SET,
|
||||
UI_FONT_SIZE_INCR,
|
||||
|
|
@ -23,18 +24,14 @@ import {
|
|||
UI_OPEN_SSH_URL,
|
||||
UI_CONTEXTMENU_OPEN,
|
||||
UI_COMMAND_EXEC
|
||||
} from '../../typings/constants/ui';
|
||||
import type {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../../typings/hyper';
|
||||
import rpc from '../rpc';
|
||||
import {getRootGroups} from '../selectors';
|
||||
import {isExecutable} from '../utils/file';
|
||||
import notify from '../utils/notify';
|
||||
import findBySession from '../utils/term-groups';
|
||||
} from '../constants/ui';
|
||||
|
||||
import {requestSession, sendSessionData, setActiveSession} from './sessions';
|
||||
import {setActiveGroup} from './term-groups';
|
||||
import parseUrl from 'parse-url';
|
||||
import {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../hyper';
|
||||
import {stat, Stats} from 'fs';
|
||||
|
||||
export function openContextMenu(uid: string, selection: string) {
|
||||
export function openContextMenu(uid: string, selection: any) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
dispatch({
|
||||
type: UI_CONTEXTMENU_OPEN,
|
||||
|
|
@ -105,10 +102,9 @@ export function setFontSmoothing() {
|
|||
};
|
||||
}
|
||||
|
||||
export function windowGeometryUpdated({isMaximized}: {isMaximized: boolean}): HyperActions {
|
||||
export function windowGeometryUpdated(): HyperActions {
|
||||
return {
|
||||
type: UI_WINDOW_GEOMETRY_CHANGED,
|
||||
isMaximized
|
||||
type: UI_WINDOW_GEOMETRY_CHANGED
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -272,11 +268,11 @@ export function openFile(path: string) {
|
|||
}
|
||||
rpc.once('session add', ({uid}) => {
|
||||
rpc.once('session data', () => {
|
||||
dispatch(sendSessionData(uid, command));
|
||||
dispatch(sendSessionData(uid, command, null));
|
||||
});
|
||||
});
|
||||
}
|
||||
dispatch(requestSession(undefined));
|
||||
dispatch(requestSession());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -295,11 +291,12 @@ export function leaveFullScreen(): HyperActions {
|
|||
};
|
||||
}
|
||||
|
||||
export function openSSH(parsedUrl: ReturnType<typeof parseUrl>) {
|
||||
export function openSSH(url: string) {
|
||||
return (dispatch: HyperDispatch) => {
|
||||
dispatch({
|
||||
type: UI_OPEN_SSH_URL,
|
||||
effect() {
|
||||
const parsedUrl = parseUrl(url, true);
|
||||
let command = `${parsedUrl.protocol} ${parsedUrl.user ? `${parsedUrl.user}@` : ''}${parsedUrl.resource}`;
|
||||
|
||||
if (parsedUrl.port) command += ` -p ${parsedUrl.port}`;
|
||||
|
|
@ -308,11 +305,11 @@ export function openSSH(parsedUrl: ReturnType<typeof parseUrl>) {
|
|||
|
||||
rpc.once('session add', ({uid}) => {
|
||||
rpc.once('session data', () => {
|
||||
dispatch(sendSessionData(uid, command));
|
||||
dispatch(sendSessionData(uid, command, null));
|
||||
});
|
||||
});
|
||||
|
||||
dispatch(requestSession(undefined));
|
||||
dispatch(requestSession());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../../typings/constants/updater';
|
||||
import type {HyperActions} from '../../typings/hyper';
|
||||
import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../constants/updater';
|
||||
import rpc from '../rpc';
|
||||
import {HyperActions} from '../hyper';
|
||||
|
||||
export function installUpdate(): HyperActions {
|
||||
return {
|
||||
type: UPDATE_INSTALL,
|
||||
effect: () => {
|
||||
rpc.emit('quit and install');
|
||||
rpc.emit('quit and install', null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
import type {HyperDispatch} from '../typings/hyper';
|
||||
|
||||
import {remote} from 'electron';
|
||||
import {HyperDispatch} from './hyper';
|
||||
import {closeSearch} from './actions/sessions';
|
||||
import {ipcRenderer} from './utils/ipc';
|
||||
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
|
||||
|
||||
const {getDecoratedKeymaps} = remote.require('./plugins') as typeof import('../app/plugins');
|
||||
|
||||
let commands: Record<string, (event: any, dispatch: HyperDispatch) => void> = {
|
||||
'editor:search-close': (e, dispatch) => {
|
||||
dispatch(closeSearch(undefined, e));
|
||||
window.focusActiveTerm();
|
||||
}
|
||||
};
|
||||
|
||||
export const getRegisteredKeys = async () => {
|
||||
const keymaps = await ipcRenderer.invoke('getDecoratedKeymaps');
|
||||
export const getRegisteredKeys = () => {
|
||||
const keymaps = getDecoratedKeymaps();
|
||||
|
||||
return Object.keys(keymaps).reduce((result: Record<string, string>, actionName) => {
|
||||
const commandKeys = keymaps[actionName];
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
import React, {forwardRef, useState} from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import type {HeaderProps} from '../../typings/hyper';
|
||||
import {decorate, getTabsProps} from '../utils/plugins';
|
||||
|
||||
import Tabs_ from './tabs';
|
||||
import {HeaderProps} from '../hyper';
|
||||
|
||||
const Tabs = decorate(Tabs_, 'Tabs');
|
||||
|
||||
const Header = forwardRef<HTMLElement, HeaderProps>((props, ref) => {
|
||||
const [headerMouseDownWindowX, setHeaderMouseDownWindowX] = useState<number>(0);
|
||||
const [headerMouseDownWindowY, setHeaderMouseDownWindowY] = useState<number>(0);
|
||||
export default class Header extends React.PureComponent<HeaderProps> {
|
||||
headerMouseDownWindowX!: number;
|
||||
headerMouseDownWindowY!: number;
|
||||
|
||||
const onChangeIntent = (active: string) => {
|
||||
onChangeIntent = (active: string) => {
|
||||
// we ignore clicks if they're a byproduct of a drag
|
||||
// motion to move the window
|
||||
if (window.screenX !== headerMouseDownWindowX || window.screenY !== headerMouseDownWindowY) {
|
||||
if (window.screenX !== this.headerMouseDownWindowX || window.screenY !== this.headerMouseDownWindowY) {
|
||||
return;
|
||||
}
|
||||
|
||||
props.onChangeTab(active);
|
||||
this.props.onChangeTab(active);
|
||||
};
|
||||
|
||||
const handleHeaderMouseDown = () => {
|
||||
handleHeaderMouseDown = () => {
|
||||
// the hack of all hacks, this prevents the term
|
||||
// iframe from losing focus, for example, when
|
||||
// the user drags the nav around
|
||||
|
|
@ -30,43 +30,43 @@ const Header = forwardRef<HTMLElement, HeaderProps>((props, ref) => {
|
|||
|
||||
// persist start positions of a potential drag motion
|
||||
// to differentiate dragging from clicking
|
||||
setHeaderMouseDownWindowX(window.screenX);
|
||||
setHeaderMouseDownWindowY(window.screenY);
|
||||
this.headerMouseDownWindowX = window.screenX;
|
||||
this.headerMouseDownWindowY = window.screenY;
|
||||
};
|
||||
|
||||
const handleHamburgerMenuClick = (event: React.MouseEvent) => {
|
||||
handleHamburgerMenuClick = (event: React.MouseEvent) => {
|
||||
let {right: x, bottom: y} = event.currentTarget.getBoundingClientRect();
|
||||
x -= 15; // to compensate padding
|
||||
y -= 12; // ^ same
|
||||
props.openHamburgerMenu({x, y});
|
||||
this.props.openHamburgerMenu({x, y});
|
||||
};
|
||||
|
||||
const handleMaximizeClick = () => {
|
||||
if (props.maximized) {
|
||||
props.unmaximize();
|
||||
handleMaximizeClick = () => {
|
||||
if (this.props.maximized) {
|
||||
this.props.unmaximize();
|
||||
} else {
|
||||
props.maximize();
|
||||
this.props.maximize();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMinimizeClick = () => {
|
||||
props.minimize();
|
||||
handleMinimizeClick = () => {
|
||||
this.props.minimize();
|
||||
};
|
||||
|
||||
const handleCloseClick = () => {
|
||||
props.close();
|
||||
handleCloseClick = () => {
|
||||
this.props.close();
|
||||
};
|
||||
|
||||
const getWindowHeaderConfig = () => {
|
||||
const {showHamburgerMenu, showWindowControls} = props;
|
||||
getWindowHeaderConfig() {
|
||||
const {showHamburgerMenu, showWindowControls} = this.props;
|
||||
|
||||
const defaults = {
|
||||
hambMenu: !props.isMac, // show by default on windows and linux
|
||||
winCtrls: !props.isMac // show by default on Windows and Linux
|
||||
hambMenu: !this.props.isMac, // show by default on windows and linux
|
||||
winCtrls: !this.props.isMac // show by default on Windows and Linux
|
||||
};
|
||||
|
||||
// don't allow the user to change defaults on macOS
|
||||
if (props.isMac) {
|
||||
if (this.props.isMac) {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
|
|
@ -74,187 +74,182 @@ const Header = forwardRef<HTMLElement, HeaderProps>((props, ref) => {
|
|||
hambMenu: showHamburgerMenu === '' ? defaults.hambMenu : showHamburgerMenu,
|
||||
winCtrls: showWindowControls === '' ? defaults.winCtrls : showWindowControls
|
||||
};
|
||||
};
|
||||
|
||||
const {isMac} = props;
|
||||
const {borderColor} = props;
|
||||
let title = 'Hyper';
|
||||
if (props.tabs.length === 1 && props.tabs[0].title) {
|
||||
// if there's only one tab we use its title as the window title
|
||||
title = props.tabs[0].title;
|
||||
}
|
||||
const {hambMenu, winCtrls} = getWindowHeaderConfig();
|
||||
const left = winCtrls === 'left';
|
||||
const maxButtonHref = props.maximized
|
||||
? './renderer/assets/icons.svg#restore-window'
|
||||
: './renderer/assets/icons.svg#maximize-window';
|
||||
|
||||
return (
|
||||
<header
|
||||
className={`header_header ${isMac && 'header_headerRounded'}`}
|
||||
onMouseDown={handleHeaderMouseDown}
|
||||
onMouseUp={() => window.focusActiveTerm()}
|
||||
onDoubleClick={handleMaximizeClick}
|
||||
ref={ref}
|
||||
>
|
||||
{!isMac && (
|
||||
<div
|
||||
className={`header_windowHeader ${props.tabs.length > 1 ? 'header_windowHeaderWithBorder' : ''}`}
|
||||
style={{borderColor}}
|
||||
>
|
||||
{hambMenu && (
|
||||
<svg
|
||||
className={`header_shape ${left ? 'header_hamburgerMenuRight' : 'header_hamburgerMenuLeft'}`}
|
||||
onClick={handleHamburgerMenuClick}
|
||||
>
|
||||
<use xlinkHref="./renderer/assets/icons.svg#hamburger-menu" />
|
||||
</svg>
|
||||
)}
|
||||
<span className="header_appTitle">{title}</span>
|
||||
{winCtrls && (
|
||||
<div className={`header_windowControls ${left ? 'header_windowControlsLeft' : ''}`}>
|
||||
<div className={`${left ? 'header_minimizeWindowLeft' : ''}`} onClick={handleMinimizeClick}>
|
||||
<svg className="header_shape">
|
||||
<use xlinkHref="./renderer/assets/icons.svg#minimize-window" />
|
||||
</svg>
|
||||
render() {
|
||||
const {isMac} = this.props;
|
||||
const props = getTabsProps(this.props, {
|
||||
tabs: this.props.tabs,
|
||||
borderColor: this.props.borderColor,
|
||||
onClose: this.props.onCloseTab,
|
||||
onChange: this.onChangeIntent,
|
||||
fullScreen: this.props.fullScreen
|
||||
});
|
||||
const {borderColor} = props;
|
||||
let title = 'Hyper';
|
||||
if (props.tabs.length === 1 && props.tabs[0].title) {
|
||||
// if there's only one tab we use its title as the window title
|
||||
title = props.tabs[0].title;
|
||||
}
|
||||
const {hambMenu, winCtrls} = this.getWindowHeaderConfig();
|
||||
const left = winCtrls === 'left';
|
||||
const maxButtonHref = this.props.maximized
|
||||
? './renderer/assets/icons.svg#restore-window'
|
||||
: './renderer/assets/icons.svg#maximize-window';
|
||||
|
||||
return (
|
||||
<header
|
||||
className={`header_header ${isMac && 'header_headerRounded'}`}
|
||||
onMouseDown={this.handleHeaderMouseDown}
|
||||
onMouseUp={() => window.focusActiveTerm()}
|
||||
onDoubleClick={this.handleMaximizeClick}
|
||||
>
|
||||
{!isMac && (
|
||||
<div
|
||||
className={`header_windowHeader ${props.tabs.length > 1 ? 'header_windowHeaderWithBorder' : ''}`}
|
||||
style={{borderColor}}
|
||||
>
|
||||
{hambMenu && (
|
||||
<svg
|
||||
className={`header_shape ${left ? 'header_hamburgerMenuRight' : 'header_hamburgerMenuLeft'}`}
|
||||
onClick={this.handleHamburgerMenuClick}
|
||||
>
|
||||
<use xlinkHref="./renderer/assets/icons.svg#hamburger-menu" />
|
||||
</svg>
|
||||
)}
|
||||
<span className="header_appTitle">{title}</span>
|
||||
{winCtrls && (
|
||||
<div className={`header_windowControls ${left ? 'header_windowControlsLeft' : ''}`}>
|
||||
<div className={`${left ? 'header_minimizeWindowLeft' : ''}`} onClick={this.handleMinimizeClick}>
|
||||
<svg className="header_shape">
|
||||
<use xlinkHref="./renderer/assets/icons.svg#minimize-window" />
|
||||
</svg>
|
||||
</div>
|
||||
<div className={`${left ? 'header_maximizeWindowLeft' : ''}`} onClick={this.handleMaximizeClick}>
|
||||
<svg className="header_shape">
|
||||
<use xlinkHref={maxButtonHref} />
|
||||
</svg>
|
||||
</div>
|
||||
<div
|
||||
className={`header_closeWindow ${left ? 'header_closeWindowLeft' : ''}`}
|
||||
onClick={this.handleCloseClick}
|
||||
>
|
||||
<svg className="header_shape">
|
||||
<use xlinkHref="./renderer/assets/icons.svg#close-window" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`${left ? 'header_maximizeWindowLeft' : ''}`} onClick={handleMaximizeClick}>
|
||||
<svg className="header_shape">
|
||||
<use xlinkHref={maxButtonHref} />
|
||||
</svg>
|
||||
</div>
|
||||
<div className={`header_closeWindow ${left ? 'header_closeWindowLeft' : ''}`} onClick={handleCloseClick}>
|
||||
<svg className="header_shape">
|
||||
<use xlinkHref="./renderer/assets/icons.svg#close-window" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{props.customChildrenBefore}
|
||||
<Tabs
|
||||
{...getTabsProps(props, {
|
||||
tabs: props.tabs,
|
||||
borderColor: props.borderColor,
|
||||
backgroundColor: props.backgroundColor,
|
||||
onClose: props.onCloseTab,
|
||||
onChange: onChangeIntent,
|
||||
fullScreen: props.fullScreen,
|
||||
defaultProfile: props.defaultProfile,
|
||||
profiles: props.profiles.asMutable({deep: true}),
|
||||
openNewTab: props.openNewTab
|
||||
})}
|
||||
/>
|
||||
{props.customChildren}
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{this.props.customChildrenBefore}
|
||||
<Tabs {...props} />
|
||||
{this.props.customChildren}
|
||||
|
||||
<style jsx>{`
|
||||
.header_header {
|
||||
position: fixed;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
right: 1px;
|
||||
z-index: 100;
|
||||
}
|
||||
<style jsx>{`
|
||||
.header_header {
|
||||
position: fixed;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
right: 1px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.header_headerRounded {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.header_headerRounded {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.header_windowHeader {
|
||||
height: 34px;
|
||||
width: 100%;
|
||||
position: fixed;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
right: 1px;
|
||||
-webkit-app-region: drag;
|
||||
-webkit-user-select: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.header_windowHeader {
|
||||
height: 34px;
|
||||
width: 100%;
|
||||
position: fixed;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
right: 1px;
|
||||
-webkit-app-region: drag;
|
||||
-webkit-user-select: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header_windowHeaderWithBorder {
|
||||
border-color: #ccc;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
.header_windowHeaderWithBorder {
|
||||
border-color: #ccc;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
|
||||
.header_appTitle {
|
||||
font-size: 12px;
|
||||
}
|
||||
.header_appTitle {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.header_shape,
|
||||
.header_shape > svg {
|
||||
width: 40px;
|
||||
height: 34px;
|
||||
padding: 12px 15px 12px 15px;
|
||||
-webkit-app-region: no-drag;
|
||||
color: #fff;
|
||||
opacity: 0.5;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
.header_shape,
|
||||
.header_shape > svg {
|
||||
width: 40px;
|
||||
height: 34px;
|
||||
padding: 12px 15px 12px 15px;
|
||||
-webkit-app-region: no-drag;
|
||||
color: #fff;
|
||||
opacity: 0.5;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
|
||||
.header_shape:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
.header_shape:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.header_shape:active {
|
||||
opacity: 0.3;
|
||||
}
|
||||
.header_shape:active {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.header_hamburgerMenuLeft {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.header_hamburgerMenuLeft {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.header_hamburgerMenuRight {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
.header_hamburgerMenuRight {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.header_windowControls {
|
||||
display: flex;
|
||||
width: 120px;
|
||||
height: 34px;
|
||||
justify-content: space-between;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
.header_windowControls {
|
||||
display: flex;
|
||||
width: 120px;
|
||||
height: 34px;
|
||||
justify-content: space-between;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.header_windowControlsLeft {
|
||||
left: 0px;
|
||||
}
|
||||
.header_windowControlsLeft {
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.header_closeWindowLeft {
|
||||
order: 1;
|
||||
}
|
||||
.header_closeWindowLeft {
|
||||
order: 1;
|
||||
}
|
||||
|
||||
.header_minimizeWindowLeft {
|
||||
order: 2;
|
||||
}
|
||||
.header_minimizeWindowLeft {
|
||||
order: 2;
|
||||
}
|
||||
|
||||
.header_maximizeWindowLeft {
|
||||
order: 3;
|
||||
}
|
||||
.header_maximizeWindowLeft {
|
||||
order: 3;
|
||||
}
|
||||
|
||||
.header_closeWindow:hover {
|
||||
color: #fe354e;
|
||||
}
|
||||
.header_closeWindow:hover {
|
||||
color: #fe354e;
|
||||
}
|
||||
|
||||
.header_closeWindow:active {
|
||||
color: #fe354e;
|
||||
}
|
||||
`}</style>
|
||||
</header>
|
||||
);
|
||||
});
|
||||
|
||||
Header.displayName = 'Header';
|
||||
|
||||
export default Header;
|
||||
.header_closeWindow:active {
|
||||
color: #fe354e;
|
||||
}
|
||||
`}</style>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,149 +0,0 @@
|
|||
import React, {useRef, useState} from 'react';
|
||||
|
||||
import {VscChevronDown} from '@react-icons/all-files/vsc/VscChevronDown';
|
||||
import useClickAway from 'react-use/lib/useClickAway';
|
||||
|
||||
import type {configOptions} from '../../typings/config';
|
||||
|
||||
interface Props {
|
||||
defaultProfile: string;
|
||||
profiles: configOptions['profiles'];
|
||||
openNewTab: (name: string) => void;
|
||||
backgroundColor: string;
|
||||
borderColor: string;
|
||||
tabsVisible: boolean;
|
||||
}
|
||||
const isMac = /Mac/.test(navigator.userAgent);
|
||||
|
||||
const DropdownButton = ({defaultProfile, profiles, openNewTab, backgroundColor, borderColor, tabsVisible}: Props) => {
|
||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||
const ref = useRef(null);
|
||||
|
||||
const toggleDropdown = () => {
|
||||
setDropdownOpen(!dropdownOpen);
|
||||
};
|
||||
|
||||
useClickAway(ref, () => {
|
||||
setDropdownOpen(false);
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
title="New Tab"
|
||||
className={`new_tab ${tabsVisible ? 'tabs_visible' : 'tabs_hidden'}`}
|
||||
onClick={toggleDropdown}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
onBlur={() => setDropdownOpen(false)}
|
||||
>
|
||||
<VscChevronDown style={{verticalAlign: 'middle'}} />
|
||||
|
||||
{dropdownOpen && (
|
||||
<ul
|
||||
key="dropdown"
|
||||
className="profile_dropdown"
|
||||
style={{
|
||||
borderColor,
|
||||
backgroundColor
|
||||
}}
|
||||
>
|
||||
{profiles.map((profile) => (
|
||||
<li
|
||||
key={profile.name}
|
||||
onClick={() => {
|
||||
openNewTab(profile.name);
|
||||
setDropdownOpen(false);
|
||||
}}
|
||||
className={`profile_dropdown_item ${
|
||||
profile.name === defaultProfile && profiles.length > 1 ? 'profile_dropdown_item_default' : ''
|
||||
}`}
|
||||
>
|
||||
{profile.name}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
<style jsx>{`
|
||||
.profile_dropdown {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-bottom-width: 0px;
|
||||
border-right-width: 0px;
|
||||
position: absolute;
|
||||
top: 33px;
|
||||
right: 0px;
|
||||
z-index: 1000;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
list-style-type: none;
|
||||
white-space: nowrap;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.profile_dropdown_item {
|
||||
padding: 0px 20px;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: transparent;
|
||||
border-width: 0px;
|
||||
border-style: solid;
|
||||
border-color: transparent;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-color: ${borderColor};
|
||||
text-align: start;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.profile_dropdown_item:hover {
|
||||
background-color: ${borderColor};
|
||||
}
|
||||
|
||||
.profile_dropdown_item_default {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.new_tab {
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
border-left: 1px;
|
||||
border-bottom: 1px;
|
||||
border-left-style: solid;
|
||||
border-bottom-style: solid;
|
||||
border-left-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
padding: 0 16px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
-webkit-user-select: none;
|
||||
${isMac ? '-webkit-app-region: drag;' : ''}
|
||||
top: '0px';
|
||||
}
|
||||
|
||||
.tabs_visible {
|
||||
border-color: ${borderColor};
|
||||
}
|
||||
|
||||
.tabs_hidden {
|
||||
border-color: transparent;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.tabs_hidden:hover {
|
||||
border-color: ${borderColor};
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DropdownButton;
|
||||
|
|
@ -1,110 +1,115 @@
|
|||
import React, {forwardRef, useEffect, useRef, useState} from 'react';
|
||||
import React from 'react';
|
||||
import {NotificationProps, NotificationState} from '../hyper';
|
||||
|
||||
import type {NotificationProps} from '../../typings/hyper';
|
||||
export default class Notification extends React.PureComponent<NotificationProps, NotificationState> {
|
||||
dismissTimer!: NodeJS.Timeout;
|
||||
constructor(props: NotificationProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
dismissing: false
|
||||
};
|
||||
}
|
||||
|
||||
const Notification = forwardRef<HTMLDivElement, React.PropsWithChildren<NotificationProps>>((props, ref) => {
|
||||
const dismissTimer = useRef<NodeJS.Timeout | undefined>(undefined);
|
||||
const [dismissing, setDismissing] = useState(false);
|
||||
componentDidMount() {
|
||||
if (this.props.dismissAfter) {
|
||||
this.setDismissTimer();
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setDismissTimer();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
componentDidUpdate(prevProps: NotificationProps, prevState: NotificationState) {
|
||||
// if we have a timer going and the notification text
|
||||
// changed we reset the timer
|
||||
resetDismissTimer();
|
||||
setDismissing(false);
|
||||
}, [props.text]);
|
||||
if (this.props.text !== prevProps.text) {
|
||||
if (prevProps.dismissAfter) {
|
||||
this.resetDismissTimer();
|
||||
}
|
||||
if (prevState.dismissing) {
|
||||
this.setState({dismissing: false});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleDismiss = () => {
|
||||
setDismissing(true);
|
||||
handleDismiss = () => {
|
||||
this.setState({dismissing: true});
|
||||
};
|
||||
|
||||
const onElement = (el: HTMLDivElement | null) => {
|
||||
onElement = (el: HTMLDivElement | null) => {
|
||||
if (el) {
|
||||
el.addEventListener('webkitTransitionEnd', () => {
|
||||
if (dismissing) {
|
||||
props.onDismiss();
|
||||
if (this.state.dismissing) {
|
||||
this.props.onDismiss();
|
||||
}
|
||||
});
|
||||
const {backgroundColor} = props;
|
||||
const {backgroundColor} = this.props;
|
||||
if (backgroundColor) {
|
||||
el.style.setProperty('background-color', backgroundColor, 'important');
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
if (typeof ref === 'function') ref(el);
|
||||
else ref.current = el;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const setDismissTimer = () => {
|
||||
if (typeof props.dismissAfter === 'number') {
|
||||
dismissTimer.current = setTimeout(() => {
|
||||
handleDismiss();
|
||||
}, props.dismissAfter);
|
||||
}
|
||||
};
|
||||
setDismissTimer() {
|
||||
this.dismissTimer = setTimeout(() => {
|
||||
this.handleDismiss();
|
||||
}, this.props.dismissAfter);
|
||||
}
|
||||
|
||||
const resetDismissTimer = () => {
|
||||
clearTimeout(dismissTimer.current);
|
||||
setDismissTimer();
|
||||
};
|
||||
resetDismissTimer() {
|
||||
clearTimeout(this.dismissTimer);
|
||||
this.setDismissTimer();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
clearTimeout(dismissTimer.current);
|
||||
};
|
||||
}, []);
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.dismissTimer);
|
||||
}
|
||||
|
||||
const {backgroundColor, color} = props;
|
||||
const opacity = dismissing ? 0 : 1;
|
||||
return (
|
||||
<div ref={onElement} style={{opacity, backgroundColor, color}} className="notification_indicator">
|
||||
{props.customChildrenBefore}
|
||||
{props.children || props.text}
|
||||
{props.userDismissable ? (
|
||||
<a className="notification_dismissLink" onClick={handleDismiss} style={{color: props.userDismissColor}}>
|
||||
[x]
|
||||
</a>
|
||||
) : null}
|
||||
{props.customChildren}
|
||||
render() {
|
||||
const {backgroundColor, color} = this.props;
|
||||
const opacity = this.state.dismissing ? 0 : 1;
|
||||
return (
|
||||
<div ref={this.onElement} style={{opacity, backgroundColor, color}} className="notification_indicator">
|
||||
{this.props.customChildrenBefore}
|
||||
{this.props.children || this.props.text}
|
||||
{this.props.userDismissable ? (
|
||||
<a
|
||||
className="notification_dismissLink"
|
||||
onClick={this.handleDismiss}
|
||||
style={{color: this.props.userDismissColor}}
|
||||
>
|
||||
[x]
|
||||
</a>
|
||||
) : null}
|
||||
{this.props.customChildren}
|
||||
|
||||
<style jsx>{`
|
||||
.notification_indicator {
|
||||
display: inline-block;
|
||||
cursor: default;
|
||||
-webkit-user-select: none;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 8px 14px 9px;
|
||||
margin-left: 10px;
|
||||
transition: 150ms opacity ease;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
|
||||
'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
<style jsx>{`
|
||||
.notification_indicator {
|
||||
display: inline-block;
|
||||
cursor: default;
|
||||
-webkit-user-select: none;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 8px 14px 9px;
|
||||
margin-left: 10px;
|
||||
transition: 150ms opacity ease;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
|
||||
'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
.notification_dismissLink {
|
||||
position: relative;
|
||||
left: 4px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
color: currentColor;
|
||||
transition: font-weight 0.1s ease-in-out;
|
||||
}
|
||||
.notification_dismissLink {
|
||||
position: relative;
|
||||
left: 4px;
|
||||
cursor: pointer;
|
||||
opacity: 0.5;
|
||||
color: currentColor;
|
||||
transition: opacity 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
.notification_dismissLink:hover,
|
||||
.notification_dismissLink:focus {
|
||||
font-weight: 900;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
Notification.displayName = 'Notification';
|
||||
|
||||
export default Notification;
|
||||
.notification_dismissLink:hover,
|
||||
.notification_dismissLink:focus {
|
||||
opacity: 1;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,132 +1,132 @@
|
|||
import React, {forwardRef} from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import type {NotificationsProps} from '../../typings/hyper';
|
||||
import {decorate} from '../utils/plugins';
|
||||
|
||||
import Notification_ from './notification';
|
||||
import {NotificationsProps} from '../hyper';
|
||||
|
||||
const Notification = decorate(Notification_, 'Notification');
|
||||
|
||||
const Notifications = forwardRef<HTMLDivElement, NotificationsProps>((props, ref) => {
|
||||
return (
|
||||
<div className="notifications_view" ref={ref}>
|
||||
{props.customChildrenBefore}
|
||||
{props.fontShowing && (
|
||||
<Notification
|
||||
key="font"
|
||||
backgroundColor="rgba(255, 255, 255, .2)"
|
||||
text={`${props.fontSize}px`}
|
||||
userDismissable={false}
|
||||
onDismiss={props.onDismissFont}
|
||||
dismissAfter={1000}
|
||||
/>
|
||||
)}
|
||||
export default class Notifications extends React.PureComponent<NotificationsProps> {
|
||||
render() {
|
||||
return (
|
||||
<div className="notifications_view">
|
||||
{this.props.customChildrenBefore}
|
||||
{this.props.fontShowing && (
|
||||
<Notification
|
||||
key="font"
|
||||
backgroundColor="rgba(255, 255, 255, .2)"
|
||||
text={`${this.props.fontSize}px`}
|
||||
userDismissable={false}
|
||||
onDismiss={this.props.onDismissFont}
|
||||
dismissAfter={1000}
|
||||
/>
|
||||
)}
|
||||
|
||||
{props.resizeShowing && (
|
||||
<Notification
|
||||
key="resize"
|
||||
backgroundColor="rgba(255, 255, 255, .2)"
|
||||
text={`${props.cols}x${props.rows}`}
|
||||
userDismissable={false}
|
||||
onDismiss={props.onDismissResize}
|
||||
dismissAfter={1000}
|
||||
/>
|
||||
)}
|
||||
{this.props.resizeShowing && (
|
||||
<Notification
|
||||
key="resize"
|
||||
backgroundColor="rgba(255, 255, 255, .2)"
|
||||
text={`${this.props.cols}x${this.props.rows}`}
|
||||
userDismissable={false}
|
||||
onDismiss={this.props.onDismissResize}
|
||||
dismissAfter={1000}
|
||||
/>
|
||||
)}
|
||||
|
||||
{props.messageShowing && (
|
||||
<Notification
|
||||
key="message"
|
||||
backgroundColor="#FE354E"
|
||||
color="#fff"
|
||||
text={props.messageText}
|
||||
onDismiss={props.onDismissMessage}
|
||||
userDismissable={props.messageDismissable}
|
||||
>
|
||||
{props.messageURL ? (
|
||||
<>
|
||||
{props.messageText} (
|
||||
<a
|
||||
style={{color: '#fff'}}
|
||||
onClick={(ev) => {
|
||||
void window.require('electron').shell.openExternal(ev.currentTarget.href);
|
||||
ev.preventDefault();
|
||||
}}
|
||||
href={props.messageURL}
|
||||
>
|
||||
more
|
||||
</a>
|
||||
)
|
||||
</>
|
||||
) : null}
|
||||
</Notification>
|
||||
)}
|
||||
|
||||
{props.updateShowing && (
|
||||
<Notification
|
||||
key="update"
|
||||
backgroundColor="#18E179"
|
||||
color="#000"
|
||||
text={`Version ${props.updateVersion} ready`}
|
||||
onDismiss={props.onDismissUpdate}
|
||||
userDismissable
|
||||
>
|
||||
Version <b>{props.updateVersion}</b> ready.
|
||||
{props.updateNote && ` ${props.updateNote.trim().replace(/\.$/, '')}`} (
|
||||
<a
|
||||
style={{color: '#000'}}
|
||||
onClick={(ev) => {
|
||||
void window.require('electron').shell.openExternal(ev.currentTarget.href);
|
||||
ev.preventDefault();
|
||||
}}
|
||||
href={`https://github.com/quine-global/hyper/releases/tag/${props.updateVersion}`}
|
||||
{this.props.messageShowing && (
|
||||
<Notification
|
||||
key="message"
|
||||
backgroundColor="#FE354E"
|
||||
text={this.props.messageText}
|
||||
onDismiss={this.props.onDismissMessage}
|
||||
userDismissable={this.props.messageDismissable}
|
||||
userDismissColor="#AA2D3C"
|
||||
>
|
||||
notes
|
||||
</a>
|
||||
).{' '}
|
||||
{props.updateCanInstall ? (
|
||||
{this.props.messageURL
|
||||
? [
|
||||
this.props.messageText,
|
||||
' (',
|
||||
<a
|
||||
key="link"
|
||||
style={{color: '#fff'}}
|
||||
onClick={(ev) => {
|
||||
void window.require('electron').shell.openExternal(ev.currentTarget.href);
|
||||
ev.preventDefault();
|
||||
}}
|
||||
href={this.props.messageURL}
|
||||
>
|
||||
more
|
||||
</a>,
|
||||
')'
|
||||
]
|
||||
: null}
|
||||
</Notification>
|
||||
)}
|
||||
|
||||
{this.props.updateShowing && (
|
||||
<Notification
|
||||
key="update"
|
||||
backgroundColor="#18E179"
|
||||
color="#000"
|
||||
text={`Version ${this.props.updateVersion} ready`}
|
||||
onDismiss={this.props.onDismissUpdate}
|
||||
userDismissable
|
||||
>
|
||||
Version <b>{this.props.updateVersion}</b> ready.
|
||||
{this.props.updateNote && ` ${this.props.updateNote.trim().replace(/\.$/, '')}`} (
|
||||
<a
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 'bold'
|
||||
}}
|
||||
onClick={props.onUpdateInstall}
|
||||
>
|
||||
Restart
|
||||
</a>
|
||||
) : (
|
||||
<a
|
||||
style={{
|
||||
color: '#000',
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 'bold'
|
||||
}}
|
||||
style={{color: '#000'}}
|
||||
onClick={(ev) => {
|
||||
void window.require('electron').shell.openExternal(ev.currentTarget.href);
|
||||
ev.preventDefault();
|
||||
}}
|
||||
href={props.updateReleaseUrl!}
|
||||
href={`https://github.com/vercel/hyper/releases/tag/${this.props.updateVersion}`}
|
||||
>
|
||||
Download
|
||||
notes
|
||||
</a>
|
||||
)}
|
||||
.{' '}
|
||||
</Notification>
|
||||
)}
|
||||
{props.customChildren}
|
||||
).{' '}
|
||||
{this.props.updateCanInstall ? (
|
||||
<a
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 'bold'
|
||||
}}
|
||||
onClick={this.props.onUpdateInstall}
|
||||
>
|
||||
Restart
|
||||
</a>
|
||||
) : (
|
||||
<a
|
||||
style={{
|
||||
color: '#000',
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 'bold'
|
||||
}}
|
||||
onClick={(ev) => {
|
||||
void window.require('electron').shell.openExternal(ev.currentTarget.href);
|
||||
ev.preventDefault();
|
||||
}}
|
||||
href={this.props.updateReleaseUrl!}
|
||||
>
|
||||
Download
|
||||
</a>
|
||||
)}
|
||||
.{' '}
|
||||
</Notification>
|
||||
)}
|
||||
{this.props.customChildren}
|
||||
|
||||
<style jsx>{`
|
||||
.notifications_view {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
Notifications.displayName = 'Notifications';
|
||||
|
||||
export default Notifications;
|
||||
<style jsx>{`
|
||||
.notifications_view {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,246 +1,80 @@
|
|||
import React, {useCallback, useRef, useEffect, forwardRef} from 'react';
|
||||
import React from 'react';
|
||||
import {SearchBoxProps} from '../hyper';
|
||||
|
||||
import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown';
|
||||
import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp';
|
||||
import {VscCaseSensitive} from '@react-icons/all-files/vsc/VscCaseSensitive';
|
||||
import {VscClose} from '@react-icons/all-files/vsc/VscClose';
|
||||
import {VscRegex} from '@react-icons/all-files/vsc/VscRegex';
|
||||
import {VscWholeWord} from '@react-icons/all-files/vsc/VscWholeWord';
|
||||
import clsx from 'clsx';
|
||||
|
||||
import type {SearchBoxProps} from '../../typings/hyper';
|
||||
|
||||
type SearchButtonColors = {
|
||||
foregroundColor: string;
|
||||
selectionColor: string;
|
||||
backgroundColor: string;
|
||||
const searchBoxStyling: React.CSSProperties = {
|
||||
float: 'right',
|
||||
height: '28px',
|
||||
backgroundColor: 'white',
|
||||
position: 'absolute',
|
||||
right: '10px',
|
||||
top: '0px',
|
||||
width: '224px',
|
||||
zIndex: 9999
|
||||
};
|
||||
|
||||
type SearchButtonProps = React.PropsWithChildren<
|
||||
{
|
||||
onClick: () => void;
|
||||
active: boolean;
|
||||
title: string;
|
||||
} & SearchButtonColors
|
||||
>;
|
||||
const enterKey = 13;
|
||||
|
||||
const SearchButton = ({
|
||||
onClick,
|
||||
active,
|
||||
title,
|
||||
foregroundColor,
|
||||
backgroundColor,
|
||||
selectionColor,
|
||||
children
|
||||
}: SearchButtonProps) => {
|
||||
const handleKeyUp = useCallback(
|
||||
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
onClick();
|
||||
}
|
||||
},
|
||||
[onClick]
|
||||
);
|
||||
export default class SearchBox extends React.PureComponent<SearchBoxProps> {
|
||||
searchTerm: string;
|
||||
constructor(props: SearchBoxProps) {
|
||||
super(props);
|
||||
this.searchTerm = '';
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={clsx('search-button', {'search-button-active': active})}
|
||||
tabIndex={0}
|
||||
onKeyUp={handleKeyUp}
|
||||
title={title}
|
||||
>
|
||||
{children}
|
||||
<style jsx>
|
||||
{`
|
||||
.search-button {
|
||||
cursor: pointer;
|
||||
color: ${foregroundColor};
|
||||
padding: 2px;
|
||||
margin: 4px 0px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.search-button:focus {
|
||||
outline: ${selectionColor} solid 2px;
|
||||
}
|
||||
|
||||
.search-button:hover {
|
||||
background-color: ${backgroundColor};
|
||||
}
|
||||
|
||||
.search-button-active {
|
||||
background-color: ${selectionColor};
|
||||
}
|
||||
|
||||
.search-button-active:hover {
|
||||
background-color: ${selectionColor};
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const SearchBox = forwardRef<HTMLDivElement, SearchBoxProps>((props, ref) => {
|
||||
const {
|
||||
caseSensitive,
|
||||
dateFocused,
|
||||
wholeWord,
|
||||
regex,
|
||||
results,
|
||||
toggleCaseSensitive,
|
||||
toggleWholeWord,
|
||||
toggleRegex,
|
||||
next,
|
||||
prev,
|
||||
close,
|
||||
backgroundColor,
|
||||
foregroundColor,
|
||||
borderColor,
|
||||
selectionColor,
|
||||
font
|
||||
} = props;
|
||||
|
||||
const searchTermRef = useRef<string>('');
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
searchTermRef.current = event.currentTarget.value;
|
||||
if (event.shiftKey && event.key === 'Enter') {
|
||||
prev(searchTermRef.current);
|
||||
} else if (event.key === 'Enter') {
|
||||
next(searchTermRef.current);
|
||||
}
|
||||
},
|
||||
[prev, next]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
inputRef.current?.focus();
|
||||
}, [inputRef.current]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!dateFocused) {
|
||||
return;
|
||||
handleChange = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
this.searchTerm = event.currentTarget.value;
|
||||
if (event.keyCode === enterKey) {
|
||||
this.props.search(event.currentTarget.value);
|
||||
}
|
||||
inputRef.current?.focus();
|
||||
inputRef.current?.select();
|
||||
}, [dateFocused]);
|
||||
|
||||
const searchButtonColors: SearchButtonColors = {
|
||||
backgroundColor: borderColor,
|
||||
selectionColor,
|
||||
foregroundColor
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex-row search-container" ref={ref}>
|
||||
<div className="flex-row search-box">
|
||||
<input className="search-input" type="text" onKeyDown={handleChange} ref={inputRef} placeholder="Search" />
|
||||
render() {
|
||||
return (
|
||||
<div style={searchBoxStyling}>
|
||||
<input type="text" className="search-box" onKeyUp={this.handleChange} ref={(input) => input?.focus()} />
|
||||
<svg className="search-button" onClick={() => this.props.prev(this.searchTerm)}>
|
||||
<use xlinkHref="./renderer/assets/search-icons.svg#left-arrow" />
|
||||
</svg>
|
||||
<svg className="search-button" onClick={() => this.props.next(this.searchTerm)}>
|
||||
<use xlinkHref="./renderer/assets/search-icons.svg#right-arrow" />
|
||||
</svg>
|
||||
<svg className="search-button" onClick={() => this.props.close()}>
|
||||
<use xlinkHref="./renderer/assets/search-icons.svg#cancel" />
|
||||
</svg>
|
||||
<style jsx>
|
||||
{`
|
||||
.search-box {
|
||||
font-size: 18px;
|
||||
padding: 3px 6px;
|
||||
width: 152px;
|
||||
border: none;
|
||||
float: left;
|
||||
}
|
||||
|
||||
<SearchButton onClick={toggleCaseSensitive} active={caseSensitive} title="Match Case" {...searchButtonColors}>
|
||||
<VscCaseSensitive size="14px" />
|
||||
</SearchButton>
|
||||
.search-box:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
<SearchButton onClick={toggleWholeWord} active={wholeWord} title="Match Whole Word" {...searchButtonColors}>
|
||||
<VscWholeWord size="14px" />
|
||||
</SearchButton>
|
||||
|
||||
<SearchButton onClick={toggleRegex} active={regex} title="Use Regular Expression" {...searchButtonColors}>
|
||||
<VscRegex size="14px" />
|
||||
</SearchButton>
|
||||
.search-button {
|
||||
background-color: #ffffff;
|
||||
color: black;
|
||||
padding: 7px 5.5px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
transition-duration: 0.4s;
|
||||
cursor: pointer;
|
||||
height: 27px;
|
||||
width: 24px;
|
||||
float: left;
|
||||
}
|
||||
.search-button:hover {
|
||||
background-color: #e7e7e7;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</div>
|
||||
|
||||
<span style={{minWidth: '60px', marginLeft: '4px'}}>
|
||||
{results === undefined
|
||||
? ''
|
||||
: results.resultCount === 0
|
||||
? 'No results'
|
||||
: `${results.resultIndex + 1} of ${results.resultCount}`}
|
||||
</span>
|
||||
|
||||
<div className="flex-row">
|
||||
<SearchButton
|
||||
onClick={() => prev(searchTermRef.current)}
|
||||
active={false}
|
||||
title="Previous Match"
|
||||
{...searchButtonColors}
|
||||
>
|
||||
<VscArrowUp size="14px" />
|
||||
</SearchButton>
|
||||
|
||||
<SearchButton
|
||||
onClick={() => next(searchTermRef.current)}
|
||||
active={false}
|
||||
title="Next Match"
|
||||
{...searchButtonColors}
|
||||
>
|
||||
<VscArrowDown size="14px" />
|
||||
</SearchButton>
|
||||
|
||||
<SearchButton onClick={close} active={false} title="Close" {...searchButtonColors}>
|
||||
<VscClose size="14px" />
|
||||
</SearchButton>
|
||||
</div>
|
||||
|
||||
<style jsx>
|
||||
{`
|
||||
.search-container {
|
||||
background-color: ${backgroundColor};
|
||||
border: 1px solid ${borderColor};
|
||||
border-radius: 2px;
|
||||
position: absolute;
|
||||
right: 13px;
|
||||
top: 4px;
|
||||
z-index: 10;
|
||||
padding: 4px;
|
||||
font-family: ${font};
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
color: ${foregroundColor};
|
||||
align-self: stretch;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.flex-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
outline: ${borderColor} solid 1px;
|
||||
background-color: ${backgroundColor};
|
||||
color: ${foregroundColor};
|
||||
padding: 0px 4px;
|
||||
}
|
||||
|
||||
.search-input::placeholder {
|
||||
color: ${foregroundColor};
|
||||
}
|
||||
|
||||
.search-box:focus-within {
|
||||
outline: ${selectionColor} solid 2px;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
SearchBox.displayName = 'SearchBox';
|
||||
|
||||
export default SearchBox;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,191 +1,219 @@
|
|||
import React, {useState, useEffect, useRef, forwardRef} from 'react';
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import {SplitPaneProps} from '../hyper';
|
||||
|
||||
import sum from 'lodash/sum';
|
||||
export default class SplitPane extends React.PureComponent<SplitPaneProps, {dragging: boolean}> {
|
||||
dragPanePosition!: number;
|
||||
dragTarget!: Element;
|
||||
panes!: Element[];
|
||||
paneIndex!: number;
|
||||
d1!: 'height' | 'width';
|
||||
d2!: 'top' | 'left';
|
||||
d3!: 'clientX' | 'clientY';
|
||||
panesSize!: number;
|
||||
dragging!: boolean;
|
||||
constructor(props: SplitPaneProps) {
|
||||
super(props);
|
||||
this.state = {dragging: false};
|
||||
}
|
||||
|
||||
import type {SplitPaneProps} from '../../typings/hyper';
|
||||
componentDidUpdate(prevProps: SplitPaneProps) {
|
||||
if (this.state.dragging && prevProps.sizes !== this.props.sizes) {
|
||||
// recompute positions for ongoing dragging
|
||||
this.dragPanePosition = this.dragTarget.getBoundingClientRect()[this.d2];
|
||||
}
|
||||
}
|
||||
|
||||
const SplitPane = forwardRef<HTMLDivElement, SplitPaneProps>((props, ref) => {
|
||||
const dragPanePosition = useRef<number>(0);
|
||||
const dragTarget = useRef<HTMLDivElement | null>(null);
|
||||
const paneIndex = useRef<number>(0);
|
||||
const d1 = props.direction === 'horizontal' ? 'height' : 'width';
|
||||
const d2 = props.direction === 'horizontal' ? 'top' : 'left';
|
||||
const d3 = props.direction === 'horizontal' ? 'clientY' : 'clientX';
|
||||
const panesSize = useRef<number | null>(null);
|
||||
const [dragging, setDragging] = useState(false);
|
||||
setupPanes(ev: any) {
|
||||
this.panes = Array.from(ev.target.parentNode.childNodes);
|
||||
this.paneIndex = this.panes.indexOf(ev.target);
|
||||
this.paneIndex -= Math.ceil(this.paneIndex / 2);
|
||||
}
|
||||
|
||||
const handleAutoResize = (ev: React.MouseEvent<HTMLDivElement>, index: number) => {
|
||||
handleAutoResize = (ev: React.MouseEvent) => {
|
||||
ev.preventDefault();
|
||||
|
||||
paneIndex.current = index;
|
||||
this.setupPanes(ev);
|
||||
|
||||
const sizes_ = getSizes();
|
||||
sizes_[paneIndex.current] = 0;
|
||||
sizes_[paneIndex.current + 1] = 0;
|
||||
const sizes_ = this.getSizes();
|
||||
sizes_[this.paneIndex] = 0;
|
||||
sizes_[this.paneIndex + 1] = 0;
|
||||
|
||||
const availableWidth = 1 - sum(sizes_);
|
||||
sizes_[paneIndex.current] = availableWidth / 2;
|
||||
sizes_[paneIndex.current + 1] = availableWidth / 2;
|
||||
const availableWidth = 1 - _.sum(sizes_);
|
||||
sizes_[this.paneIndex] = availableWidth / 2;
|
||||
sizes_[this.paneIndex + 1] = availableWidth / 2;
|
||||
|
||||
props.onResize(sizes_);
|
||||
this.props.onResize(sizes_);
|
||||
};
|
||||
|
||||
const handleDragStart = (ev: React.MouseEvent<HTMLDivElement>, index: number) => {
|
||||
handleDragStart = (ev: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
ev.preventDefault();
|
||||
setDragging(true);
|
||||
window.addEventListener('mousemove', onDrag);
|
||||
window.addEventListener('mouseup', onDragEnd);
|
||||
this.setState({dragging: true});
|
||||
window.addEventListener('mousemove', this.onDrag);
|
||||
window.addEventListener('mouseup', this.onDragEnd);
|
||||
|
||||
const target = ev.target as HTMLDivElement;
|
||||
dragTarget.current = target;
|
||||
dragPanePosition.current = dragTarget.current.getBoundingClientRect()[d2];
|
||||
panesSize.current = target.parentElement!.getBoundingClientRect()[d1];
|
||||
paneIndex.current = index;
|
||||
// dimensions to consider
|
||||
if (this.props.direction === 'horizontal') {
|
||||
this.d1 = 'height';
|
||||
this.d2 = 'top';
|
||||
this.d3 = 'clientY';
|
||||
} else {
|
||||
this.d1 = 'width';
|
||||
this.d2 = 'left';
|
||||
this.d3 = 'clientX';
|
||||
}
|
||||
|
||||
this.dragTarget = ev.target;
|
||||
this.dragPanePosition = this.dragTarget.getBoundingClientRect()[this.d2];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
this.panesSize = ev.target.parentNode.getBoundingClientRect()[this.d1];
|
||||
this.setupPanes(ev);
|
||||
};
|
||||
|
||||
const getSizes = () => {
|
||||
const {sizes} = props;
|
||||
getSizes() {
|
||||
const {sizes} = this.props;
|
||||
let sizes_: number[];
|
||||
|
||||
if (sizes) {
|
||||
sizes_ = [...sizes.asMutable()];
|
||||
} else {
|
||||
const total = props.children.length;
|
||||
const total = (this.props.children as React.ReactNodeArray).length;
|
||||
const count = new Array<number>(total).fill(1 / total);
|
||||
|
||||
sizes_ = count;
|
||||
}
|
||||
return sizes_;
|
||||
};
|
||||
}
|
||||
|
||||
const onDrag = (ev: MouseEvent) => {
|
||||
const sizes_ = getSizes();
|
||||
onDrag = (ev: MouseEvent) => {
|
||||
const sizes_ = this.getSizes();
|
||||
|
||||
const i = paneIndex.current;
|
||||
const pos = ev[d3];
|
||||
const d = Math.abs(dragPanePosition.current - pos) / panesSize.current!;
|
||||
if (pos > dragPanePosition.current) {
|
||||
const i = this.paneIndex;
|
||||
const pos = ev[this.d3];
|
||||
const d = Math.abs(this.dragPanePosition - pos) / this.panesSize;
|
||||
if (pos > this.dragPanePosition) {
|
||||
sizes_[i] += d;
|
||||
sizes_[i + 1] -= d;
|
||||
} else {
|
||||
sizes_[i] -= d;
|
||||
sizes_[i + 1] += d;
|
||||
}
|
||||
props.onResize(sizes_);
|
||||
this.props.onResize(sizes_);
|
||||
};
|
||||
|
||||
const onDragEnd = () => {
|
||||
window.removeEventListener('mousemove', onDrag);
|
||||
window.removeEventListener('mouseup', onDragEnd);
|
||||
setDragging(false);
|
||||
onDragEnd = () => {
|
||||
if (this.state.dragging) {
|
||||
window.removeEventListener('mousemove', this.onDrag);
|
||||
window.removeEventListener('mouseup', this.onDragEnd);
|
||||
this.setState({dragging: false});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
onDragEnd();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const {children, direction, borderColor} = props;
|
||||
const sizeProperty = direction === 'horizontal' ? 'height' : 'width';
|
||||
// workaround for the fact that if we don't specify
|
||||
// sizes, sometimes flex fails to calculate the
|
||||
// right height for the horizontal panes
|
||||
const sizes = props.sizes || new Array<number>(children.length).fill(1 / children.length);
|
||||
return (
|
||||
<div className={`splitpane_panes splitpane_panes_${direction}`} ref={ref}>
|
||||
{children.map((child, i) => {
|
||||
const style = {
|
||||
// flexBasis doesn't work for the first horizontal pane, height need to be specified
|
||||
[sizeProperty]: `${sizes[i] * 100}%`,
|
||||
flexBasis: `${sizes[i] * 100}%`,
|
||||
flexGrow: 0
|
||||
};
|
||||
|
||||
return (
|
||||
<React.Fragment key={i}>
|
||||
<div className="splitpane_pane" style={style}>
|
||||
render() {
|
||||
const children = this.props.children as React.ReactNodeArray;
|
||||
const {direction, borderColor} = this.props;
|
||||
const sizeProperty = direction === 'horizontal' ? 'height' : 'width';
|
||||
// workaround for the fact that if we don't specify
|
||||
// sizes, sometimes flex fails to calculate the
|
||||
// right height for the horizontal panes
|
||||
const sizes = this.props.sizes || new Array<number>(children.length).fill(1 / children.length);
|
||||
return (
|
||||
<div className={`splitpane_panes splitpane_panes_${direction}`}>
|
||||
{React.Children.map(children, (child, i) => {
|
||||
const style = {
|
||||
// flexBasis doesn't work for the first horizontal pane, height need to be specified
|
||||
[sizeProperty]: `${sizes[i] * 100}%`,
|
||||
flexBasis: `${sizes[i] * 100}%`,
|
||||
flexGrow: 0
|
||||
};
|
||||
return [
|
||||
<div key="pane" className="splitpane_pane" style={style}>
|
||||
{child}
|
||||
</div>
|
||||
{i < children.length - 1 ? (
|
||||
</div>,
|
||||
i < children.length - 1 ? (
|
||||
<div
|
||||
onMouseDown={(e) => handleDragStart(e, i)}
|
||||
onDoubleClick={(e) => handleAutoResize(e, i)}
|
||||
key="divider"
|
||||
onMouseDown={this.handleDragStart}
|
||||
onDoubleClick={this.handleAutoResize}
|
||||
style={{backgroundColor: borderColor}}
|
||||
className={`splitpane_divider splitpane_divider_${direction}`}
|
||||
/>
|
||||
) : null}
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
<div style={{display: dragging ? 'block' : 'none'}} className="splitpane_shim" />
|
||||
) : null
|
||||
];
|
||||
})}
|
||||
<div style={{display: this.state.dragging ? 'block' : 'none'}} className="splitpane_shim" />
|
||||
|
||||
<style jsx>{`
|
||||
.splitpane_panes {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
outline: none;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
<style jsx>{`
|
||||
.splitpane_panes {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
outline: none;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.splitpane_panes_vertical {
|
||||
flex-direction: row;
|
||||
}
|
||||
.splitpane_panes_vertical {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.splitpane_panes_horizontal {
|
||||
flex-direction: column;
|
||||
}
|
||||
.splitpane_panes_horizontal {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.splitpane_pane {
|
||||
flex: 1;
|
||||
outline: none;
|
||||
position: relative;
|
||||
}
|
||||
.splitpane_pane {
|
||||
flex: 1;
|
||||
outline: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.splitpane_divider {
|
||||
box-sizing: border-box;
|
||||
z-index: 1;
|
||||
background-clip: padding-box;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.splitpane_divider {
|
||||
box-sizing: border-box;
|
||||
z-index: 1;
|
||||
background-clip: padding-box;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.splitpane_divider_vertical {
|
||||
border-left: 5px solid rgba(255, 255, 255, 0);
|
||||
border-right: 5px solid rgba(255, 255, 255, 0);
|
||||
width: 11px;
|
||||
margin: 0 -5px;
|
||||
cursor: col-resize;
|
||||
}
|
||||
.splitpane_divider_vertical {
|
||||
border-left: 5px solid rgba(255, 255, 255, 0);
|
||||
border-right: 5px solid rgba(255, 255, 255, 0);
|
||||
width: 11px;
|
||||
margin: 0 -5px;
|
||||
cursor: col-resize;
|
||||
}
|
||||
|
||||
.splitpane_divider_horizontal {
|
||||
height: 11px;
|
||||
margin: -5px 0;
|
||||
border-top: 5px solid rgba(255, 255, 255, 0);
|
||||
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: row-resize;
|
||||
width: 100%;
|
||||
}
|
||||
.splitpane_divider_horizontal {
|
||||
height: 11px;
|
||||
margin: -5px 0;
|
||||
border-top: 5px solid rgba(255, 255, 255, 0);
|
||||
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: row-resize;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/*
|
||||
this shim is used to make sure mousemove events
|
||||
trigger in all the draggable area of the screen
|
||||
this is not the case due to hterm's <iframe>
|
||||
*/
|
||||
.splitpane_shim {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: transparent;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
/*
|
||||
this shim is used to make sure mousemove events
|
||||
trigger in all the draggable area of the screen
|
||||
this is not the case due to hterm's <iframe>
|
||||
*/
|
||||
.splitpane_shim {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: transparent;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
SplitPane.displayName = 'SplitPane';
|
||||
|
||||
export default SplitPane;
|
||||
componentWillUnmount() {
|
||||
// ensure drag end
|
||||
if (this.dragging) {
|
||||
this.onDragEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,154 @@
|
|||
import React, {forwardRef} from 'react';
|
||||
import React from 'react';
|
||||
import {StyleSheetProps} from '../hyper';
|
||||
|
||||
import {useDevicePixelRatio} from 'use-device-pixel-ratio';
|
||||
export default class StyleSheet extends React.PureComponent<StyleSheetProps> {
|
||||
render() {
|
||||
const {backgroundColor, fontFamily, foregroundColor, borderColor} = this.props;
|
||||
|
||||
import type {StyleSheetProps} from '../../typings/hyper';
|
||||
return (
|
||||
<style jsx global>{`
|
||||
.xterm {
|
||||
font-family: ${fontFamily};
|
||||
font-feature-settings: 'liga' 0;
|
||||
position: relative;
|
||||
user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
const StyleSheet = forwardRef<HTMLStyleElement, StyleSheetProps>((props, ref) => {
|
||||
const {borderColor} = props;
|
||||
.xterm.focus,
|
||||
.xterm:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
const dpr = useDevicePixelRatio();
|
||||
.xterm .xterm-helpers {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
/**
|
||||
* The z-index of the helpers must be higher than the canvases in order for
|
||||
* IMEs to appear on top.
|
||||
*/
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
return (
|
||||
<style jsx global ref={ref}>{`
|
||||
::-webkit-scrollbar {
|
||||
width: ${5 * dpr}px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
background: ${borderColor};
|
||||
}
|
||||
::-webkit-scrollbar-thumb:window-inactive {
|
||||
background: ${borderColor};
|
||||
}
|
||||
`}</style>
|
||||
);
|
||||
});
|
||||
.xterm .xterm-helper-textarea {
|
||||
/*
|
||||
* HACK: to fix IE's blinking cursor
|
||||
* Move textarea out of the screen to the far left, so that the cursor is not visible.
|
||||
*/
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
left: -9999em;
|
||||
top: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
z-index: -10;
|
||||
/** Prevent wrapping so the IME appears against the textarea at the correct position */
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
StyleSheet.displayName = 'StyleSheet';
|
||||
.xterm .composition-view {
|
||||
/* TODO: Composition position got messed up somewhere */
|
||||
background: ${backgroundColor};
|
||||
color: ${foregroundColor};
|
||||
display: none;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
export default StyleSheet;
|
||||
.xterm .composition-view.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.xterm .xterm-viewport {
|
||||
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||
background-color: ${backgroundColor};
|
||||
overflow-y: scroll;
|
||||
cursor: default;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.xterm .xterm-screen {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.xterm canvas {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.xterm .xterm-scroll-area {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.xterm .xterm-char-measure-element {
|
||||
display: inline-block;
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
left: -9999em;
|
||||
}
|
||||
|
||||
.xterm {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.xterm.enable-mouse-events {
|
||||
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.xterm.xterm-cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.xterm.xterm-cursor-crosshair {
|
||||
/* Column selection mode */
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.xterm .xterm-accessibility,
|
||||
.xterm .xterm-message {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.xterm .xterm-accessibility-tree:focus [id^='xterm-active-item-'] {
|
||||
outline: 1px solid #f80;
|
||||
}
|
||||
|
||||
.xterm .live-region {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
background: ${borderColor};
|
||||
}
|
||||
::-webkit-scrollbar-thumb:window-inactive {
|
||||
background: ${borderColor};
|
||||
}
|
||||
`}</style>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,179 +1,164 @@
|
|||
import React, {useEffect, useRef} from 'react';
|
||||
import React from 'react';
|
||||
import {TabProps} from '../hyper';
|
||||
|
||||
import type {TabProps} from '../../typings/hyper';
|
||||
export default class Tab extends React.PureComponent<TabProps> {
|
||||
constructor(props: TabProps) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
const Tab = (props: TabProps) => {
|
||||
const handleClick = (event: React.MouseEvent) => {
|
||||
handleClick = (event: React.MouseEvent) => {
|
||||
const isLeftClick = event.nativeEvent.which === 1;
|
||||
|
||||
if (isLeftClick && !props.isActive) {
|
||||
props.onSelect();
|
||||
if (isLeftClick && !this.props.isActive) {
|
||||
this.props.onSelect();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseUp = (event: React.MouseEvent) => {
|
||||
handleMouseUp = (event: React.MouseEvent) => {
|
||||
const isMiddleClick = event.nativeEvent.which === 2;
|
||||
|
||||
if (isMiddleClick) {
|
||||
props.onClose();
|
||||
this.props.onClose();
|
||||
}
|
||||
};
|
||||
|
||||
const ref = useRef<HTMLLIElement>(null);
|
||||
render() {
|
||||
const {isActive, isFirst, isLast, borderColor, hasActivity} = this.props;
|
||||
|
||||
useEffect(() => {
|
||||
if (props.lastFocused) {
|
||||
ref?.current?.scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
}, [props.lastFocused]);
|
||||
|
||||
const {isActive, isFirst, isLast, borderColor, hasActivity} = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<li
|
||||
onClick={props.onClick}
|
||||
style={{borderColor}}
|
||||
className={`tab_tab ${isFirst ? 'tab_first' : ''} ${isActive ? 'tab_active' : ''} ${
|
||||
isFirst && isActive ? 'tab_firstActive' : ''
|
||||
} ${hasActivity ? 'tab_hasActivity' : ''}`}
|
||||
ref={ref}
|
||||
>
|
||||
{props.customChildrenBefore}
|
||||
<span
|
||||
className={`tab_text ${isLast ? 'tab_textLast' : ''} ${isActive ? 'tab_textActive' : ''}`}
|
||||
onClick={handleClick}
|
||||
onMouseUp={handleMouseUp}
|
||||
return (
|
||||
<React.Fragment>
|
||||
<li
|
||||
onClick={this.props.onClick}
|
||||
style={{borderColor}}
|
||||
className={`tab_tab ${isFirst ? 'tab_first' : ''} ${isActive ? 'tab_active' : ''} ${
|
||||
isFirst && isActive ? 'tab_firstActive' : ''
|
||||
} ${hasActivity ? 'tab_hasActivity' : ''}`}
|
||||
>
|
||||
<span title={props.text} className="tab_textInner">
|
||||
{props.text}
|
||||
{this.props.customChildrenBefore}
|
||||
<span
|
||||
className={`tab_text ${isLast ? 'tab_textLast' : ''} ${isActive ? 'tab_textActive' : ''}`}
|
||||
onClick={this.handleClick}
|
||||
onMouseUp={this.handleMouseUp}
|
||||
>
|
||||
<span title={this.props.text} className="tab_textInner">
|
||||
{this.props.text}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<i className="tab_icon" onClick={props.onClose}>
|
||||
<svg className="tab_shape">
|
||||
<use xlinkHref="./renderer/assets/icons.svg#close-tab" />
|
||||
</svg>
|
||||
</i>
|
||||
{props.customChildren}
|
||||
</li>
|
||||
<i className="tab_icon" onClick={this.props.onClose}>
|
||||
<svg className="tab_shape">
|
||||
<use xlinkHref="./renderer/assets/icons.svg#close-tab" />
|
||||
</svg>
|
||||
</i>
|
||||
{this.props.customChildren}
|
||||
</li>
|
||||
|
||||
<style jsx>{`
|
||||
.tab_tab {
|
||||
color: #ccc;
|
||||
border-color: #ccc;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
border-left-width: 1px;
|
||||
border-left-style: solid;
|
||||
list-style-type: none;
|
||||
flex-grow: 1;
|
||||
position: relative;
|
||||
min-width: 10em;
|
||||
}
|
||||
<style jsx>{`
|
||||
.tab_tab {
|
||||
color: #ccc;
|
||||
border-color: #ccc;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
border-left-width: 1px;
|
||||
border-left-style: solid;
|
||||
list-style-type: none;
|
||||
flex-grow: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab_tab:hover {
|
||||
color: #ccc;
|
||||
}
|
||||
.tab_tab:hover {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.tab_first {
|
||||
border-left-width: 0;
|
||||
padding-left: 1px;
|
||||
}
|
||||
.tab_first {
|
||||
border-left-width: 0;
|
||||
padding-left: 1px;
|
||||
}
|
||||
|
||||
.tab_firstActive {
|
||||
border-left-width: 1px;
|
||||
padding-left: 0;
|
||||
}
|
||||
.tab_firstActive {
|
||||
border-left-width: 1px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.tab_active {
|
||||
color: #fff;
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
.tab_active:hover {
|
||||
color: #fff;
|
||||
}
|
||||
.tab_active {
|
||||
color: #fff;
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
.tab_active:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tab_hasActivity {
|
||||
color: #50e3c2;
|
||||
}
|
||||
.tab_hasActivity {
|
||||
color: #50e3c2;
|
||||
}
|
||||
|
||||
.tab_hasActivity:hover {
|
||||
color: #50e3c2;
|
||||
}
|
||||
.tab_hasActivity:hover {
|
||||
color: #50e3c2;
|
||||
}
|
||||
|
||||
.tab_text {
|
||||
transition: color 0.2s ease;
|
||||
height: 34px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.tab_text {
|
||||
transition: color 0.2s ease;
|
||||
height: 34px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tab_textInner {
|
||||
position: absolute;
|
||||
left: 24px;
|
||||
right: 24px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
text-align: center;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.tab_textInner {
|
||||
position: absolute;
|
||||
left: 24px;
|
||||
right: 24px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
text-align: center;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tab_icon {
|
||||
transition:
|
||||
opacity 0.2s ease,
|
||||
color 0.2s ease,
|
||||
transform 0.25s ease,
|
||||
background-color 0.1s ease;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: 7px;
|
||||
top: 10px;
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 100%;
|
||||
color: #e9e9e9;
|
||||
opacity: 0;
|
||||
transform: scale(0.95);
|
||||
}
|
||||
.tab_icon {
|
||||
transition: opacity 0.2s ease, color 0.2s ease, transform 0.25s ease, background-color 0.1s ease;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: 7px;
|
||||
top: 10px;
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 100%;
|
||||
color: #e9e9e9;
|
||||
opacity: 0;
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.tab_icon:hover {
|
||||
background-color: rgba(255, 255, 255, 0.13);
|
||||
color: #fff;
|
||||
}
|
||||
.tab_icon:hover {
|
||||
background-color: rgba(255, 255, 255, 0.13);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tab_icon:active {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: #909090;
|
||||
}
|
||||
.tab_icon:active {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: #909090;
|
||||
}
|
||||
|
||||
.tab_tab:hover .tab_icon {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
pointer-events: all;
|
||||
}
|
||||
.tab_tab:hover .tab_icon {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.tab_shape {
|
||||
position: absolute;
|
||||
left: 4px;
|
||||
top: 4px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
vertical-align: middle;
|
||||
fill: currentColor;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
`}</style>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Tab.displayName = 'Tab';
|
||||
|
||||
export default Tab;
|
||||
.tab_shape {
|
||||
position: absolute;
|
||||
left: 4px;
|
||||
top: 4px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
vertical-align: middle;
|
||||
fill: currentColor;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
`}</style>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,142 +1,105 @@
|
|||
import React, {forwardRef, useEffect, useState} from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
import type {ITab, TabsProps} from '../../typings/hyper';
|
||||
import {decorate, getTabProps} from '../utils/plugins';
|
||||
|
||||
import DropdownButton from './new-tab';
|
||||
import Tab_ from './tab';
|
||||
import {TabsProps} from '../hyper';
|
||||
|
||||
const Tab = decorate(Tab_, 'Tab');
|
||||
const isMac = /Mac/.test(navigator.userAgent);
|
||||
|
||||
const Tabs = forwardRef<HTMLElement, TabsProps>((props, ref) => {
|
||||
const {tabs = [], borderColor, onChange, onClose, fullScreen} = props;
|
||||
export default class Tabs extends React.PureComponent<TabsProps> {
|
||||
render() {
|
||||
const {tabs = [], borderColor, onChange, onClose, fullScreen} = this.props;
|
||||
|
||||
const [shouldFocusCounter, setShouldFocusCounter] = useState({
|
||||
index: 0,
|
||||
when: undefined as Date | undefined
|
||||
});
|
||||
const hide = !isMac && tabs.length === 1;
|
||||
|
||||
const scrollToActiveTab = debounce((currTabs: ITab[]) => {
|
||||
const activeTab = currTabs.findIndex((t) => t.isActive);
|
||||
setShouldFocusCounter({
|
||||
index: activeTab,
|
||||
when: new Date()
|
||||
});
|
||||
}, 100);
|
||||
return (
|
||||
<nav className={`tabs_nav ${hide ? 'tabs_hiddenNav' : ''}`}>
|
||||
{this.props.customChildrenBefore}
|
||||
{tabs.length === 1 && isMac ? <div className="tabs_title">{tabs[0].title}</div> : null}
|
||||
{tabs.length > 1
|
||||
? [
|
||||
<ul key="list" className={`tabs_list ${fullScreen && isMac ? 'tabs_fullScreen' : ''}`}>
|
||||
{tabs.map((tab, i) => {
|
||||
const {uid, title, isActive, hasActivity} = tab;
|
||||
const props = getTabProps(tab, this.props, {
|
||||
text: title === '' ? 'Shell' : title,
|
||||
isFirst: i === 0,
|
||||
isLast: tabs.length - 1 === i,
|
||||
borderColor,
|
||||
isActive,
|
||||
hasActivity,
|
||||
onSelect: onChange.bind(null, uid),
|
||||
onClose: onClose.bind(null, uid)
|
||||
});
|
||||
return <Tab key={`tab-${uid}`} {...props} />;
|
||||
})}
|
||||
</ul>,
|
||||
isMac && (
|
||||
<div
|
||||
key="shim"
|
||||
style={{borderColor}}
|
||||
className={`tabs_borderShim ${fullScreen ? 'tabs_borderShimUndo' : ''}`}
|
||||
/>
|
||||
)
|
||||
]
|
||||
: null}
|
||||
{this.props.customChildren}
|
||||
|
||||
useEffect(() => {
|
||||
scrollToActiveTab(tabs);
|
||||
}, [tabs, tabs.length]);
|
||||
<style jsx>{`
|
||||
.tabs_nav {
|
||||
font-size: 12px;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
vertical-align: middle;
|
||||
color: #9b9b9b;
|
||||
cursor: default;
|
||||
position: relative;
|
||||
-webkit-user-select: none;
|
||||
-webkit-app-region: ${isMac ? 'drag' : ''};
|
||||
top: ${isMac ? '0px' : '34px'};
|
||||
}
|
||||
|
||||
const hide = !isMac && tabs.length === 1;
|
||||
.tabs_hiddenNav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
return (
|
||||
<nav className={`tabs_nav ${hide ? 'tabs_hiddenNav' : ''}`} ref={ref}>
|
||||
{props.customChildrenBefore}
|
||||
{tabs.length === 1 && isMac ? <div className="tabs_title">{tabs[0].title}</div> : null}
|
||||
{tabs.length > 1 ? (
|
||||
<>
|
||||
<ul key="list" className={`tabs_list ${fullScreen && isMac ? 'tabs_fullScreen' : ''}`}>
|
||||
{tabs.map((tab, i) => {
|
||||
const {uid, title, isActive, hasActivity} = tab;
|
||||
const tabProps = getTabProps(tab, props, {
|
||||
text: title === '' ? 'Shell' : title,
|
||||
isFirst: i === 0,
|
||||
isLast: tabs.length - 1 === i,
|
||||
borderColor,
|
||||
isActive,
|
||||
hasActivity,
|
||||
onSelect: onChange.bind(null, uid),
|
||||
onClose: onClose.bind(null, uid),
|
||||
lastFocused: undefined as Date | undefined
|
||||
});
|
||||
if (shouldFocusCounter.index === i) {
|
||||
tabProps.lastFocused = shouldFocusCounter.when;
|
||||
}
|
||||
return <Tab key={`tab-${uid}`} {...tabProps} />;
|
||||
})}
|
||||
</ul>
|
||||
{isMac && (
|
||||
<div
|
||||
key="shim"
|
||||
style={{borderColor}}
|
||||
className={`tabs_borderShim ${fullScreen ? 'tabs_borderShimUndo' : ''}`}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
<DropdownButton {...props} tabsVisible={tabs.length > 1} />
|
||||
{props.customChildren}
|
||||
.tabs_title {
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding-left: 76px;
|
||||
padding-right: 76px;
|
||||
}
|
||||
|
||||
<style jsx>{`
|
||||
.tabs_nav {
|
||||
font-size: 12px;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
vertical-align: middle;
|
||||
color: #9b9b9b;
|
||||
cursor: default;
|
||||
position: relative;
|
||||
-webkit-user-select: none;
|
||||
-webkit-app-region: ${isMac ? 'drag' : ''};
|
||||
top: ${isMac ? '0px' : '34px'};
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
}
|
||||
.tabs_list {
|
||||
max-height: 34px;
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
margin-left: ${isMac ? '76px' : '0'};
|
||||
}
|
||||
|
||||
.tabs_hiddenNav {
|
||||
display: none;
|
||||
}
|
||||
.tabs_fullScreen {
|
||||
margin-left: -1px;
|
||||
}
|
||||
|
||||
.tabs_title {
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding-left: 76px;
|
||||
padding-right: 76px;
|
||||
flex-grow: 1;
|
||||
}
|
||||
.tabs_borderShim {
|
||||
position: absolute;
|
||||
width: 76px;
|
||||
bottom: 0;
|
||||
border-color: #ccc;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
|
||||
.tabs_list {
|
||||
max-height: 34px;
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
margin-left: ${isMac ? '76px' : '0'};
|
||||
flex-grow: 1;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.tabs_list::-webkit-scrollbar,
|
||||
.tabs_list::-webkit-scrollbar-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabs_fullScreen {
|
||||
margin-left: -1px;
|
||||
}
|
||||
|
||||
.tabs_borderShim {
|
||||
position: absolute;
|
||||
width: 76px;
|
||||
bottom: 0;
|
||||
border-color: #ccc;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
|
||||
.tabs_borderShimUndo {
|
||||
border-bottom-width: 0px;
|
||||
}
|
||||
`}</style>
|
||||
</nav>
|
||||
);
|
||||
});
|
||||
|
||||
Tabs.displayName = 'Tabs';
|
||||
|
||||
export default Tabs;
|
||||
.tabs_borderShimUndo {
|
||||
border-bottom-width: 0px;
|
||||
}
|
||||
`}</style>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
import React from 'react';
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import type {HyperState, HyperDispatch, TermGroupProps, TermGroupOwnProps} from '../../typings/hyper';
|
||||
import {resizeTermGroup} from '../actions/term-groups';
|
||||
import {decorate, getTermProps, getTermGroupProps} from '../utils/plugins';
|
||||
|
||||
import SplitPane_ from './split-pane';
|
||||
import {resizeTermGroup} from '../actions/term-groups';
|
||||
import Term_ from './term';
|
||||
import SplitPane_ from './split-pane';
|
||||
import {HyperState, HyperDispatch, TermGroupProps, TermGroupOwnProps} from '../hyper';
|
||||
|
||||
const Term = decorate(Term_, 'Term');
|
||||
const SplitPane = decorate(SplitPane_, 'SplitPane');
|
||||
|
|
@ -85,6 +82,7 @@ class TermGroup_ extends React.PureComponent<TermGroupProps> {
|
|||
letterSpacing: this.props.letterSpacing,
|
||||
modifierKeys: this.props.modifierKeys,
|
||||
padding: this.props.padding,
|
||||
url: session.url,
|
||||
cleared: session.cleared,
|
||||
search: session.search,
|
||||
cols: session.cols,
|
||||
|
|
@ -97,8 +95,7 @@ class TermGroup_ extends React.PureComponent<TermGroupProps> {
|
|||
onResize: this.bind(this.props.onResize, null, uid),
|
||||
onTitle: this.bind(this.props.onTitle, null, uid),
|
||||
onData: this.bind(this.props.onData, null, uid),
|
||||
onOpenSearch: this.bind(this.props.onOpenSearch, null, uid),
|
||||
onCloseSearch: this.bind(this.props.onCloseSearch, null, uid),
|
||||
toggleSearch: this.bind(this.props.toggleSearch, null, uid),
|
||||
onContextMenu: this.bind(this.props.onContextMenu, null, uid),
|
||||
borderColor: this.props.borderColor,
|
||||
selectionColor: this.props.selectionColor,
|
||||
|
|
@ -107,9 +104,6 @@ class TermGroup_ extends React.PureComponent<TermGroupProps> {
|
|||
webLinksActivationKey: this.props.webLinksActivationKey,
|
||||
macOptionSelectionMode: this.props.macOptionSelectionMode,
|
||||
disableLigatures: this.props.disableLigatures,
|
||||
screenReaderMode: this.props.screenReaderMode,
|
||||
windowsPty: this.props.windowsPty,
|
||||
imageSupport: this.props.imageSupport,
|
||||
uid
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,20 @@
|
|||
import {clipboard, shell} from 'electron';
|
||||
import React from 'react';
|
||||
|
||||
import {CanvasAddon} from '@xterm/addon-canvas';
|
||||
import {FitAddon} from '@xterm/addon-fit';
|
||||
import {ImageAddon} from '@xterm/addon-image';
|
||||
import {LigaturesAddon} from '@xterm/addon-ligatures';
|
||||
import {SearchAddon} from '@xterm/addon-search';
|
||||
import type {ISearchDecorationOptions} from '@xterm/addon-search';
|
||||
import {Unicode11Addon} from '@xterm/addon-unicode11';
|
||||
import {WebLinksAddon} from '@xterm/addon-web-links';
|
||||
import {WebglAddon} from '@xterm/addon-webgl';
|
||||
import {Terminal} from '@xterm/xterm';
|
||||
import type {ITerminalOptions, IDisposable} from '@xterm/xterm';
|
||||
import {Terminal, ITerminalOptions, IDisposable} from 'xterm';
|
||||
import {FitAddon} from 'xterm-addon-fit';
|
||||
import {WebLinksAddon} from 'xterm-addon-web-links';
|
||||
import {SearchAddon} from 'xterm-addon-search';
|
||||
import {WebglAddon} from 'xterm-addon-webgl';
|
||||
import {LigaturesAddon} from 'xterm-addon-ligatures';
|
||||
import {Unicode11Addon} from 'xterm-addon-unicode11';
|
||||
import {clipboard, shell} from 'electron';
|
||||
import Color from 'color';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import pickBy from 'lodash/pickBy';
|
||||
|
||||
import type {TermProps} from '../../typings/hyper';
|
||||
import terms from '../terms';
|
||||
import processClipboard from '../utils/paste';
|
||||
import {decorate} from '../utils/plugins';
|
||||
import SearchBox from './searchBox';
|
||||
import {TermProps} from '../hyper';
|
||||
import {ObjectTypedKeys} from '../utils/object';
|
||||
|
||||
import _SearchBox from './searchBox';
|
||||
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
|
||||
const SearchBox = decorate(_SearchBox, 'SearchBox');
|
||||
|
||||
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform) || process.platform === 'win32';
|
||||
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform);
|
||||
|
||||
// map old hterm constants to xterm.js
|
||||
const CURSOR_STYLES = {
|
||||
|
|
@ -51,7 +38,7 @@ const isWebgl2Supported = (() => {
|
|||
const getTermOptions = (props: TermProps): ITerminalOptions => {
|
||||
// Set a background color only if it is opaque
|
||||
const needTransparency = Color(props.backgroundColor).alpha() < 1;
|
||||
const backgroundColor = needTransparency ? 'rgba(0,0,0,0)' : props.backgroundColor;
|
||||
const backgroundColor = needTransparency ? 'transparent' : props.backgroundColor;
|
||||
|
||||
return {
|
||||
macOptionIsMeta: props.modifierKeys.altIsMeta,
|
||||
|
|
@ -66,14 +53,14 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
|
|||
letterSpacing: props.letterSpacing,
|
||||
allowTransparency: needTransparency,
|
||||
macOptionClickForcesSelection: props.macOptionSelectionMode === 'force',
|
||||
bellStyle: props.bell === 'SOUND' ? 'sound' : 'none',
|
||||
windowsMode: isWindows,
|
||||
...(isWindows && props.windowsPty && {windowsPty: props.windowsPty}),
|
||||
theme: {
|
||||
foreground: props.foregroundColor,
|
||||
background: backgroundColor,
|
||||
cursor: props.cursorColor,
|
||||
cursorAccent: props.cursorAccentColor,
|
||||
selectionBackground: props.selectionColor,
|
||||
selection: props.selectionColor,
|
||||
black: props.colors.black,
|
||||
red: props.colors.red,
|
||||
green: props.colors.green,
|
||||
|
|
@ -90,51 +77,22 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
|
|||
brightMagenta: props.colors.lightMagenta,
|
||||
brightCyan: props.colors.lightCyan,
|
||||
brightWhite: props.colors.lightWhite
|
||||
},
|
||||
screenReaderMode: props.screenReaderMode,
|
||||
overviewRulerWidth: 20,
|
||||
allowProposedApi: true
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default class Term extends React.PureComponent<
|
||||
TermProps,
|
||||
{
|
||||
searchOptions: {
|
||||
caseSensitive: boolean;
|
||||
wholeWord: boolean;
|
||||
regex: boolean;
|
||||
};
|
||||
searchResults:
|
||||
| {
|
||||
resultIndex: number;
|
||||
resultCount: number;
|
||||
}
|
||||
| undefined;
|
||||
}
|
||||
> {
|
||||
export default class Term extends React.PureComponent<TermProps> {
|
||||
termRef: HTMLElement | null;
|
||||
termWrapperRef: HTMLElement | null;
|
||||
termOptions: ITerminalOptions;
|
||||
disposableListeners: IDisposable[];
|
||||
defaultBellSound: HTMLAudioElement | null;
|
||||
bellSound: HTMLAudioElement | null;
|
||||
termDefaultBellSound: string | null;
|
||||
fitAddon: FitAddon;
|
||||
searchAddon: SearchAddon;
|
||||
static rendererTypes: Record<string, string>;
|
||||
term!: Terminal;
|
||||
resizeObserver!: ResizeObserver;
|
||||
resizeTimeout!: NodeJS.Timeout;
|
||||
searchDecorations: ISearchDecorationOptions;
|
||||
state = {
|
||||
searchOptions: {
|
||||
caseSensitive: false,
|
||||
wholeWord: false,
|
||||
regex: false
|
||||
},
|
||||
searchResults: undefined
|
||||
};
|
||||
|
||||
constructor(props: TermProps) {
|
||||
super(props);
|
||||
props.ref_(props.uid, this);
|
||||
|
|
@ -142,17 +100,9 @@ export default class Term extends React.PureComponent<
|
|||
this.termWrapperRef = null;
|
||||
this.termOptions = {};
|
||||
this.disposableListeners = [];
|
||||
this.defaultBellSound = null;
|
||||
this.bellSound = null;
|
||||
this.termDefaultBellSound = null;
|
||||
this.fitAddon = new FitAddon();
|
||||
this.searchAddon = new SearchAddon();
|
||||
this.searchDecorations = {
|
||||
activeMatchColorOverviewRuler: Color(this.props.cursorColor).hex(),
|
||||
matchOverviewRuler: Color(this.props.borderColor).hex(),
|
||||
activeMatchBackground: Color(this.props.cursorColor).hex(),
|
||||
activeMatchBorder: Color(this.props.cursorColor).hex(),
|
||||
matchBorder: Color(this.props.cursorColor).hex()
|
||||
};
|
||||
}
|
||||
|
||||
// The main process shows this in the About dialog
|
||||
|
|
@ -170,14 +120,7 @@ export default class Term extends React.PureComponent<
|
|||
|
||||
this.termOptions = getTermOptions(props);
|
||||
this.term = props.term || new Terminal(this.termOptions);
|
||||
this.defaultBellSound = new Audio(
|
||||
// Source: https://freesound.org/people/altemark/sounds/45759/
|
||||
// This sound is released under the Creative Commons Attribution 3.0 Unported
|
||||
// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been
|
||||
// made, apart from the conversion to base64.
|
||||
'data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'
|
||||
);
|
||||
this.setBellSound(props.bell, props.bellSound);
|
||||
this.termDefaultBellSound = this.term.getOption('bellSound');
|
||||
|
||||
// The parent element for the terminal is attached and removed manually so
|
||||
// that we can preserve it across mounts and unmounts of the component
|
||||
|
|
@ -205,9 +148,9 @@ export default class Term extends React.PureComponent<
|
|||
}
|
||||
Term.reportRenderer(props.uid, useWebGL ? 'WebGL' : 'Canvas');
|
||||
|
||||
const shallActivateWebLink = (event: MouseEvent): boolean => {
|
||||
if (!event) return false;
|
||||
return props.webLinksActivationKey ? event[`${props.webLinksActivationKey}Key`] : true;
|
||||
const shallActivateWebLink = (event: Record<string, any> | undefined): boolean => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return event && (!props.webLinksActivationKey || event[`${props.webLinksActivationKey}Key`]);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
|
|
@ -215,46 +158,35 @@ export default class Term extends React.PureComponent<
|
|||
this.term.loadAddon(this.fitAddon);
|
||||
this.term.loadAddon(this.searchAddon);
|
||||
this.term.loadAddon(
|
||||
new WebLinksAddon((event, uri) => {
|
||||
if (shallActivateWebLink(event)) void shell.openExternal(uri);
|
||||
})
|
||||
new WebLinksAddon(
|
||||
(event: MouseEvent | undefined, uri: string) => {
|
||||
if (shallActivateWebLink(event)) void shell.openExternal(uri);
|
||||
},
|
||||
{
|
||||
// prevent default electron link handling to allow selection, e.g. via double-click
|
||||
willLinkActivate: (event: MouseEvent | undefined) => {
|
||||
event?.preventDefault();
|
||||
return shallActivateWebLink(event);
|
||||
},
|
||||
priority: Date.now()
|
||||
}
|
||||
)
|
||||
);
|
||||
this.term.open(this.termRef);
|
||||
|
||||
if (useWebGL) {
|
||||
const webglAddon = new WebglAddon();
|
||||
this.term.loadAddon(webglAddon);
|
||||
webglAddon.onContextLoss(() => {
|
||||
console.warn('WebGL context lost. Falling back to canvas-based rendering.');
|
||||
webglAddon.dispose();
|
||||
this.term.loadAddon(new CanvasAddon());
|
||||
});
|
||||
} else {
|
||||
this.term.loadAddon(new CanvasAddon());
|
||||
this.term.loadAddon(new WebglAddon());
|
||||
}
|
||||
|
||||
if (props.disableLigatures !== true && !useWebGL) {
|
||||
this.term.loadAddon(new LigaturesAddon());
|
||||
}
|
||||
|
||||
this.term.loadAddon(new Unicode11Addon());
|
||||
this.term.unicode.activeVersion = '11';
|
||||
|
||||
if (props.imageSupport) {
|
||||
this.term.loadAddon(new ImageAddon());
|
||||
}
|
||||
} else {
|
||||
// get the cached plugins
|
||||
this.fitAddon = props.fitAddon!;
|
||||
this.searchAddon = props.searchAddon!;
|
||||
}
|
||||
|
||||
try {
|
||||
this.term.element!.style.padding = props.padding;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
this.fitAddon.fit();
|
||||
|
||||
if (this.props.isTermActive) {
|
||||
|
|
@ -276,10 +208,6 @@ export default class Term extends React.PureComponent<
|
|||
this.disposableListeners.push(this.term.onData(props.onData));
|
||||
}
|
||||
|
||||
this.term.onBell(() => {
|
||||
this.ringBell();
|
||||
});
|
||||
|
||||
if (props.onResize) {
|
||||
this.disposableListeners.push(
|
||||
this.term.onResize(({cols, rows}) => {
|
||||
|
|
@ -307,15 +235,6 @@ export default class Term extends React.PureComponent<
|
|||
);
|
||||
}
|
||||
|
||||
this.disposableListeners.push(
|
||||
this.searchAddon.onDidChangeResults((results) => {
|
||||
this.setState((state) => ({
|
||||
...state,
|
||||
searchResults: results
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
window.addEventListener('paste', this.onWindowPaste, {
|
||||
capture: true
|
||||
});
|
||||
|
|
@ -343,7 +262,8 @@ export default class Term extends React.PureComponent<
|
|||
if (processed) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.term.paste(processed);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
(this.term as any)._core.handler(processed);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -364,9 +284,9 @@ export default class Term extends React.PureComponent<
|
|||
this.term.write(data);
|
||||
}
|
||||
|
||||
focus = () => {
|
||||
focus() {
|
||||
this.term.focus();
|
||||
};
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.term.clear();
|
||||
|
|
@ -376,29 +296,20 @@ export default class Term extends React.PureComponent<
|
|||
this.term.reset();
|
||||
}
|
||||
|
||||
search = (searchTerm = '') => {
|
||||
this.searchAddon.findNext(searchTerm);
|
||||
};
|
||||
|
||||
searchNext = (searchTerm: string) => {
|
||||
this.searchAddon.findNext(searchTerm, {
|
||||
...this.state.searchOptions,
|
||||
decorations: this.searchDecorations
|
||||
});
|
||||
this.searchAddon.findNext(searchTerm);
|
||||
};
|
||||
|
||||
searchPrevious = (searchTerm: string) => {
|
||||
this.searchAddon.findPrevious(searchTerm, {
|
||||
...this.state.searchOptions,
|
||||
decorations: this.searchDecorations
|
||||
});
|
||||
this.searchAddon.findPrevious(searchTerm);
|
||||
};
|
||||
|
||||
closeSearchBox = () => {
|
||||
this.props.onCloseSearch();
|
||||
this.searchAddon.clearDecorations();
|
||||
this.searchAddon.clearActiveDecoration();
|
||||
this.setState((state) => ({
|
||||
...state,
|
||||
searchResults: undefined
|
||||
}));
|
||||
this.term.focus();
|
||||
this.props.toggleSearch();
|
||||
};
|
||||
|
||||
resize(cols: number, rows: number) {
|
||||
|
|
@ -421,18 +332,6 @@ export default class Term extends React.PureComponent<
|
|||
return !e.catched;
|
||||
}
|
||||
|
||||
setBellSound(bell: 'SOUND' | false, sound: string | null) {
|
||||
if (bell && bell.toUpperCase() === 'SOUND') {
|
||||
this.bellSound = sound ? new Audio(sound) : this.defaultBellSound;
|
||||
} else {
|
||||
this.bellSound = null;
|
||||
}
|
||||
}
|
||||
|
||||
ringBell() {
|
||||
void this.bellSound?.play();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: TermProps) {
|
||||
if (!prevProps.cleared && this.props.cleared) {
|
||||
this.clear();
|
||||
|
|
@ -440,28 +339,42 @@ export default class Term extends React.PureComponent<
|
|||
|
||||
const nextTermOptions = getTermOptions(this.props);
|
||||
|
||||
if (prevProps.bell !== this.props.bell || prevProps.bellSound !== this.props.bellSound) {
|
||||
this.setBellSound(this.props.bell, this.props.bellSound);
|
||||
}
|
||||
// Use bellSound in nextProps if it exists
|
||||
// otherwise use the default sound found in xterm.
|
||||
nextTermOptions.bellSound = this.props.bellSound || this.termDefaultBellSound!;
|
||||
|
||||
if (prevProps.search && !this.props.search) {
|
||||
this.closeSearchBox();
|
||||
if (!prevProps.search && this.props.search) {
|
||||
this.search();
|
||||
}
|
||||
|
||||
// Update only options that have changed.
|
||||
this.term.options = pickBy(
|
||||
nextTermOptions,
|
||||
(value, key) => !isEqual(this.termOptions[key as keyof ITerminalOptions], value)
|
||||
);
|
||||
ObjectTypedKeys(nextTermOptions)
|
||||
.filter((option) => option !== 'theme' && nextTermOptions[option] !== this.termOptions[option])
|
||||
.forEach((option) => {
|
||||
try {
|
||||
this.term.setOption(option, nextTermOptions[option]);
|
||||
} catch (e) {
|
||||
if (/The webgl renderer only works with the webgl char atlas/i.test(e.message)) {
|
||||
// Ignore this because the char atlas will also be changed
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Do we need to update theme?
|
||||
const shouldUpdateTheme =
|
||||
!this.termOptions.theme ||
|
||||
nextTermOptions.rendererType !== this.termOptions.rendererType ||
|
||||
ObjectTypedKeys(nextTermOptions.theme!).some(
|
||||
(option) => nextTermOptions.theme![option] !== this.termOptions.theme![option]
|
||||
);
|
||||
if (shouldUpdateTheme) {
|
||||
this.term.setOption('theme', nextTermOptions.theme);
|
||||
}
|
||||
|
||||
this.termOptions = nextTermOptions;
|
||||
|
||||
try {
|
||||
this.term.element!.style.padding = this.props.padding;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
if (
|
||||
this.props.fontSize !== prevProps.fontSize ||
|
||||
this.props.fontFamily !== prevProps.fontFamily ||
|
||||
|
|
@ -512,45 +425,24 @@ export default class Term extends React.PureComponent<
|
|||
|
||||
render() {
|
||||
return (
|
||||
<div className={`term_fit ${this.props.isTermActive ? 'term_active' : ''}`} onMouseUp={this.onMouseUp}>
|
||||
<div
|
||||
className={`term_fit ${this.props.isTermActive ? 'term_active' : ''}`}
|
||||
style={{padding: this.props.padding}}
|
||||
onMouseUp={this.onMouseUp}
|
||||
>
|
||||
{this.props.customChildrenBefore}
|
||||
<div ref={this.onTermWrapperRef} className="term_fit term_wrapper" />
|
||||
{this.props.customChildren}
|
||||
{this.props.search ? (
|
||||
<SearchBox
|
||||
dateFocused={this.props.search}
|
||||
search={this.search}
|
||||
next={this.searchNext}
|
||||
prev={this.searchPrevious}
|
||||
close={this.closeSearchBox}
|
||||
caseSensitive={this.state.searchOptions.caseSensitive}
|
||||
wholeWord={this.state.searchOptions.wholeWord}
|
||||
regex={this.state.searchOptions.regex}
|
||||
results={this.state.searchResults}
|
||||
toggleCaseSensitive={() =>
|
||||
this.setState({
|
||||
...this.state,
|
||||
searchOptions: {...this.state.searchOptions, caseSensitive: !this.state.searchOptions.caseSensitive}
|
||||
})
|
||||
}
|
||||
toggleWholeWord={() =>
|
||||
this.setState({
|
||||
...this.state,
|
||||
searchOptions: {...this.state.searchOptions, wholeWord: !this.state.searchOptions.wholeWord}
|
||||
})
|
||||
}
|
||||
toggleRegex={() =>
|
||||
this.setState({
|
||||
...this.state,
|
||||
searchOptions: {...this.state.searchOptions, regex: !this.state.searchOptions.regex}
|
||||
})
|
||||
}
|
||||
selectionColor={this.props.selectionColor}
|
||||
backgroundColor={this.props.backgroundColor}
|
||||
foregroundColor={this.props.foregroundColor}
|
||||
borderColor={this.props.borderColor}
|
||||
font={this.props.uiFontFamily}
|
||||
/>
|
||||
) : null}
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
|
||||
<style jsx global>{`
|
||||
.term_fit {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
import React from 'react';
|
||||
|
||||
import type {TermsProps, HyperDispatch} from '../../typings/hyper';
|
||||
import {registerCommandHandlers} from '../command-registry';
|
||||
import {ObjectTypedKeys} from '../utils/object';
|
||||
import {decorate, getTermGroupProps} from '../utils/plugins';
|
||||
|
||||
import StyleSheet_ from './style-sheet';
|
||||
import type Term from './term';
|
||||
import {registerCommandHandlers} from '../command-registry';
|
||||
import TermGroup_ from './term-group';
|
||||
import StyleSheet_ from './style-sheet';
|
||||
import {TermsProps, HyperDispatch} from '../hyper';
|
||||
import Term from './term';
|
||||
import {ObjectTypedKeys} from '../utils/object';
|
||||
|
||||
const TermGroup = decorate(TermGroup_, 'TermGroup');
|
||||
const StyleSheet = decorate(StyleSheet_, 'StyleSheet');
|
||||
|
||||
const isMac = /Mac/.test(navigator.userAgent);
|
||||
|
||||
export default class Terms extends React.Component<React.PropsWithChildren<TermsProps>> {
|
||||
export default class Terms extends React.Component<TermsProps> {
|
||||
terms: Record<string, Term>;
|
||||
registerCommands: (cmds: Record<string, (e: any, dispatch: HyperDispatch) => void>) => void;
|
||||
constructor(props: TermsProps, context: any) {
|
||||
|
|
@ -94,7 +92,6 @@ export default class Terms extends React.Component<React.PropsWithChildren<Terms
|
|||
cursorShape: this.props.cursorShape,
|
||||
cursorBlink: this.props.cursorBlink,
|
||||
cursorColor: this.props.cursorColor,
|
||||
cursorAccentColor: this.props.cursorAccentColor,
|
||||
fontSize: this.props.fontSize,
|
||||
fontFamily: this.props.fontFamily,
|
||||
uiFontFamily: this.props.uiFontFamily,
|
||||
|
|
@ -112,17 +109,13 @@ export default class Terms extends React.Component<React.PropsWithChildren<Terms
|
|||
onResize: this.props.onResize,
|
||||
onTitle: this.props.onTitle,
|
||||
onData: this.props.onData,
|
||||
onOpenSearch: this.props.onOpenSearch,
|
||||
onCloseSearch: this.props.onCloseSearch,
|
||||
toggleSearch: this.props.toggleSearch,
|
||||
onContextMenu: this.props.onContextMenu,
|
||||
quickEdit: this.props.quickEdit,
|
||||
webGLRenderer: this.props.webGLRenderer,
|
||||
webLinksActivationKey: this.props.webLinksActivationKey,
|
||||
macOptionSelectionMode: this.props.macOptionSelectionMode,
|
||||
disableLigatures: this.props.disableLigatures,
|
||||
screenReaderMode: this.props.screenReaderMode,
|
||||
windowsPty: this.props.windowsPty,
|
||||
imageSupport: this.props.imageSupport,
|
||||
parentProps: this.props
|
||||
});
|
||||
|
||||
|
|
|
|||
80
lib/config.d.ts
vendored
Normal file
80
lib/config.d.ts
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import {FontWeight} from 'xterm';
|
||||
|
||||
export type ColorMap = {
|
||||
black: string;
|
||||
blue: string;
|
||||
cyan: string;
|
||||
green: string;
|
||||
lightBlack: string;
|
||||
lightBlue: string;
|
||||
lightCyan: string;
|
||||
lightGreen: string;
|
||||
lightMagenta: string;
|
||||
lightRed: string;
|
||||
lightWhite: string;
|
||||
lightYellow: string;
|
||||
magenta: string;
|
||||
red: string;
|
||||
white: string;
|
||||
yellow: string;
|
||||
};
|
||||
|
||||
export type configOptions = {
|
||||
autoUpdatePlugins: boolean | string;
|
||||
backgroundColor: string;
|
||||
bell: string;
|
||||
bellSound: string | null;
|
||||
bellSoundURL: string | null;
|
||||
borderColor: string;
|
||||
colors: ColorMap;
|
||||
copyOnSelect: boolean;
|
||||
css: string;
|
||||
cursorAccentColor: string;
|
||||
cursorBlink: boolean;
|
||||
cursorColor: string;
|
||||
cursorShape: 'BEAM' | 'UNDERLINE' | 'BLOCK';
|
||||
defaultSSHApp: boolean;
|
||||
disableLigatures: boolean;
|
||||
env: Record<string, string>;
|
||||
fontFamily: string;
|
||||
fontSize: number;
|
||||
fontWeight: FontWeight;
|
||||
fontWeightBold: FontWeight;
|
||||
foregroundColor: string;
|
||||
letterSpacing: number;
|
||||
lineHeight: number;
|
||||
macOptionSelectionMode: string;
|
||||
modifierKeys: {
|
||||
altIsMeta: boolean;
|
||||
cmdIsMeta: boolean;
|
||||
};
|
||||
padding: string;
|
||||
quickEdit: boolean;
|
||||
scrollback: number;
|
||||
selectionColor: string;
|
||||
shell: string;
|
||||
shellArgs: string[];
|
||||
showHamburgerMenu: boolean | '';
|
||||
showWindowControls: string;
|
||||
termCSS: string;
|
||||
uiFontFamily: string;
|
||||
updateChannel: 'stable' | 'canary';
|
||||
useConpty: boolean;
|
||||
webGLRenderer: boolean;
|
||||
webLinksActivationKey: 'ctrl' | 'alt' | 'meta' | 'shift';
|
||||
windowSize: [number, number];
|
||||
};
|
||||
|
||||
export type rawConfig = {
|
||||
config?: configOptions;
|
||||
plugins?: string[];
|
||||
localPlugins?: string[];
|
||||
keymaps?: Record<string, string | string[]>;
|
||||
};
|
||||
|
||||
export type parsedConfig = {
|
||||
config: configOptions;
|
||||
plugins: string[];
|
||||
localPlugins: string[];
|
||||
keymaps: Record<string, string[]>;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue