Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3012a8820 | |||
| 3c38c11aeb | |||
| da0625dc90 | |||
| fdb177aecf | |||
| fb98bb1e8b | |||
| f947e0b0fd | |||
| cea86d69e8 | |||
| b67f224a00 | |||
| 810a98a4b6 | |||
| c1c70ff576 | |||
| acf873f0d6 | |||
| 8de8aab23e | |||
| 3b012b7d36 | |||
| 5ed4c77e4d | |||
| 46ea46f5f7 | |||
| 827541ff8b | |||
| 2af127ac06 | |||
| c57c53972a | |||
| 2839b68e5f | |||
| 06d78bf0cf | |||
| 120e22729f | |||
| 9b210e047d | |||
| 19806f8064 | |||
| d67c1c97b7 | |||
| 0ede82dd92 | |||
| 6ac8cbe56c | |||
| f6b8460eca | |||
| a37d41813f | |||
| 528a118239 | |||
| f392fbab83 | |||
| b2ac106db4 | |||
| 57d4fa1759 | |||
| 584c07afea | |||
| 2f2bb5f16f | |||
| 817c18b40b | |||
| f01de3d1ff | |||
| 06d018883b | |||
| bcc32deda1 | |||
| c0d5c88cf2 | |||
| b6c81183e9 | |||
| f48560ef60 | |||
| 6de5d56f29 | |||
| a7ce902a16 | |||
| 42afc2b9f5 | |||
| 70c6a5e7c6 | |||
| dd44b482a2 | |||
| f41f557493 | |||
| c060df6d22 | |||
| 44013c6212 | |||
| 6a33d2c436 | |||
| c4f6886211 | |||
| e65dd130b8 | |||
| a34be65644 | |||
| 71a591792a | |||
| 2711fafb06 | |||
| 06cb95ef97 | |||
| e32ade3b54 | |||
| 9f3c6d3029 | |||
| 557eaab44c | |||
| 75b7eab2e1 | |||
| 38c9e329ac | |||
| 46d948e00f | |||
| 01d9040554 | |||
| 9319d0698a | |||
| f65ffdb412 | |||
| 516b895efe | |||
| 4d64a96f75 |
@@ -1,3 +0,0 @@
|
||||
node_modules
|
||||
Dockerfile
|
||||
docker-compose.*
|
||||
@@ -1,9 +1,18 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# https://github.com/jokeyrhyme/standard-editorconfig
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# defaults
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* TODO: Rewrite this config to ESM
|
||||
* But currently electron-builder doesn't support ESM configs
|
||||
* @see https://github.com/develar/read-config-file/issues/10
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {() => import('electron-builder').Configuration}
|
||||
* @see https://www.electron.build/configuration/configuration
|
||||
*/
|
||||
module.exports = async function () {
|
||||
const {getVersion} = await import('./version/getVersion.mjs');
|
||||
|
||||
return {
|
||||
directories: {
|
||||
output: 'dist',
|
||||
buildResources: 'buildResources',
|
||||
},
|
||||
files: ['packages/**/dist/**'],
|
||||
extraMetadata: {
|
||||
version: getVersion(),
|
||||
},
|
||||
productName: 'Feishin',
|
||||
appId: 'org.jeffvli.feishin',
|
||||
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
|
||||
win: {
|
||||
target: ['nsis', 'zip'],
|
||||
},
|
||||
publish: {
|
||||
provider: 'github',
|
||||
owner: 'jeffvli',
|
||||
repo: 'feishin',
|
||||
},
|
||||
// Specify linux target just for disabling snap compilation
|
||||
linux: {
|
||||
target: 'deb',
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"node": true,
|
||||
"browser": false
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
/** @see https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#recommended-configs */
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"ignorePatterns": ["node_modules/**", "**/dist/**"],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"varsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/consistent-type-imports": "error",
|
||||
/**
|
||||
* Having a semicolon helps the optimizer interpret your code correctly.
|
||||
* This avoids rare errors in optimized code.
|
||||
* @see https://twitter.com/alex_kozack/status/1364210394328408066
|
||||
*/
|
||||
"semi": ["error", "always"],
|
||||
/**
|
||||
* This will make the history of changes in the hit a little cleaner
|
||||
*/
|
||||
"comma-dangle": ["warn", "always-multiline"],
|
||||
/**
|
||||
* Just for beauty
|
||||
*/
|
||||
"quotes": [
|
||||
"warn",
|
||||
"single",
|
||||
{
|
||||
"avoidEscape": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,4 @@
|
||||
* text eol=lf
|
||||
*.exe binary
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.ico binary
|
||||
*.icns binary
|
||||
*.eot binary
|
||||
*.otf binary
|
||||
*.ttf binary
|
||||
*.woff binary
|
||||
*.woff2 binary
|
||||
.github/actions/**/*.js linguist-detectable=false
|
||||
scripts/*.js linguist-detectable=false
|
||||
*.config.js linguist-detectable=false
|
||||
* text=auto eol=lf
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: jeffvli
|
||||
liberapay: #
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: cawa-93
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -1,63 +0,0 @@
|
||||
name: Bug report
|
||||
description: You're having technical issues. 🐞
|
||||
labels: ['bug']
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: What should have happened?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Current Behavior
|
||||
description: What went wrong? Add screenshots to help explain your problem. (Open the browser dev tools in the menu or using CTRL + SHIFT + I)
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
placeholder: |
|
||||
<!-- Add relevant code and/or a live example -->
|
||||
<!-- Add stack traces -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Possible Solution
|
||||
description: Suggest a reason for the bug or how to fix it.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Context
|
||||
description: How has this issue affected you? What are you trying to accomplish?
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
attributes:
|
||||
label: Application version
|
||||
placeholder: (e.g. v0.1.0)
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Operating System and version
|
||||
placeholder: (e.g. Windows 11 desktop, Webapp in Firefox)
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Server and Version
|
||||
placeholder: (e.g. Navidrome v0.48.0)
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Node Version (if developing locally)
|
||||
validations:
|
||||
required: false
|
||||
@@ -1,5 +1,5 @@
|
||||
blank_issues_enabled: true
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Question
|
||||
url: https://github.com/jeffvli/feishin/discussions
|
||||
about: Please ask and answer questions here.
|
||||
- name: Questions & Discussions
|
||||
url: https://github.com/cawa-93/vite-electron-builder/discussions/categories/q-a
|
||||
about: Use GitHub discussions for message-board style questions and discussions.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: cawa-93
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,20 +0,0 @@
|
||||
name: Feature request - NOT ACCEPTING NEW FEATURE REQUESTS
|
||||
description: Feature requests are currently closed. The application is actively being rewritten https://github.com/audioling/audioling.
|
||||
labels: ['enhancement']
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: What do you want to be added?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
validations:
|
||||
required: false
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Is this a server-specific feature? (e.g. Jellyfin only)
|
||||
options:
|
||||
- label: 'Yes'
|
||||
required: false
|
||||
@@ -1,6 +0,0 @@
|
||||
requiredHeaders:
|
||||
- Prerequisites
|
||||
- Expected Behavior
|
||||
- Current Behavior
|
||||
- Possible Solution
|
||||
- Your Environment
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base",
|
||||
":semanticCommits",
|
||||
":semanticCommitTypeAll(deps)",
|
||||
":semanticCommitScopeDisabled",
|
||||
":automergeAll",
|
||||
":automergeBranch",
|
||||
":disableDependencyDashboard",
|
||||
":pinVersions",
|
||||
":onlyNpm",
|
||||
":label(dependencies)"
|
||||
],
|
||||
"gitNoVerify": [
|
||||
"commit",
|
||||
"push"
|
||||
]
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- discussion
|
||||
- security
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: wontfix
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
|
||||
|
||||
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
@@ -0,0 +1,47 @@
|
||||
# This workflow is the entry point for all CI processes.
|
||||
# It is from here that all other workflows are launched.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'renovate/**'
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '!.github/workflows/ci.yml'
|
||||
- '!.github/workflows/typechecking.yml'
|
||||
- '!.github/workflows/tests.yml'
|
||||
- '!.github/workflows/release.yml'
|
||||
- '**.md'
|
||||
- .editorconfig
|
||||
- .gitignore
|
||||
- '.idea/**'
|
||||
- '.vscode/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '!.github/workflows/ci.yml'
|
||||
- '!.github/workflows/typechecking.yml'
|
||||
- '!.github/workflows/tests.yml'
|
||||
- '!.github/workflows/release.yml'
|
||||
- '**.md'
|
||||
- .editorconfig
|
||||
- .gitignore
|
||||
- '.idea/**'
|
||||
- '.vscode/**'
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
typechecking:
|
||||
uses: ./.github/workflows/typechecking.yml
|
||||
tests:
|
||||
uses: ./.github/workflows/tests.yml
|
||||
draft_release:
|
||||
with:
|
||||
dry-run: ${{ github.event_name != 'push' || github.ref_name != 'main' }}
|
||||
needs: [ typechecking, tests ]
|
||||
uses: ./.github/workflows/release.yml
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- '**.js'
|
||||
- '**.mjs'
|
||||
- '**.cjs'
|
||||
- '**.jsx'
|
||||
- '**.ts'
|
||||
- '**.mts'
|
||||
- '**.cts'
|
||||
- '**.tsx'
|
||||
- '**.vue'
|
||||
- '**.json'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.js'
|
||||
- '**.mjs'
|
||||
- '**.cjs'
|
||||
- '**.jsx'
|
||||
- '**.ts'
|
||||
- '**.mts'
|
||||
- '**.cts'
|
||||
- '**.tsx'
|
||||
- '**.vue'
|
||||
- '**.json'
|
||||
|
||||
concurrency:
|
||||
group: lint-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: 'bash'
|
||||
|
||||
jobs:
|
||||
eslint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16 # Need for npm >=7.7
|
||||
cache: 'npm'
|
||||
|
||||
- run: npm ci
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
- run: npm run lint --if-present
|
||||
|
||||
# This job just check code style for in-template contributions.
|
||||
code-style:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16 # Need for npm >=7.7
|
||||
cache: 'npm'
|
||||
|
||||
- run: npm i prettier
|
||||
- run: npx prettier --check "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue,json}"
|
||||
@@ -1,54 +0,0 @@
|
||||
# Referenced from: https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#introduction
|
||||
name: Publish Docker to GHCR
|
||||
permissions: write-all
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm/v7
|
||||
linux/arm64/v8
|
||||
@@ -1,46 +0,0 @@
|
||||
# Referenced from: https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#introduction
|
||||
name: Publish Docker to GHCR (Manual)
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm/v7
|
||||
linux/arm64/v8
|
||||
@@ -1,49 +0,0 @@
|
||||
name: Publish Linux (Manual)
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout git repo
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Node and PNPM
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build and Publish releases
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:linux
|
||||
pnpm run publish:linux
|
||||
on_retry_command: pnpm cache delete
|
||||
|
||||
- name: Build and Publish releases (arm64)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:linux-arm64
|
||||
pnpm run publish:linux-arm64
|
||||
on_retry_command: pnpm cache delete
|
||||
@@ -1,36 +0,0 @@
|
||||
name: Publish macOS (Manual)
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout git repo
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Node and PNPM
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build and Publish releases
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:mac
|
||||
pnpm run publish:mac
|
||||
on_retry_command: pnpm cache delete
|
||||
@@ -1,54 +0,0 @@
|
||||
name: Comment on pull request
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Publish (PR)']
|
||||
types: [completed]
|
||||
jobs:
|
||||
pr_comment:
|
||||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v6
|
||||
with:
|
||||
# This snippet is public-domain, taken from
|
||||
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
|
||||
script: |
|
||||
async function upsertComment(owner, repo, issue_number, purpose, body) {
|
||||
const {data: comments} = await github.rest.issues.listComments(
|
||||
{owner, repo, issue_number});
|
||||
const marker = `<!-- bot: ${purpose} -->`;
|
||||
body = marker + "\n" + body;
|
||||
const existing = comments.filter((c) => c.body.includes(marker));
|
||||
if (existing.length > 0) {
|
||||
const last = existing[existing.length - 1];
|
||||
core.info(`Updating comment ${last.id}`);
|
||||
await github.rest.issues.updateComment({
|
||||
owner, repo,
|
||||
body,
|
||||
comment_id: last.id,
|
||||
});
|
||||
} else {
|
||||
core.info(`Creating a comment in issue / PR #${issue_number}`);
|
||||
await github.rest.issues.createComment({issue_number, body, owner, repo});
|
||||
}
|
||||
}
|
||||
const {owner, repo} = context.repo;
|
||||
const run_id = ${{github.event.workflow_run.id}};
|
||||
const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
|
||||
if (!pull_requests.length) {
|
||||
return core.error("This workflow doesn't match any pull requests!");
|
||||
}
|
||||
const artifacts = await github.paginate(
|
||||
github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
|
||||
if (!artifacts.length) {
|
||||
return core.error(`No artifacts found`);
|
||||
}
|
||||
let body = `Download the artifacts for this pull request:\n`;
|
||||
for (const art of artifacts) {
|
||||
body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
|
||||
}
|
||||
core.info("Review thread message body:", body);
|
||||
for (const pr of pull_requests) {
|
||||
await upsertComment(owner, repo, pr.number,
|
||||
"nightly-link", body);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
name: Publish (PR)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- development
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout git repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node and PNPM
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build for Windows
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:win:pr
|
||||
|
||||
- name: Build for Linux
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:linux:pr
|
||||
|
||||
- name: Build for MacOS
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:mac:pr
|
||||
|
||||
- name: Zip Windows Binaries
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
Compress-Archive -Path "dist/*.exe" -DestinationPath "dist/windows-binaries.zip" -Force
|
||||
|
||||
- name: Zip Linux Binaries
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: |
|
||||
zip -r dist/linux-binaries.zip dist/*.{AppImage,deb,rpm}
|
||||
|
||||
- name: Zip MacOS Binaries
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
run: |
|
||||
zip -r dist/macos-binaries.zip dist/*.dmg
|
||||
|
||||
- name: Upload Windows Binaries
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-binaries
|
||||
path: dist/windows-binaries.zip
|
||||
|
||||
- name: Upload Linux Binaries
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-binaries
|
||||
path: dist/linux-binaries.zip
|
||||
|
||||
- name: Upload MacOS Binaries
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos-binaries
|
||||
path: dist/macos-binaries.zip
|
||||
@@ -1,36 +0,0 @@
|
||||
name: Publish Windows (Manual)
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout git repo
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Node and PNPM
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build and Publish releases
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: nick-invision/retry@v2.8.2
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
pnpm run package:win
|
||||
pnpm run publish:win
|
||||
on_retry_command: pnpm cache delete
|
||||
@@ -0,0 +1,60 @@
|
||||
name: Release
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
dry-run:
|
||||
description: 'Compiles the app but not upload artifacts to distribution server'
|
||||
default: false
|
||||
required: false
|
||||
type: boolean
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: 'bash'
|
||||
|
||||
|
||||
jobs:
|
||||
draft_release:
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ macos-latest, ubuntu-latest, windows-latest ]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16 # Need for npm >=7.7
|
||||
cache: 'npm'
|
||||
|
||||
- run: npm ci
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
- run: npm run build
|
||||
|
||||
- name: Compile artifacts ${{ inputs.dry-run && '' || 'and upload them to github release' }}
|
||||
# I use this action because it is capable of retrying multiple times if there are any issues with the distribution server
|
||||
uses: nick-fields/retry@v2
|
||||
with:
|
||||
timeout_minutes: 15
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
shell: 'bash'
|
||||
command: npx --no-install electron-builder --config .electron-builder.config.js --publish ${{ inputs.dry-run && 'never' || 'always' }}
|
||||
env:
|
||||
# Code Signing params
|
||||
# See https://www.electron.build/code-signing
|
||||
# CSC_LINK: ''
|
||||
# CSC_KEY_PASSWORD: ''
|
||||
# Publishing artifacts
|
||||
GH_TOKEN: ${{ secrets.github_token }} # GitHub token, automatically provided (No need to define this secret in the repo settings)
|
||||
@@ -1,26 +0,0 @@
|
||||
name: Test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Node.js and PNPM
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Lint Files
|
||||
run: pnpm run lint
|
||||
@@ -0,0 +1,53 @@
|
||||
name: Tests
|
||||
on: [ workflow_call ]
|
||||
|
||||
concurrency:
|
||||
group: tests-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: 'bash'
|
||||
|
||||
jobs:
|
||||
unit:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ windows-latest, ubuntu-latest, macos-latest ]
|
||||
package: [ main, preload, renderer ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
- run: npm run test:${{ matrix.package }} --if-present
|
||||
|
||||
e2e:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ windows-latest, ubuntu-latest, macos-latest ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
# I ran into problems trying to run an electron window in ubuntu due to a missing graphics server.
|
||||
# That's why this special command for Ubuntu is here
|
||||
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e --if-present
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
- run: npm run test:e2e --if-present
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
@@ -0,0 +1,27 @@
|
||||
name: Typechecking
|
||||
on: [ workflow_call ]
|
||||
|
||||
concurrency:
|
||||
group: typechecking-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: 'bash'
|
||||
|
||||
jobs:
|
||||
typescript:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16 # Need for npm >=7.7
|
||||
cache: 'npm'
|
||||
|
||||
- run: npm ci
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
- run: npm run typecheck --if-present
|
||||
@@ -1,7 +1,58 @@
|
||||
node_modules
|
||||
dist
|
||||
out
|
||||
.DS_Store
|
||||
dist
|
||||
*.local
|
||||
thumbs.db
|
||||
|
||||
.eslintcache
|
||||
*.log*
|
||||
release
|
||||
.browserslistrc
|
||||
.electron-vendors.cache.json
|
||||
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
.idea/artifacts
|
||||
.idea/compiler.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/modules.xml
|
||||
.idea/*.iml
|
||||
.idea/modules
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
/.idea/csv-plugin.xml
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<HTMLCodeStyleSettings>
|
||||
<option name="HTML_ATTRIBUTE_WRAP" value="4" />
|
||||
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||
<option name="HTML_ENFORCE_QUOTES" value="true" />
|
||||
</HTMLCodeStyleSettings>
|
||||
<JSCodeStyleSettings version="0">
|
||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||
<option name="SPACES_WITHIN_OBJECT_TYPE_BRACES" value="false" />
|
||||
</JSCodeStyleSettings>
|
||||
<JSON>
|
||||
<option name="OBJECT_WRAPPING" value="5" />
|
||||
<option name="ARRAY_WRAPPING" value="5" />
|
||||
</JSON>
|
||||
<TypeScriptCodeStyleSettings version="0">
|
||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||
<option name="SPACES_WITHIN_OBJECT_TYPE_BRACES" value="false" />
|
||||
</TypeScriptCodeStyleSettings>
|
||||
<VueCodeStyleSettings>
|
||||
<option name="UNIFORM_INDENT" value="false" />
|
||||
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
||||
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
||||
</VueCodeStyleSettings>
|
||||
<codeStyleSettings language="HTML">
|
||||
<option name="SOFT_MARGINS" value="100" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JavaScript">
|
||||
<option name="SOFT_MARGINS" value="100" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TypeScript">
|
||||
<option name="SOFT_MARGINS" value="100" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Vue">
|
||||
<option name="SOFT_MARGINS" value="120" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||
<serverData>
|
||||
<paths name="ihappymama-aliexpress">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="iosico.com">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="somespeed.com">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<includedPredefinedLibrary name="Node.js Core" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EslintConfiguration">
|
||||
<work-dir-patterns value="src/**/*.{ts,vue} {bin,config}/**/*.js" />
|
||||
<option name="fix-on-save" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JsonSchemaMappingsProjectConfiguration">
|
||||
<state>
|
||||
<map>
|
||||
<entry key="GitHub Workflow">
|
||||
<value>
|
||||
<SchemaInfo>
|
||||
<option name="name" value="GitHub Workflow" />
|
||||
<option name="relativePathToSchema" value="https://json.schemastore.org/github-workflow.json" />
|
||||
<option name="applicationDefined" value="true" />
|
||||
<option name="patterns">
|
||||
<list>
|
||||
<Item>
|
||||
<option name="path" value=".github/workflows/release.yml" />
|
||||
</Item>
|
||||
<Item>
|
||||
<option name="path" value=".github/workflows/ci.yml" />
|
||||
</Item>
|
||||
</list>
|
||||
</option>
|
||||
</SchemaInfo>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</state>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/vite-electron-builder.iml" filepath="$PROJECT_DIR$/.idea/vite-electron-builder.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PrettierConfiguration">
|
||||
<option name="myRunOnSave" value="true" />
|
||||
<option name="myRunOnReformat" value="true" />
|
||||
<option name="myFilesPattern" value="{**/*,*}.{js,mjs,cjs,ts,mts,cts,vue,json}" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/packages/main/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/packages/preload/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/packages/renderer/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/renderer/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/main/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/preload/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/preload/node_modules" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/main/node_modules" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WebResourcesPaths">
|
||||
<contentEntries>
|
||||
<entry url="file://$PROJECT_DIR$">
|
||||
<entryData>
|
||||
<resourceRoots>
|
||||
<path value="file://$PROJECT_DIR$/packages/renderer/assets" />
|
||||
</resourceRoots>
|
||||
</entryData>
|
||||
</entry>
|
||||
</contentEntries>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,24 @@
|
||||
import {resolve, sep} from 'path';
|
||||
|
||||
export default {
|
||||
'*.{js,mjs,cjs,ts,mts,cts,vue}': 'eslint --cache --fix',
|
||||
|
||||
/**
|
||||
* Run typechecking if any type-sensitive files or project dependencies was changed
|
||||
* @param {string[]} filenames
|
||||
* @return {string[]}
|
||||
*/
|
||||
'{package-lock.json,packages/**/{*.ts,*.vue,tsconfig.json}}': ({filenames}) => {
|
||||
// if dependencies was changed run type checking for all packages
|
||||
if (filenames.some(f => f.endsWith('package-lock.json'))) {
|
||||
return ['npm run typecheck --if-present'];
|
||||
}
|
||||
|
||||
// else run type checking for staged packages
|
||||
const fileNameToPackageName = filename =>
|
||||
filename.replace(resolve(process.cwd(), 'packages') + sep, '').split(sep)[0];
|
||||
return [...new Set(filenames.map(fileNameToPackageName))].map(
|
||||
p => `npm run typecheck:${p} --if-present`,
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,6 +1,10 @@
|
||||
out
|
||||
dist
|
||||
pnpm-lock.yaml
|
||||
LICENSE.md
|
||||
tsconfig.json
|
||||
tsconfig.*.json
|
||||
**/node_modules
|
||||
**/dist
|
||||
**/*.svg
|
||||
|
||||
package.json
|
||||
package-lock.json
|
||||
.electron-vendors.cache.json
|
||||
|
||||
.github
|
||||
.idea
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.css", "**/*.scss", "**/*.html"],
|
||||
"options": {
|
||||
"singleQuote": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"proseWrap": "never",
|
||||
"htmlWhitespaceSensitivity": "strict",
|
||||
"endOfLine": "lf",
|
||||
"singleAttributePerLine": true
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
singleQuote: true
|
||||
semi: true
|
||||
printWidth: 100
|
||||
tabWidth: 4
|
||||
trailingComma: all
|
||||
useTabs: false
|
||||
arrowParens: always
|
||||
proseWrap: never
|
||||
htmlWhitespaceSensitivity: strict
|
||||
endOfLine: lf
|
||||
singleAttributePerLine: true
|
||||
bracketSpacing: true
|
||||
plugins:
|
||||
- prettier-plugin-packagejson
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"pre-commit": "npx nano-staged"
|
||||
}
|
||||
@@ -1,17 +1,28 @@
|
||||
{
|
||||
"customSyntax": "postcss-styled-syntax",
|
||||
"extends": [
|
||||
"stylelint-config-standard",
|
||||
"stylelint-config-styled-components",
|
||||
"stylelint-config-recess-order"
|
||||
"processors": ["stylelint-processor-styled-components"],
|
||||
"customSyntax": "postcss-scss",
|
||||
"extends": [
|
||||
"stylelint-config-standard-scss",
|
||||
"stylelint-config-styled-components",
|
||||
"stylelint-config-rational-order"
|
||||
],
|
||||
"rules": {
|
||||
"color-function-notation": ["legacy"],
|
||||
"declaration-empty-line-before": null,
|
||||
"order/properties-order": [],
|
||||
"plugin/rational-order": [
|
||||
true,
|
||||
{
|
||||
"border-in-box-model": false,
|
||||
"empty-line-between-groups": false
|
||||
}
|
||||
],
|
||||
"rules": {
|
||||
"declaration-empty-line-before": null,
|
||||
"declaration-block-no-redundant-longhand-properties": null,
|
||||
"selector-class-pattern": null,
|
||||
"selector-type-case": ["lower", { "ignoreTypes": ["/^\\$\\w+/"] }],
|
||||
"selector-type-no-unknown": [true, { "ignoreTypes": ["/-styled-mixin/", "/^\\$\\w+/"] }],
|
||||
"declaration-colon-newline-after": null,
|
||||
"property-no-vendor-prefix": null
|
||||
}
|
||||
"string-quotes": "single",
|
||||
"declaration-block-no-redundant-longhand-properties": null,
|
||||
"selector-class-pattern": null,
|
||||
"selector-type-case": ["lower", { "ignoreTypes": ["/^\\$\\w+/"] }],
|
||||
"selector-type-no-unknown": [true, { "ignoreTypes": ["/-styled-mixin/", "/^\\$\\w+/"] }],
|
||||
"value-keyword-case": ["lower", { "ignoreKeywords": ["dummyValue"] }],
|
||||
"declaration-colon-newline-after": null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
{
|
||||
"recommendations": ["dbaeumer.vscode-eslint"]
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"stylelint.vscode-stylelint",
|
||||
"esbenp.prettier-vscode",
|
||||
"ms-vscode.vscode-typescript-next"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,38 +2,12 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Main Process",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd"
|
||||
},
|
||||
"runtimeArgs": ["--sourcemap"],
|
||||
"env": {
|
||||
"REMOTE_DEBUGGING_PORT": "9222"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug Renderer Process",
|
||||
"port": 9222,
|
||||
"request": "attach",
|
||||
"type": "chrome",
|
||||
"webRoot": "${workspaceFolder}/src/renderer",
|
||||
"timeout": 60000,
|
||||
"presentation": {
|
||||
"hidden": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Debug All",
|
||||
"configurations": ["Debug Main Process", "Debug Renderer Process"],
|
||||
"presentation": {
|
||||
"order": 1
|
||||
}
|
||||
"name": "Debug Main Process",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"program": "${workspaceFolder}\\scripts\\watch.mjs",
|
||||
"autoAttachChildProcesses": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,82 +1,8 @@
|
||||
{
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"files.associations": {
|
||||
".eslintrc": "jsonc",
|
||||
".prettierrc": "jsonc",
|
||||
".eslintignore": "ignore"
|
||||
},
|
||||
"eslint.validate": ["typescript"],
|
||||
"eslint.workingDirectories": [
|
||||
{ "directory": "./", "changeProcessCWD": true },
|
||||
{ "directory": "./server", "changeProcessCWD": true }
|
||||
],
|
||||
"typescript.tsserver.experimental.enableProjectDiagnostics": false,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.fixAll.stylelint": "explicit",
|
||||
"source.organizeImports": "never",
|
||||
"source.formatDocument": "explicit"
|
||||
},
|
||||
"css.validate": true,
|
||||
"less.validate": false,
|
||||
"scss.validate": true,
|
||||
"scss.lint.unknownAtRules": "warning",
|
||||
"scss.lint.unknownProperties": "warning",
|
||||
"javascript.validate.enable": false,
|
||||
"javascript.format.enable": false,
|
||||
"typescript.format.enable": false,
|
||||
"search.exclude": {
|
||||
".git": true,
|
||||
".eslintcache": true,
|
||||
".erb/dll": true,
|
||||
"release/{build,app/dist}": true,
|
||||
"node_modules": true,
|
||||
"npm-debug.log.*": true,
|
||||
"test/**/__snapshots__": true,
|
||||
"package-lock.json": true,
|
||||
"*.{css,sass,scss}.d.ts": true,
|
||||
"out/**/*": true,
|
||||
"dist/**/*": true
|
||||
},
|
||||
"i18n-ally.localesPaths": ["src/i18n", "src/i18n/locales"],
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||
"typescript.preferences.importModuleSpecifier": "non-relative",
|
||||
"stylelint.validate": ["css", "scss", "typescript", "typescriptreact"],
|
||||
"typescript.updateImportsOnFileMove.enabled": "always",
|
||||
"[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
|
||||
"folderTemplates.structures": [
|
||||
{
|
||||
"name": "TypeScript Feature Component With CSS Modules",
|
||||
"omitParentDirectory": true,
|
||||
"structure": [
|
||||
{
|
||||
"fileName": "<FTName | kebabcase>.tsx",
|
||||
"template": "Functional Component with CSS Modules"
|
||||
},
|
||||
{
|
||||
"fileName": "<FTName | kebabcase>.module.scss"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"folderTemplates.fileTemplates": {
|
||||
"Functional Component with CSS Modules": [
|
||||
"import styles from './<FTName | kebabcase>.module.scss';",
|
||||
"",
|
||||
"interface <FTName | pascalcase>Props {}",
|
||||
"",
|
||||
"export const <FTName | pascalcase> = ({}: <FTName | pascalcase>Props) => {",
|
||||
" return <div></div>;",
|
||||
"};"
|
||||
]
|
||||
}
|
||||
"typescript.preferences.importModuleSpecifier": "non-relative",
|
||||
"stylelint.validate": ["css", "less", "postcss", "typescript", "typescriptreact", "scss"],
|
||||
"typescript.updateImportsOnFileMove.enabled": "always",
|
||||
"[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||
"[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
@@ -1,23 +0,0 @@
|
||||
# --- Builder stage
|
||||
FROM node:18-alpine as builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json first to cache node_modules
|
||||
COPY package.json package-lock.json .
|
||||
|
||||
RUN pnpm install
|
||||
|
||||
# Copy code and build with cached modules
|
||||
COPY . .
|
||||
RUN pnpm run build:web
|
||||
|
||||
# --- Production stage
|
||||
FROM nginx:alpine-slim
|
||||
|
||||
COPY --chown=nginx:nginx --from=builder /app/release/app/dist/web /usr/share/nginx/html
|
||||
COPY ./settings.js.template /etc/nginx/templates/settings.js.template
|
||||
COPY ng.conf.template /etc/nginx/templates/default.conf.template
|
||||
|
||||
ENV PUBLIC_PATH="/"
|
||||
EXPOSE 9180
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -1,3 +1,19 @@
|
||||
Copyright (C) 2022 jeffvli
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
@@ -70,7 +86,7 @@ modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
1. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
@@ -618,57 +634,4 @@ an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,180 +1,305 @@
|
||||
<img src="assets/icons/icon.png" alt="logo" title="feishin" align="right" height="60px" />
|
||||
# Vite Electron Builder Boilerplate
|
||||
|
||||
# Feishin
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/jeffvli/feishin/blob/main/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/jeffvli/feishin?style=flat-square&color=brightgreen"
|
||||
alt="License">
|
||||
</a>
|
||||
<a href="https://github.com/jeffvli/feishin/releases">
|
||||
<img src="https://img.shields.io/github/v/release/jeffvli/feishin?style=flat-square&color=blue"
|
||||
alt="Release">
|
||||
</a>
|
||||
<a href="https://github.com/jeffvli/feishin/releases">
|
||||
<img src="https://img.shields.io/github/downloads/jeffvli/feishin/total?style=flat-square&color=orange"
|
||||
alt="Downloads">
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/FVKpcMDy5f">
|
||||
<img src="https://img.shields.io/discord/922656312888811530?color=black&label=discord&logo=discord&logoColor=white"
|
||||
alt="Discord">
|
||||
</a>
|
||||
<a href="https://matrix.to/#/#sonixd:matrix.org">
|
||||
<img src="https://img.shields.io/matrix/sonixd:matrix.org?color=black&label=matrix&logo=matrix&logoColor=white"
|
||||
alt="Matrix">
|
||||
</a>
|
||||
</p>
|
||||
[](https://stand-with-ukraine.pp.ua)
|
||||
|
||||
---
|
||||
[](https://github.com/cawa-93/vite-electron-builder/issues?q=label%3A%22help+wanted%22+is%3Aopen+is%3Aissue)
|
||||
[](https://nodejs.org/about/releases/)
|
||||
[](https://github.com/npm/cli/releases)
|
||||
|
||||
Rewrite of [Sonixd](https://github.com/jeffvli/sonixd).
|
||||
> Vite+Electron = 🔥
|
||||
|
||||
This is a template for secure electron applications. Written following the latest safety requirements, recommendations
|
||||
and best practices.
|
||||
|
||||
Under the hood is [Vite] — A next-generation blazing fast bundler, and [electron-builder] for packaging.
|
||||
|
||||
## Get started
|
||||
|
||||
Follow these steps to get started with the template:
|
||||
|
||||
1. Click the **[Use this template](https://github.com/cawa-93/vite-electron-builder/generate)** button (you must be
|
||||
logged in) or just clone this repo.
|
||||
2. If you want to use another package manager don't forget to edit [`.github/workflows`](/.github/workflows) -- it
|
||||
uses `npm` by default.
|
||||
|
||||
That's all you need. 😉
|
||||
|
||||
**Note**: This template uses npm v7 feature — [**Installing Peer Dependencies
|
||||
Automatically**](https://github.com/npm/rfcs/blob/latest/implemented/0025-install-peer-deps.md). If you are using a
|
||||
different package manager, you may need to install some peerDependencies manually.
|
||||
|
||||
**Note**: Find more useful forks [here](https://github.com/cawa-93/vite-electron-builder/discussions/categories/forks).
|
||||
|
||||
## Features
|
||||
|
||||
- [x] MPV player backend
|
||||
- [x] Web player backend
|
||||
- [x] Modern UI
|
||||
- [x] Scrobble playback to your server
|
||||
- [x] Smart playlist editor (Navidrome)
|
||||
- [x] Synchronized and unsynchronized lyrics support
|
||||
- [ ] [Request a feature](https://github.com/jeffvli/feishin/issues) or [view taskboard](https://github.com/users/jeffvli/projects/5/views/1)
|
||||
### Electron [][electron]
|
||||
|
||||
## Screenshots
|
||||
- This template uses the latest electron version with all the latest security patches.
|
||||
- The architecture of the application is built according to the
|
||||
security [guides](https://www.electronjs.org/docs/tutorial/security) and best practices.
|
||||
- The latest version of the [electron-builder] is used to package the application.
|
||||
|
||||
<a href="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_full_screen_player.png"><img src="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_full_screen_player.png" width="49.5%"/></a> <a href="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_album_artist_detail.png"><img src="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_album_artist_detail.png" width="49.5%"/></a> <a href="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_album_detail.png"><img src="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_album_detail.png" width="49.5%"/></a> <a href="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_smart_playlist.png"><img src="https://raw.githubusercontent.com/jeffvli/feishin/development/media/preview_smart_playlist.png" width="49.5%"/></a>
|
||||
### Vite [][vite]
|
||||
|
||||
## Getting Started
|
||||
- [Vite] is used to bundle all source codes. It's an extremely fast bundler, that has a vast array of amazing features.
|
||||
You can learn more about how it is arranged in [this](https://www.youtube.com/watch?v=xXrhg26VCSc) video.
|
||||
- Vite [supports](https://vitejs.dev/guide/env-and-mode.html) reading `.env` files. You can also specify the types of
|
||||
your environment variables in [`types/env.d.ts`](types/env.d.ts).
|
||||
- Automatic hot-reloads for the `Main` and `Renderer` processes.
|
||||
|
||||
### Desktop (recommended)
|
||||
Vite provides many useful features, such as: `TypeScript`, `TSX/JSX`, `CSS/JSON Importing`, `CSS Modules`
|
||||
, `Web Assembly` and much more.
|
||||
|
||||
Download the [latest desktop client](https://github.com/jeffvli/feishin/releases). The desktop client is the recommended way to use Feishin. It supports both the MPV and web player backends, as well as includes built-in fetching for lyrics.
|
||||
[See all Vite features](https://vitejs.dev/guide/features.html).
|
||||
|
||||
#### macOS Notes
|
||||
### TypeScript [][typescript] (optional)
|
||||
|
||||
If you're using a device running macOS 12 (Monterey) or higher, [check here](https://github.com/jeffvli/feishin/issues/104#issuecomment-1553914730) for instructions on how to remove the app from quarantine.
|
||||
- The latest version of TypeScript is used for all the source code.
|
||||
- **Vite** supports TypeScript out of the box. However, it does not support type checking.
|
||||
- Code formatting rules follow the latest TypeScript recommendations and best practices thanks
|
||||
to [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin).
|
||||
|
||||
For media keys to work, you will be prompted to allow Feishin to be a Trusted Accessibility Client. After allowing, you will need to restart Feishin for the privacy settings to take effect.
|
||||
**[See this discussion](https://github.com/cawa-93/vite-electron-builder/discussions/339)** if you want completely
|
||||
remove TypeScript.
|
||||
|
||||
### Web and Docker
|
||||
### Vue [][vue] (optional)
|
||||
|
||||
Visit [https://feishin.vercel.app](https://feishin.vercel.app) to use the hosted web version of Feishin. The web client only supports the web player backend.
|
||||
- By default, web pages are built using [Vue]. However, you can easily change that. Or not use additional frameworks at
|
||||
all.
|
||||
- Code formatting rules follow the latest Vue recommendations and best practices thanks to [eslint-plugin-vue].
|
||||
|
||||
Feishin is also available as a Docker image. The images are hosted via `ghcr.io` and are available to view [here](https://github.com/jeffvli/feishin/pkgs/container/feishin). You can run the container using the following commands:
|
||||
See [examples of web pages for different frameworks](https://github.com/vitejs/vite/tree/main/packages/create-vite).
|
||||
|
||||
```bash
|
||||
# Run the latest version
|
||||
docker run --name feishin -p 9180:9180 ghcr.io/jeffvli/feishin:latest
|
||||
### Continuous Integration
|
||||
|
||||
# Build the image locally
|
||||
docker build -t feishin .
|
||||
docker run --name feishin -p 9180:9180 feishin
|
||||
- The configured workflow will check the types for each push and PR.
|
||||
- The configured workflow will check the code style for each push and PR.
|
||||
- **Automatic tests**
|
||||
used [Vitest ][vitest]
|
||||
-- A blazing fast test framework powered by Vite.
|
||||
- Unit tests are placed within each package and are ran separately.
|
||||
- End-to-end tests are placed in the root [`tests`](tests) directory and use [playwright].
|
||||
|
||||

|
||||
|
||||
|
||||
### Publishing
|
||||
|
||||
- Each time you push changes to the `main` branch, the [`release`](.github/workflows/release.yml) workflow starts, which creates a new draft release. For each next commit will be created and replaced artifacts. That way you will always have draft with latest artifacts, and the release can be published once it is ready.
|
||||
- Code signing supported. See [`release` workflow](.github/workflows/release.yml).
|
||||
- **Auto-update is supported**. After the release is published, all client applications will download the new version
|
||||
and install updates silently.
|
||||
|
||||
This template configured for GitHub, but electron-builder supports multiple auto-update servers. See [docs](https://www.electron.build/configuration/publish).
|
||||
|
||||
## How it works
|
||||
|
||||
The template requires a minimum amount [dependencies](package.json). Only **Vite** is used for building, nothing more.
|
||||
|
||||
### Project Structure
|
||||
|
||||
The structure of this template is very similar to the structure of a monorepo.
|
||||
|
||||
```mermaid
|
||||
flowchart TB;
|
||||
|
||||
packages/preload <-. IPC Messages .-> packages/main
|
||||
|
||||
subgraph packages/main
|
||||
M[index.ts] --> EM[Electron Main Process Modules]
|
||||
M --> N2[Node.js API]
|
||||
end
|
||||
|
||||
|
||||
subgraph packages/preload
|
||||
P[index.ts] --> N[Node.js API]
|
||||
P --> ED[External dependencies]
|
||||
P --> ER[Electron Renderer Process Modules]
|
||||
end
|
||||
|
||||
|
||||
subgraph packages/renderer
|
||||
R[index.html] --> W[Web API]
|
||||
R --> BD[Bundled dependencies]
|
||||
R --> F[Web Frameforks]
|
||||
end
|
||||
|
||||
packages/renderer -- Call Exposed API --> P
|
||||
```
|
||||
|
||||
#### Docker Compose
|
||||
The entire source code of the project is divided into three modules (packages) that are each bundled independently:
|
||||
|
||||
To install via Docker Compose use the following snippit. This also works on Portainer.
|
||||
- [`packages/renderer`](packages/renderer). Responsible for the contents of the application window. In fact, it is a
|
||||
regular web application. In developer mode, you can even open it in a browser. The development and build process is
|
||||
the same as for classic web applications. Access to low-level API electrons or Node.js is done through the _preload_
|
||||
layer.
|
||||
- [`packages/preload`](packages/preload). Acts as an intermediate bridge between the _renderer_ process and the API
|
||||
exposed by electron and Node.js. Runs in an _isolated browser context_, but has direct access to the full Node.js
|
||||
functionality.
|
||||
See [Checklist: Security Recommendations](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content)
|
||||
.
|
||||
- [`packages/main`](packages/main)
|
||||
Electron [**main script**](https://www.electronjs.org/docs/tutorial/quick-start#create-the-main-script-file). This is
|
||||
the main process that powers the application. It manages creating and handling the spawned BrowserWindow, setting and
|
||||
enforcing secure permissions and request handlers. You can also configure it to do much more as per your need, such
|
||||
as: logging, reporting statistics and health status among others.
|
||||
|
||||
```yaml
|
||||
services:
|
||||
feishin:
|
||||
container_name: feishin
|
||||
image: 'ghcr.io/jeffvli/feishin:latest'
|
||||
environment:
|
||||
- SERVER_NAME=jellyfin # pre defined server name
|
||||
- SERVER_LOCK=true # When true AND name/type/url are set, only username/password can be toggled
|
||||
- SERVER_TYPE=jellyfin # navidrome also works
|
||||
- SERVER_URL= # http://address:port
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- UMASK=002
|
||||
- TZ=America/Los_Angeles
|
||||
ports:
|
||||
- 9180:9180
|
||||
restart: unless-stopped
|
||||
### Build web resources
|
||||
|
||||
The `main` and `preload` packages are built in [library mode](https://vitejs.dev/guide/build.html#library-mode) as it is
|
||||
simple javascript.
|
||||
The `renderer` package builds as a regular web app.
|
||||
|
||||
### Compile App
|
||||
|
||||
The next step is to package a ready to distribute Electron app for macOS, Windows and Linux with "auto update" support
|
||||
out of the box.
|
||||
|
||||
To do this, use [electron-builder]:
|
||||
|
||||
- Using the npm script `compile`: This script is configured to compile the application as quickly as possible. It is not
|
||||
ready for distribution, it is compiled only for the current platform and is used for debugging.
|
||||
- Using GitHub Actions: The application is compiled for any platform and ready-to-distribute files are automatically
|
||||
added as a draft to the GitHub releases page.
|
||||
|
||||
### Working with dependencies
|
||||
|
||||
Because the `renderer` works and builds like a _regular web application_, you can only use dependencies that support the
|
||||
browser or compile to a browser-friendly format.
|
||||
|
||||
This means that in the `renderer` you are free to use any frontend dependencies such as Vue, React, lodash, axios and so
|
||||
on.However, you _CANNOT_ use any native Node.js APIs, such as, `systeminformation`. These APIs are _only_ available in
|
||||
a Node.js runtime environment and will cause your application to crash if used in the `renderer` layer. Instead, if you
|
||||
need access to Node.js runtime APIs in your frontend, export a function form the `preload` package.
|
||||
|
||||
All dependencies that require Node.js api can be used in
|
||||
the [`preload` script](https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts).
|
||||
|
||||
#### Expose in main world
|
||||
Here is an example. Let's say you need to read some data from the file system or database in the renderer.
|
||||
|
||||
In the preload context, create a function that reads and returns data. To make the function announced in the preload
|
||||
available in the render, you usually need to call
|
||||
the [`electron.contextBridge.exposeInMainWorld`](https://www.electronjs.org/ru/docs/latest/api/context-bridge). However,
|
||||
this template uses the [unplugin-auto-expose](https://github.com/cawa-93/unplugin-auto-expose) plugin, so you just need
|
||||
to export the method from the preload. The `exposeInMainWorld` will be called automatically.
|
||||
|
||||
```ts
|
||||
// preload/index.ts
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
// Encapsulate types if you use typescript
|
||||
interface UserData {
|
||||
prop: string
|
||||
}
|
||||
|
||||
// Encapsulate all node.js api
|
||||
// Everything you exported from preload/index.ts may be called in renderer
|
||||
export function getUserData(): Promise<UserData> {
|
||||
return readFile('/path/to/file/in/user/filesystem.json', {encoding:'utf8'}).then(JSON.parse);
|
||||
}
|
||||
```
|
||||
|
||||
### Configuration
|
||||
Now you can import and call the method in renderer
|
||||
|
||||
1. Upon startup you will be greeted with a prompt to select the path to your MPV binary. If you do not have MPV installed, you can download it [here](https://mpv.io/installation/) or install it using any package manager supported by your OS. After inputting the path, restart the app.
|
||||
|
||||
2. After restarting the app, you will be prompted to select a server. Click the `Open menu` button and select `Manage servers`. Click the `Add server` button in the popup and fill out all applicable details. You will need to enter the full URL to your server, including the protocol and port if applicable (e.g. `https://navidrome.my-server.com` or `http://192.168.0.1:4533`).
|
||||
|
||||
- **Navidrome** - For the best experience, select "Save password" when creating the server and configure the `SessionTimeout` setting in your Navidrome config to a larger value (e.g. 72h).
|
||||
- **Linux users** - The default password store uses `libsecret`. `kwallet4/5/6` are also supported, but must be explicitly set in Settings > Window > Passwords/secret score.
|
||||
|
||||
3. _Optional_ - If you want to host Feishin on a subpath (not `/`), then pass in the following environment variable: `PUBLIC_PATH=PATH`. For example, to host on `/feishin`, pass in `PUBLIC_PATH=/feishin`.
|
||||
|
||||
4. _Optional_ - To hard code the server url, pass the following environment variables: `SERVER_NAME`, `SERVER_TYPE` (one of `jellyfin` or `navidrome`), `SERVER_URL`. To prevent users from changing these settings, pass `SERVER_LOCK=true`. This can only be set if all three of the previous values are set.
|
||||
|
||||
## FAQ
|
||||
|
||||
### MPV is either not working or is rapidly switching between pause/play states
|
||||
|
||||
First thing to do is check that your MPV binary path is correct. Navigate to the settings page and re-set the path and restart the app. If your issue still isn't resolved, try reinstalling MPV. Known working versions include `v0.35.x` and `v0.36.x`. `v0.34.x` is a known broken version.
|
||||
|
||||
### What music servers does Feishin support?
|
||||
|
||||
Feishin supports any music server that implements a [Navidrome](https://www.navidrome.org/) or [Jellyfin](https://jellyfin.org/) API. **Subsonic API is not currently supported**. This will likely be added in [later when the new Subsonic API is decided on](https://support.symfonium.app/t/subsonic-servers-participation/1233).
|
||||
|
||||
- [Navidrome](https://github.com/navidrome/navidrome)
|
||||
- [Jellyfin](https://github.com/jellyfin/jellyfin)
|
||||
- Subsonic-compatible servers
|
||||
- [Airsonic-Advanced](https://github.com/airsonic-advanced/airsonic-advanced)
|
||||
- [Ampache](https://ampache.org)
|
||||
- [Astiga](https://asti.ga/)
|
||||
- [Funkwhale](https://www.funkwhale.audio/)
|
||||
- [Gonic](https://github.com/sentriz/gonic)
|
||||
- [LMS](https://github.com/epoupon/lms)
|
||||
- [Nextcloud Music](https://apps.nextcloud.com/apps/music)
|
||||
- [Supysonic](https://github.com/spl0k/supysonic)
|
||||
- More (?)
|
||||
|
||||
### I have the issue "The SUID sandbox helper binary was found, but is not configured correctly" on Linux
|
||||
|
||||
This happens when you have user (unprivileged) namespaces disabled (`sysctl kernel.unprivileged_userns_clone` returns 0). You can fix this by either enabling unprivileged namespaces, or by making the `chrome-sandbox` Setuid.
|
||||
|
||||
```bash
|
||||
chmod 4755 chrome-sandbox
|
||||
sudo chown root:root chrome-sandbox
|
||||
```ts
|
||||
// renderer/anywere/component.ts
|
||||
import { getUserData } from '#preload'
|
||||
const userData = await getUserData()
|
||||
```
|
||||
|
||||
Ubunutu 24.04 specifically introduced breaking changes that affect how namespaces work. Please see https://discourse.ubuntu.com/t/ubuntu-24-04-lts-noble-numbat-release-notes/39890#:~:text=security%20improvements%20 for possible fixes.
|
||||
[Read more about Security Considerations](https://www.electronjs.org/docs/tutorial/context-isolation#security-considerations).
|
||||
|
||||
## Development
|
||||
### Working with Electron API
|
||||
|
||||
Built and tested using Node `v23.11.0`.
|
||||
Although the preload has access to all of Node.js's API, it **still runs in the BrowserWindow context**, so a limited
|
||||
electron modules are available in it. Check the [electron docs](https://www.electronjs.org/ru/docs/latest/api/clipboard)
|
||||
for full list of available methods.
|
||||
|
||||
This project is built off of [electron-vite](https://github.com/alex8088/electron-vite)
|
||||
All other electron methods can be invoked in the `main`.
|
||||
|
||||
- `pnpm run dev` - Start the development server
|
||||
- `pnpm run dev:watch` - Start the development server in watch mode (for main / preload HMR)
|
||||
- `pnpm run start` - Starts the app in production preview mode
|
||||
- `pnpm run build` - Builds the app for desktop
|
||||
- `pnpm run build:electron` - Build the electron app (main, preload, and renderer)
|
||||
- `pnpm run build:remote` - Build the remote app (remote)
|
||||
- `pnpm run build:web` - Build the standalone web app (renderer)
|
||||
- `pnpm run package` - Package the project
|
||||
- `pnpm run package:dev` - Package the project for development
|
||||
- `pnpm run package:linux` - Package the project for Linux
|
||||
- `pnpm run package:mac` - Package the project for Mac
|
||||
- `pnpm run package:win` - Package the project for Windows
|
||||
- `pnpm run publish:linux` - Publish the project for Linux
|
||||
- `pnpm run publish:linux-arm64` - Publish the project for Linux ARM64
|
||||
- `pnpm run publish:mac` - Publish the project for Mac
|
||||
- `pnpm run publish:win` - Publish the project for Windows
|
||||
- `pnpm run typecheck` - Type check the project
|
||||
- `pnpm run typecheck:node` - Type check the project with tsconfig.node.json
|
||||
- `pnpm run typecheck:web` - Type check the project with tsconfig.web.json
|
||||
- `pnpm run lint` - Lint the project
|
||||
- `pnpm run lint:fix` - Lint the project and fix linting errors
|
||||
- `pnpm run i18next` - Generate i18n files
|
||||
As a result, the architecture of interaction between all modules is as follows:
|
||||
|
||||
## Translation
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
renderer->>+preload: Read data from file system
|
||||
preload->>-renderer: Data
|
||||
renderer->>preload: Maximize window
|
||||
activate preload
|
||||
preload-->>main: Invoke IPC command
|
||||
activate main
|
||||
main-->>preload: IPC response
|
||||
deactivate main
|
||||
preload->>renderer: Window maximized
|
||||
deactivate preload
|
||||
```
|
||||
|
||||
This project uses [Weblate](https://hosted.weblate.org/projects/feishin/) for translations. If you would like to contribute, please visit the link and submit a translation.
|
||||
[Read more about Inter-Process Communication](https://www.electronjs.org/docs/latest/tutorial/ipc)
|
||||
|
||||
## License
|
||||
### Modes and Environment Variables
|
||||
|
||||
[GNU General Public License v3.0 ©](https://github.com/jeffvli/feishin/blob/dev/LICENSE)
|
||||
All environment variables are set as part of the `import.meta`, so you can access them vie the following
|
||||
way: `import.meta.env`.
|
||||
|
||||
If you are using TypeScript and want to get code completion you must add all the environment variables to
|
||||
the [`ImportMetaEnv` in `types/env.d.ts`](types/env.d.ts).
|
||||
|
||||
The mode option is used to specify the value of `import.meta.env.MODE` and the corresponding environment variables files
|
||||
that need to be loaded.
|
||||
|
||||
By default, there are two modes:
|
||||
|
||||
- `production` is used by default
|
||||
- `development` is used by `npm run watch` script
|
||||
|
||||
When running the build script, the environment variables are loaded from the following files in your project root:
|
||||
|
||||
```
|
||||
.env # loaded in all cases
|
||||
.env.local # loaded in all cases, ignored by git
|
||||
.env.[mode] # only loaded in specified env mode
|
||||
.env.[mode].local # only loaded in specified env mode, ignored by git
|
||||
```
|
||||
|
||||
To prevent accidentally leaking env variables to the client, only variables prefixed with `VITE_` are exposed to your
|
||||
Vite-processed code.
|
||||
|
||||
For example let's take the following `.env` file:
|
||||
|
||||
```
|
||||
DB_PASSWORD=foobar
|
||||
VITE_SOME_KEY=123
|
||||
```
|
||||
|
||||
Only `VITE_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your client source code, but `DB_PASSWORD`
|
||||
will not.
|
||||
|
||||
## Contribution
|
||||
|
||||
See [Contributing Guide](contributing.md).
|
||||
|
||||
|
||||
[vite]: https://github.com/vitejs/vite/
|
||||
|
||||
[electron]: https://github.com/electron/electron
|
||||
|
||||
[electron-builder]: https://github.com/electron-userland/electron-builder
|
||||
|
||||
[vue]: https://github.com/vuejs/vue-next
|
||||
|
||||
[vue-router]: https://github.com/vuejs/vue-router-next/
|
||||
|
||||
[typescript]: https://github.com/microsoft/TypeScript/
|
||||
|
||||
[playwright]: https://playwright.dev
|
||||
|
||||
[vitest]: https://vitest.dev
|
||||
|
||||
[vue-tsc]: https://github.com/johnsoncodehk/vue-tsc
|
||||
|
||||
[eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
|
||||
|
||||
[cawa-93-github]: https://github.com/cawa-93/
|
||||
|
||||
[cawa-93-sponsor]: https://www.patreon.com/Kozack/
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
type Styles = Record<string, string>;
|
||||
|
||||
declare module '*.svg' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.png' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.jpg' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.scss' {
|
||||
const content: Styles;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.sass' {
|
||||
const content: Styles;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.css' {
|
||||
const content: Styles;
|
||||
export default content;
|
||||
}
|
||||
@@ -1,12 +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.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
Before Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 896 B |
|
Before Width: | Height: | Size: 971 B |
|
Before Width: | Height: | Size: 479 B |
|
Before Width: | Height: | Size: 524 B |
|
After Width: | Height: | Size: 84 KiB |
@@ -0,0 +1,34 @@
|
||||
# Contributing
|
||||
|
||||
First and foremost, thank you! We appreciate that you want to contribute to vite-electron-builder, your time is
|
||||
valuable, and your contributions mean a lot to us.
|
||||
|
||||
## Issues
|
||||
|
||||
Do not create issues about bumping dependencies unless a bug has been identified, and you can demonstrate that it
|
||||
effects this library.
|
||||
|
||||
**Help us to help you**
|
||||
|
||||
Remember that we’re here to help, but not to make guesses about what you need help with:
|
||||
|
||||
- Whatever bug or issue you're experiencing, assume that it will not be as obvious to the maintainers as it is to you.
|
||||
- Spell it out completely. Keep in mind that maintainers need to think about _all potential use cases_ of a library.
|
||||
It's important that you explain how you're using a library so that maintainers can make that connection and solve the
|
||||
issue.
|
||||
|
||||
_It can't be understated how frustrating and draining it can be to maintainers to have to ask clarifying questions on
|
||||
the most basic things, before it's even possible to start debugging. Please try to make the best use of everyone's time
|
||||
involved, including yourself, by providing this information up front._
|
||||
|
||||
## Repo Setup
|
||||
|
||||
The package manager used to install and link dependencies must be npm v7 or later.
|
||||
|
||||
1. Clone repo
|
||||
1. `npm run watch` start electron app in watch mode.
|
||||
1. `npm run compile` build app but for local debugging only.
|
||||
1. `npm run lint` lint your code.
|
||||
1. `npm run typecheck` Run typescript check.
|
||||
1. `npm run test` Run app test.
|
||||
1. `npm run format` Reformat all codebase to project code style.
|
||||
@@ -1,3 +0,0 @@
|
||||
provider: generic
|
||||
url: https://example.com/auto-updates
|
||||
updaterCacheDirName: feishin-updater
|
||||
@@ -1,13 +0,0 @@
|
||||
version: '3.5'
|
||||
services:
|
||||
feishin:
|
||||
container_name: feishin
|
||||
image: ghcr.io/jeffvli/feishin:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 9180:9180
|
||||
environment:
|
||||
- SERVER_NAME=jellyfin # pre defined server name
|
||||
- SERVER_LOCK=true # When true AND name/type/url are set, only username/password can be toggled
|
||||
- SERVER_TYPE=jellyfin # navidrome also works
|
||||
- SERVER_URL= # http://address:port
|
||||
@@ -1,75 +0,0 @@
|
||||
appId: org.jeffvli.feishin
|
||||
productName: Feishin
|
||||
artifactName: ${productName}-${version}-${os}-${arch}.${ext}
|
||||
electronVersion: 35.1.5
|
||||
directories:
|
||||
buildResources: assets
|
||||
files:
|
||||
- 'out/**/*'
|
||||
- 'package.json'
|
||||
extraResources:
|
||||
- assets/**
|
||||
asarUnpack:
|
||||
- resources/**
|
||||
win:
|
||||
target:
|
||||
- zip
|
||||
- nsis
|
||||
icon: assets/icons/icon.png
|
||||
nsis:
|
||||
shortcutName: ${productName}
|
||||
uninstallDisplayName: ${productName}
|
||||
createDesktopShortcut: always
|
||||
mac:
|
||||
target:
|
||||
target: default
|
||||
arch:
|
||||
- arm64
|
||||
- x64
|
||||
icon: assets/icons/icon.icns
|
||||
type: distribution
|
||||
hardenedRuntime: true
|
||||
entitlements: assets/entitlements.mac.plist
|
||||
entitlementsInherit: assets/entitlements.mac.plist
|
||||
gatekeeperAssess: false
|
||||
notarize: false
|
||||
dmg:
|
||||
contents: [{ x: 130, y: 220 }, { x: 410, y: 220, type: link, path: /Applications }]
|
||||
deb:
|
||||
depends:
|
||||
- libgssapi_krb5.so.2
|
||||
- libavahi-common.so.3
|
||||
- libavahi-client.so.3
|
||||
- libkrb5.so.3
|
||||
- libkrb5support.so.0
|
||||
- libkeyutils.so.1
|
||||
- libcups.so.2
|
||||
rpm:
|
||||
depends:
|
||||
- libgssapi_krb5.so.2
|
||||
- libavahi-common.so.3
|
||||
- libavahi-client.so.3
|
||||
- libkrb5.so.3
|
||||
- libkrb5support.so.0
|
||||
- libkeyutils.so.1
|
||||
- libcups.so.2
|
||||
freebsd:
|
||||
depends:
|
||||
- libgssapi_krb5.so.2
|
||||
- libavahi-common.so.3
|
||||
- libavahi-client.so.3
|
||||
- libkrb5.so.3
|
||||
- libkrb5support.so.0
|
||||
- libkeyutils.so.1
|
||||
- libcups.so.2
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
- tar.xz
|
||||
category: AudioVideo;Audio;Player
|
||||
icon: assets/icons/icon.png
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: github
|
||||
owner: jeffvli
|
||||
repo: feishin
|
||||
@@ -1,65 +0,0 @@
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { externalizeDepsPlugin, UserConfig } from 'electron-vite';
|
||||
import { resolve } from 'path';
|
||||
import conditionalImportPlugin from 'vite-plugin-conditional-import';
|
||||
import dynamicImportPlugin from 'vite-plugin-dynamic-import';
|
||||
import { ViteEjsPlugin } from 'vite-plugin-ejs';
|
||||
|
||||
const currentOSEnv = process.platform;
|
||||
|
||||
const config: UserConfig = {
|
||||
main: {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: ['source-map-support'],
|
||||
},
|
||||
},
|
||||
define: {
|
||||
'import.meta.env.IS_LINUX': JSON.stringify(currentOSEnv === 'linux'),
|
||||
'import.meta.env.IS_MACOS': JSON.stringify(currentOSEnv === 'darwin'),
|
||||
'import.meta.env.IS_WIN': JSON.stringify(currentOSEnv === 'win32'),
|
||||
},
|
||||
plugins: [
|
||||
externalizeDepsPlugin(),
|
||||
dynamicImportPlugin(),
|
||||
conditionalImportPlugin({
|
||||
currentEnv: currentOSEnv,
|
||||
envs: ['win32', 'linux', 'darwin'],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'/@/main': resolve('src/main'),
|
||||
'/@/shared': resolve('src/shared'),
|
||||
},
|
||||
},
|
||||
},
|
||||
preload: {
|
||||
plugins: [externalizeDepsPlugin()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'/@/preload': resolve('src/preload'),
|
||||
'/@/shared': resolve('src/shared'),
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer: {
|
||||
css: {
|
||||
modules: {
|
||||
generateScopedName: '[name]__[local]__[hash:base64:5]',
|
||||
localsConvention: 'camelCase',
|
||||
},
|
||||
},
|
||||
plugins: [react(), ViteEjsPlugin({ web: false })],
|
||||
resolve: {
|
||||
alias: {
|
||||
'/@/i18n': resolve('src/i18n'),
|
||||
'/@/remote': resolve('src/remote'),
|
||||
'/@/renderer': resolve('src/renderer'),
|
||||
'/@/shared': resolve('src/shared'),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,52 +0,0 @@
|
||||
import eslintConfigPrettier from '@electron-toolkit/eslint-config-prettier';
|
||||
import tseslint from '@electron-toolkit/eslint-config-ts';
|
||||
import perfectionist from 'eslint-plugin-perfectionist';
|
||||
import eslintPluginReact from 'eslint-plugin-react';
|
||||
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
|
||||
import eslintPluginReactRefresh from 'eslint-plugin-react-refresh';
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['**/node_modules', '**/dist', '**/out'] },
|
||||
tseslint.configs.recommended,
|
||||
perfectionist.configs['recommended-natural'],
|
||||
eslintPluginReact.configs.flat.recommended,
|
||||
eslintPluginReact.configs.flat['jsx-runtime'],
|
||||
{
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
plugins: {
|
||||
'react-hooks': eslintPluginReactHooks,
|
||||
'react-refresh': eslintPluginReactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...eslintPluginReactHooks.configs.recommended.rules,
|
||||
...eslintPluginReactRefresh.configs.vite.rules,
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'warn',
|
||||
curly: ['error', 'all'],
|
||||
indent: [
|
||||
'error',
|
||||
'tab',
|
||||
{
|
||||
offsetTernaryExpressions: true,
|
||||
SwitchCase: 1,
|
||||
},
|
||||
],
|
||||
'no-unused-vars': 'off',
|
||||
'no-use-before-define': 'off',
|
||||
quotes: ['error', 'single'],
|
||||
'react-refresh/only-export-components': 'off',
|
||||
'react/display-name': 'off',
|
||||
semi: ['error', 'always'],
|
||||
},
|
||||
},
|
||||
eslintConfigPrettier,
|
||||
);
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Alex Kozack
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
Before Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 644 KiB |
|
Before Width: | Height: | Size: 186 KiB |
|
Before Width: | Height: | Size: 465 KiB |
|
Before Width: | Height: | Size: 887 KiB |
|
Before Width: | Height: | Size: 396 KiB |
@@ -1,174 +1,128 @@
|
||||
{
|
||||
"name": "feishin",
|
||||
"version": "0.14.0",
|
||||
"description": "A modern self-hosted music player.",
|
||||
"keywords": [
|
||||
"subsonic",
|
||||
"navidrome",
|
||||
"jellyfin",
|
||||
"react",
|
||||
"electron"
|
||||
],
|
||||
"homepage": "https://github.com/jeffvli/feishin",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jeffvli/feishin/issues"
|
||||
},
|
||||
"license": "GPL-3.0",
|
||||
"author": {
|
||||
"name": "jeffvli",
|
||||
"url": "https://github.com/jeffvli/"
|
||||
},
|
||||
"main": "./out/main/index.js",
|
||||
"scripts": {
|
||||
"build": "pnpm run typecheck && pnpm run build:electron && pnpm run build:remote",
|
||||
"build:electron": "electron-vite build",
|
||||
"build:remote": "vite build --config remote.vite.config.ts",
|
||||
"build:web": "vite build --config web.vite.config.ts",
|
||||
"dev": "electron-vite dev",
|
||||
"dev:watch": "electron-vite dev --watch",
|
||||
"i18next": "i18next -c src/i18n/i18next-parser.config.js",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"lint": "eslint --cache .",
|
||||
"lint:fix": "eslint --cache --fix .",
|
||||
"package": "pnpm run build && electron-builder",
|
||||
"package:dev": "pnpm run build && electron-builder --dir",
|
||||
"package:linux": "pnpm run build && electron-builder --linux",
|
||||
"package:linux-arm64:pr": "pnpm run build && electron-builder --linux --arm64 --publish never",
|
||||
"package:linux:pr": "pnpm run build && electron-builder --linux --publish never",
|
||||
"package:mac": "pnpm run build && electron-builder --mac",
|
||||
"package:mac:pr": "pnpm run build && electron-builder --mac --publish never",
|
||||
"package:win": "pnpm run build && electron-builder --win",
|
||||
"package:win:pr": "pnpm run build && electron-builder --win --publish never",
|
||||
"publish:linux": "electron-builder --publish always --linux",
|
||||
"publish:linux-arm64": "electron-builder --publish always --linux --arm64",
|
||||
"publish:mac": "electron-builder --publish always --mac",
|
||||
"publish:win": "electron-builder --publish always --win",
|
||||
"start": "electron-vite preview",
|
||||
"typecheck": "pnpm run typecheck:node && pnpm run typecheck:web",
|
||||
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
|
||||
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ag-grid-community/client-side-row-model": "^28.2.1",
|
||||
"@ag-grid-community/core": "^28.2.1",
|
||||
"@ag-grid-community/infinite-row-model": "^28.2.1",
|
||||
"@ag-grid-community/react": "^28.2.1",
|
||||
"@ag-grid-community/styles": "^28.2.1",
|
||||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/utils": "^4.0.0",
|
||||
"@emotion/react": "^11.10.4",
|
||||
"@mantine/core": "^6.0.22",
|
||||
"@mantine/dates": "^6.0.22",
|
||||
"@mantine/form": "^6.0.22",
|
||||
"@mantine/hooks": "^6.0.22",
|
||||
"@mantine/modals": "^6.0.22",
|
||||
"@mantine/notifications": "^6.0.22",
|
||||
"@mantine/utils": "^6.0.22",
|
||||
"@tanstack/react-query": "^4.32.1",
|
||||
"@tanstack/react-query-devtools": "^4.32.1",
|
||||
"@tanstack/react-query-persist-client": "^4.32.1",
|
||||
"@ts-rest/core": "^3.23.0",
|
||||
"@xhayper/discord-rpc": "^1.0.24",
|
||||
"audiomotion-analyzer": "^4.5.0",
|
||||
"auto-text-size": "^0.2.3",
|
||||
"axios": "^1.6.0",
|
||||
"cheerio": "^1.0.0",
|
||||
"clsx": "^2.0.0",
|
||||
"cmdk": "^0.2.0",
|
||||
"dayjs": "^1.11.6",
|
||||
"dompurify": "^3.1.6",
|
||||
"electron-debug": "^3.2.0",
|
||||
"electron-localshortcut": "^3.2.1",
|
||||
"electron-log": "^5.1.1",
|
||||
"electron-store": "^8.1.0",
|
||||
"electron-updater": "^6.3.9",
|
||||
"fast-average-color": "^9.3.0",
|
||||
"format-duration": "^2.0.0",
|
||||
"framer-motion": "^11.0.0",
|
||||
"fuse.js": "^6.6.2",
|
||||
"i18next": "^21.10.0",
|
||||
"idb-keyval": "^6.2.1",
|
||||
"immer": "^9.0.21",
|
||||
"is-electron": "^2.2.2",
|
||||
"lodash": "^4.17.21",
|
||||
"md5": "^2.3.0",
|
||||
"memoize-one": "^6.0.0",
|
||||
"mpris-service": "^2.1.2",
|
||||
"nanoid": "^3.3.3",
|
||||
"node-mpv": "github:jeffvli/Node-MPV#32b4d64395289ad710c41d481d2707a7acfc228f",
|
||||
"overlayscrollbars": "^2.11.1",
|
||||
"overlayscrollbars-react": "^0.5.6",
|
||||
"qs": "^6.14.0",
|
||||
"react-error-boundary": "^3.1.4",
|
||||
"react-i18next": "^11.18.6",
|
||||
"react-icons": "^4.10.1",
|
||||
"react-player": "^2.11.0",
|
||||
"react-router": "^6.16.0",
|
||||
"react-router-dom": "^6.16.0",
|
||||
"react-simple-img": "^3.0.0",
|
||||
"react-virtualized-auto-sizer": "^1.0.17",
|
||||
"react-window": "^1.8.9",
|
||||
"react-window-infinite-loader": "^1.0.9",
|
||||
"semver": "^7.5.4",
|
||||
"styled-components": "^6.0.8",
|
||||
"swiper": "^9.3.1",
|
||||
"ws": "^8.18.2",
|
||||
"zod": "^3.22.3",
|
||||
"zustand": "^4.3.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
|
||||
"@electron-toolkit/eslint-config-ts": "^3.0.0",
|
||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
||||
"@types/electron-localshortcut": "^3.1.0",
|
||||
"@types/lodash": "^4.14.188",
|
||||
"@types/md5": "^2.3.2",
|
||||
"@types/node": "^22.14.1",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@types/react-window": "^1.8.5",
|
||||
"@types/react-window-infinite-loader": "^1.0.6",
|
||||
"@types/source-map-support": "^0.5.10",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"concurrently": "^7.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"electron": "^35.1.5",
|
||||
"electron-builder": "^26.0.12",
|
||||
"electron-devtools-installer": "^3.2.0",
|
||||
"electron-vite": "^3.1.0",
|
||||
"eslint": "^9.24.0",
|
||||
"eslint-plugin-perfectionist": "^4.13.0",
|
||||
"eslint-plugin-prettier": "^5.4.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.19",
|
||||
"i18next-parser": "^9.0.2",
|
||||
"postcss-styled-syntax": "^0.5.0",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-packagejson": "^2.5.14",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"sass-embedded": "^1.89.0",
|
||||
"stylelint": "^15.10.3",
|
||||
"stylelint-config-css-modules": "^4.3.0",
|
||||
"stylelint-config-recess-order": "^4.3.0",
|
||||
"stylelint-config-standard": "^34.0.0",
|
||||
"stylelint-config-standard-scss": "^4.0.0",
|
||||
"stylelint-config-styled-components": "^0.1.1",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-plugin-styled-components": "^3.0.0",
|
||||
"vite": "^6.3.5",
|
||||
"vite-plugin-conditional-import": "^0.1.7",
|
||||
"vite-plugin-dynamic-import": "^1.6.0",
|
||||
"vite-plugin-ejs": "^1.7.0"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"electron",
|
||||
"esbuild"
|
||||
]
|
||||
},
|
||||
"productName": "feishin"
|
||||
"name": "feishin",
|
||||
"description": "A full featured Jellyfin/Subsonic/Navidrome music player.",
|
||||
"version": "1.0.0-alpha1",
|
||||
"author": {
|
||||
"name": "jeffvli",
|
||||
"email": "jeffvictorli@gmail.com",
|
||||
"url": "https://github.com/jeffvli"
|
||||
},
|
||||
"main": "packages/main/dist/index.cjs",
|
||||
"scripts": {
|
||||
"build": "npm run build:main && npm run build:preload && npm run build:renderer",
|
||||
"build:main": "cd ./packages/main && vite build",
|
||||
"build:preload": "cd ./packages/preload && vite build",
|
||||
"build:renderer": "cd ./packages/renderer && vite build",
|
||||
"compile": "cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.js --dir",
|
||||
"test": "npm run test:main && npm run test:preload && npm run test:renderer && npm run test:e2e",
|
||||
"test:e2e": "npm run build && vitest run",
|
||||
"test:main": "vitest run -r packages/main --passWithNoTests",
|
||||
"test:preload": "vitest run -r packages/preload --passWithNoTests",
|
||||
"test:renderer": "vitest run -r packages/renderer --passWithNoTests",
|
||||
"watch": "node scripts/watch.mjs",
|
||||
"lint": "eslint . --ext js,mjs,cjs,ts,mts,cts,tsx",
|
||||
"typecheck:main": "tsc --noEmit -p packages/main/tsconfig.json",
|
||||
"typecheck:preload": "tsc --noEmit -p packages/preload/tsconfig.json",
|
||||
"typecheck:renderer": "tsc --noEmit -p packages/renderer/tsconfig.json",
|
||||
"typecheck": "npm run typecheck:main && npm run typecheck:preload && npm run typecheck:renderer",
|
||||
"postinstall": "cross-env ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.mjs",
|
||||
"format": "npx prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/electron-localshortcut": "^3.1.0",
|
||||
"@types/lodash": "^4.14.191",
|
||||
"@types/md5": "^2.3.2",
|
||||
"@types/node": "18.11.10",
|
||||
"@types/react": "^18.0.26",
|
||||
"@types/react-dom": "^18.0.9",
|
||||
"@types/react-slider": "^1.3.1",
|
||||
"@types/react-virtualized-auto-sizer": "^1.0.1",
|
||||
"@types/react-window": "^1.8.5",
|
||||
"@types/react-window-infinite-loader": "^1.0.6",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"@typescript-eslint/eslint-plugin": "^5.45.1",
|
||||
"@typescript-eslint/parser": "^5.45.1",
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "22.0.0",
|
||||
"electron-builder": "23.6.0",
|
||||
"electron-devtools-installer": "^3.2.0",
|
||||
"eslint": "8.29.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-erb": "^4.0.3",
|
||||
"eslint-import-resolver-typescript": "^2.7.1",
|
||||
"eslint-import-resolver-webpack": "^0.13.2",
|
||||
"eslint-plugin-compat": "^4.0.2",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-jest": "^26.1.3",
|
||||
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"eslint-plugin-react": "^7.31.11",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
||||
"eslint-plugin-typescript-sort-keys": "^2.1.0",
|
||||
"happy-dom": "7.7.2",
|
||||
"nano-staged": "0.8.0",
|
||||
"playwright": "1.27.1",
|
||||
"rollup-plugin-visualizer": "^5.8.3",
|
||||
"sass": "^1.56.1",
|
||||
"simple-git-hooks": "2.8.1",
|
||||
"stylelint": "^14.16.0",
|
||||
"stylelint-config-rational-order": "^0.1.2",
|
||||
"stylelint-config-standard-scss": "^6.1.0",
|
||||
"stylelint-config-styled-components": "^0.1.1",
|
||||
"stylelint-order": "^5.0.0",
|
||||
"stylelint-processor-styled-components": "^1.10.0",
|
||||
"typescript": "4.9.3",
|
||||
"unplugin-auto-expose": "0.0.4",
|
||||
"vite": "3.2.4",
|
||||
"vitest": "0.25.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ag-grid-community/client-side-row-model": "^28.2.1",
|
||||
"@ag-grid-community/core": "^28.2.1",
|
||||
"@ag-grid-community/react": "^28.2.1",
|
||||
"@ag-grid-community/styles": "^28.2.1",
|
||||
"@mantine/core": "^5.9.2",
|
||||
"@mantine/dates": "^5.9.2",
|
||||
"@mantine/dropzone": "^5.9.2",
|
||||
"@mantine/form": "^5.9.2",
|
||||
"@mantine/hooks": "^5.9.2",
|
||||
"@mantine/modals": "^5.9.2",
|
||||
"@mantine/notifications": "^5.9.2",
|
||||
"@mantine/spotlight": "^5.9.2",
|
||||
"@tanstack/react-query": "^4.19.1",
|
||||
"@tanstack/react-query-devtools": "^4.19.1",
|
||||
"@vitejs/plugin-react": "^2.2.0",
|
||||
"electron-localshortcut": "^3.2.1",
|
||||
"electron-store": "^8.1.0",
|
||||
"electron-updater": "5.3.0",
|
||||
"fast-average-color": "^9.1.1",
|
||||
"format-duration": "^2.0.0",
|
||||
"framer-motion": "^7.6.19",
|
||||
"immer": "^9.0.16",
|
||||
"is-electron": "^2.2.1",
|
||||
"ky": "^0.32.2",
|
||||
"ky-universal": "^0.11.0",
|
||||
"lodash": "^4.17.21",
|
||||
"md5": "^2.3.0",
|
||||
"memoize-one": "^6.0.0",
|
||||
"nanoid": "^4.0.0",
|
||||
"node-mpv": "^2.0.0-beta.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-error-boundary": "^3.1.4",
|
||||
"react-i18next": "^11.16.7",
|
||||
"react-icons": "^4.7.1",
|
||||
"react-player": "^2.11.0",
|
||||
"react-router": "^6.4.4",
|
||||
"react-router-dom": "^6.4.4",
|
||||
"react-simple-img": "^3.0.0",
|
||||
"react-slider": "^2.0.4",
|
||||
"react-virtualized-auto-sizer": "^1.0.7",
|
||||
"react-window": "^1.8.8",
|
||||
"react-window-infinite-loader": "^1.0.8",
|
||||
"styled-components": "^5.3.6",
|
||||
"zod": "^3.19.1",
|
||||
"zustand": "^4.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import './player';
|
||||
import './media-keys';
|
||||
import './settings';
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { BrowserWindow } from 'electron';
|
||||
import { globalShortcut } from 'electron';
|
||||
|
||||
export const enableMediaKeys = (window: BrowserWindow | null) => {
|
||||
globalShortcut.register('MediaStop', () => {
|
||||
window?.webContents.send('renderer-player-stop');
|
||||
});
|
||||
|
||||
globalShortcut.register('MediaPlayPause', () => {
|
||||
window?.webContents.send('renderer-player-play-pause');
|
||||
});
|
||||
|
||||
globalShortcut.register('MediaNextTrack', () => {
|
||||
window?.webContents.send('renderer-player-next');
|
||||
});
|
||||
|
||||
globalShortcut.register('MediaPreviousTrack', () => {
|
||||
window?.webContents.send('renderer-player-previous');
|
||||
});
|
||||
};
|
||||
|
||||
export const disableMediaKeys = () => {
|
||||
globalShortcut.unregister('MediaStop');
|
||||
globalShortcut.unregister('MediaPlayPause');
|
||||
globalShortcut.unregister('MediaNextTrack');
|
||||
globalShortcut.unregister('MediaPreviousTrack');
|
||||
};
|
||||
@@ -0,0 +1,167 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import MpvAPI from 'node-mpv';
|
||||
import { store } from '../settings';
|
||||
import uniq from 'lodash/uniq';
|
||||
import type { PlayerData } from '../../../../../renderer/src/store/player.store';
|
||||
import { getBrowserWindow } from '/@/mainWindow';
|
||||
|
||||
declare module 'node-mpv';
|
||||
|
||||
const BINARY_PATH = store.get('mpv_path') as string | undefined;
|
||||
const MPV_PARAMETERS = store.get('mpv_parameters') as Array<string> | undefined;
|
||||
const DEFAULT_MPV_PARAMETERS = () => {
|
||||
const parameters = [];
|
||||
if (
|
||||
!MPV_PARAMETERS?.includes('--gapless-audio=weak') ||
|
||||
!MPV_PARAMETERS?.includes('--gapless-audio=no') ||
|
||||
!MPV_PARAMETERS?.includes('--gapless-audio=yes') ||
|
||||
!MPV_PARAMETERS?.includes('--gapless-audio')
|
||||
) {
|
||||
parameters.push('--gapless-audio=yes');
|
||||
}
|
||||
|
||||
if (
|
||||
!MPV_PARAMETERS?.includes('--prefetch-playlist=no') ||
|
||||
!MPV_PARAMETERS?.includes('--prefetch-playlist=yes') ||
|
||||
!MPV_PARAMETERS?.includes('--prefetch-playlist')
|
||||
) {
|
||||
parameters.push('--prefetch-playlist=yes');
|
||||
}
|
||||
|
||||
return parameters;
|
||||
};
|
||||
|
||||
const mpv = new MpvAPI(
|
||||
{
|
||||
audio_only: true,
|
||||
auto_restart: true,
|
||||
binary: BINARY_PATH || '',
|
||||
time_update: 1,
|
||||
},
|
||||
MPV_PARAMETERS
|
||||
? uniq([...DEFAULT_MPV_PARAMETERS(), ...MPV_PARAMETERS])
|
||||
: DEFAULT_MPV_PARAMETERS(),
|
||||
);
|
||||
|
||||
mpv
|
||||
.start()
|
||||
.then(async () => {
|
||||
// await mpv.load('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3', 'replace');
|
||||
// await mpv.play();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error', error);
|
||||
});
|
||||
|
||||
mpv.on('status', (status) => {
|
||||
if (status.property === 'playlist-pos') {
|
||||
if (status.value !== 0) {
|
||||
getBrowserWindow()?.webContents.send('renderer-player-auto-next');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Automatically updates the play button when the player is playing
|
||||
mpv.on('resumed', () => {
|
||||
getBrowserWindow()?.webContents.send('renderer-player-play');
|
||||
});
|
||||
|
||||
// Automatically updates the play button when the player is stopped
|
||||
mpv.on('stopped', () => {
|
||||
getBrowserWindow()?.webContents.send('renderer-player-stop');
|
||||
});
|
||||
|
||||
// Automatically updates the play button when the player is paused
|
||||
mpv.on('paused', () => {
|
||||
getBrowserWindow()?.webContents.send('renderer-player-pause');
|
||||
});
|
||||
|
||||
mpv.on('quit', () => {
|
||||
console.log('mpv quit');
|
||||
});
|
||||
|
||||
// Event output every interval set by time_update, used to update the current time
|
||||
mpv.on('timeposition', (time: number) => {
|
||||
getBrowserWindow()?.webContents.send('renderer-player-current-time', time);
|
||||
});
|
||||
|
||||
// Starts the player
|
||||
ipcMain.on('player-play', async () => {
|
||||
await mpv.play();
|
||||
});
|
||||
|
||||
// Pauses the player
|
||||
ipcMain.on('player-pause', async () => {
|
||||
await mpv.pause();
|
||||
});
|
||||
|
||||
// Stops the player
|
||||
ipcMain.on('player-stop', async () => {
|
||||
await mpv.stop();
|
||||
});
|
||||
|
||||
// Goes to the next track in the playlist
|
||||
ipcMain.on('player-next', async () => {
|
||||
await mpv.next();
|
||||
});
|
||||
|
||||
// Goes to the previous track in the playlist
|
||||
ipcMain.on('player-previous', async () => {
|
||||
await mpv.prev();
|
||||
});
|
||||
|
||||
// Seeks forward or backward by the given amount of seconds
|
||||
ipcMain.on('player-seek', async (_event, time: number) => {
|
||||
await mpv.seek(time);
|
||||
});
|
||||
|
||||
// Seeks to the given time in seconds
|
||||
ipcMain.on('player-seek-to', async (_event, time: number) => {
|
||||
await mpv.goToPosition(time);
|
||||
});
|
||||
|
||||
// Sets the queue in position 0 and 1 to the given data. Used when manually starting a song or using the next/prev buttons
|
||||
ipcMain.on('player-set-queue', async (_event, data: PlayerData) => {
|
||||
if (data.queue.current) {
|
||||
await mpv.load(data.queue.current.streamUrl, 'replace');
|
||||
}
|
||||
|
||||
if (data.queue.next) {
|
||||
await mpv.load(data.queue.next.streamUrl, 'append');
|
||||
}
|
||||
});
|
||||
|
||||
// Replaces the queue in position 1 to the given data
|
||||
ipcMain.on('player-set-queue-next', async (_event, data: PlayerData) => {
|
||||
const size = await mpv.getPlaylistSize();
|
||||
|
||||
if (size > 1) {
|
||||
await mpv.playlistRemove(1);
|
||||
}
|
||||
|
||||
if (data.queue.next) {
|
||||
await mpv.load(data.queue.next.streamUrl, 'append');
|
||||
}
|
||||
});
|
||||
|
||||
// Sets the next song in the queue when reaching the end of the queue
|
||||
ipcMain.on('player-auto-next', async (_event, data: PlayerData) => {
|
||||
// Always keep the current song as position 0 in the mpv queue
|
||||
// This allows us to easily set update the next song in the queue without
|
||||
// disturbing the currently playing song
|
||||
await mpv.playlistRemove(0);
|
||||
|
||||
if (data.queue.next) {
|
||||
await mpv.load(data.queue.next.streamUrl, 'append');
|
||||
}
|
||||
});
|
||||
|
||||
// Sets the volume to the given value (0-100)
|
||||
ipcMain.on('player-volume', async (_event, value: number) => {
|
||||
mpv.volume(value);
|
||||
});
|
||||
|
||||
// Toggles the mute status
|
||||
ipcMain.on('player-mute', async () => {
|
||||
mpv.mute();
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
import Store from 'electron-store';
|
||||
|
||||
export const store = new Store();
|
||||
@@ -0,0 +1,3 @@
|
||||
import './core';
|
||||
|
||||
// require(`./${process.platform}`);
|
||||
@@ -0,0 +1,71 @@
|
||||
import { app, ipcMain } from 'electron';
|
||||
import './security-restrictions';
|
||||
import { restoreOrCreateWindow } from '/@/mainWindow';
|
||||
|
||||
ipcMain.on('app-restart', () => {
|
||||
app.relaunch();
|
||||
app.exit(0);
|
||||
});
|
||||
|
||||
/**
|
||||
* Prevent electron from running multiple instances.
|
||||
*/
|
||||
const isSingleInstance = app.requestSingleInstanceLock();
|
||||
if (!isSingleInstance) {
|
||||
app.quit();
|
||||
process.exit(0);
|
||||
}
|
||||
app.on('second-instance', restoreOrCreateWindow);
|
||||
|
||||
/**
|
||||
* Disable Hardware Acceleration to save more system resources.
|
||||
*/
|
||||
app.disableHardwareAcceleration();
|
||||
|
||||
/**
|
||||
* Shout down background process if all windows was closed
|
||||
*/
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @see https://www.electronjs.org/docs/latest/api/app#event-activate-macos Event: 'activate'.
|
||||
*/
|
||||
app.on('activate', restoreOrCreateWindow);
|
||||
|
||||
/**
|
||||
* Create the application window when the background process is ready.
|
||||
*/
|
||||
app
|
||||
.whenReady()
|
||||
.then(restoreOrCreateWindow)
|
||||
.catch((e) => console.error('Failed create window:', e));
|
||||
|
||||
/**
|
||||
* Install Vue.js or any other extension in development mode only.
|
||||
* Note: You must install `electron-devtools-installer` manually
|
||||
*/
|
||||
// if (import.meta.env.DEV) {
|
||||
// app.whenReady()
|
||||
// .then(() => import('electron-devtools-installer'))
|
||||
// .then(({default: installExtension, VUEJS3_DEVTOOLS}) => installExtension(VUEJS3_DEVTOOLS, {
|
||||
// loadExtensionOptions: {
|
||||
// allowFileAccess: true,
|
||||
// },
|
||||
// }))
|
||||
// .catch(e => console.error('Failed install extension:', e));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Check for new version of the application - production mode only.
|
||||
*/
|
||||
if (import.meta.env.PROD) {
|
||||
app
|
||||
.whenReady()
|
||||
.then(() => import('electron-updater'))
|
||||
.then(({ autoUpdater }) => autoUpdater.checkForUpdatesAndNotify())
|
||||
.catch((e) => console.error('Failed check updates:', e));
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import { join } from 'path';
|
||||
import { URL } from 'url';
|
||||
import { disableMediaKeys, enableMediaKeys } from './features/core/media-keys';
|
||||
import { store } from './features/core/settings';
|
||||
import electronLocalShortcut from 'electron-localshortcut';
|
||||
import './features';
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||
|
||||
const installExtensions = async () => {
|
||||
const installer = require('electron-devtools-installer');
|
||||
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
|
||||
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];
|
||||
|
||||
return installer
|
||||
.default(
|
||||
extensions.map((name) => installer[name]),
|
||||
forceDownload,
|
||||
)
|
||||
.catch(console.log);
|
||||
};
|
||||
|
||||
let browserWindow: BrowserWindow | null = null;
|
||||
|
||||
async function createWindow() {
|
||||
if (isDevelopment) {
|
||||
await installExtensions();
|
||||
}
|
||||
|
||||
browserWindow = new BrowserWindow({
|
||||
show: false, // Use the 'ready-to-show' event to show the instantiated BrowserWindow.
|
||||
frame: false,
|
||||
minWidth: 640,
|
||||
minHeight: 600,
|
||||
height: 900,
|
||||
width: 1440,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
sandbox: false, // Sandbox disabled because the demo of preload script depend on the Node.js api
|
||||
webviewTag: false, // The webview tag is not recommended. Consider alternatives like an iframe or Electron's BrowserView. @see https://www.electronjs.org/docs/latest/api/webview-tag#warning
|
||||
preload: join(app.getAppPath(), 'packages/preload/dist/index.cjs'),
|
||||
backgroundThrottling: false,
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* If the 'show' property of the BrowserWindow's constructor is omitted from the initialization options,
|
||||
* it then defaults to 'true'. This can cause flickering as the window loads the html content,
|
||||
* and it also has show problematic behaviour with the closing of the window.
|
||||
* Use `show: false` and listen to the `ready-to-show` event to show the window.
|
||||
*
|
||||
* @see https://github.com/electron/electron/issues/25012 for the afford mentioned issue.
|
||||
*/
|
||||
browserWindow.on('ready-to-show', () => {
|
||||
browserWindow?.show();
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
browserWindow?.webContents.openDevTools();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('window-maximize', () => {
|
||||
browserWindow?.maximize();
|
||||
});
|
||||
|
||||
ipcMain.on('window-unmaximize', () => {
|
||||
browserWindow?.unmaximize();
|
||||
});
|
||||
|
||||
ipcMain.on('window-minimize', () => {
|
||||
browserWindow?.minimize();
|
||||
});
|
||||
|
||||
ipcMain.on('window-close', () => {
|
||||
browserWindow?.close();
|
||||
});
|
||||
|
||||
electronLocalShortcut.register(browserWindow, 'Ctrl+Shift+I', () => {
|
||||
browserWindow?.webContents.openDevTools();
|
||||
});
|
||||
|
||||
const globalMediaKeysEnabled = store.get('global_media_hotkeys') as boolean;
|
||||
|
||||
if (globalMediaKeysEnabled) {
|
||||
enableMediaKeys(browserWindow);
|
||||
}
|
||||
|
||||
ipcMain.on('global-media-keys-enable', () => {
|
||||
enableMediaKeys(browserWindow);
|
||||
});
|
||||
|
||||
ipcMain.on('global-media-keys-disable', () => {
|
||||
disableMediaKeys();
|
||||
});
|
||||
|
||||
/**
|
||||
* URL for main window.
|
||||
* Vite dev server for development.
|
||||
* `file://../renderer/index.html` for production and test.
|
||||
*/
|
||||
const pageUrl =
|
||||
import.meta.env.DEV && import.meta.env.VITE_DEV_SERVER_URL !== undefined
|
||||
? import.meta.env.VITE_DEV_SERVER_URL
|
||||
: new URL('../renderer/dist/index.html', 'file://' + __dirname).toString();
|
||||
|
||||
await browserWindow.loadURL(pageUrl);
|
||||
|
||||
return browserWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore an existing BrowserWindow or Create a new BrowserWindow.
|
||||
*/
|
||||
export async function restoreOrCreateWindow() {
|
||||
let window = BrowserWindow.getAllWindows().find((w) => !w.isDestroyed());
|
||||
|
||||
if (window === undefined) {
|
||||
window = await createWindow();
|
||||
}
|
||||
|
||||
if (window.isMinimized()) {
|
||||
window.restore();
|
||||
}
|
||||
|
||||
window.focus();
|
||||
}
|
||||
|
||||
ipcMain.on('app-restart', () => {
|
||||
app.relaunch();
|
||||
app.exit(0);
|
||||
});
|
||||
|
||||
export const getBrowserWindow = () => {
|
||||
return browserWindow;
|
||||
};
|
||||
@@ -0,0 +1,135 @@
|
||||
import {app, shell} from 'electron';
|
||||
import {URL} from 'url';
|
||||
|
||||
type Permissions =
|
||||
| 'clipboard-read'
|
||||
| 'media'
|
||||
| 'display-capture'
|
||||
| 'mediaKeySystem'
|
||||
| 'geolocation'
|
||||
| 'notifications'
|
||||
| 'midi'
|
||||
| 'midiSysex'
|
||||
| 'pointerLock'
|
||||
| 'fullscreen'
|
||||
| 'openExternal'
|
||||
| 'unknown';
|
||||
|
||||
/**
|
||||
* A list of origins that you allow open INSIDE the application and permissions for them.
|
||||
*
|
||||
* In development mode you need allow open `VITE_DEV_SERVER_URL`.
|
||||
*/
|
||||
const ALLOWED_ORIGINS_AND_PERMISSIONS = new Map<string, Set<Permissions>>(
|
||||
import.meta.env.DEV && import.meta.env.VITE_DEV_SERVER_URL
|
||||
? [[new URL(import.meta.env.VITE_DEV_SERVER_URL).origin, new Set()]]
|
||||
: [],
|
||||
);
|
||||
|
||||
/**
|
||||
* A list of origins that you allow open IN BROWSER.
|
||||
* Navigation to the origins below is only possible if the link opens in a new window.
|
||||
*
|
||||
* @example
|
||||
* <a
|
||||
* target="_blank"
|
||||
* href="https://github.com/"
|
||||
* >
|
||||
*/
|
||||
const ALLOWED_EXTERNAL_ORIGINS = new Set<`https://${string}`>(['https://github.com']);
|
||||
|
||||
app.on('web-contents-created', (_, contents) => {
|
||||
/**
|
||||
* Block navigation to origins not on the allowlist.
|
||||
*
|
||||
* Navigation exploits are quite common. If an attacker can convince the app to navigate away from its current page,
|
||||
* they can possibly force the app to open arbitrary web resources/websites on the web.
|
||||
*
|
||||
* @see https://www.electronjs.org/docs/latest/tutorial/security#13-disable-or-limit-navigation
|
||||
*/
|
||||
contents.on('will-navigate', (event, url) => {
|
||||
const {origin} = new URL(url);
|
||||
if (ALLOWED_ORIGINS_AND_PERMISSIONS.has(origin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent navigation
|
||||
event.preventDefault();
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
console.warn(`Blocked navigating to disallowed origin: ${origin}`);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Block requests for disallowed permissions.
|
||||
* By default, Electron will automatically approve all permission requests.
|
||||
*
|
||||
* @see https://www.electronjs.org/docs/latest/tutorial/security#5-handle-session-permission-requests-from-remote-content
|
||||
*/
|
||||
contents.session.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
const {origin} = new URL(webContents.getURL());
|
||||
|
||||
const permissionGranted = !!ALLOWED_ORIGINS_AND_PERMISSIONS.get(origin)?.has(permission);
|
||||
callback(permissionGranted);
|
||||
|
||||
if (!permissionGranted && import.meta.env.DEV) {
|
||||
console.warn(`${origin} requested permission for '${permission}', but was rejected.`);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Hyperlinks leading to allowed sites are opened in the default browser.
|
||||
*
|
||||
* The creation of new `webContents` is a common attack vector. Attackers attempt to convince the app to create new windows,
|
||||
* frames, or other renderer processes with more privileges than they had before; or with pages opened that they couldn't open before.
|
||||
* You should deny any unexpected window creation.
|
||||
*
|
||||
* @see https://www.electronjs.org/docs/latest/tutorial/security#14-disable-or-limit-creation-of-new-windows
|
||||
* @see https://www.electronjs.org/docs/latest/tutorial/security#15-do-not-use-openexternal-with-untrusted-content
|
||||
*/
|
||||
contents.setWindowOpenHandler(({url}) => {
|
||||
const {origin} = new URL(url);
|
||||
|
||||
// @ts-expect-error Type checking is performed in runtime.
|
||||
if (ALLOWED_EXTERNAL_ORIGINS.has(origin)) {
|
||||
// Open url in default browser.
|
||||
shell.openExternal(url).catch(console.error);
|
||||
} else if (import.meta.env.DEV) {
|
||||
console.warn(`Blocked the opening of a disallowed origin: ${origin}`);
|
||||
}
|
||||
|
||||
// Prevent creating a new window.
|
||||
return {action: 'deny'};
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify webview options before creation.
|
||||
*
|
||||
* Strip away preload scripts, disable Node.js integration, and ensure origins are on the allowlist.
|
||||
*
|
||||
* @see https://www.electronjs.org/docs/latest/tutorial/security#12-verify-webview-options-before-creation
|
||||
*/
|
||||
contents.on('will-attach-webview', (event, webPreferences, params) => {
|
||||
const {origin} = new URL(params.src);
|
||||
if (!ALLOWED_ORIGINS_AND_PERMISSIONS.has(origin)) {
|
||||
if (import.meta.env.DEV) {
|
||||
console.warn(`A webview tried to attach ${params.src}, but was blocked.`);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip away preload scripts if unused or verify their location is legitimate.
|
||||
delete webPreferences.preload;
|
||||
// @ts-expect-error `preloadURL` exists. - @see https://www.electronjs.org/docs/latest/api/web-contents#event-will-attach-webview
|
||||
delete webPreferences.preloadURL;
|
||||
|
||||
// Disable Node.js integration
|
||||
webPreferences.nodeIntegration = false;
|
||||
|
||||
// Enable contextIsolation
|
||||
webPreferences.contextIsolation = true;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import type {MockedClass} from 'vitest';
|
||||
import {beforeEach, expect, test, vi} from 'vitest';
|
||||
import {restoreOrCreateWindow} from '../src/mainWindow';
|
||||
|
||||
import {BrowserWindow} from 'electron';
|
||||
|
||||
/**
|
||||
* Mock real electron BrowserWindow API
|
||||
*/
|
||||
vi.mock('electron', () => {
|
||||
// Use "as unknown as" because vi.fn() does not have static methods
|
||||
const bw = vi.fn() as unknown as MockedClass<typeof BrowserWindow>;
|
||||
bw.getAllWindows = vi.fn(() => bw.mock.instances);
|
||||
bw.prototype.loadURL = vi.fn((_: string, __?: Electron.LoadURLOptions) => Promise.resolve());
|
||||
// Use "any" because the on function is overloaded
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
bw.prototype.on = vi.fn<any>();
|
||||
bw.prototype.destroy = vi.fn();
|
||||
bw.prototype.isDestroyed = vi.fn();
|
||||
bw.prototype.isMinimized = vi.fn();
|
||||
bw.prototype.focus = vi.fn();
|
||||
bw.prototype.restore = vi.fn();
|
||||
|
||||
const app: Pick<Electron.App, 'getAppPath'> = {
|
||||
getAppPath(): string {
|
||||
return '';
|
||||
},
|
||||
};
|
||||
|
||||
return {BrowserWindow: bw, app};
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
test('Should create a new window', async () => {
|
||||
const {mock} = vi.mocked(BrowserWindow);
|
||||
expect(mock.instances).toHaveLength(0);
|
||||
|
||||
await restoreOrCreateWindow();
|
||||
expect(mock.instances).toHaveLength(1);
|
||||
expect(mock.instances[0].loadURL).toHaveBeenCalledOnce();
|
||||
expect(mock.instances[0].loadURL).toHaveBeenCalledWith(expect.stringMatching(/index\.html$/));
|
||||
});
|
||||
|
||||
test('Should restore an existing window', async () => {
|
||||
const {mock} = vi.mocked(BrowserWindow);
|
||||
|
||||
// Create a window and minimize it.
|
||||
await restoreOrCreateWindow();
|
||||
expect(mock.instances).toHaveLength(1);
|
||||
const appWindow = vi.mocked(mock.instances[0]);
|
||||
appWindow.isMinimized.mockReturnValueOnce(true);
|
||||
|
||||
await restoreOrCreateWindow();
|
||||
expect(mock.instances).toHaveLength(1);
|
||||
expect(appWindow.restore).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
test('Should create a new window if the previous one was destroyed', async () => {
|
||||
const {mock} = vi.mocked(BrowserWindow);
|
||||
|
||||
// Create a window and destroy it.
|
||||
await restoreOrCreateWindow();
|
||||
expect(mock.instances).toHaveLength(1);
|
||||
const appWindow = vi.mocked(mock.instances[0]);
|
||||
appWindow.isDestroyed.mockReturnValueOnce(true);
|
||||
|
||||
await restoreOrCreateWindow();
|
||||
expect(mock.instances).toHaveLength(2);
|
||||
});
|
||||