mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-12 01:39:43 +00:00
Compare commits
184 Commits
Kunkun-v0.
...
develop
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3542eec277 | ||
![]() |
de3886d416 | ||
![]() |
bb9a46935c | ||
![]() |
bf51fdadbc | ||
![]() |
9cf06b1835 | ||
![]() |
48e2e47f96 | ||
![]() |
9fe51f6260 | ||
![]() |
7759e615dd | ||
![]() |
11226ee2ef | ||
![]() |
c39e98258c | ||
![]() |
d27731d0e6 | ||
![]() |
0bca6739a7 | ||
![]() |
993e276e72 | ||
![]() |
310969e597 | ||
![]() |
cd7301255b | ||
![]() |
b4afcaac6c | ||
![]() |
234f245a9c | ||
![]() |
cc7cea7fe9 | ||
![]() |
90ba943fb6 | ||
![]() |
6ffc6f1543 | ||
![]() |
2cbe45f6d1 | ||
![]() |
a42d4d97eb | ||
![]() |
5fc99ca26c | ||
![]() |
41302a29ff | ||
![]() |
8751fbeff4 | ||
![]() |
6df1c9865a | ||
![]() |
f09b2832e9 | ||
![]() |
6555ebcfcb | ||
![]() |
9e52ea331e | ||
![]() |
70f7d4131e | ||
![]() |
97cd20906f | ||
![]() |
a92c266d32 | ||
![]() |
66135624b9 | ||
![]() |
8940d25245 | ||
![]() |
8d49f50495 | ||
![]() |
441abbcdae | ||
![]() |
330678cb45 | ||
![]() |
52919b8d2f | ||
![]() |
ed20f9a142 | ||
![]() |
b5ea128aca | ||
![]() |
872b601338 | ||
![]() |
a0bd2d8573 | ||
![]() |
ec951bfc80 | ||
![]() |
4d90e2cf29 | ||
![]() |
8a9f6bcb09 | ||
![]() |
07c62e236c | ||
![]() |
ac6e2c3f78 | ||
![]() |
b986121708 | ||
![]() |
369a9719fd | ||
![]() |
9cfb59e7e4 | ||
![]() |
d3215d386d | ||
![]() |
0bd65db3e5 | ||
![]() |
dfd84db783 | ||
![]() |
60f442dafb | ||
![]() |
742cf3af09 | ||
![]() |
ba36b6226a | ||
![]() |
eeeeaf1822 | ||
![]() |
71b88e0a22 | ||
![]() |
513cf16d72 | ||
![]() |
41f864e996 | ||
![]() |
b119c4e8aa | ||
![]() |
bbee92fa9f | ||
![]() |
162a8dd685 | ||
![]() |
b866967dda | ||
![]() |
a359c8b739 | ||
![]() |
b5848ecea5 | ||
![]() |
63403b6118 | ||
![]() |
03450e8a12 | ||
![]() |
e36237facd | ||
![]() |
4221b574c9 | ||
![]() |
f1cace38d4 | ||
![]() |
c8112b43bc | ||
![]() |
e9dfaf519e | ||
![]() |
474b0f59b3 | ||
![]() |
6bd7d71df6 | ||
![]() |
b28573713a | ||
![]() |
bdf99ee196 | ||
![]() |
183af3fb84 | ||
![]() |
5573923a76 | ||
![]() |
0eacf01de2 | ||
![]() |
839bad6751 | ||
![]() |
27fdff03d9 | ||
![]() |
7b6c0934ab | ||
![]() |
490368428e | ||
![]() |
e49c0f5da5 | ||
![]() |
f37605f9a2 | ||
![]() |
872bcfdfd1 | ||
![]() |
f895594b62 | ||
![]() |
46d6872614 | ||
![]() |
b4b7851366 | ||
![]() |
4862484857 | ||
![]() |
4626acf534 | ||
![]() |
2fd119f842 | ||
![]() |
892c31ae31 | ||
![]() |
e260264797 | ||
![]() |
798cc773e5 | ||
![]() |
33e4451be2 | ||
![]() |
0bb59e4f66 | ||
![]() |
c93ebd895e | ||
![]() |
63bc401d8e | ||
![]() |
b7b81013ba | ||
![]() |
51f2f22f69 | ||
![]() |
fd41247d37 | ||
![]() |
e719176b9c | ||
![]() |
0cc744592f | ||
![]() |
f03cb6cbad | ||
![]() |
646801ac99 | ||
![]() |
f05ffdfcfd | ||
![]() |
5250a25283 | ||
![]() |
b115e0a574 | ||
![]() |
c260ca2fc2 | ||
![]() |
090271bdb9 | ||
![]() |
402208e95a | ||
![]() |
7a3b6f3983 | ||
![]() |
21a90259ac | ||
![]() |
e3e50e2f18 | ||
![]() |
e4d1441d73 | ||
![]() |
de00107972 | ||
![]() |
0b1658228b | ||
![]() |
d73ae6542c | ||
![]() |
9cda312523 | ||
![]() |
f78403eeb6 | ||
![]() |
7e811440b8 | ||
![]() |
130608cd92 | ||
![]() |
80a854e432 | ||
![]() |
f6b70bade0 | ||
![]() |
0af6ef2d0a | ||
![]() |
836a92cf14 | ||
![]() |
3b888351cf | ||
![]() |
c9d5801d8c | ||
![]() |
dea35f261b | ||
![]() |
2bb24799f3 | ||
![]() |
becfc184be | ||
![]() |
2890af9599 | ||
![]() |
0367dd666a | ||
![]() |
e21bef154e | ||
![]() |
e096e10bc0 | ||
![]() |
7c68a8d70f | ||
![]() |
59855992d7 | ||
![]() |
83efba033d | ||
![]() |
a090c23efc | ||
![]() |
943f52d929 | ||
![]() |
b1e21aa040 | ||
![]() |
1b8a99d897 | ||
![]() |
470f8a210d | ||
![]() |
01bc0ea932 | ||
![]() |
f48484f476 | ||
![]() |
6ce27244a5 | ||
![]() |
f89cf8fe6a | ||
![]() |
d3f18e6618 | ||
![]() |
41d9c72277 | ||
![]() |
6995e0b8d9 | ||
![]() |
caa252b4dd | ||
![]() |
80ad705f7c | ||
![]() |
99b940b03b | ||
![]() |
da8e37c4a1 | ||
![]() |
84b82f47a4 | ||
![]() |
b7724a25ee | ||
![]() |
ad30a8c3bb | ||
![]() |
e812d4229d | ||
![]() |
5ead38bf71 | ||
![]() |
e9609cf8ee | ||
![]() |
7b9be980b9 | ||
![]() |
fb0e5761c9 | ||
![]() |
292d03a51e | ||
![]() |
c7003326db | ||
![]() |
7865d18580 | ||
![]() |
0600eca59a | ||
![]() |
f29fe00dcf | ||
![]() |
b24236b9ca | ||
![]() |
71e5c5f316 | ||
![]() |
b311866355 | ||
![]() |
e57e181276 | ||
![]() |
4a05c5a475 | ||
![]() |
ce42409a39 | ||
![]() |
f043d7afe0 | ||
![]() |
605a7844f2 | ||
![]() |
2c99f231f7 | ||
![]() |
f64e562034 | ||
![]() |
54b7cc58c4 | ||
![]() |
9c250b99f0 | ||
![]() |
e74835ad79 | ||
![]() |
0c7c1e8612 | ||
![]() |
be07e16b36 |
@ -1,11 +1,19 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": []
|
||||
"$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "develop",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": [
|
||||
"jarvis",
|
||||
"form-view",
|
||||
"@kksh/desktop",
|
||||
"@kksh/utils",
|
||||
"@kksh/extension",
|
||||
"@kksh/schema",
|
||||
"@kksh/ui"
|
||||
]
|
||||
}
|
||||
|
11
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
11
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -15,7 +15,7 @@ body:
|
||||
placeholder: Bug description
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
@ -40,4 +40,11 @@ body:
|
||||
label: Contributes
|
||||
options:
|
||||
- label: I am willing to submit a PR to fix this issue
|
||||
- label: I am willing to submit a PR with failing tests
|
||||
- label: I am willing to submit a PR with failing tests
|
||||
|
||||
- type: checkboxes
|
||||
id: searched
|
||||
attributes:
|
||||
label: Searched
|
||||
options:
|
||||
- label: I have searched for similar issues and found none
|
||||
|
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -2,7 +2,7 @@ blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: GitHub Discussions
|
||||
url: https://github.com/kunkunsh/kunkun/discussions
|
||||
about: Please ask and answer questions here.
|
||||
about: Discussions and questions here
|
||||
- name: 💬 Discord
|
||||
url: https://discord.gg/7dzw3TYeTU
|
||||
about: Please ask and answer questions here.
|
||||
about: Please ask and answer questions here
|
||||
|
7
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
7
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -41,4 +41,9 @@ body:
|
||||
options:
|
||||
- label: I am willing to submit a PR to implement this feature
|
||||
|
||||
|
||||
- type: checkboxes
|
||||
id: searched
|
||||
attributes:
|
||||
label: Searched
|
||||
options:
|
||||
- label: I have searched for similar issues and found none
|
||||
|
30
.github/workflows/beta-build.yml
vendored
30
.github/workflows/beta-build.yml
vendored
@ -1,20 +1,23 @@
|
||||
name: Build Beta Package
|
||||
name: Build Beta
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "22 22 * * *"
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
updater:
|
||||
description: "Enable updater?"
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
default: false
|
||||
platform_windows:
|
||||
description: "windows"
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
default: false
|
||||
platform_linux:
|
||||
description: "linux"
|
||||
required: true
|
||||
@ -90,8 +93,8 @@ jobs:
|
||||
id: setting
|
||||
run: |
|
||||
matrix=""
|
||||
if [ "${{ github.event_name }}" == "schedule" ]; then
|
||||
matrix="\"windows-latest\",\"ubuntu-22.04\",\"macos-14\",\"macos-12\""
|
||||
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||
matrix="\"windows-latest\",\"ubuntu-22.04\",\"macos-14\",\"macos-13\""
|
||||
build_mode=""
|
||||
build_path="release"
|
||||
retention_days='1'
|
||||
@ -106,7 +109,7 @@ jobs:
|
||||
matrix="${matrix}\"macos-14\","
|
||||
fi
|
||||
if [ "${{ inputs.platform_macos_x86_64 }}" == "true" ]; then
|
||||
matrix="${matrix}\"macos-12\","
|
||||
matrix="${matrix}\"macos-13\","
|
||||
fi
|
||||
if [ -z "${matrix}" ]; then
|
||||
matrix="\"windows-latest\","
|
||||
@ -137,8 +140,6 @@ jobs:
|
||||
RETENTION_DAYS: ${{ needs.preprocess.outputs.retention_days }}
|
||||
FILE_PREFIX: ${{ needs.preprocess.outputs.file_prefix }}
|
||||
# BUILD_TIME: ${{ needs.preprocess.outputs.build_time }}
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||
NO_STRIP: true
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@ -172,10 +173,6 @@ jobs:
|
||||
if: startsWith(matrix.os, 'macos')
|
||||
run: |
|
||||
brew install protobuf
|
||||
- name: Install and Protobuf (Ubuntu)
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt install -y protobuf-compiler
|
||||
- name: Install protoc and openssl for windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
@ -188,7 +185,7 @@ jobs:
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev protobuf-compiler
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
@ -208,12 +205,15 @@ jobs:
|
||||
run: pnpm prepare
|
||||
|
||||
- name: Build Packages
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: pnpm build
|
||||
|
||||
- name: Build the app (Windows)
|
||||
- name: Build the App
|
||||
working-directory: apps/desktop
|
||||
env:
|
||||
CI: false
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: pnpm tauri build ${{ env.BUILD_MODE}} ${{ matrix.os == 'windows-latest' && '-b nsis' || '' }}
|
||||
|
||||
- name: Rename macos-aarch64
|
||||
@ -221,7 +221,7 @@ jobs:
|
||||
run: mv target/${{ env.BUILD_PATH }}/bundle/dmg/*.dmg target/${{ env.BUILD_PATH }}/bundle/dmg/${{ env.FILE_PREFIX }}-aarch64.dmg
|
||||
|
||||
- name: Rename macos-x86_64
|
||||
if: matrix.os == 'macos-12'
|
||||
if: matrix.os == 'macos-13'
|
||||
run: mv target/${{ env.BUILD_PATH }}/bundle/dmg/*.dmg target/${{ env.BUILD_PATH }}/bundle/dmg/${{ env.FILE_PREFIX }}-amd64.dmg
|
||||
|
||||
- name: Rename windows
|
||||
|
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@ -5,6 +5,7 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
@ -29,11 +30,38 @@ jobs:
|
||||
- uses: denoland/setup-deno@v2
|
||||
with:
|
||||
deno-version: v2.x
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
- name: Install protobuf (Mac)
|
||||
if: matrix.os == 'macos-14'
|
||||
run: |
|
||||
brew install protobuf
|
||||
- name: Install Protobuf (Ubuntu)
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y protobuf-compiler libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev
|
||||
- name: Install protoc and openssl for windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
choco install protoc
|
||||
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
vcpkg install openssl:x64-windows-static-md
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
- name: Setup
|
||||
run: pnpm prepare
|
||||
- name: Build
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: pnpm build
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
- name: JS Test
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: |
|
||||
pnpm test
|
||||
pnpm lint
|
||||
- name: Cargo Build and Test
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: |
|
||||
cargo build
|
||||
cargo test
|
||||
|
57
.github/workflows/desktop-publish.yml
vendored
57
.github/workflows/desktop-publish.yml
vendored
@ -15,15 +15,16 @@ jobs:
|
||||
matrix:
|
||||
settings:
|
||||
- platform: "macos-14" # for Arm based macs (M1 and above).
|
||||
args: "--target aarch64-apple-darwin --verbose"
|
||||
- platform: "macos-14" # for Intel based macs.
|
||||
args: "--target x86_64-apple-darwin --verbose"
|
||||
args: "--target aarch64-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json"
|
||||
- platform: "macos-13" # for Intel based macs.
|
||||
args: "--target x86_64-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json"
|
||||
# Universal Build no longer supported after adding openssl, which is not cross-compilable.
|
||||
- platform: "macos-14" # for Both Arm and Intel based macs.
|
||||
args: "--target universal-apple-darwin --verbose"
|
||||
args: "--target universal-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json"
|
||||
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
|
||||
args: "--verbose"
|
||||
args: "--verbose --config src-tauri/tauri.conf.publish.json"
|
||||
- platform: "windows-latest"
|
||||
args: "--verbose"
|
||||
args: "--verbose --config src-tauri/tauri.conf.publish.json"
|
||||
|
||||
runs-on: ${{ matrix.settings.platform }}
|
||||
steps:
|
||||
@ -31,35 +32,36 @@ jobs:
|
||||
with:
|
||||
submodules: "true"
|
||||
|
||||
- name: install dependencies (ubuntu only)
|
||||
- name: Install Dependencies (ubuntu only)
|
||||
if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above.
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev
|
||||
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.
|
||||
- name: Install protobuf (Mac)
|
||||
if: matrix.settings.platform == 'macos-14'
|
||||
if: startsWith(matrix.settings.platform, 'macos')
|
||||
run: |
|
||||
brew install protobuf
|
||||
brew install openssl
|
||||
- name: Install Protobuf (Ubuntu)
|
||||
if: matrix.settings.platform == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt install -y protobuf-compiler
|
||||
- name: Install protoc and openssl for windows
|
||||
if: matrix.settings.platform == 'windows-latest'
|
||||
run: |
|
||||
choco install protoc
|
||||
choco install openssl
|
||||
echo OPENSSL_DIR='"C:\\Program Files\\OpenSSL-Win64"' >> $env:GITHUB_ENV
|
||||
echo OPENSSL_INCLUDE_DIR='"C:\\Program Files\\OpenSSL-Win64\\include"' >> $env:GITHUB_ENV
|
||||
echo OPENSSL_LIB_DIR='"C:\\Program Files\\OpenSSL-Win64\\lib"' >> $env:GITHUB_ENV
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: setup node
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
||||
cache-dependency-path: ./pnpm-lock.yaml
|
||||
- name: Install protoc and openssl for windows
|
||||
if: matrix.settings.platform == 'windows-latest'
|
||||
run: |
|
||||
choco install protoc
|
||||
choco install openssl
|
||||
echo OPENSSL_DIR='C:\Program Files\OpenSSL' >> $env:GITHUB_ENV
|
||||
echo OPENSSL_INCLUDE_DIR='C:\Program Files\OpenSSL\include' >> $env:GITHUB_ENV
|
||||
echo OPENSSL_LIB_DIR='C:\Program Files\OpenSSL\lib\VC\x64\MDd' >> $env:GITHUB_ENV
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
@ -71,18 +73,23 @@ jobs:
|
||||
run: |
|
||||
rustup target add aarch64-apple-darwin
|
||||
rustup target add x86_64-apple-darwin
|
||||
- name: Rust cache
|
||||
- name: Rust Cache
|
||||
uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: "./apps/desktop/src-tauri -> target"
|
||||
workspaces: ". -> target"
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: 1.1.27
|
||||
bun-version: latest
|
||||
- name: Install Dependencies
|
||||
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
|
||||
run: pnpm install
|
||||
- name: Environment Check
|
||||
run: |
|
||||
pnpm install
|
||||
pnpm prepare
|
||||
# pnpm --filter=@kksh/ci run ci-env-check
|
||||
bun packages/ci/scripts/ci-env-check.ts
|
||||
- name: Build Packages
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: pnpm build
|
||||
- name: Get App Version
|
||||
if: matrix.settings.platform == 'windows-latest'
|
||||
id: appversion
|
||||
@ -91,7 +98,9 @@ jobs:
|
||||
- uses: tauri-apps/tauri-action@v0
|
||||
env:
|
||||
CI: false
|
||||
KUNKUN_PUBLISH: true
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
||||
|
4
.github/workflows/jsr-publish.yml
vendored
4
.github/workflows/jsr-publish.yml
vendored
@ -1,5 +1,7 @@
|
||||
name: JSR Publish
|
||||
on:
|
||||
push:
|
||||
branches: [develop, main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@ -12,6 +14,8 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: denoland/setup-deno@v2
|
||||
with:
|
||||
deno-version: v2.x
|
||||
|
4
.github/workflows/manifest-schema-upload.yml
vendored
4
.github/workflows/manifest-schema-upload.yml
vendored
@ -23,6 +23,10 @@ jobs:
|
||||
- uses: denoland/setup-deno@v2
|
||||
with:
|
||||
deno-version: v2.x
|
||||
- name: Install Protobuf
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y protobuf-compiler
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
- name: Setup
|
||||
|
23
.github/workflows/ninja_i18n.yml
vendored
Normal file
23
.github/workflows/ninja_i18n.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
name: Ninja i18n action
|
||||
|
||||
on: pull_request_target
|
||||
|
||||
# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
|
||||
permissions:
|
||||
pull-requests: write # Necessary to comment on PRs
|
||||
issues: read # Necessary to read issue comments
|
||||
contents: read # Necessary to access the repo content
|
||||
|
||||
jobs:
|
||||
ninja-i18n:
|
||||
name: Ninja i18n - GitHub Lint Action
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run Ninja i18n
|
||||
# @main ensures that the latest version of the action is used
|
||||
uses: opral/ninja-i18n-action@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
39
.github/workflows/npm-publish.yml
vendored
Normal file
39
.github/workflows/npm-publish.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: NPM Package Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [develop, main]
|
||||
release:
|
||||
types: [created]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22.x"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
- uses: pnpm/action-setup@v4
|
||||
- run: pnpm install
|
||||
- run: pnpm build
|
||||
working-directory: packages/api
|
||||
- name: Check if version is already published
|
||||
working-directory: packages/api
|
||||
run: |
|
||||
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
||||
npm view @kksh/api@$PACKAGE_VERSION
|
||||
continue-on-error: true
|
||||
id: check_version
|
||||
- name: Publish
|
||||
working-directory: packages/api
|
||||
if: steps.check_version.outcome != 'success'
|
||||
run: npm publish --provenance --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
121
.github/workflows/test-build.yml
vendored
Normal file
121
.github/workflows/test-build.yml
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
name: "Desktop Test build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "test-build"
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
permissions:
|
||||
contents: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
settings:
|
||||
- platform: "macos-14" # for Arm based macs (M1 and above).
|
||||
args: "--target aarch64-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json"
|
||||
- platform: "macos-13" # for Intel based macs.
|
||||
args: "--target x86_64-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json"
|
||||
# Universal Build no longer supported after adding openssl, which is not cross-compilable.
|
||||
- platform: "macos-14" # for Both Arm and Intel based macs.
|
||||
args: "--target universal-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json"
|
||||
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
|
||||
args: "--verbose --config src-tauri/tauri.conf.publish.json"
|
||||
- platform: "windows-latest"
|
||||
args: "--verbose --config src-tauri/tauri.conf.publish.json"
|
||||
|
||||
runs-on: ${{ matrix.settings.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: "true"
|
||||
|
||||
- name: Install Dependencies (ubuntu only)
|
||||
if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above.
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev
|
||||
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.
|
||||
- name: Install protobuf (Mac)
|
||||
if: startsWith(matrix.settings.platform, 'macos')
|
||||
run: |
|
||||
brew install protobuf
|
||||
brew install openssl
|
||||
- name: Install Protobuf (Ubuntu)
|
||||
if: matrix.settings.platform == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt install -y protobuf-compiler
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
||||
cache-dependency-path: ./pnpm-lock.yaml
|
||||
- name: Install protoc and openssl for windows
|
||||
if: matrix.settings.platform == 'windows-latest'
|
||||
run: |
|
||||
choco install protoc
|
||||
choco install openssl
|
||||
echo OPENSSL_DIR='C:\Program Files\OpenSSL' >> $env:GITHUB_ENV
|
||||
echo OPENSSL_INCLUDE_DIR='C:\Program Files\OpenSSL\include' >> $env:GITHUB_ENV
|
||||
echo OPENSSL_LIB_DIR='C:\Program Files\OpenSSL\lib\VC\x64\MDd' >> $env:GITHUB_ENV
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
|
||||
targets: ${{ matrix.settings.platform == 'macos-14' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||
- name: Add rust target (macos only)
|
||||
if: matrix.settings.platform == 'macos-14'
|
||||
run: |
|
||||
rustup target add aarch64-apple-darwin
|
||||
rustup target add x86_64-apple-darwin
|
||||
- name: Rust Cache
|
||||
uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: ". -> target"
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: latest
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
- name: Environment Check
|
||||
run: |
|
||||
# pnpm --filter=@kksh/ci run ci-env-check
|
||||
bun packages/ci/scripts/ci-env-check.ts
|
||||
- name: Build Packages
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: pnpm build
|
||||
- name: Get App Version
|
||||
if: matrix.settings.platform == 'windows-latest'
|
||||
id: appversion
|
||||
run: |
|
||||
echo "version=$(node -p "require('./apps/desktop/package.json').version")" >> $env:GITHUB_OUTPUT
|
||||
- uses: tauri-apps/tauri-action@v0
|
||||
env:
|
||||
CI: false
|
||||
KUNKUN_PUBLISH: true
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||
with:
|
||||
tagName: Kunkun-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
|
||||
releaseName: "Kunkun v__VERSION__"
|
||||
releaseBody: "See the assets to download this version and install."
|
||||
releaseDraft: false
|
||||
prerelease: false
|
||||
args: ${{ matrix.settings.args }} ${{ contains(steps.appversion.outputs.version, 'beta') && matrix.settings.platform == 'windows-latest' && '-b nsis' || '' }}
|
||||
projectPath: "./apps/desktop"
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,3 +38,4 @@ yarn-error.log*
|
||||
*.pem
|
||||
stats.html
|
||||
target/
|
||||
.idea/
|
||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -7,3 +7,9 @@
|
||||
[submodule "vendors/tauri-plugin-system-info"]
|
||||
path = vendors/tauri-plugin-system-info
|
||||
url = https://github.com/HuakunShen/tauri-plugin-system-info.git
|
||||
[submodule "vendors/tauri-plugin-user-input"]
|
||||
path = vendors/tauri-plugin-user-input
|
||||
url = https://github.com/kunkunsh/tauri-plugin-user-input.git
|
||||
[submodule "vendors/tauri-plugin-keyring"]
|
||||
path = vendors/tauri-plugin-keyring
|
||||
url = https://github.com/HuakunShen/tauri-plugin-keyring.git
|
@ -1,3 +1,5 @@
|
||||
.svelte-kit/
|
||||
target/
|
||||
vendors
|
||||
vendors/**
|
||||
vendors
|
||||
.nuxt/
|
||||
|
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
@ -3,6 +3,7 @@
|
||||
"svelte.svelte-vscode",
|
||||
"tauri-apps.tauri-vscode",
|
||||
"rust-lang.rust-analyzer",
|
||||
"denoland.vscode-deno"
|
||||
"denoland.vscode-deno",
|
||||
"tamasfe.even-better-toml"
|
||||
]
|
||||
}
|
||||
|
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Tauri Development Debug",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--manifest-path=./apps/desktop/src-tauri/Cargo.toml",
|
||||
"--no-default-features"
|
||||
]
|
||||
},
|
||||
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
|
||||
"preLaunchTask": "ui:dev"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Tauri Production Debug",
|
||||
"cargo": {
|
||||
"args": ["build", "--release", "--manifest-path=./apps/desktop/src-tauri/Cargo.toml"]
|
||||
},
|
||||
// task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json`
|
||||
"preLaunchTask": "ui:build"
|
||||
}
|
||||
]
|
||||
}
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -9,5 +9,11 @@
|
||||
"titleBar.activeBackground": "#2f0ec4",
|
||||
"titleBar.activeForeground": "#FFFBFC"
|
||||
},
|
||||
"svelte.enable-ts-plugin": true
|
||||
"svelte.enable-ts-plugin": true,
|
||||
"deno.enable": false,
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
"**/bower_components": true,
|
||||
"**/*.code-search": true
|
||||
}
|
||||
}
|
||||
|
18
.vscode/tasks.json
vendored
Normal file
18
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "ui:dev",
|
||||
"type": "shell",
|
||||
"isBackground": true,
|
||||
"command": "pnpm",
|
||||
"args": ["-F", "desktop", "dev"]
|
||||
},
|
||||
{
|
||||
"label": "ui:build",
|
||||
"type": "shell",
|
||||
"command": "pnpm",
|
||||
"args": ["-F", "desktop", "build"]
|
||||
}
|
||||
]
|
||||
}
|
@ -26,13 +26,15 @@ If you are interested in contributing to the project, please read the following
|
||||
- [cmake](https://cmake.org/)
|
||||
- MacOS: `brew install cmake`
|
||||
- Linux: `sudo apt install -y cmake`
|
||||
- Other Linux Dependencies
|
||||
- `sudo apt-get install -y protobuf-compiler libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev`
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/kunkunsh/kunkun.git --recursive
|
||||
pnpm install
|
||||
pnpm prepare
|
||||
pnpm build # build submodules
|
||||
```
|
||||
|
||||
### Run Desktop App
|
||||
@ -43,3 +45,17 @@ pnpm --filter @kksh/desktop tauri dev
|
||||
cd apps/desktop
|
||||
pnpm tauri dev
|
||||
```
|
||||
|
||||
### Build from Source
|
||||
|
||||
If you have problem running the app, consider building from source to see if it works.
|
||||
|
||||
```bash
|
||||
cd apps/desktop
|
||||
pnpm tauri build
|
||||
```
|
||||
|
||||
## i188n
|
||||
|
||||
If you are willing to help with the translation, please use translations in json files in `apps/desktop/messages`.
|
||||
Use `en.json` as a reference.
|
||||
|
2756
Cargo.lock
generated
2756
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
23
Cargo.toml
23
Cargo.toml
@ -7,6 +7,8 @@ members = [
|
||||
"packages/db",
|
||||
"packages/mac-security-rs",
|
||||
"packages/tauri-plugins/jarvis",
|
||||
"packages/crypto",
|
||||
"packages/grpc",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
@ -14,15 +16,34 @@ serde = { version = "1", features = ["derive"] }
|
||||
anyhow = "1.0.86"
|
||||
serde_json = "1"
|
||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "signal"] }
|
||||
tokio-util = "0.7.12"
|
||||
mdns-sd = "0.11.1"
|
||||
tauri-plugin-network = { path = "./vendors/tauri-plugin-network" }
|
||||
tauri-plugin-clipboard = "2.1.8"
|
||||
tauri-plugin-keyring = { path = "./vendors/tauri-plugin-keyring" }
|
||||
tauri-plugin-shellx = { version = "2.0.16" }
|
||||
tauri-plugin-clipboard = "2.1.11"
|
||||
mac-security-rs = { path = "./packages/mac-security-rs" }
|
||||
log = "0.4.22"
|
||||
strum = "0.26"
|
||||
strum_macros = "0.26"
|
||||
chrono = "0.4.38"
|
||||
applications = { path = "./vendors/applications-rs" }
|
||||
grpc = { path = "./packages/grpc" }
|
||||
tauri-plugin-jarvis = { path = "./packages/tauri-plugins/jarvis" }
|
||||
tauri-plugin-system-info = { path = "./vendors/tauri-plugin-system-info" }
|
||||
tauri-plugin-user-input = { path = "./vendors/tauri-plugin-user-input" }
|
||||
db = { path = "./packages/db" }
|
||||
axum = { version = "0.6.20" }
|
||||
axum-extra = { version = "0.8.0" }
|
||||
axum-server = { version = "0.5", features = ["tls-rustls"] }
|
||||
rustls = { version = "0.23", features = ["ring"] }
|
||||
reqwest = { version = "0.12", features = ["json", "rustls-tls"] }
|
||||
crypto = { path = "./packages/crypto" }
|
||||
base64 = "0.22.1"
|
||||
obfstr = "0.4.4"
|
||||
sysinfo = "0.32.0"
|
||||
openssl = "0.10.68"
|
||||
tower = { version = "0.4", features = ["util"] }
|
||||
tower-http = { version = "0.4.0", features = ["fs", "trace", "cors"] }
|
||||
rayon = "1.10.0"
|
||||
tauri-plugin-upload = { git = "https://github.com/HuakunShen/tauri-plugins-workspace.git", branch = "kunkun", package = "tauri-plugin-upload" }
|
||||
|
686
LICENSE
Normal file
686
LICENSE
Normal file
@ -0,0 +1,686 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
|
||||
Additional Terms:
|
||||
|
||||
You may use, modify, and distribute this software freely, including for
|
||||
commercial purposes, but you are not permitted to repackage or redistribute
|
||||
the software as-is or in modified form for profit. Specifically, you may
|
||||
not sell the software, either in its original or modified form, without
|
||||
obtaining explicit written permission from the original author.
|
||||
This restriction is intended to prevent the software from being used in
|
||||
a way that undermines its status as free software and the principle of
|
||||
shared development.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
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 <https://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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
191
README.md
191
README.md
@ -1,7 +1,188 @@
|
||||
# Kunkun
|
||||

|
||||
|
||||
> Kunkun is a cross-platform extensible app launcher like Raycast or Alfred.
|
||||
> All extensions run in a sandboxed environment by default to ensure security.
|
||||
> [!WARNING]
|
||||
> 🚧 Work in Progress 🚧
|
||||
> This project is still in its early stages.
|
||||
>
|
||||
> We know it’s not perfect yet. The author is pouring heart, soul, and a few sleepless nights into fixing the issues. Your patience means everything.
|
||||
>
|
||||
> Got feedback or found a bug? Open an issue—it helps more than you know.
|
||||
|
||||
- Website: https://kunkun.sh/
|
||||
- Documentation: https://docs.kunkun.sh/
|
||||

|
||||
[![YouTube badge][]][YouTube link]
|
||||
[](https://discord.gg/7dzw3TYeTU)
|
||||
|
||||
[YouTube badge]: https://img.shields.io/youtube/channel/subscribers/UC1gJeFbvRcQXDC_C8nKetdA?style=social
|
||||
[YouTube link]: https://www.youtube.com/@huakun
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Demo Video and Instructions</th>
|
||||
<th>Download</th>
|
||||
<th>Platforms</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="https://youtu.be/HfQb38s8VjY">Introduction Video</a></li>
|
||||
<li><a href="https://kunkun.sh/">Visit Website</a></li>
|
||||
<li><a href="https://docs.kunkun.sh/">Documentation</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="https://kunkun.sh/download/">From Website</a></li>
|
||||
<li><a href="https://github.com/kunkunsh/kunkun/releases">From GitHub Releases</a></li>
|
||||
<li><a href="https://formulae.brew.sh/cask/kunkun">Via Homebrew</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>MacOS</li>
|
||||
<li>Linux</li>
|
||||
<li>Windows</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Extension Request</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
You can <a href="https://github.com/kunkunsh/kunkun/discussions/new?category=extension-requests&body=%3E%20%5B!IMPORTANT%5D%0A%3E%20Upvote%20if%20you%20want%20this">Submit Extension Request</a>
|
||||
request in the
|
||||
<a href="https://github.com/kunkunsh/kunkun/discussions/categories/extension-requests?discussions_q=is%3Aopen+sort%3Atop+category%3A%22Extension+Requests%22">Extension Requests discussion</a>
|
||||
section to gauge interest in your request.
|
||||
<br/>
|
||||
If there is significant demand, the extension may be considered for implementation.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<a href="https://star-history.com/#kunkunsh/kunkun&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kunkunsh/kunkun&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kunkunsh/kunkun&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kunkunsh/kunkun&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## Sample Extensions
|
||||
|
||||
##### Kunkun Dance
|
||||
|
||||

|
||||
|
||||
##### Extension Store
|
||||
|
||||

|
||||
|
||||
##### Battery Health
|
||||
|
||||

|
||||
|
||||
##### IP Info
|
||||
|
||||

|
||||
|
||||
##### Image Format Conversion
|
||||
|
||||

|
||||
|
||||
##### List of Commands
|
||||
|
||||

|
||||
|
||||
##### Extension Details in Store (Permission Inspector)
|
||||
|
||||

|
||||
|
||||
##### Video Info
|
||||
|
||||

|
||||
|
||||
##### Video Conversion
|
||||
|
||||

|
||||
|
||||
##### 3D Git Skyline
|
||||
|
||||

|
||||
|
||||
##### Letterboxd Movie Search
|
||||
|
||||

|
||||
|
||||
##### Key Displayer
|
||||
|
||||

|
||||
|
||||
##### JWT Inspector
|
||||
|
||||

|
||||
|
||||
##### Image Info
|
||||
|
||||

|
||||
|
||||
##### Hacker News
|
||||
|
||||

|
||||
|
||||
##### QRCode Generator
|
||||
|
||||

|
||||
|
||||
##### File Transfer
|
||||
|
||||

|
||||

|
||||
|
||||
##### Disk Speed Test
|
||||
|
||||

|
||||
|
||||
##### Clipboard History
|
||||
|
||||

|
||||
|
||||
## Stats
|
||||
|
||||

|
||||
|
||||
<!-- Copy-paste in your Readme.md file -->
|
||||
|
||||
<a href="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats?repo_id=882158748" target="_blank" style="display: block" align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats/thumbnail.png?repo_id=882158748&image_size=auto&color_scheme=dark" width="655" height="auto">
|
||||
<img alt="Performance Stats of kunkunsh/kunkun - Last 28 days" src="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats/thumbnail.png?repo_id=882158748&image_size=auto&color_scheme=light" width="655" height="auto">
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<!-- Made with [OSS Insight](https://ossinsight.io/) -->
|
||||
|
||||
<!-- Copy-paste in your Readme.md file -->
|
||||
|
||||
<a href="https://next.ossinsight.io/widgets/official/compose-org-activity-growth-total?activity=stars&period=past_28_days&owner_id=176965503" target="_blank" style="display: block" align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-activity-growth-total/thumbnail.png?activity=stars&period=past_28_days&owner_id=176965503&image_size=4x7&color_scheme=dark" width="657" height="auto">
|
||||
<img alt="Stars trends of kunkunsh" src="https://next.ossinsight.io/widgets/official/compose-org-activity-growth-total/thumbnail.png?activity=stars&period=past_28_days&owner_id=176965503&image_size=4x7&color_scheme=light" width="657" height="auto">
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<!-- Made with [OSS Insight](https://ossinsight.io/) -->
|
||||
|
||||
<!-- Copy-paste in your Readme.md file -->
|
||||
|
||||
<a href="https://next.ossinsight.io/widgets/official/compose-org-overview-stars?period=past_28_days&owner_id=176965503" target="_blank" style="display: block" align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-overview-stars/thumbnail.png?period=past_28_days&owner_id=176965503&image_size=2x6&color_scheme=dark" width="561" height="auto">
|
||||
<img alt="Overview of Stars earned of kunkunsh" src="https://next.ossinsight.io/widgets/official/compose-org-overview-stars/thumbnail.png?period=past_28_days&owner_id=176965503&image_size=2x6&color_scheme=light" width="561" height="auto">
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<!-- Made with [OSS Insight](https://ossinsight.io/) -->
|
||||
|
156
apps/cli/CHANGELOG.md
Normal file
156
apps/cli/CHANGELOG.md
Normal file
@ -0,0 +1,156 @@
|
||||
# kksh
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.5
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.4
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.2
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.1
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.0
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.53
|
||||
|
||||
## 0.0.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Disable check for folder name. identifier and folder name no longer need to be the same.
|
||||
|
||||
## 0.0.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Improve entrypoint, add custom entrypoint for build cmd
|
||||
|
||||
## 0.0.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.48
|
||||
|
||||
## 0.0.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.47
|
||||
|
||||
## 0.0.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.43
|
||||
|
||||
## 0.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.23
|
||||
|
||||
## 0.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.22
|
||||
|
||||
## 0.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Re-enable server-based dev extension refresh. Deep Link forces switch focus to kunkun
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.21
|
||||
|
||||
## 0.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix Some Windows incompatibilities
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.20
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9fa3d8e]
|
||||
- Updated dependencies [0a1ab7c]
|
||||
- Updated dependencies [b48d53b]
|
||||
- @kksh/api@0.0.20
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.10
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.9
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Add publish mode to verify command, will exit with 1 when invalid.
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.6
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ec47e1e]
|
||||
- @kksh/api@0.0.5
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.4
|
16
apps/cli/README.md
Normal file
16
apps/cli/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# kksh
|
||||
|
||||
This is a CLI tool for developers to develop Kunkun extensions.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Create an extension template first
|
||||
npm init kunkun@latest
|
||||
|
||||
# You can verify the extension manifest, this expect `npm run build` is done already and all generated artifacts listed in manifest is present.
|
||||
npx kksh verify <path to extension>
|
||||
|
||||
# Build extension with docker, simulate how Kunkun's CI builds the extension
|
||||
npx kksh build <path to extension>
|
||||
```
|
30
apps/cli/__tests__/verify.test.ts
Normal file
30
apps/cli/__tests__/verify.test.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import path from "path"
|
||||
import { getRootDir } from "@/constants"
|
||||
import { expect, test } from "bun:test"
|
||||
import fs from "fs-extra"
|
||||
import { verifyCmd } from "../src/commands/verify"
|
||||
|
||||
const rootDir = getRootDir()
|
||||
const extensionsDir = path.join(rootDir, "../../packages/extensions")
|
||||
const templatesDir = path.join(rootDir, "../../packages/templates")
|
||||
|
||||
const extsPaths = fs
|
||||
.readdirSync(extensionsDir)
|
||||
.map((extensionName) => path.join(extensionsDir, extensionName))
|
||||
.filter((extPath) => fs.statSync(extPath).isDirectory())
|
||||
const templatesPaths = fs
|
||||
.readdirSync(templatesDir)
|
||||
.map((templateName) => path.join(templatesDir, templateName))
|
||||
.filter((extPath) => fs.statSync(extPath).isDirectory())
|
||||
|
||||
test("Verify Extensions", () => {
|
||||
for (const extPath of extsPaths) {
|
||||
expect(verifyCmd(extPath, false)).toBeTrue()
|
||||
}
|
||||
})
|
||||
|
||||
// test("Verify Templates", () => {
|
||||
// for (const templatePath of templatesPaths) {
|
||||
// expect(verifyCmd(templatePath, false)).toBeTrue()
|
||||
// }
|
||||
// })
|
24
apps/cli/build.ts
Normal file
24
apps/cli/build.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { $ } from "bun"
|
||||
import fs from "fs-extra"
|
||||
|
||||
process.env.NODE_ENV = "production"
|
||||
|
||||
if (Bun.env.NODE_ENV !== "production") {
|
||||
console.error("This script should be run in production mode. Set NODE_ENV=production.")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await $`rm -rf dist`
|
||||
// building with bun doesn't work with debug
|
||||
fs.mkdirSync("./dist")
|
||||
process.env.NODE_ENV = "production"
|
||||
await Bun.build({
|
||||
entrypoints: ["./cli.ts"],
|
||||
outdir: "./dist",
|
||||
target: "node",
|
||||
// minify: true,
|
||||
format: "esm"
|
||||
})
|
||||
|
||||
// await $`bun build --target node cli.ts > dist/cli.js`
|
||||
fs.cpSync("./src/docker", "./dist/docker", { recursive: true })
|
BIN
apps/cli/bun.lockb
Executable file
BIN
apps/cli/bun.lockb
Executable file
Binary file not shown.
42
apps/cli/cli.ts
Normal file
42
apps/cli/cli.ts
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
import { verifyCmd } from "@/commands"
|
||||
import { NODE_ENV } from "@/constants"
|
||||
import logger from "@/logger"
|
||||
import { program } from "commander"
|
||||
import { version } from "./package.json"
|
||||
|
||||
const cwd = process.cwd()
|
||||
console.log("Environment:", NODE_ENV)
|
||||
|
||||
program.name("Kunkun CLI").description("CLI for Kunkun Extension Development").version(version)
|
||||
|
||||
function computeProjectDir(projectPath: string | undefined) {
|
||||
if (!projectPath) {
|
||||
projectPath = cwd
|
||||
} else if (fs.existsSync(projectPath)) {
|
||||
projectPath = path.resolve(projectPath)
|
||||
} else if (fs.existsSync(path.join(cwd, projectPath))) {
|
||||
projectPath = path.join(cwd, projectPath)
|
||||
} else {
|
||||
logger.error("Invalid project path")
|
||||
process.exit(1)
|
||||
}
|
||||
return projectPath
|
||||
}
|
||||
|
||||
program
|
||||
.command("verify [project_path]")
|
||||
.description("Verify the validity of a Kunkun extension")
|
||||
.option("-b, --batch", "Batch mode", false)
|
||||
.option("-p, --publish", "Publish Mode. Will exit with 1 if invalid", false)
|
||||
.action((projectPath: string | undefined, opts: { batch: boolean; publish: boolean }) => {
|
||||
logger.info("cwd:", cwd)
|
||||
const valid = verifyCmd(computeProjectDir(projectPath), opts.batch)
|
||||
if (opts.publish && !valid) {
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
program.parse()
|
6
apps/cli/mod.ts
Normal file
6
apps/cli/mod.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export {
|
||||
verifyCustomUiCommand,
|
||||
verifyTemplateUiCommand,
|
||||
verifySingleProject,
|
||||
verifyCmd
|
||||
} from "@/commands/verify"
|
39
apps/cli/package.json
Normal file
39
apps/cli/package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "kksh",
|
||||
"module": "dist/cli.js",
|
||||
"version": "0.1.3",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"kksh": "./dist/cli.js",
|
||||
"docker-entrypoint.sh": "./dist/docker/entrypoint.sh"
|
||||
},
|
||||
"author": "Huakun",
|
||||
"scripts": {
|
||||
"build": "bun build.ts",
|
||||
"test": "cross-env NODE_ENV=test bun test --coverage",
|
||||
"check-types": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/debug": "^4.1.12",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"cross-env": "^7.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@inquirer/prompts": "^7.2.1",
|
||||
"@kksh/api": "workspace:*",
|
||||
"chalk": "^5.4.1",
|
||||
"commander": "^13.0.0",
|
||||
"console-table-printer": "^2.12.1",
|
||||
"debug": "^4.4.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"inquirer": "^10.1.2",
|
||||
"valibot": "^1.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
1
apps/cli/src/commands/index.ts
Normal file
1
apps/cli/src/commands/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export { default as verifyCmd } from "./verify"
|
101
apps/cli/src/commands/verify.ts
Normal file
101
apps/cli/src/commands/verify.ts
Normal file
@ -0,0 +1,101 @@
|
||||
import path from "path"
|
||||
import { NODE_ENV } from "@/constants"
|
||||
import logger from "@/logger"
|
||||
import { CustomUiCmd, ExtPackageJson, TemplateUiCmd } from "@kksh/api/models"
|
||||
import { printTable } from "console-table-printer"
|
||||
import fs from "fs-extra"
|
||||
import * as v from "valibot"
|
||||
|
||||
export function verifyCustomUiCommand(projectRoot: string, cmd: CustomUiCmd): boolean {
|
||||
if (!cmd.main.startsWith("http")) {
|
||||
const mainPath = path.join(projectRoot, cmd.dist, cmd.main)
|
||||
if (
|
||||
!(
|
||||
fs.existsSync(mainPath) ||
|
||||
fs.existsSync(mainPath + ".html") ||
|
||||
fs.existsSync(path.join(mainPath, "index.html"))
|
||||
)
|
||||
) {
|
||||
logger.error(`main file not found at '${mainPath}' for command ${cmd.name}`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export function verifyTemplateUiCommand(projectRoot: string, cmd: TemplateUiCmd): boolean {
|
||||
const mainPath = path.join(projectRoot, cmd.main)
|
||||
if (!fs.existsSync(mainPath)) {
|
||||
logger.error(`main file not found at ${mainPath} for command ${cmd.name}`)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export function verifySingleProject(projectPath: string): boolean {
|
||||
logger.info(`Verifying project at ${projectPath}`)
|
||||
const pkgJsonPath = path.join(projectPath, "package.json")
|
||||
if (!fs.existsSync(pkgJsonPath)) {
|
||||
logger.error(`package.json not found at [${pkgJsonPath}]`)
|
||||
return false
|
||||
}
|
||||
const pkgJson = fs.readJSONSync(pkgJsonPath)
|
||||
const result = v.safeParse(ExtPackageJson, pkgJson)
|
||||
|
||||
if (!result.success) {
|
||||
logger.error("package.json is invalid, see issues below:")
|
||||
console.error(v.flatten<typeof ExtPackageJson>(result.issues))
|
||||
return false
|
||||
}
|
||||
const pkg = result.output
|
||||
logger.info(`package.json is valid`)
|
||||
logger.info(`name`, pkg.name)
|
||||
logger.info(`version`, pkg.version)
|
||||
logger.info(`identifier`, pkg.kunkun.identifier)
|
||||
|
||||
if ((pkg.files?.length ?? 0) === 0) {
|
||||
logger.warn(
|
||||
`"files" field is empty, it is recommended to include only the necessary files, e.g. dist`
|
||||
)
|
||||
}
|
||||
// check if kunkun extension name is the same as the folder name
|
||||
const folderName = path.basename(projectPath)
|
||||
|
||||
if (NODE_ENV === "test") {
|
||||
// if (pkg.kunkun.identifier === "{{projectName}}") {
|
||||
console.log("Patching project name from {{projectName}} to", folderName)
|
||||
pkg.kunkun.identifier = folderName
|
||||
// }
|
||||
}
|
||||
for (const cmd of pkg.kunkun.customUiCmds ?? []) {
|
||||
if (!verifyCustomUiCommand(projectPath, cmd)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for (const cmd of pkg.kunkun.templateUiCmds ?? []) {
|
||||
if (!verifyTemplateUiCommand(projectPath, cmd)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export function verifyCmd(projectPath: string, batch: boolean): boolean {
|
||||
let success = true
|
||||
if (!batch) {
|
||||
success = verifySingleProject(projectPath)
|
||||
} else {
|
||||
const records: { valid: boolean; path: string }[] = []
|
||||
fs.readdirSync(projectPath).forEach((dir) => {
|
||||
const dirPath = path.join(projectPath, dir)
|
||||
if (fs.existsSync(path.join(dirPath, "package.json"))) {
|
||||
records.push({ path: dirPath, valid: verifySingleProject(dirPath) })
|
||||
logger.printDivider("=")
|
||||
}
|
||||
})
|
||||
printTable(records)
|
||||
success = records.every((record) => record.valid)
|
||||
}
|
||||
return success
|
||||
}
|
||||
export default verifyCmd
|
31
apps/cli/src/constants.ts
Normal file
31
apps/cli/src/constants.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import path from "path"
|
||||
import { fileURLToPath } from "url"
|
||||
|
||||
const filepath = fileURLToPath(import.meta.url)
|
||||
const filename = path.basename(filepath)
|
||||
const __dirname = path.dirname(filepath)
|
||||
const isInJs = filename.endsWith(".js")
|
||||
|
||||
function inferNodeEnv() {
|
||||
if (isInJs) {
|
||||
return "production"
|
||||
}
|
||||
if (process.env.NODE_ENV) {
|
||||
return process.env.NODE_ENV
|
||||
}
|
||||
return "development"
|
||||
}
|
||||
|
||||
export const NODE_ENV = inferNodeEnv()
|
||||
|
||||
export function getRootDir() {
|
||||
return isInJs ? __dirname : path.dirname(__dirname)
|
||||
}
|
||||
|
||||
export function getDockerFolder() {
|
||||
return isInJs ? path.join(getRootDir(), "docker") : path.join(getRootDir(), "src/docker")
|
||||
}
|
||||
|
||||
export function getDockerEntrypoint() {
|
||||
return path.join(getDockerFolder(), "entrypoint.sh")
|
||||
}
|
50
apps/cli/src/docker/entrypoint.sh
Executable file
50
apps/cli/src/docker/entrypoint.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
cd /workspace # source code will be mounted to /workspace
|
||||
echo $PWD
|
||||
source ~/.bashrc
|
||||
bun --version
|
||||
rm *.tgz
|
||||
rm -rf node_modules
|
||||
cp -r /workspace /workspace-copy
|
||||
cd /workspace-copy
|
||||
|
||||
# Detect package manager based on lock files
|
||||
if [ -f "bun.lockb" ]; then
|
||||
echo "Using bun package manager"
|
||||
bun install
|
||||
echo $?
|
||||
bun run build
|
||||
elif [ -f "pnpm-lock.yaml" ]; then
|
||||
echo "Using pnpm package manager"
|
||||
corepack enable pnpm
|
||||
pnpm install
|
||||
echo $?
|
||||
ls node_modules
|
||||
pnpm build
|
||||
elif [ -f "package-lock.json" ]; then
|
||||
echo "Using npm package manager"
|
||||
npm install
|
||||
echo $?
|
||||
npm run build
|
||||
else
|
||||
corepack enable pnpm
|
||||
echo "No lock file found, defaulting to pnpm"
|
||||
pnpm install
|
||||
echo $?
|
||||
pnpm build
|
||||
fi
|
||||
echo $?
|
||||
npx kksh@latest verify --publish
|
||||
# if previous exit code is not 0, then exit with error
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Build failed"
|
||||
exit 1
|
||||
fi
|
||||
npm pack
|
||||
# check number of *.tgz file in current directory
|
||||
# if more than 1, then exit with error
|
||||
if [ $(ls -1 *.tgz 2>/dev/null | wc -l) -gt 1 ]; then
|
||||
echo "More than one tgz file found"
|
||||
exit 1
|
||||
fi
|
||||
cp *.tgz /workspace
|
17
apps/cli/src/logger.ts
Normal file
17
apps/cli/src/logger.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import chalk from "chalk"
|
||||
import debug from "debug"
|
||||
|
||||
debug.enable("*")
|
||||
|
||||
export function printDivider(char: string = "=") {
|
||||
const divider = chalk.blue(char.repeat(process.stdout.columns))
|
||||
console.log(divider)
|
||||
}
|
||||
|
||||
export default {
|
||||
debug: debug("debug"),
|
||||
info: debug("info"),
|
||||
warn: debug("warn"),
|
||||
error: debug("error"),
|
||||
printDivider
|
||||
}
|
9
apps/cli/src/types.ts
Normal file
9
apps/cli/src/types.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { ExtPackageJson } from "@kksh/api/models"
|
||||
|
||||
export type BuildResult = {
|
||||
shasum: string
|
||||
tarballFilename: string
|
||||
tarballPath: string
|
||||
extPath: string
|
||||
pkg: ExtPackageJson
|
||||
}
|
32
apps/cli/tsconfig.json
Normal file
32
apps/cli/tsconfig.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"],
|
||||
"~/*": ["src/*"]
|
||||
},
|
||||
"outDir": "dist",
|
||||
"declaration": true,
|
||||
"declarationMap": true
|
||||
}
|
||||
}
|
175
apps/create-kunkun/.gitignore
vendored
Normal file
175
apps/create-kunkun/.gitignore
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||
|
||||
# Logs
|
||||
|
||||
logs
|
||||
_.log
|
||||
npm-debug.log_
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Caches
|
||||
|
||||
.cache
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
|
||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# Runtime data
|
||||
|
||||
pids
|
||||
_.pid
|
||||
_.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
191
apps/create-kunkun/CHANGELOG.md
Normal file
191
apps/create-kunkun/CHANGELOG.md
Normal file
@ -0,0 +1,191 @@
|
||||
# create-kunkun
|
||||
|
||||
## 0.1.49
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.5
|
||||
|
||||
## 0.1.48
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.4
|
||||
|
||||
## 0.1.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.2
|
||||
|
||||
## 0.1.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.1
|
||||
|
||||
## 0.1.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.1.0
|
||||
|
||||
## 0.1.42
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update sveltekit template
|
||||
|
||||
## 0.1.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.53
|
||||
|
||||
## 0.1.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Add headless command template
|
||||
|
||||
## 0.1.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.48
|
||||
|
||||
## 0.1.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.47
|
||||
|
||||
## 0.1.35
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.43
|
||||
|
||||
## 0.1.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.23
|
||||
|
||||
## 0.1.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.22
|
||||
|
||||
## 0.1.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Re-enable server-based dev extension refresh. Deep Link forces switch focus to kunkun
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.21
|
||||
|
||||
## 0.1.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix Some Windows incompatibilities
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.20
|
||||
|
||||
## 0.1.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix windows compatibility errors
|
||||
|
||||
## 0.1.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Store templates as .tgz in dist, to avoid missing .gitignore problem
|
||||
|
||||
## 0.1.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update templates README with detailed instructions
|
||||
|
||||
## 0.1.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9fa3d8e]
|
||||
- Updated dependencies [0a1ab7c]
|
||||
- Updated dependencies [b48d53b]
|
||||
- @kksh/api@0.0.20
|
||||
|
||||
## 0.1.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9fa3d8e]
|
||||
- Updated dependencies [0a1ab7c]
|
||||
- Updated dependencies [b48d53b]
|
||||
- @kksh/api@0.0.20
|
||||
|
||||
## 0.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.11
|
||||
|
||||
## 0.1.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.10
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update templates, custom ui templates now requires base url. Due to a Tauri API problem on Windows.
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.9
|
||||
|
||||
## 0.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Add some helper functions for template worker extension building. Replace rollup with bun.
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.6
|
||||
|
||||
## 0.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ec47e1e]
|
||||
- @kksh/api@0.0.5
|
||||
|
||||
## 0.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @kksh/api@0.0.4
|
16
apps/create-kunkun/README.md
Normal file
16
apps/create-kunkun/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Kunkun Extension Initializer
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
npm init kunkun@latest
|
||||
|
||||
npx create-kunkun@latest
|
||||
```
|
||||
|
||||
## Develop
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
node dist/index.mjs
|
||||
```
|
42
apps/create-kunkun/__tests__/create-template.test.ts
Normal file
42
apps/create-kunkun/__tests__/create-template.test.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* This is a E2E test, create every template from production build and run `npm install` and `npm run build`
|
||||
* When running `npm install` with bun shell, it fails in bun test environment, so I simply run everything as regular ts without test()
|
||||
*/
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import { $ } from "bun"
|
||||
import { afterAll, beforeAll, describe, expect, test } from "bun:test"
|
||||
import fs from "fs-extra"
|
||||
import { getRootDir } from "../src/constants"
|
||||
|
||||
const testDir = path.join(os.tmpdir(), "kunkun-create-kunkun-test")
|
||||
console.log("Test Dir: ", testDir)
|
||||
const distDir = path.join(getRootDir(), "dist")
|
||||
const indexjsPath = path.join(distDir, "index.mjs")
|
||||
const templateNames = ["template", "react", "vue", "nuxt", "svelte", "sveltekit"]
|
||||
|
||||
if (fs.existsSync(testDir)) {
|
||||
fs.rmdirSync(testDir, { recursive: true })
|
||||
}
|
||||
fs.mkdirpSync(testDir)
|
||||
for (const templateName of templateNames) {
|
||||
const folderName = `${templateName}-ext`
|
||||
await $`node ${indexjsPath} --outdir ${testDir} --name ${folderName} --template ${templateName}`
|
||||
const templateDir = path.join(testDir, folderName)
|
||||
await $`rm -rf node_modules`.cwd(templateDir) // this doesn't work within bun test
|
||||
await $`pnpm install`.cwd(templateDir) // this doesn't work within bun test
|
||||
const out = await $`pnpm run build`.cwd(templateDir)
|
||||
}
|
||||
|
||||
test("Build Artifact Existence", () => {
|
||||
templateNames.forEach(async (templateName) => {
|
||||
const expectedOutDir = templateName === "sveltekit" ? "build" : "dist"
|
||||
const folderName = `${templateName}-ext`
|
||||
const templateDir = path.join(testDir, folderName)
|
||||
expect(fs.existsSync(path.join(templateDir, expectedOutDir))).toBeTrue()
|
||||
})
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
fs.rmdirSync(testDir, { recursive: true })
|
||||
})
|
83
apps/create-kunkun/build.ts
Normal file
83
apps/create-kunkun/build.ts
Normal file
@ -0,0 +1,83 @@
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import { $ } from "bun"
|
||||
import chalk from "chalk"
|
||||
import fs from "fs-extra"
|
||||
import getFolderSize from "get-folder-size"
|
||||
import { getRootDir } from "./src/constants"
|
||||
import { cleanExtension, patchManifestJsonSchema, patchPkgJsonDep } from "./src/patch"
|
||||
import { tarCompress } from "./src/utils"
|
||||
|
||||
await $`rm -rf dist`
|
||||
await $`bun build index.ts --outfile=dist/index.mjs --target node`.env({
|
||||
NODE_ENV: "production"
|
||||
})
|
||||
// await $`pnpm rolldown -c`
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Post Build */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
const distPath = path.join(getRootDir(), "dist")
|
||||
const distTemplatesPath = path.join(distPath, "templates")
|
||||
const tmpDistTemplatesPath = path.join(distPath, "tmp-templates")
|
||||
// clear distTemplatesPath
|
||||
fs.emptyDirSync(distTemplatesPath)
|
||||
fs.emptyDirSync(tmpDistTemplatesPath)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* copy ../../templates to dist/templates */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
console.log(getRootDir())
|
||||
|
||||
const templatesPath = path.join(getRootDir(), "../..", "packages/templates")
|
||||
console.log(`Copy from ${templatesPath} to ${tmpDistTemplatesPath}`)
|
||||
fs.copySync(templatesPath, tmpDistTemplatesPath, { dereference: os.platform() === "win32" })
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Clean Dist Folder */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
for (const p of fs.readdirSync(tmpDistTemplatesPath)) {
|
||||
console.log("Clean Extension", path.join(tmpDistTemplatesPath, p))
|
||||
cleanExtension(path.join(tmpDistTemplatesPath, p))
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Patch Templates */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
for (const p of fs.readdirSync(tmpDistTemplatesPath)) {
|
||||
const pkgJsonPath = path.join(tmpDistTemplatesPath, p, "package.json")
|
||||
if (fs.existsSync(pkgJsonPath)) {
|
||||
/* ----------------------- Patch Package Dependencies ----------------------- */
|
||||
// Replace local dependencies (workspace:*) with real dependencies
|
||||
await patchPkgJsonDep(pkgJsonPath)
|
||||
/* ----------------------- Patch Manifest JSON Schema ----------------------- */
|
||||
// Replace local template with remote schema
|
||||
patchManifestJsonSchema(pkgJsonPath)
|
||||
// remove node_modules
|
||||
const nodeModulesPath = path.join(distPath, "templates", p, "node_modules")
|
||||
if (fs.existsSync(nodeModulesPath)) {
|
||||
fs.rmdirSync(nodeModulesPath, { recursive: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Zip Templates */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
for (const p of fs.readdirSync(tmpDistTemplatesPath)) {
|
||||
const src = path.join(tmpDistTemplatesPath, p)
|
||||
// skip if src is not a directory
|
||||
if (!fs.statSync(src).isDirectory()) {
|
||||
continue
|
||||
}
|
||||
const dest = path.join(distTemplatesPath, `${p}.tgz`)
|
||||
console.log(`${chalk.green("Zipping")} ${chalk.blue(src)} to ${chalk.blue(dest)}`)
|
||||
await tarCompress(src, dest)
|
||||
}
|
||||
|
||||
fs.rmSync(tmpDistTemplatesPath, { recursive: true })
|
||||
|
||||
// get total folder size of distTemplatesPath
|
||||
const size = await getFolderSize.loose(distTemplatesPath)
|
||||
console.log(`dist size ${(size / 1000 / 1000).toFixed(2)} MB`)
|
BIN
apps/create-kunkun/bun.lockb
Executable file
BIN
apps/create-kunkun/bun.lockb
Executable file
Binary file not shown.
202
apps/create-kunkun/index.ts
Normal file
202
apps/create-kunkun/index.ts
Normal file
@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env node
|
||||
import path from "path"
|
||||
import { input, select } from "@inquirer/prompts"
|
||||
import { version as kkApiVersion } from "@kksh/api/package.json"
|
||||
import chalk from "chalk"
|
||||
import { Command, Option } from "commander"
|
||||
import fs from "fs-extra"
|
||||
import pkgJson from "./package.json"
|
||||
import { createKunkunVersion, getTemplateRoot, isProduction, NODE_ENV } from "./src/constants"
|
||||
import { cleanExtension, patchHBS, patchManifestJsonSchema, patchPkgJsonDep } from "./src/patch"
|
||||
import { getLatestNpmPkgVersion, tarExtract } from "./src/utils"
|
||||
|
||||
console.log(`${chalk.blue("create-kunkun version:")} ${createKunkunVersion}`)
|
||||
const latestCreateKunkunVersion = await getLatestNpmPkgVersion("create-kunkun")
|
||||
console.log(`${chalk.blue("Latest create-kunkun version:")} latestCreateKunkunVersion`)
|
||||
if (latestCreateKunkunVersion !== createKunkunVersion) {
|
||||
const msg = `You are using create-kunkun version ${createKunkunVersion}, but the latest version is ${latestCreateKunkunVersion}. It may not work with the latest Kunkun app.`
|
||||
console.warn(chalk.red(msg))
|
||||
}
|
||||
|
||||
const cwd = process.cwd()
|
||||
const templateRoot = getTemplateRoot()
|
||||
console.info(`${chalk.blue("Current Working Directory")}: ${cwd}`)
|
||||
console.info(`${chalk.blue("Template Root:")}`, templateRoot)
|
||||
if (!fs.existsSync(templateRoot)) {
|
||||
console.error(`Template directory not found; Expected at ${templateRoot}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const program = new Command()
|
||||
|
||||
program
|
||||
.version(pkgJson.version)
|
||||
.addOption(
|
||||
new Option("-t, --template <template>", "Extension Template").choices([
|
||||
"template",
|
||||
"headless",
|
||||
"react",
|
||||
"vue",
|
||||
"svelte",
|
||||
"nuxt",
|
||||
"sveltekit",
|
||||
"next"
|
||||
])
|
||||
)
|
||||
.addOption(new Option("-n, --name <name>", "Extension Name"))
|
||||
.addOption(new Option("-f, --force", "Overwrite existing files").default(false))
|
||||
.addOption(new Option("-o, --outdir <outdir>", "Output directory").default(cwd))
|
||||
.parse(process.argv)
|
||||
type Template = "react" | "template" | "headless" | "vue" | "svelte" | "nuxt" | "sveltekit" | "next"
|
||||
const options = program.opts<{
|
||||
template?: Template
|
||||
outdir: string
|
||||
force: boolean
|
||||
name?: string
|
||||
}>()
|
||||
let template: Template | undefined = options.template
|
||||
let name = options.name
|
||||
console.log("Options:", options)
|
||||
|
||||
const outdir = path.resolve(options.outdir)
|
||||
console.info(`${chalk.blue("Outdir: ")}${outdir}`)
|
||||
if (!fs.existsSync(outdir)) {
|
||||
fs.mkdirSync(outdir, { recursive: true })
|
||||
}
|
||||
|
||||
async function copyTemplate(templateTgz: string, targetFolderName: string): Promise<string> {
|
||||
const destDir = path.join(outdir, targetFolderName)
|
||||
|
||||
if (!fs.existsSync(templateTgz)) {
|
||||
console.error(`Worker Extension Template not found at ${templateTgz}`)
|
||||
process.exit(1)
|
||||
}
|
||||
console.info(`${chalk.blue("Template Source Path:")} ${templateTgz}`)
|
||||
if (fs.existsSync(destDir)) {
|
||||
if (!options.force) {
|
||||
console.error(`Destination directory already exists: ${destDir}`)
|
||||
process.exit(1)
|
||||
} else {
|
||||
fs.removeSync(destDir)
|
||||
}
|
||||
}
|
||||
await tarExtract(templateTgz, destDir)
|
||||
// fs.mkdirSync(destDir, { recursive: true })
|
||||
console.info(
|
||||
`Template copied from \n\t${chalk.blue(templateTgz)} \nto \n\t${chalk.blue(destDir)}`
|
||||
)
|
||||
// fs.copySync(templateTgz, destDir)
|
||||
return destDir
|
||||
}
|
||||
|
||||
;(async function () {
|
||||
if (!template) {
|
||||
template = await select({
|
||||
message: "Select an Extension Template",
|
||||
choices: [
|
||||
{
|
||||
name: "Template UI (Web Worker)",
|
||||
value: "template",
|
||||
description:
|
||||
"Write regular logic in TypeScript in OOP manner to render extension UI based on predefined template."
|
||||
},
|
||||
{
|
||||
name: "Headless Command",
|
||||
value: "headless",
|
||||
description:
|
||||
'Write regular logic in TypeScript to implement "fire and forget" style command.'
|
||||
},
|
||||
{
|
||||
name: "React Custom UI",
|
||||
value: "react",
|
||||
description:
|
||||
"Extension will be rendered within iframe as a regular web app. The UI can be arbitrarily complex. Choose this if you want to use React to build complex UI."
|
||||
},
|
||||
{
|
||||
name: "Vue Custom UI",
|
||||
value: "vue",
|
||||
description:
|
||||
"Extension will be rendered within iframe as a regular web app. The UI can be arbitrarily complex. Choose this if you want to use React to build complex UI."
|
||||
},
|
||||
{
|
||||
name: "Svelte Custom UI",
|
||||
value: "svelte",
|
||||
description:
|
||||
"Extension will be rendered within iframe as a regular web app. The UI can be arbitrarily complex. Choose this if you want to use React to build complex UI."
|
||||
},
|
||||
{
|
||||
name: "Nuxt Custom UI",
|
||||
value: "nuxt",
|
||||
description:
|
||||
"Extension will be rendered within iframe as a regular web app. The UI can be arbitrarily complex. Choose this if you want to use Nuxt to build complex UI."
|
||||
},
|
||||
{
|
||||
name: "Next.js Custom UI",
|
||||
value: "next",
|
||||
description:
|
||||
"Extension will be rendered within iframe as a regular web app. The UI can be arbitrarily complex. Choose this if you want to use Next.js to build complex UI."
|
||||
},
|
||||
{
|
||||
name: "Sveltekit Custom UI",
|
||||
value: "sveltekit",
|
||||
description:
|
||||
"Extension will be rendered within iframe as a regular web app. The UI can be arbitrarily complex. Choose this if you want to use Sveltekit to build complex UI."
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
if (!name) {
|
||||
name = await input({
|
||||
message: "Enter Extension Name",
|
||||
default: `kunkun-extension-${template}`
|
||||
})
|
||||
}
|
||||
let destDir = ""
|
||||
if (template === "template") {
|
||||
destDir = await copyTemplate(path.join(templateRoot, "template-ext-worker.tgz"), name)
|
||||
cleanExtension(destDir)
|
||||
} else if (
|
||||
["react", "vue", "svelte", "nuxt", "sveltekit", "next", "headless"].includes(template)
|
||||
) {
|
||||
destDir = await copyTemplate(path.join(templateRoot, `template-ext-${template}.tgz`), name)
|
||||
cleanExtension(destDir)
|
||||
} else {
|
||||
console.error("Invalid template")
|
||||
process.exit(1)
|
||||
}
|
||||
console.log("Destination Dir:", destDir)
|
||||
if (!isProduction) {
|
||||
const pkgJsonPath = path.join(destDir, "package.json")
|
||||
patchManifestJsonSchema(pkgJsonPath)
|
||||
patchPkgJsonDep(pkgJsonPath)
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Patch HBS Templates */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
console.log(`Start Patching ${name}`)
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000)) // add some delay after files are created, otherwsie files can't be overwritten
|
||||
patchHBS(path.join(destDir, "package.json"), { projectName: name })
|
||||
switch (template) {
|
||||
case "nuxt":
|
||||
patchHBS(path.join(destDir, "nuxt.config.ts"), { projectName: name })
|
||||
break
|
||||
case "react":
|
||||
patchHBS(path.join(destDir, "vite.config.ts"), { projectName: name })
|
||||
break
|
||||
case "vue":
|
||||
patchHBS(path.join(destDir, "vite.config.ts"), { projectName: name })
|
||||
break
|
||||
case "svelte":
|
||||
patchHBS(path.join(destDir, "vite.config.ts"), { projectName: name })
|
||||
break
|
||||
case "sveltekit":
|
||||
patchHBS(path.join(destDir, "svelte.config.js"), { projectName: name })
|
||||
break
|
||||
case "next":
|
||||
patchHBS(path.join(destDir, "next.config.mjs"), { projectName: name })
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
})()
|
35
apps/create-kunkun/package.json
Normal file
35
apps/create-kunkun/package.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "create-kunkun",
|
||||
"type": "module",
|
||||
"version": "0.1.49",
|
||||
"bin": {
|
||||
"create-kunkun": "dist/index.mjs"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "bun build.ts",
|
||||
"build": "bun build.ts",
|
||||
"test": "bun test --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"get-folder-size": "^5.0.0",
|
||||
"tar": "^7.4.3",
|
||||
"vitest": "^2.1.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@inquirer/prompts": "^5.5.0",
|
||||
"@kksh/api": "workspace:*",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.1.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"handlebars": "^4.7.8",
|
||||
"valibot": "^1.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
32
apps/create-kunkun/rollup.config.js
Normal file
32
apps/create-kunkun/rollup.config.js
Normal file
@ -0,0 +1,32 @@
|
||||
import commonjs from "@rollup/plugin-commonjs"
|
||||
import json from "@rollup/plugin-json"
|
||||
import resolve from "@rollup/plugin-node-resolve"
|
||||
import replace from "@rollup/plugin-replace"
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import { visualizer } from "rollup-plugin-visualizer"
|
||||
|
||||
/** @type {import('rollup').RollupOptions} */
|
||||
const config = {
|
||||
input: "index.ts", // Path to your worker file
|
||||
output: {
|
||||
file: "dist/index.cjs",
|
||||
format: "cjs"
|
||||
},
|
||||
plugins: [
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "production")
|
||||
}),
|
||||
json(),
|
||||
typescript(),
|
||||
resolve({
|
||||
preferBuiltins: true
|
||||
}),
|
||||
commonjs(),
|
||||
terser(),
|
||||
visualizer()
|
||||
]
|
||||
}
|
||||
|
||||
export default config
|
39
apps/create-kunkun/scripts/postbuild.ts
Normal file
39
apps/create-kunkun/scripts/postbuild.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import path from "path"
|
||||
import fs from "fs-extra"
|
||||
import { getRootDir } from "../src/constants"
|
||||
import { cleanExtension, patchManifestJsonSchema, patchPkgJsonDep } from "../src/patch"
|
||||
|
||||
const distPath = path.join(getRootDir(), "dist")
|
||||
const distTemplatesPath = path.join(distPath, "templates")
|
||||
// clear distTemplatesPath
|
||||
fs.emptyDirSync(distTemplatesPath)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* copy ../../templates to dist/templates */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
const templatesPath = path.join(getRootDir(), "../..", "templates")
|
||||
await fs.copy(templatesPath, distTemplatesPath)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Clean Dist Folder */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
for (const p of fs.readdirSync(distTemplatesPath)) {
|
||||
cleanExtension(path.join(distPath, "templates", p))
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Patch Templates */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
for (const p of fs.readdirSync(distTemplatesPath)) {
|
||||
const pkgJsonPath = path.join(distPath, "templates", p, "package.json")
|
||||
if (fs.existsSync(pkgJsonPath)) {
|
||||
/* ----------------------- Patch Package Dependencies ----------------------- */
|
||||
// Replace local dependencies (workspace:*) with real dependencies
|
||||
await patchPkgJsonDep(pkgJsonPath)
|
||||
/* ----------------------- Patch Manifest JSON Schema ----------------------- */
|
||||
// Replace local template with remote schema
|
||||
patchManifestJsonSchema(pkgJsonPath)
|
||||
// remove node_modules
|
||||
fs.rmdirSync(path.join(distPath, "templates", p, "node_modules"), { recursive: true })
|
||||
}
|
||||
}
|
13
apps/create-kunkun/src/__tests__/util.test.ts
Normal file
13
apps/create-kunkun/src/__tests__/util.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { getLatestNpmPkgInfo, getLatestNpmPkgVersion } from "../utils"
|
||||
|
||||
test("getLatestNpmPkgInfo", async () => {
|
||||
const pkg = await getLatestNpmPkgInfo("@kksh/vue")
|
||||
expect(pkg.name).toBe("@kksh/vue")
|
||||
expect(pkg.version).toBeDefined()
|
||||
})
|
||||
|
||||
test("getLatestNpmPkgVersion", async () => {
|
||||
const version = await getLatestNpmPkgVersion("@kksh/vue")
|
||||
expect(version).toBeDefined()
|
||||
})
|
18
apps/create-kunkun/src/constants.ts
Normal file
18
apps/create-kunkun/src/constants.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import path from "path"
|
||||
import { fileURLToPath } from "url"
|
||||
import { version } from "../package.json"
|
||||
|
||||
export const NODE_ENV = process.env.NODE_ENV ?? "development"
|
||||
export const isProduction = NODE_ENV === "production"
|
||||
export function getRootDir() {
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
return isProduction ? __dirname : path.dirname(__dirname)
|
||||
}
|
||||
export function getTemplateRoot() {
|
||||
return isProduction
|
||||
? path.join(getRootDir(), "templates")
|
||||
: path.join(getRootDir(), "../../packages/templates")
|
||||
}
|
||||
|
||||
export const createKunkunVersion = version
|
101
apps/create-kunkun/src/patch.ts
Normal file
101
apps/create-kunkun/src/patch.ts
Normal file
@ -0,0 +1,101 @@
|
||||
import { execSync } from "child_process"
|
||||
import path from "path"
|
||||
import { ExtPackageJson } from "@kksh/api/models"
|
||||
import { $ } from "bun"
|
||||
import fs from "fs-extra"
|
||||
import Handlebars from "handlebars"
|
||||
import { flatten, safeParse } from "valibot"
|
||||
import { isProduction } from "./constants"
|
||||
import { findPkgVersions } from "./utils"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Worker Extension */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
export function cleanExtension(dir: string) {
|
||||
// Read .gitignore if it exists
|
||||
const gitignorePath = path.join(dir, ".gitignore")
|
||||
let ignorePatterns: string[] = []
|
||||
|
||||
if (fs.existsSync(gitignorePath)) {
|
||||
ignorePatterns = fs
|
||||
.readFileSync(gitignorePath, "utf-8")
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line && !line.startsWith("#"))
|
||||
}
|
||||
|
||||
// Always include some common build/dependency directories
|
||||
const defaultIgnores = ["node_modules", "dist", ".turbo", "build"]
|
||||
ignorePatterns.push(...defaultIgnores)
|
||||
|
||||
// Find and remove all ignored files/directories
|
||||
for (const pattern of ignorePatterns) {
|
||||
const itemPath = path.join(dir, pattern)
|
||||
if (fs.existsSync(itemPath)) {
|
||||
fs.removeSync(itemPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function patchManifestJsonSchema(pkgJsonPath: string) {
|
||||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"))
|
||||
pkgJson["$schema"] = "https://schema.kunkun.sh"
|
||||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove workspace:* dependencies and add dependencies with proper versions
|
||||
* This should be run only in development mode
|
||||
* @param pkgJsonPath path to created template's package.json
|
||||
* @param kkApiVersion @kksh/api version with the current create-kunkun version
|
||||
*/
|
||||
export async function patchPkgJsonDep(pkgJsonPath: string) {
|
||||
if (isProduction) {
|
||||
throw new Error("This function is only available in development mode")
|
||||
}
|
||||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"))
|
||||
pkgJson.name = `{{projectName}}`
|
||||
pkgJson.kunkun.identifier = `{{projectName}}`
|
||||
const monorepoPkgVersions = await findPkgVersions()
|
||||
for (const [dep, v] of Object.entries(pkgJson.dependencies)) {
|
||||
if ((v as string).startsWith("workspace:")) {
|
||||
if (!monorepoPkgVersions[dep]) {
|
||||
console.error(`Package ${dep} not found in monorepo`)
|
||||
process.exit(1)
|
||||
}
|
||||
pkgJson.dependencies[dep] = monorepoPkgVersions[dep]
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
|
||||
}
|
||||
|
||||
export function validatePackageJson(pkgJsonPath: string) {
|
||||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"))
|
||||
const parseRes = safeParse(ExtPackageJson, pkgJson)
|
||||
if (!parseRes.success) {
|
||||
console.error(
|
||||
`Unexpected Error: Invalid package.json: ${flatten<typeof ExtPackageJson>(parseRes.issues)}`
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
export function patchInstallAPI(dir: string) {
|
||||
// cd into the directory and run `npm install`, and run `npm install @kksh/react`
|
||||
console.info(`Running: npm install`)
|
||||
execSync("npm install", { cwd: dir, stdio: "inherit" })
|
||||
// TODO: Uncomment the following line after @kksh/react is published
|
||||
// console.info(`Running: npm install @kksh/react`)
|
||||
// execSync("npm install @kksh/react", { cwd: dir, stdio: "inherit" })
|
||||
}
|
||||
|
||||
export function patchHBS(filePath: string, data: Record<string, any>) {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.error(`Patch HBS: File ${filePath} not found`)
|
||||
process.exit(1)
|
||||
}
|
||||
const template = Handlebars.compile(fs.readFileSync(filePath, "utf-8"))
|
||||
const result = template(data)
|
||||
fs.writeFileSync(filePath, result)
|
||||
}
|
110
apps/create-kunkun/src/utils.ts
Normal file
110
apps/create-kunkun/src/utils.ts
Normal file
@ -0,0 +1,110 @@
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import chalk from "chalk"
|
||||
import fs from "fs-extra"
|
||||
import { create as createTar, extract as extractTar } from "tar"
|
||||
import * as v from "valibot"
|
||||
import { getRootDir, isProduction } from "../src/constants"
|
||||
|
||||
export function getLatestNpmPkgInfo(pkgName: string): Promise<Record<string, any>> {
|
||||
return fetch(`https://registry.npmjs.org/${pkgName}/latest`).then((res) => res.json())
|
||||
}
|
||||
|
||||
export function getLatestNpmPkgVersion(pkgName: string): Promise<string> {
|
||||
return getLatestNpmPkgInfo(pkgName)
|
||||
.then((data) => v.parse(v.object({ version: v.string() }), data).version)
|
||||
.catch((err) => {
|
||||
throw new Error(`Failed to get latest version of ${pkgName}: ${err.message}`)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the current package verisons of all packages in the monorepo
|
||||
* This function is used only in development mode
|
||||
* @returns
|
||||
*/
|
||||
export async function findPkgVersions() {
|
||||
if (isProduction) {
|
||||
throw new Error("This function is only available in development mode")
|
||||
}
|
||||
const pkgVersions: Record<string, string> = {}
|
||||
const root = getRootDir()
|
||||
const repoRoot = path.join(root, "../../")
|
||||
const searchFolders = [path.join(repoRoot, "apps"), path.join(repoRoot, "packages")]
|
||||
for (const folder of searchFolders) {
|
||||
const packages = fs.readdirSync(folder)
|
||||
// console.log("Packages: ", packages);
|
||||
|
||||
for (const pkg of packages) {
|
||||
const pkgJsonPath = path.join(folder, pkg, "package.json")
|
||||
if (fs.existsSync(pkgJsonPath)) {
|
||||
const pkgJson = fs.readJsonSync(pkgJsonPath)
|
||||
pkgVersions[pkgJson.name] = pkgJson.version
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const pkgName of ["@kksh/vue", "@kksh/react", "@kksh/svelte"]) {
|
||||
const version = await getLatestNpmPkgVersion(pkgName)
|
||||
pkgVersions[pkgName] = version
|
||||
}
|
||||
return pkgVersions
|
||||
}
|
||||
|
||||
export function tarCompress(src: string, dest: string) {
|
||||
// get src parent dir
|
||||
const srcParentDir = path.dirname(src)
|
||||
const srcFileName = path.basename(src)
|
||||
return createTar(
|
||||
{
|
||||
file: dest,
|
||||
gzip: true,
|
||||
cwd: srcParentDir,
|
||||
filter: (path) => {
|
||||
const ignoreList = ["node_modules", "dist", ".turbo", "extensions_support"]
|
||||
return !ignoreList.some((ignore) => path.includes(ignore))
|
||||
}
|
||||
},
|
||||
[srcFileName]
|
||||
)
|
||||
}
|
||||
|
||||
export function tarExtract(src: string, dest: string) {
|
||||
const srcFileName = path.basename(src)
|
||||
const destDir = path.dirname(dest)
|
||||
const destFolderName = path.basename(dest)
|
||||
if (!fs.existsSync(destDir)) {
|
||||
fs.mkdirSync(destDir, { recursive: true })
|
||||
}
|
||||
if (fs.existsSync(dest)) {
|
||||
const msg = `${dest} already exists`
|
||||
console.log(chalk.red(msg))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// get a tmp dir
|
||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "create-kunkun-extract"))
|
||||
|
||||
if (fs.existsSync(tmpDir)) {
|
||||
// remove tmp dir
|
||||
fs.rmSync(tmpDir, { recursive: true })
|
||||
}
|
||||
fs.mkdirSync(tmpDir, { recursive: true })
|
||||
return extractTar({
|
||||
file: src,
|
||||
C: tmpDir
|
||||
}).then(() => {
|
||||
const srcFileNameExt = path.extname(src)
|
||||
const srcFileNameWithoutExt = path.basename(src, srcFileNameExt)
|
||||
|
||||
const intermediateDest = path.join(tmpDir, srcFileNameWithoutExt)
|
||||
if (!fs.existsSync(intermediateDest)) {
|
||||
const msg = `Intermediate destination ${intermediateDest} not found, extraction failed`
|
||||
console.log(chalk.red(msg))
|
||||
process.exit(1)
|
||||
}
|
||||
// move intermediateDest to dest
|
||||
fs.copySync(intermediateDest, dest)
|
||||
// remove tmp dir
|
||||
fs.rmSync(tmpDir, { recursive: true })
|
||||
})
|
||||
}
|
27
apps/create-kunkun/tsconfig.json
Normal file
27
apps/create-kunkun/tsconfig.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": false,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
}
|
||||
}
|
2
apps/desktop/.prettierignore
Normal file
2
apps/desktop/.prettierignore
Normal file
@ -0,0 +1,2 @@
|
||||
src-tauri
|
||||
src/lib/paraglide/**
|
2
apps/desktop/app.d.ts
vendored
2
apps/desktop/app.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
import type { AttributifyAttributes } from "@unocss/preset-attributify"
|
||||
|
||||
declare module "svelte/elements" {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unused-vars
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
interface HTMLAttributes<T> extends AttributifyAttributes {}
|
||||
}
|
||||
|
||||
|
17
apps/desktop/components.json
Normal file
17
apps/desktop/components.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "https://next.shadcn-svelte.com/schema.json",
|
||||
"style": "new-york",
|
||||
"tailwind": {
|
||||
"config": "tailwind.config.ts",
|
||||
"css": "src/app.css",
|
||||
"baseColor": "neutral"
|
||||
},
|
||||
"aliases": {
|
||||
"components": "$lib/components",
|
||||
"utils": "$lib/utils",
|
||||
"ui": "$lib/components/ui",
|
||||
"hooks": "$lib/hooks"
|
||||
},
|
||||
"typescript": true,
|
||||
"registry": "https://next.shadcn-svelte.com/registry"
|
||||
}
|
13
apps/desktop/dev.ts
Normal file
13
apps/desktop/dev.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { IconType } from "@kksh/api/models"
|
||||
import { getExtensionsLatestPublishByIdentifier } from "@kksh/sdk"
|
||||
|
||||
const latestPublish = await getExtensionsLatestPublishByIdentifier({
|
||||
path: {
|
||||
identifier: "RAG1"
|
||||
}
|
||||
})
|
||||
console.log(latestPublish)
|
||||
// latestPublish
|
||||
|
||||
// console.log(typeof IconEnum.Iconify)
|
||||
console.log(IconType.options)
|
42
apps/desktop/eslint.config.js
Normal file
42
apps/desktop/eslint.config.js
Normal file
@ -0,0 +1,42 @@
|
||||
import js from "@eslint/js"
|
||||
import prettier from "eslint-config-prettier"
|
||||
import svelte from "eslint-plugin-svelte"
|
||||
import globals from "globals"
|
||||
import ts from "typescript-eslint"
|
||||
|
||||
export default ts.config(
|
||||
js.configs.recommended,
|
||||
...ts.configs.recommended,
|
||||
...svelte.configs["flat/recommended"],
|
||||
prettier,
|
||||
...svelte.configs["flat/prettier"],
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["**/*.svelte"],
|
||||
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
parser: ts.parser
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
ignores: ["build/", ".svelte-kit/", "dist/"]
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
// The following 2 rules are disabled because they cause errors that I am unable to solve
|
||||
"@typescript-eslint/no-unused-expressions": "off",
|
||||
"svelte/no-inner-declarations": "off"
|
||||
}
|
||||
}
|
||||
)
|
91
apps/desktop/messages/de.json
Normal file
91
apps/desktop/messages/de.json
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
|
||||
"app_name": "KunKun",
|
||||
"secondary_app_name": "KunKun",
|
||||
|
||||
"common_edit": "Bearbeiten",
|
||||
"common_clear": "Löschen",
|
||||
"common_check": "Prüfen",
|
||||
"common_install": "Installieren",
|
||||
|
||||
"home_command_input_placeholder": "Suchen…",
|
||||
"home_command_input_dropdown_quit": "Beenden",
|
||||
"home_command_input_dropdown_developer_title": "Entwickler",
|
||||
"home_command_input_dropdown_close_window": "Fenster schließen",
|
||||
"home_command_input_dropdown_toggle_devtools": "Entwicklertools umschalten",
|
||||
"home_command_input_dropdown_reload_window": "Fenster neu laden",
|
||||
"home_command_input_dropdown_open_preference": "Einstellungen öffnen",
|
||||
"home_command_input_dropdown_toggle_dev_extension_hmr": "Entwicklererweiterungen HMR umschalten",
|
||||
|
||||
"command_group_heading_dev_ext": "Entwicklererweiterungen",
|
||||
"command_group_heading_ext": "Erweiterungen",
|
||||
"command_group_heading_quick_links": "Quick Links",
|
||||
|
||||
"settings_menu_settings": "Einstellungen",
|
||||
"settings_menu_general": "Allgemein",
|
||||
"settings_menu_app_search_paths": "Verzeichnisse für Programme",
|
||||
"settings_menu_developer": "Entwickler",
|
||||
"settings_menu_extensions": "Erweiterungen",
|
||||
"settings_menu_set_dev_ext": "Dev-Erweiterung festlegen",
|
||||
"settings_menu_add_dev_ext": "Dev-Erweiterung hinzufügen",
|
||||
"settings_menu_about": "Über",
|
||||
|
||||
"settings_general_launch_at_login": "Beim Systemstart öffnen",
|
||||
"settings_general_hotkey": "Tastenkombination",
|
||||
"settings_general_menu_bar_icon": "Menüleiste-Symbol",
|
||||
"settings_general_hide_on_blur": "Automatisch ausblenden",
|
||||
"settings_general_extension_auto_upgrade": "Erweiterungen automatisch aktualisieren",
|
||||
"settings_general_dev_extension_hmr": "Entwicklererweiterungen HMR",
|
||||
"settings_general_join_beta_updates": "Beta-Updates nutzen",
|
||||
"settings_general_developer_mode": "Entwickler-Modus",
|
||||
"settings_general_language": "Sprache",
|
||||
"settings_general_loading_animation": "Ladeanimation",
|
||||
|
||||
"settings_app_search_paths_title": "Zusätzliche Verzeichnisse für die Programm-Suche",
|
||||
"settings_app_search_paths_add_app_search_path": "Verzeichnis für Programm-Suche hinzufügen",
|
||||
"settings_app_search_paths_table_col_search_path": "Suchpfad",
|
||||
"settings_app_search_paths_table_col_depth": "Tiefe",
|
||||
"settings_app_search_paths_table_col_actions": "Aktionen",
|
||||
|
||||
"settings_about_version": "Version",
|
||||
"settings_about_author": "Autor",
|
||||
"settings_about_source_code": "Quellcode",
|
||||
"settings_about_extensions_source_code": "Quellcode für Erweiterungen",
|
||||
"settings_about_check_for_updates": "Nach Updates suchen",
|
||||
|
||||
"settings_set_dev_ext_title": "Verzeichnis der Entwicklererweiterungen",
|
||||
"settings_set_dev_ext_description": "Hier werden Entwicklererweiterungen installiert.",
|
||||
"settings_set_dev_ext_enter_path": "Verzeichnis eingeben",
|
||||
|
||||
"settings_extensions_title": "Deine Erweiterungen",
|
||||
"settings_extensions_table_col_name": "Name",
|
||||
"settings_extensions_table_col_identifier": "Identifikator",
|
||||
"settings_extensions_table_col_type": "Typ",
|
||||
"settings_extensions_table_col_version": "Version",
|
||||
"settings_extensions_table_col_uninstall": "Deinstallieren",
|
||||
|
||||
"settings_add_dev_ext_title": "Entwicklererweiterung hinzufügen",
|
||||
"settings_add_dev_ext_description": "Es gibt vier Möglichkeiten, eine Erweiterung als Entwicklererweiterung zu installieren. Tarball-Archiv, lokales Verzeichnis, URL zu Tarball-Archiv oder NPM-Paketnamen.",
|
||||
"settings_add_dev_ext_install_from_ext_folders": "Verzeichnis",
|
||||
"settings_add_dev_ext_install_from_ext_files": "Tarball-Archiv",
|
||||
"settings_add_dev_ext_drag_and_drop": "Drag and Drop",
|
||||
"settings_add_dev_ext_drag_and_drop_strike": "Drag and Drop",
|
||||
"settings_add_dev_ext_drag_and_drop2": "Verzeichnis oder Tarball-Archiv",
|
||||
"settings_add_dev_ext_install_tarball_from_url": "Tarball-Archiv aus URL installieren",
|
||||
|
||||
"troubleshooters_sidebar_title": "Fehlerbehebung",
|
||||
"troubleshooters_sidebar_extension_loading_title": "Ladevorgang",
|
||||
"troubleshooters_sidebar_extension_window_title": "Darstellung",
|
||||
"troubleshooters_sidebar_mdns_debugger_title": "MDNS-Debugger",
|
||||
|
||||
"troubleshooters_extension_window_title": "Fehlerbehebung für die Darstellung von Erweiterungen",
|
||||
"troubleshooters_extension_window_refresh_every_second": "Jede Sekunde neu laden",
|
||||
"troubleshooters_extension_window_refresh": "Neu laden",
|
||||
"troubleshooters_extension_window_refreshed": "{count}x neu geladen",
|
||||
|
||||
"troubleshooters_extension_loading_title": "Fehlerbehebung für den Ladevorgang von Erweiterungen",
|
||||
"troubleshooters_extension_loading_table_col_identifier": "Identifikator",
|
||||
"troubleshooters_extension_loading_table_col_path": "Verzeichnis",
|
||||
"troubleshooters_extension_loading_table_col_error": "Fehler"
|
||||
}
|
91
apps/desktop/messages/en.json
Normal file
91
apps/desktop/messages/en.json
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
|
||||
"app_name": "KunKun",
|
||||
"secondary_app_name": "KunKun",
|
||||
|
||||
"common_edit": "Edit",
|
||||
"common_clear": "Clear",
|
||||
"common_check": "Check",
|
||||
"common_install": "Install",
|
||||
|
||||
"home_command_input_placeholder": "Type \"\/\" to search...",
|
||||
"home_command_input_dropdown_quit": "Quit",
|
||||
"home_command_input_dropdown_developer_title": "Developer",
|
||||
"home_command_input_dropdown_close_window": "Close Window",
|
||||
"home_command_input_dropdown_toggle_devtools": "Toggle Devtools",
|
||||
"home_command_input_dropdown_reload_window": "Reload Window",
|
||||
"home_command_input_dropdown_open_preference": "Open Preference",
|
||||
"home_command_input_dropdown_toggle_dev_extension_hmr": "Toggle Dev Extension HMR",
|
||||
|
||||
"command_group_heading_dev_ext": "Dev Extensions",
|
||||
"command_group_heading_ext": "Extensions",
|
||||
"command_group_heading_quick_links": "Quick Links",
|
||||
|
||||
"settings_menu_settings": "Settings",
|
||||
"settings_menu_general": "General",
|
||||
"settings_menu_app_search_paths": "App Search Paths",
|
||||
"settings_menu_developer": "Developer",
|
||||
"settings_menu_extensions": "Extensions",
|
||||
"settings_menu_set_dev_ext": "Set Dev Extension",
|
||||
"settings_menu_add_dev_ext": "Add Dev Extension",
|
||||
"settings_menu_about": "About",
|
||||
|
||||
"settings_general_launch_at_login": "Launch at Login",
|
||||
"settings_general_hotkey": "Hotkey",
|
||||
"settings_general_menu_bar_icon": "Menu Bar Icon",
|
||||
"settings_general_hide_on_blur": "Hide On Blur",
|
||||
"settings_general_extension_auto_upgrade": "Extension Auto Upgrade",
|
||||
"settings_general_dev_extension_hmr": "Dev Extension HMR",
|
||||
"settings_general_join_beta_updates": "Join Beta Updates",
|
||||
"settings_general_developer_mode": "Developer Mode",
|
||||
"settings_general_language": "Language",
|
||||
"settings_general_loading_animation": "Loading Animation",
|
||||
|
||||
"settings_app_search_paths_title": "Extra App Search Paths",
|
||||
"settings_app_search_paths_add_app_search_path": "Add App Search Path",
|
||||
"settings_app_search_paths_table_col_search_path": "Search Path",
|
||||
"settings_app_search_paths_table_col_depth": "Depth",
|
||||
"settings_app_search_paths_table_col_actions": "Actions",
|
||||
|
||||
"settings_about_version": "Version",
|
||||
"settings_about_author": "Author",
|
||||
"settings_about_source_code": "Source Code",
|
||||
"settings_about_extensions_source_code": "Extensions Source Code",
|
||||
"settings_about_check_for_updates": "Check for Updates",
|
||||
|
||||
"settings_set_dev_ext_title": "Set Dev Extension Path",
|
||||
"settings_set_dev_ext_description": "This is where your extensions will be installed.",
|
||||
"settings_set_dev_ext_enter_path": "Enter Path",
|
||||
|
||||
"settings_extensions_title": "Your Extensions",
|
||||
"settings_extensions_table_col_name": "Name",
|
||||
"settings_extensions_table_col_identifier": "Identifier",
|
||||
"settings_extensions_table_col_type": "Type",
|
||||
"settings_extensions_table_col_version": "Version",
|
||||
"settings_extensions_table_col_uninstall": "Uninstall",
|
||||
|
||||
"settings_add_dev_ext_title": "Add Dev Extension",
|
||||
"settings_add_dev_ext_description": "There are 4 options to install an extension in developer mode. Either load it from your local tarball file, local folder, a tarball remote URL, or npm package name.",
|
||||
"settings_add_dev_ext_install_from_ext_folders": "Install from Extension Folders",
|
||||
"settings_add_dev_ext_install_from_ext_files": "Install from Extension Tarball File",
|
||||
"settings_add_dev_ext_drag_and_drop": "Drag and Drop",
|
||||
"settings_add_dev_ext_drag_and_drop_strike": "Drag and Drop",
|
||||
"settings_add_dev_ext_drag_and_drop2": "Extension Folder or Tarball",
|
||||
"settings_add_dev_ext_install_tarball_from_url": "Install Tarball From URL",
|
||||
|
||||
"troubleshooters_sidebar_title": "Troubleshooters",
|
||||
"troubleshooters_sidebar_extension_loading_title": "Extension Loading",
|
||||
"troubleshooters_sidebar_extension_window_title": "Extension Window",
|
||||
"troubleshooters_sidebar_mdns_debugger_title": "MDNS Debugger",
|
||||
|
||||
"troubleshooters_extension_window_title": "Extension Window Troubleshooter",
|
||||
"troubleshooters_extension_window_refresh_every_second": "Refresh Every Second",
|
||||
"troubleshooters_extension_window_refresh": "Refresh",
|
||||
"troubleshooters_extension_window_refreshed": "Refreshed {count} times",
|
||||
|
||||
"troubleshooters_extension_loading_title": "Extension Loading Troubleshooter",
|
||||
"troubleshooters_extension_loading_table_col_identifier": "Identifier",
|
||||
"troubleshooters_extension_loading_table_col_path": "Path",
|
||||
"troubleshooters_extension_loading_table_col_error": "Error"
|
||||
}
|
84
apps/desktop/messages/pt.json
Normal file
84
apps/desktop/messages/pt.json
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
|
||||
"app_name": "KunKun",
|
||||
"secondary_app_name": "KunKun",
|
||||
|
||||
"common_edit": "Editar",
|
||||
"common_clear": "Limpar",
|
||||
"common_check": "Verificar",
|
||||
"common_install": "Instalar",
|
||||
|
||||
"home_command_input_placeholder": "Digite \"\/\" para buscar...",
|
||||
"home_command_input_dropdown_quit": "Sair",
|
||||
"home_command_input_dropdown_developer_title": "Desenvolvedor",
|
||||
"home_command_input_dropdown_close_window": "Fechar Janela",
|
||||
"home_command_input_dropdown_toggle_devtools": "Alternar Ferramentas de Desenvolvedor",
|
||||
"home_command_input_dropdown_reload_window": "Recarregar Janela",
|
||||
"home_command_input_dropdown_open_preference": "Abrir Preferências",
|
||||
"home_command_input_dropdown_toggle_dev_extension_hmr": "Alternar HMR de Extensão de Desenvolvedor",
|
||||
|
||||
"command_group_heading_dev_ext": "Extensões de Desenvolvedor",
|
||||
"command_group_heading_ext": "Extensões",
|
||||
"command_group_heading_quick_links": "Links Rápidos",
|
||||
|
||||
"settings_menu_settings": "Configurações",
|
||||
"settings_menu_general": "Geral",
|
||||
"settings_menu_developer": "Desenvolvedor",
|
||||
"settings_menu_extensions": "Extensões",
|
||||
"settings_menu_set_dev_ext": "Definir Extensão de Desenvolvedor",
|
||||
"settings_menu_add_dev_ext": "Adicionar Extensão de Desenvolvedor",
|
||||
"settings_menu_about": "Sobre",
|
||||
|
||||
"settings_general_launch_at_login": "Iniciar ao Fazer Login",
|
||||
"settings_general_hotkey": "Tecla de Atalho",
|
||||
"settings_general_menu_bar_icon": "Ícone na Barra de Menu",
|
||||
"settings_general_hide_on_blur": "Ocultar ao Perder Foco",
|
||||
"settings_general_extension_auto_upgrade": "Atualização Automática de Extensões",
|
||||
"settings_general_dev_extension_hmr": "HMR de Extensão de Desenvolvedor",
|
||||
"settings_general_join_beta_updates": "Participar das Atualizações Beta",
|
||||
"settings_general_developer_mode": "Modo Desenvolvedor",
|
||||
"settings_general_language": "Idioma",
|
||||
"settings_general_loading_animation": "Animação de Carregamento",
|
||||
|
||||
"settings_about_version": "Versão",
|
||||
"settings_about_author": "Autor",
|
||||
"settings_about_source_code": "Código Fonte",
|
||||
"settings_about_extensions_source_code": "Código Fonte das Extensões",
|
||||
"settings_about_check_for_updates": "Verificar Atualizações",
|
||||
|
||||
"settings_set_dev_ext_title": "Definir Caminho da Extensão de Desenvolvedor",
|
||||
"settings_set_dev_ext_description": "Aqui é onde suas extensões serão instaladas.",
|
||||
"settings_set_dev_ext_enter_path": "Digite o Caminho",
|
||||
|
||||
"settings_extensions_title": "Suas Extensões",
|
||||
"settings_extensions_table_col_name": "Nome",
|
||||
"settings_extensions_table_col_identifier": "Identificador",
|
||||
"settings_extensions_table_col_type": "Tipo",
|
||||
"settings_extensions_table_col_version": "Versão",
|
||||
"settings_extensions_table_col_uninstall": "Desinstalar",
|
||||
|
||||
"settings_add_dev_ext_title": "Adicionar Extensão de Desenvolvedor",
|
||||
"settings_add_dev_ext_description": "Existem 4 opções para instalar uma extensão em modo desenvolvedor. Você pode carregá-la de um arquivo tarball local, pasta local, URL remota de tarball ou nome de pacote npm.",
|
||||
"settings_add_dev_ext_install_from_ext_folders": "Instalar de Pastas de Extensão",
|
||||
"settings_add_dev_ext_install_from_ext_files": "Instalar de Arquivo Tarball de Extensão",
|
||||
"settings_add_dev_ext_drag_and_drop": "Arraste e Solte",
|
||||
"settings_add_dev_ext_drag_and_drop_strike": "Arraste e Solte",
|
||||
"settings_add_dev_ext_drag_and_drop2": "Pasta ou Tarball da Extensão",
|
||||
"settings_add_dev_ext_install_tarball_from_url": "Instalar Tarball da URL",
|
||||
|
||||
"troubleshooters_sidebar_title": "Solucionadores de Problemas",
|
||||
"troubleshooters_sidebar_extension_loading_title": "Carregamento de Extensão",
|
||||
"troubleshooters_sidebar_extension_window_title": "Janela da Extensão",
|
||||
"troubleshooters_sidebar_mdns_debugger_title": "Depurador MDNS",
|
||||
|
||||
"troubleshooters_extension_window_title": "Solucionador de Problemas da Janela de Extensão",
|
||||
"troubleshooters_extension_window_refresh_every_second": "Atualizar a Cada Segundo",
|
||||
"troubleshooters_extension_window_refresh": "Atualizar",
|
||||
"troubleshooters_extension_window_refreshed": "Atualizado {count} vezes",
|
||||
|
||||
"troubleshooters_extension_loading_title": "Solucionador de Problemas do Carregamento de Extensão",
|
||||
"troubleshooters_extension_loading_table_col_identifier": "Identificador",
|
||||
"troubleshooters_extension_loading_table_col_path": "Caminho",
|
||||
"troubleshooters_extension_loading_table_col_error": "Erro"
|
||||
}
|
85
apps/desktop/messages/ru.json
Normal file
85
apps/desktop/messages/ru.json
Normal file
@ -0,0 +1,85 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
|
||||
"app_name": "KunKun",
|
||||
"secondary_app_name": "KunKun",
|
||||
|
||||
"common_edit": "Редактировать",
|
||||
"common_clear": "Очистить",
|
||||
"common_check": "Проверить",
|
||||
"common_install": "Установить",
|
||||
|
||||
"home_command_input_placeholder": "Нажмите \"/\" для поиска...",
|
||||
"home_command_input_dropdown_quit": "Выйти",
|
||||
"home_command_input_dropdown_developer_title": "Разработчик",
|
||||
"home_command_input_dropdown_close_window": "Закрыть окно",
|
||||
"home_command_input_dropdown_toggle_devtools": "Вкл/выкл инструменты разработчика",
|
||||
"home_command_input_dropdown_reload_window": "Перезагрузить окно",
|
||||
"home_command_input_dropdown_open_preference": "Открыть настройки",
|
||||
"home_command_input_dropdown_toggle_dev_extension_hmr": "Вкл/выкл горячую замену (HMR) у dev-расширений",
|
||||
|
||||
"command_group_heading_dev_ext": "Dev-расширения",
|
||||
"command_group_heading_ext": "Расширения",
|
||||
"command_group_heading_quick_links": "Быстрые ссылки",
|
||||
|
||||
"settings_menu_settings": "Настройки",
|
||||
"settings_menu_general": "Общие",
|
||||
"settings_menu_developer": "Разработчик",
|
||||
"settings_menu_extensions": "Расширения",
|
||||
"settings_menu_set_dev_ext": "Dev-расширения",
|
||||
"settings_menu_add_dev_ext": "Добавить dev-расширение",
|
||||
"settings_menu_about": "О программе",
|
||||
|
||||
"settings_general_launch_at_login": "Автозагрузка при входе в систему",
|
||||
"settings_general_hotkey": "Сочетание клавиш",
|
||||
"settings_general_menu_bar_icon": "Иконка в строке меню",
|
||||
"settings_general_hide_on_blur": "Скрыть окно при потере фокуса",
|
||||
"settings_general_extension_auto_upgrade": "Автообновление расширений",
|
||||
"settings_general_dev_extension_hmr": "Горячая замена модуля (HMR) у dev-расширений",
|
||||
"settings_general_join_beta_updates": "Получать бета-обновления",
|
||||
"settings_general_developer_mode": "Режим разработчика",
|
||||
"settings_general_language": "Язык",
|
||||
"settings_general_loading_animation": "Анимация загрузки",
|
||||
|
||||
"settings_about_version": "Версия",
|
||||
"settings_about_author": "Автор",
|
||||
"settings_about_source_code": "Исходный код",
|
||||
"settings_about_extensions_source_code": "Исходный код расширения",
|
||||
"settings_about_check_for_updates": "Проверить на наличие обновлений",
|
||||
|
||||
"settings_set_dev_ext_title": "Настроить путь для dev-расширений",
|
||||
"settings_set_dev_ext_description": "Это место, где будут установлены ваши расширения.",
|
||||
"settings_set_dev_ext_enter_path": "Введите путь",
|
||||
|
||||
"settings_extensions_title": "Ваши расширения",
|
||||
"settings_extensions_table_col_name": "Название",
|
||||
"settings_extensions_table_col_identifier": "Идентификатор",
|
||||
"settings_extensions_table_col_type": "Тип",
|
||||
"settings_extensions_table_col_version": "Версия",
|
||||
"settings_extensions_table_col_uninstall": "Удалить",
|
||||
|
||||
"settings_add_dev_ext_title": "Добавить dev-расширение",
|
||||
"settings_add_dev_ext_description": "В режиме разработчика у вас есть четыре способа установки dev-расширений: из локального tar-архива, из локальной директории, по URL-адресу на tar-архив либо по названию пакета npm.",
|
||||
"settings_add_dev_ext_install_from_ext_folders": "Установить из директори",
|
||||
"settings_add_dev_ext_install_from_ext_files": "Установить из tar-архива",
|
||||
"settings_add_dev_ext_drag_and_drop_strike": "Локальные расширения",
|
||||
"settings_add_dev_ext_drag_and_drop": "Можете перетащить сюда расширения",
|
||||
"settings_add_dev_ext_drag_and_drop2": "в виде директории или tar-архива",
|
||||
|
||||
"settings_add_dev_ext_install_tarball_from_url": "Установить tar-архив по URL-адресу",
|
||||
|
||||
"troubleshooters_sidebar_title": "Диагностика",
|
||||
"troubleshooters_sidebar_extension_loading_title": "Загрузка расширения",
|
||||
"troubleshooters_sidebar_extension_window_title": "Окно расширения",
|
||||
"troubleshooters_sidebar_mdns_debugger_title": "mDNS-отладка",
|
||||
|
||||
"troubleshooters_extension_window_title": "Диагностика окна расишрения",
|
||||
"troubleshooters_extension_window_refresh_every_second": "Обновлять каждую секунду",
|
||||
"troubleshooters_extension_window_refresh": "Обновить",
|
||||
"troubleshooters_extension_window_refreshed": "Обновлено {count} раз",
|
||||
|
||||
"troubleshooters_extension_loading_title": "Диагностика загрузки расширений",
|
||||
"troubleshooters_extension_loading_table_col_identifier": "Идентификатор",
|
||||
"troubleshooters_extension_loading_table_col_path": "Путь",
|
||||
"troubleshooters_extension_loading_table_col_error": "Ошибка"
|
||||
}
|
84
apps/desktop/messages/vi.json
Normal file
84
apps/desktop/messages/vi.json
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
|
||||
"app_name": "KunKun",
|
||||
"secondary_app_name": "KunKun",
|
||||
|
||||
"common_edit": "Sửa",
|
||||
"common_clear": "Xoá",
|
||||
"common_check": "Kiểm tra",
|
||||
"common_install": "Cài đặt",
|
||||
|
||||
"home_command_input_placeholder": "Gõ \"\/\" để tìm kiếm...",
|
||||
"home_command_input_dropdown_quit": "Thoát",
|
||||
"home_command_input_dropdown_developer_title": "Nhà phát triển",
|
||||
"home_command_input_dropdown_close_window": "Đóng cửa sổ",
|
||||
"home_command_input_dropdown_toggle_devtools": "Bật\/Tắt DevTools",
|
||||
"home_command_input_dropdown_reload_window": "Khởi động lại",
|
||||
"home_command_input_dropdown_open_preference": "Mở cài đặt",
|
||||
"home_command_input_dropdown_toggle_dev_extension_hmr": "Bật\/tắt HMR cho tiện ích đang phát triển",
|
||||
|
||||
"command_group_heading_dev_ext": "Tiện Ích Mở Rộng Đang Phát Triển",
|
||||
"command_group_heading_ext": "Tiện Ích Mở Rộng",
|
||||
"command_group_heading_quick_links": "Liên kết nhanh",
|
||||
|
||||
"settings_menu_settings": "Cài đặt",
|
||||
"settings_menu_general": "Chung",
|
||||
"settings_menu_developer": "Nhà phát triển",
|
||||
"settings_menu_extensions": "Tiện ích mở rộng",
|
||||
"settings_menu_set_dev_ext": "Đường dẫn tiện ích",
|
||||
"settings_menu_add_dev_ext": "Thêm tiện ích",
|
||||
"settings_menu_about": "Thông tin",
|
||||
|
||||
"settings_general_launch_at_login": "Khởi động khi đăng nhập",
|
||||
"settings_general_hotkey": "Phím tắt",
|
||||
"settings_general_menu_bar_icon": "Biểu tượng thanh menu",
|
||||
"settings_general_hide_on_blur": "Ẩn khi chuyển sang ứng dụng khác",
|
||||
"settings_general_extension_auto_upgrade": "Tự động nâng cấp tiện ích mở rộng",
|
||||
"settings_general_dev_extension_hmr": "HMR cho tiện ích mở rộng đang phát triển",
|
||||
"settings_general_join_beta_updates": "Cài đặt cập nhật thử nghiệm (beta)",
|
||||
"settings_general_developer_mode": "Chế độ nhà phát triển",
|
||||
"settings_general_language": "Ngôn ngữ",
|
||||
"settings_general_loading_animation": "Hình ảnh tải",
|
||||
|
||||
"settings_about_version": "Phiên bản",
|
||||
"settings_about_author": "Tác giả",
|
||||
"settings_about_source_code": "Mã nguồn",
|
||||
"settings_about_extensions_source_code": "Mã nguồn tiện ích mở rộng",
|
||||
"settings_about_check_for_updates": "Kiểm tra cập nhật",
|
||||
|
||||
"settings_set_dev_ext_title": "Đặt đường dẫn tiện ích mở rộng đang phát triển",
|
||||
"settings_set_dev_ext_description": "Đây là đường dẫn cài đặt các tiện ích mở rộng của bạn.",
|
||||
"settings_set_dev_ext_enter_path": "Nhập đường dẫn",
|
||||
|
||||
"settings_extensions_title": "Tiện ích mở rộng của bạn",
|
||||
"settings_extensions_table_col_name": "Tên",
|
||||
"settings_extensions_table_col_identifier": "Định danh",
|
||||
"settings_extensions_table_col_type": "Loại",
|
||||
"settings_extensions_table_col_version": "Phiên bản",
|
||||
"settings_extensions_table_col_uninstall": "Gỡ cài đặt",
|
||||
|
||||
"settings_add_dev_ext_title": "Thêm tiện ích đang phát triển",
|
||||
"settings_add_dev_ext_description": "Có 4 cách để cài đặt một tiện ích mở rộng trong chế độ nhà phát triển. Nạp nó từ file tarball, thư mục từ máy tính, file tarball từ liên kết ngoài, hoặc tên gói npm.",
|
||||
"settings_add_dev_ext_install_from_ext_folders": "Cài Đặt Từ Thư Mục Tiện Ích",
|
||||
"settings_add_dev_ext_install_from_ext_files": "Cài Đặt Từ File Tarball",
|
||||
"settings_add_dev_ext_drag_and_drop": "Kéo và Thả",
|
||||
"settings_add_dev_ext_drag_and_drop_strike": "Kéo và Thả",
|
||||
"settings_add_dev_ext_drag_and_drop2": "Thư Mục Tiện Ích hoặc File Tarball",
|
||||
"settings_add_dev_ext_install_tarball_from_url": "Cài Đặt File Tarball Từ Liên kết",
|
||||
|
||||
"troubleshooters_sidebar_title": "Khắc Phục Sự Cố",
|
||||
"troubleshooters_sidebar_extension_loading_title": "Tải Tiện ích Mở Rộng",
|
||||
"troubleshooters_sidebar_extension_window_title": "Cửa sổ Tiện ích Mở Rộng",
|
||||
"troubleshooters_sidebar_mdns_debugger_title": "Trình Gỡ Lỗi MDNS",
|
||||
|
||||
"troubleshooters_extension_window_title": "Khắc Phục Sự Cố Cửa sổ Tiện ích Mở Rộng",
|
||||
"troubleshooters_extension_window_refresh_every_second": "Làm mới mỗi giây",
|
||||
"troubleshooters_extension_window_refresh": "Làm mới",
|
||||
"troubleshooters_extension_window_refreshed": "Đã làm mới {count} lần",
|
||||
|
||||
"troubleshooters_extension_loading_title": "Khắc Phục Sự Cố Tải Tiện ích Mở Rộng",
|
||||
"troubleshooters_extension_loading_table_col_identifier": "Định danh",
|
||||
"troubleshooters_extension_loading_table_col_path": "Đường dẫn",
|
||||
"troubleshooters_extension_loading_table_col_error": "Lỗi"
|
||||
}
|
91
apps/desktop/messages/zh.json
Normal file
91
apps/desktop/messages/zh.json
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
|
||||
"app_name": "KunKun",
|
||||
"secondary_app_name": "鲲鲲",
|
||||
|
||||
"common_edit": "编辑",
|
||||
"common_clear": "清除",
|
||||
"common_check": "检查",
|
||||
"common_install": "安装",
|
||||
|
||||
"home_command_input_placeholder": "按 \"/\" 开始搜索...",
|
||||
"home_command_input_dropdown_quit": "退出",
|
||||
"home_command_input_dropdown_developer_title": "开发者",
|
||||
"home_command_input_dropdown_close_window": "关闭窗口",
|
||||
"home_command_input_dropdown_toggle_devtools": "切换开发者工具",
|
||||
"home_command_input_dropdown_reload_window": "重新加载窗口",
|
||||
"home_command_input_dropdown_open_preference": "打开设置",
|
||||
"home_command_input_dropdown_toggle_dev_extension_hmr": "切换开发插件 HMR",
|
||||
|
||||
"command_group_heading_dev_ext": "开发插件",
|
||||
"command_group_heading_ext": "插件",
|
||||
"command_group_heading_quick_links": "快捷链接",
|
||||
|
||||
"settings_menu_settings": "设置",
|
||||
"settings_menu_general": "通用",
|
||||
"settings_menu_app_search_paths": "应用搜索路径",
|
||||
"settings_menu_developer": "开发者",
|
||||
"settings_menu_extensions": "插件",
|
||||
"settings_menu_set_dev_ext": "设置开发插件",
|
||||
"settings_menu_add_dev_ext": "添加开发插件",
|
||||
"settings_menu_about": "关于",
|
||||
|
||||
"settings_general_launch_at_login": "开机启动",
|
||||
"settings_general_hotkey": "快捷键",
|
||||
"settings_general_menu_bar_icon": "菜单栏图标",
|
||||
"settings_general_hide_on_blur": "隐藏在后台",
|
||||
"settings_general_extension_auto_upgrade": "自动更新插件",
|
||||
"settings_general_dev_extension_hmr": "开发模式",
|
||||
"settings_general_join_beta_updates": "加入 Beta 更新",
|
||||
"settings_general_developer_mode": "开发者模式",
|
||||
"settings_general_language": "语言",
|
||||
"settings_general_loading_animation": "加载动画",
|
||||
|
||||
"settings_app_search_paths_title": "额外应用搜索路径",
|
||||
"settings_app_search_paths_add_app_search_path": "添加应用搜索路径",
|
||||
"settings_app_search_paths_table_col_search_path": "搜索路径",
|
||||
"settings_app_search_paths_table_col_depth": "深度",
|
||||
"settings_app_search_paths_table_col_actions": "操作",
|
||||
|
||||
"settings_about_version": "版本",
|
||||
"settings_about_author": "作者",
|
||||
"settings_about_source_code": "源代码",
|
||||
"settings_about_extensions_source_code": "插件源代码",
|
||||
"settings_about_check_for_updates": "检查更新",
|
||||
|
||||
"settings_set_dev_ext_title": "设置开发插件安装路径",
|
||||
"settings_set_dev_ext_description": "这是你的开发插件将被安装的地方。",
|
||||
"settings_set_dev_ext_enter_path": "输入路径",
|
||||
|
||||
"settings_extensions_title": "你的插件",
|
||||
"settings_extensions_table_col_name": "名称",
|
||||
"settings_extensions_table_col_identifier": "标识符",
|
||||
"settings_extensions_table_col_type": "类型",
|
||||
"settings_extensions_table_col_version": "版本",
|
||||
"settings_extensions_table_col_uninstall": "卸载",
|
||||
|
||||
"settings_add_dev_ext_title": "添加开发插件",
|
||||
"settings_add_dev_ext_description": "有四种方法可以在开发模式下安装插件。 从本地 tarball 文件、tarball 远程 URL、npm 包名称或远程 URL 加载。",
|
||||
"settings_add_dev_ext_install_from_ext_folders": "从插件文件夹安装",
|
||||
"settings_add_dev_ext_install_from_ext_files": "从插件 tarball 文件安装",
|
||||
"settings_add_dev_ext_drag_and_drop": "拖放",
|
||||
"settings_add_dev_ext_drag_and_drop_strike": "拖放",
|
||||
"settings_add_dev_ext_drag_and_drop2": "插件文件夹或 tarball",
|
||||
"settings_add_dev_ext_install_tarball_from_url": "从 tarball URL 安装",
|
||||
|
||||
"troubleshooters_sidebar_title": "故障排除器",
|
||||
"troubleshooters_sidebar_extension_loading_title": "插件加载",
|
||||
"troubleshooters_sidebar_extension_window_title": "插件窗口",
|
||||
"troubleshooters_sidebar_mdns_debugger_title": "MDNS 调试器",
|
||||
|
||||
"troubleshooters_extension_window_title": "插件窗口故障排除器",
|
||||
"troubleshooters_extension_window_refresh_every_second": "每秒刷新",
|
||||
"troubleshooters_extension_window_refresh": "刷新",
|
||||
"troubleshooters_extension_window_refreshed": "已刷新 {count} 次",
|
||||
|
||||
"troubleshooters_extension_loading_title": "插件加载故障排除器",
|
||||
"troubleshooters_extension_loading_table_col_identifier": "标识符",
|
||||
"troubleshooters_extension_loading_table_col_path": "路径",
|
||||
"troubleshooters_extension_loading_table_col_error": "错误"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kksh/desktop",
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.37",
|
||||
"description": "",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@ -8,6 +8,7 @@
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"tauri": "tauri"
|
||||
@ -15,50 +16,71 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@formkit/auto-animate": "^0.8.2",
|
||||
"@huakunshen/comlink": "^4.4.1",
|
||||
"@inlang/paraglide-sveltekit": "0.16.0",
|
||||
"@kksh/drizzle": "workspace:*",
|
||||
"@kksh/extension": "workspace:*",
|
||||
"@kksh/supabase": "workspace:*",
|
||||
"@kksh/svelte5": "^0.1.15",
|
||||
"@kksh/ui": "workspace:*",
|
||||
"@kksh/utils": "workspace:*",
|
||||
"@std/semver": "npm:@jsr/std__semver@^1.0.3",
|
||||
"@tauri-apps/api": "^2",
|
||||
"@tauri-apps/plugin-shell": "^2",
|
||||
"bits-ui": "1.0.0-next.36",
|
||||
"gsap": "^3.12.5",
|
||||
"lucide-svelte": "^0.454.0",
|
||||
"@std/semver": "npm:@jsr/std__semver@^1.0.4",
|
||||
"@supabase/supabase-js": "^2.49.1",
|
||||
"@tanstack/table-core": "^8.21.2",
|
||||
"@tauri-apps/api": "^2.3.0",
|
||||
"@tauri-apps/plugin-autostart": "^2.2.0",
|
||||
"@tauri-apps/plugin-shell": "^2.2.0",
|
||||
"@tauri-apps/plugin-sql": "^2.2.0",
|
||||
"@tauri-apps/plugin-stronghold": "^2.2.0",
|
||||
"@tauri-store/svelte": "^2.1.1",
|
||||
"dompurify": "^3.2.4",
|
||||
"drizzle-orm": "^0.41.0",
|
||||
"eslint": "^9.21.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
"gsap": "^3.12.7",
|
||||
"kkrpc": "^0.2.2",
|
||||
"lz-string": "^1.5.0",
|
||||
"mode-watcher": "^0.4.1",
|
||||
"semver": "^7.6.3",
|
||||
"svelte-radix": "^2.0.1",
|
||||
"pretty-bytes": "^6.1.1",
|
||||
"semver": "^7.7.1",
|
||||
"svelte-inspect-value": "^0.5.0",
|
||||
"svelte-sonner": "^0.3.28",
|
||||
"sveltekit-superforms": "^2.20.0",
|
||||
"uuid": "^11.0.2"
|
||||
"sveltekit-superforms": "^2.23.1",
|
||||
"tauri-plugin-clipboard-api": "^2.1.11",
|
||||
"tauri-plugin-shellx-api": "^2.0.16",
|
||||
"tauri-plugin-svelte": "1.2.1",
|
||||
"tauri-plugin-user-input-api": "workspace:*",
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@inlang/paraglide-js": "1.11.8",
|
||||
"@kksh/types": "workspace:*",
|
||||
"@sveltejs/adapter-static": "^3.0.6",
|
||||
"@sveltejs/kit": "^2.7.4",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@sveltejs/adapter-static": "^3.0.8",
|
||||
"@sveltejs/kit": "^2.17.3",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"@tailwindcss/aspect-ratio": "^0.4.2",
|
||||
"@tailwindcss/container-queries": "^0.1.1",
|
||||
"@tailwindcss/forms": "^0.5.9",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@tauri-apps/cli": "^2.0.4",
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@tauri-apps/cli": "^2.3.1",
|
||||
"@types/bun": "latest",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@unocss/preset-attributify": "^0.64.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.25.0",
|
||||
"@typescript-eslint/parser": "^8.25.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"bits-ui": "1.0.0-next.86",
|
||||
"clsx": "^2.1.1",
|
||||
"embla-carousel-svelte": "^8.3.1",
|
||||
"formsnap": "^1.0.1",
|
||||
"tailwind-merge": "^2.5.4",
|
||||
"tailwind-variants": "^0.2.1",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.46.1",
|
||||
"globals": "^15.14.0",
|
||||
"lucide-svelte": "^0.474.0",
|
||||
"prettier": "^3.5.2",
|
||||
"svelte-radix": "^2.0.1",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"tailwind-variants": "^0.3.1",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.6.3",
|
||||
"unocss": "^0.64.0",
|
||||
"vaul-svelte": "^0.3.2",
|
||||
"vite": "^5.4.10"
|
||||
"typescript-eslint": "^8.25.0",
|
||||
"vite": "^6.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
export default {
|
||||
plugins: {
|
||||
plugins: {
|
||||
tailwindcss: {
|
||||
config: "tailwind.config.ts"
|
||||
// config: "../../packages/ui/tailwind.config.ts"
|
||||
},
|
||||
autoprefixer: {}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
1
apps/desktop/project.inlang/.gitignore
vendored
Normal file
1
apps/desktop/project.inlang/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
cache
|
1
apps/desktop/project.inlang/project_id
Normal file
1
apps/desktop/project.inlang/project_id
Normal file
@ -0,0 +1 @@
|
||||
9800f324a732adb2ed22a4b600a0025820caaba8c4d886b0949b04616bba4726
|
15
apps/desktop/project.inlang/settings.json
Normal file
15
apps/desktop/project.inlang/settings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/project-settings",
|
||||
"sourceLanguageTag": "en",
|
||||
"languageTags": ["en", "zh", "ru", "pt", "vi", "de"],
|
||||
"modules": [
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js"
|
||||
],
|
||||
"plugin.inlang.messageFormat": {
|
||||
"pathPattern": "./messages/{languageTag}.json"
|
||||
}
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
import assert from "assert"
|
||||
import fs from "fs"
|
||||
import { compressString, decompressString } from "@kksh/utils"
|
||||
import { $ } from "bun"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Download Dance JSON */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
console.log("Downloading Dance Data...")
|
||||
const rawData = await fetch("https://dance.kunkun.sh/api/data").then((res) => res.text())
|
||||
|
||||
if (!fs.existsSync("./src/data")) {
|
||||
fs.mkdirSync("./src/data", { recursive: true })
|
||||
}
|
||||
function formatFileSize(size: number) {
|
||||
return `${(size / 1024).toFixed(2)} KB`
|
||||
}
|
||||
|
@ -14,16 +14,17 @@ name = "kunkun_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.2", features = [] }
|
||||
tauri-build = { version = "2.0.5", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2.0.6", features = [ "macos-private-api",
|
||||
tauri = { version = "2.2.5", features = [
|
||||
"macos-private-api",
|
||||
"image-png",
|
||||
"image-ico",
|
||||
"tray-icon",
|
||||
"devtools",
|
||||
] }
|
||||
tauri-plugin-shell = "2"
|
||||
tauri-plugin-shell = "2.2.0"
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
@ -32,32 +33,43 @@ mdns-sd = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
log = { workspace = true }
|
||||
urlencoding = "2.1.3"
|
||||
tauri-plugin-process = "2.0.1"
|
||||
tauri-plugin-shellx = "2.0.11"
|
||||
tauri-plugin-fs = "2.0.1"
|
||||
tauri-plugin-dialog = "2.0.1"
|
||||
tauri-plugin-notification = "2.0.1"
|
||||
tauri-plugin-os = "2.0.1"
|
||||
tauri-plugin-http = "2.0.1"
|
||||
tauri-plugin-upload = "2.0.1"
|
||||
tauri-plugin-process = "2.2.0"
|
||||
tauri-plugin-shellx = { workspace = true }
|
||||
tauri-plugin-fs = { version = "2.2.0", features = ["watch"] }
|
||||
tauri-plugin-dialog = "2.2.0"
|
||||
tauri-plugin-notification = "2.2.1"
|
||||
tauri-plugin-os = "2.2.0"
|
||||
tauri-plugin-http = "2.3.0"
|
||||
tauri-plugin-upload = { workspace = true }
|
||||
# tauri-plugin-upload = "2.2.1"
|
||||
tauri-plugin-jarvis = { workspace = true }
|
||||
tauri-plugin-keyring = { workspace = true }
|
||||
tauri-plugin-network = { workspace = true }
|
||||
tauri-plugin-system-info = { workspace = true }
|
||||
tauri-plugin-user-input = { workspace = true }
|
||||
tauri-plugin-clipboard = { workspace = true }
|
||||
tauri-plugin-store = "2.1.0"
|
||||
tauri-plugin-deep-link = "2"
|
||||
tauri-plugin-log = { version = "2.0.1", features = ["colored"] }
|
||||
zip = "2.1.3"
|
||||
tauri-plugin-store = "2.2.0"
|
||||
tauri-plugin-deep-link = "2.2.0"
|
||||
tauri-plugin-log = { version = "2.2.1", features = ["colored"] }
|
||||
crypto = { workspace = true }
|
||||
zip = "2.2.2"
|
||||
uuid = "1.14.0"
|
||||
# tauri-plugin-devtools = "2.0.0"
|
||||
obfstr = { workspace = true }
|
||||
base64 = { workspace = true }
|
||||
tauri-plugin-stronghold = "2.2.0"
|
||||
tauri-plugin-sql = "2"
|
||||
|
||||
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
cocoa = "0.24.1"
|
||||
mac-security-rs = { workspace = true }
|
||||
objc = "0.2.7"
|
||||
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-autostart = "2"
|
||||
tauri-plugin-cli = "2"
|
||||
tauri-plugin-global-shortcut = "2.0.1"
|
||||
tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }
|
||||
tauri-plugin-updater = "2.0.2"
|
||||
tauri-plugin-svelte = "2.1.1"
|
||||
|
@ -1,3 +1,8 @@
|
||||
fn main() {
|
||||
let db_enc_key = match std::env::var("DB_ENCRYPTION_KEY") {
|
||||
Ok(key) => key,
|
||||
Err(_) => String::from("none"),
|
||||
};
|
||||
println!("cargo:rustc-env=DB_ENCRYPTION_KEY={}", db_enc_key);
|
||||
tauri_build::build()
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main*"],
|
||||
"windows": ["main*", "splashscreen"],
|
||||
"permissions": [
|
||||
{
|
||||
"identifier": "http:default",
|
||||
@ -23,6 +23,8 @@
|
||||
"core:path:default",
|
||||
"core:event:default",
|
||||
"core:window:default",
|
||||
"core:window:allow-set-size",
|
||||
"core:window:allow-set-enabled",
|
||||
"core:window:allow-start-dragging",
|
||||
"core:window:allow-set-focus",
|
||||
"core:window:allow-toggle-maximize",
|
||||
@ -38,6 +40,7 @@
|
||||
"core:webview:allow-create-webview",
|
||||
"core:webview:allow-create-webview-window",
|
||||
"core:app:default",
|
||||
"core:app:allow-app-hide",
|
||||
"core:resources:default",
|
||||
"core:menu:default",
|
||||
"core:tray:default",
|
||||
@ -58,9 +61,11 @@
|
||||
"shellx:allow-execute",
|
||||
"shellx:allow-open",
|
||||
"shellx:allow-kill",
|
||||
"shellx:allow-kill-pid",
|
||||
"shellx:allow-spawn",
|
||||
"shellx:allow-stdin-write",
|
||||
"shellx:allow-fix-path-env",
|
||||
"shellx:allow-where-is-command",
|
||||
"dialog:default",
|
||||
"dialog:allow-open",
|
||||
"dialog:allow-confirm",
|
||||
@ -109,28 +114,7 @@
|
||||
"identifier": "fs:scope",
|
||||
"allow": [
|
||||
{
|
||||
"path": "$DESKTOP"
|
||||
},
|
||||
{
|
||||
"path": "$DESKTOP/**"
|
||||
},
|
||||
{
|
||||
"path": "$DOWNLOAD"
|
||||
},
|
||||
{
|
||||
"path": "$DOWNLOAD/**"
|
||||
},
|
||||
{
|
||||
"path": "$DOCUMENT"
|
||||
},
|
||||
{
|
||||
"path": "$DOCUMENT/**"
|
||||
},
|
||||
{
|
||||
"path": "$TEMP/**"
|
||||
},
|
||||
{
|
||||
"path": "$TEMP"
|
||||
"path": "**/*"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -144,7 +128,10 @@
|
||||
"upload:default",
|
||||
"process:default",
|
||||
"system-info:allow-all",
|
||||
"user-input:default",
|
||||
"shell:default",
|
||||
"keyring:default",
|
||||
"stronghold:default",
|
||||
{
|
||||
"identifier": "shell:allow-spawn",
|
||||
"allow": [
|
||||
@ -159,6 +146,9 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"deep-link:default"
|
||||
"deep-link:default",
|
||||
"autostart:allow-enable",
|
||||
"autostart:allow-disable",
|
||||
"autostart:allow-is-enabled"
|
||||
]
|
||||
}
|
||||
|
5
apps/desktop/src-tauri/capabilities/svelte.json
Normal file
5
apps/desktop/src-tauri/capabilities/svelte.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"identifier": "svelte",
|
||||
"windows": ["*"],
|
||||
"permissions": ["svelte:default", "core:event:default"]
|
||||
}
|
13
apps/desktop/src-tauri/src/commands/keyring.rs
Normal file
13
apps/desktop/src-tauri/src/commands/keyring.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use tauri::Runtime;
|
||||
use tauri_plugin_keyring::KeyringExt;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_stronghold_key<R: Runtime>(app: tauri::AppHandle<R>) -> Result<String, String> {
|
||||
app.keyring()
|
||||
.get_or_set_password(
|
||||
"kunkun",
|
||||
"stronghold_key",
|
||||
uuid::Uuid::new_v4().to_string().as_str(),
|
||||
)
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
1
apps/desktop/src-tauri/src/commands/mod.rs
Normal file
1
apps/desktop/src-tauri/src/commands/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod keyring;
|
@ -1,12 +1,16 @@
|
||||
use std::{path::PathBuf, sync::Mutex};
|
||||
pub mod commands;
|
||||
mod setup;
|
||||
pub mod utils;
|
||||
use base64::prelude::*;
|
||||
use log;
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::ActivationPolicy;
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_autostart::MacosLauncher;
|
||||
use tauri_plugin_deep_link::DeepLinkExt;
|
||||
use tauri_plugin_jarvis::{
|
||||
constants::KUNKUN_PUBLISH,
|
||||
db::JarvisDB,
|
||||
server::Protocol,
|
||||
utils::{
|
||||
@ -14,6 +18,7 @@ use tauri_plugin_jarvis::{
|
||||
settings::AppSettings,
|
||||
},
|
||||
};
|
||||
use tauri_plugin_keyring::KeyringExt;
|
||||
pub use tauri_plugin_log::fern::colors::ColoredLevelConfig;
|
||||
use tauri_plugin_store::{StoreBuilder, StoreExt};
|
||||
use utils::server::tauri_file_server;
|
||||
@ -22,6 +27,16 @@ use utils::server::tauri_file_server;
|
||||
pub fn run() {
|
||||
let context = tauri::generate_context!();
|
||||
let mut builder = tauri::Builder::default();
|
||||
// let app_data_path = tauri::path::PathResolver::app_data_dir().unwrap();
|
||||
// let db_key = if cfg!(debug_assertions) {
|
||||
// None
|
||||
// } else {
|
||||
// let db_enc_key_env = obfstr::obfstr!(env!("DB_ENCRYPTION_KEY")).to_string();
|
||||
// match db_enc_key_env == "none" {
|
||||
// true => None,
|
||||
// false => Some(db_enc_key_env),
|
||||
// }
|
||||
// };
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
@ -50,14 +65,29 @@ pub fn run() {
|
||||
// .build(),
|
||||
// );
|
||||
// }
|
||||
|
||||
if KUNKUN_PUBLISH == "true" {
|
||||
// only include updater with KUNKUN_PUBLISH = true, this is used to avoid using updater in beta build CI, which requires secrets for the updater endpoint if updater is included
|
||||
println!("KUNKUN_PUBLISH: {}", KUNKUN_PUBLISH);
|
||||
builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
|
||||
}
|
||||
let shell_unlocked = true;
|
||||
builder = builder
|
||||
.plugin(tauri_plugin_single_instance::init(|app, args, cwd| {
|
||||
let _ = app
|
||||
.get_webview_window("main")
|
||||
.expect("no main window")
|
||||
.set_focus();
|
||||
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
|
||||
let window = app.get_webview_window("main").expect("no main window");
|
||||
|
||||
// if toggle is passed, we want to show/hide the main window
|
||||
if args.get(1).map_or(false, |arg| arg == "toggle") {
|
||||
if window.is_visible().unwrap_or(false) {
|
||||
log::info!("hiding main window");
|
||||
window.hide().unwrap();
|
||||
} else {
|
||||
log::info!("showing main window");
|
||||
window.show().unwrap();
|
||||
window.set_focus().unwrap();
|
||||
};
|
||||
} else {
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}))
|
||||
.plugin(
|
||||
tauri_plugin_log::Builder::new()
|
||||
@ -78,12 +108,22 @@ pub fn run() {
|
||||
.build(),
|
||||
)
|
||||
.plugin(tauri_plugin_cli::init())
|
||||
.plugin(
|
||||
tauri_plugin_sql::Builder::default()
|
||||
// .add_migrations("sqlite:mydatabase.db", migrations)
|
||||
.build(),
|
||||
)
|
||||
.plugin(tauri_plugin_user_input::init())
|
||||
.plugin(tauri_plugin_deep_link::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_svelte::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
Some(vec![]),
|
||||
))
|
||||
.plugin(tauri_plugin_upload::init())
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_store::Builder::default().build())
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
@ -93,8 +133,12 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_shellx::init(shell_unlocked))
|
||||
.plugin(tauri_plugin_jarvis::init())
|
||||
.plugin(tauri_plugin_clipboard::init())
|
||||
.plugin(tauri_plugin_keyring::init())
|
||||
.plugin(tauri_plugin_network::init())
|
||||
.plugin(tauri_plugin_system_info::init());
|
||||
.plugin(tauri_plugin_system_info::init())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::keyring::get_stronghold_key,
|
||||
]);
|
||||
|
||||
let app = builder
|
||||
.register_uri_scheme_protocol("appicon", |_app, request| {
|
||||
@ -105,7 +149,7 @@ pub fn run() {
|
||||
})
|
||||
.register_uri_scheme_protocol("ext", |app, request| {
|
||||
let app_handle = app.app_handle();
|
||||
// app_handle.
|
||||
|
||||
let win_label = app.webview_label();
|
||||
let jarvis_state = app_handle.state::<tauri_plugin_jarvis::JarvisState>();
|
||||
let window_ext_map = jarvis_state.window_label_ext_map.lock().unwrap();
|
||||
@ -113,8 +157,12 @@ pub fn run() {
|
||||
Some(ext) => {
|
||||
// let app_state = app_handle.state::<tauri_plugin_jarvis::model::app_state::AppState>();
|
||||
// let extension_path = app_state.extension_path.lock().unwrap().clone();
|
||||
// tauri_file_server(app_handle, request, extension_path)
|
||||
tauri_file_server(app_handle, request, ext.path.clone(), ext.dist.clone())
|
||||
tauri_file_server(
|
||||
app_handle,
|
||||
request,
|
||||
ext.info.path.clone(),
|
||||
ext.info.dist.clone(),
|
||||
)
|
||||
}
|
||||
None => tauri::http::Response::builder()
|
||||
.status(tauri::http::StatusCode::NOT_FOUND)
|
||||
@ -123,16 +171,73 @@ pub fn run() {
|
||||
.unwrap(),
|
||||
}
|
||||
})
|
||||
.setup(|app| {
|
||||
.register_uri_scheme_protocol("cbimg", |app, request| {
|
||||
// sample url: cb_img?id=123
|
||||
// parse id from url
|
||||
let path = &request.uri().path()[1..]; // skip the first /
|
||||
let path = urlencoding::decode(path).unwrap().to_string();
|
||||
let query_params: Vec<&str> = path.split('?').collect();
|
||||
let id = if query_params.len() > 1 {
|
||||
query_params[1].split('=').nth(1).unwrap_or("")
|
||||
} else {
|
||||
return tauri::http::Response::builder()
|
||||
.status(tauri::http::StatusCode::BAD_REQUEST)
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.body("Invalid Request".as_bytes().to_vec())
|
||||
.unwrap();
|
||||
};
|
||||
let app_handle = app.app_handle();
|
||||
let clipboard_history = app_handle
|
||||
.state::<tauri_plugin_jarvis::model::clipboard_history::ClipboardHistory>(
|
||||
);
|
||||
let jarvis_db = clipboard_history.jarvis_db.lock().unwrap();
|
||||
let img_data = jarvis_db.get_extension_data_by_id(id.parse::<i32>().unwrap(), None);
|
||||
let image_data = if let Ok(img_data) = img_data {
|
||||
let img_data = img_data.unwrap().data;
|
||||
match img_data {
|
||||
Some(data) => match BASE64_STANDARD.decode(data) {
|
||||
Ok(img_data) => img_data,
|
||||
Err(e) => {
|
||||
return tauri::http::Response::builder()
|
||||
.status(tauri::http::StatusCode::NOT_FOUND)
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.body("Image Not Found".as_bytes().to_vec())
|
||||
.unwrap();
|
||||
}
|
||||
},
|
||||
None => {
|
||||
return tauri::http::Response::builder()
|
||||
.status(tauri::http::StatusCode::NOT_FOUND)
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.body("Image Not Found".as_bytes().to_vec())
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return tauri::http::Response::builder()
|
||||
.status(tauri::http::StatusCode::NOT_FOUND)
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.body("Image Not Found".as_bytes().to_vec())
|
||||
.unwrap();
|
||||
};
|
||||
return tauri::http::Response::builder()
|
||||
.status(tauri::http::StatusCode::OK)
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.body(image_data)
|
||||
.unwrap();
|
||||
})
|
||||
.setup(move |app| {
|
||||
setup::window::setup_window(app.handle());
|
||||
setup::tray::create_tray(app.handle())?;
|
||||
setup::stronghold::setup_stronghold(app.handle())?;
|
||||
#[cfg(all(not(target_os = "macos"), debug_assertions))]
|
||||
{
|
||||
app.deep_link().register("kunkun")?;
|
||||
}
|
||||
// setup::deeplink::setup_deeplink(app);
|
||||
// #[cfg(all(target_os = "macos", debug_assertions))]
|
||||
// app.set_activation_policy(ActivationPolicy::Accessory);
|
||||
#[cfg(target_os = "macos")]
|
||||
app.set_activation_policy(ActivationPolicy::Accessory);
|
||||
// let mut store = StoreBuilder::new("appConfig.bin").build(app.handle().clone());
|
||||
// let store = app.handle().store_builder("appConfig.json").build()?;
|
||||
|
||||
@ -141,25 +246,29 @@ pub fn run() {
|
||||
// Err(_) => AppSettings::default(),
|
||||
// };
|
||||
// let dev_extension_path: Option<PathBuf> = app_settings.dev_extension_path.clone();
|
||||
let my_port = tauri_plugin_network::network::scan::find_available_port_from_list(
|
||||
tauri_plugin_jarvis::server::CANDIDATE_PORTS.to_vec(),
|
||||
)
|
||||
.unwrap();
|
||||
log::info!("Jarvis Server Port: {}", my_port);
|
||||
// let my_port = tauri_plugin_network::network::scan::find_available_port_from_list(
|
||||
// tauri_plugin_jarvis::server::CANDIDATE_PORTS.to_vec(),
|
||||
// )
|
||||
// .unwrap();
|
||||
// log::info!("Jarvis Server Port: {}", my_port);
|
||||
// log::info!(
|
||||
// "App Settings Dev Extension Path: {:?}",
|
||||
// app_settings.dev_extension_path.clone(),
|
||||
// );
|
||||
let my_port = 9559;
|
||||
app.manage(tauri_plugin_jarvis::server::http::Server::new(
|
||||
app.handle().clone(),
|
||||
my_port,
|
||||
Protocol::Http,
|
||||
// Protocol::Https,
|
||||
// Protocol::Http,
|
||||
Protocol::Https,
|
||||
));
|
||||
app.manage(tauri_plugin_jarvis::model::app_state::AppState {});
|
||||
tauri_plugin_jarvis::setup::server::setup_server(app.handle())?; // start the server
|
||||
|
||||
let mdns = tauri_plugin_jarvis::setup::peer_discovery::setup_mdns(my_port)?;
|
||||
let jarvis_state = app.state::<tauri_plugin_jarvis::JarvisState>();
|
||||
let mdns = tauri_plugin_jarvis::setup::peer_discovery::setup_mdns(
|
||||
my_port,
|
||||
crypto::RsaCrypto::public_key_to_string(&jarvis_state.rsa_public_key),
|
||||
)?;
|
||||
tauri_plugin_jarvis::setup::peer_discovery::handle_mdns_service_evt(
|
||||
app.handle(),
|
||||
mdns.browse()?,
|
||||
@ -167,15 +276,28 @@ pub fn run() {
|
||||
|
||||
/* ----------------------------- Database Setup ----------------------------- */
|
||||
// setup::db::setup_db(app)?;
|
||||
/* ------------------------- Clipboard History Setup ------------------------ */
|
||||
let db_key = setup::keyring::setup_keyring(app.handle())?;
|
||||
let db_path = get_kunkun_db_path(app.app_handle())?;
|
||||
let db_key: Option<String> = None;
|
||||
let jarvis_db = JarvisDB::new(db_path.clone(), db_key.clone())?;
|
||||
app.manage(tauri_plugin_jarvis::commands::db::DBState::new(
|
||||
db_path.clone(),
|
||||
db_key.clone(),
|
||||
)?);
|
||||
tauri_plugin_jarvis::setup::db::setup_db(app.app_handle())?;
|
||||
/* ------------------------- Clipboard History Setup ------------------------ */
|
||||
|
||||
// println!("DB_ENCRYPTION_KEY: {:?}", db_key);
|
||||
// let jarvis_db = JarvisDB::new(db_path.clone(), db_key.clone())?;
|
||||
// The clipboard extension should be created in setup_db, ext is guaranteed to be Some
|
||||
// let jarvis_db = app
|
||||
// .state::<tauri_plugin_jarvis::commands::db::DBState>()
|
||||
// .db
|
||||
// .lock()
|
||||
// .unwrap();
|
||||
|
||||
let jarvis_db = tauri_plugin_jarvis::utils::db::get_db(db_path, db_key)?;
|
||||
let ext = jarvis_db.get_unique_extension_by_identifier(
|
||||
tauri_plugin_jarvis::constants::KUNKUN_CLIPBOARD_EXT_IDENTIFIER,
|
||||
)?;
|
||||
|
||||
app.manage(
|
||||
tauri_plugin_jarvis::model::clipboard_history::ClipboardHistory::new(
|
||||
jarvis_db,
|
||||
@ -214,7 +336,29 @@ pub fn run() {
|
||||
app.run(|_app_handle, event| match event {
|
||||
// tauri::RunEvent::Exit => todo!(),
|
||||
// tauri::RunEvent::ExitRequested { code, api, .. } => todo!(),
|
||||
// tauri::RunEvent::WindowEvent { label, event, .. } => todo!(),
|
||||
tauri::RunEvent::WindowEvent { label, event, .. } => {
|
||||
if label == "main" {
|
||||
match event {
|
||||
// tauri::WindowEvent::Resized(physical_size) => todo!(),
|
||||
// tauri::WindowEvent::Moved(physical_position) => todo!(),
|
||||
tauri::WindowEvent::CloseRequested { api, .. } => {
|
||||
api.prevent_close();
|
||||
log::info!("main window close requested, hiding");
|
||||
let window = _app_handle.get_webview_window("main").unwrap();
|
||||
window.hide().unwrap();
|
||||
}
|
||||
// tauri::WindowEvent::Destroyed => todo!(),
|
||||
// tauri::WindowEvent::Focused(_) => todo!(),
|
||||
// tauri::WindowEvent::ScaleFactorChanged {
|
||||
// scale_factor,
|
||||
// new_inner_size,
|
||||
// } => todo!(),
|
||||
// tauri::WindowEvent::DragDrop(drag_drop_event) => todo!(),
|
||||
// tauri::WindowEvent::ThemeChanged(theme) => todo!(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
// tauri::RunEvent::WebviewEvent { label, event, .. } => todo!(),
|
||||
// tauri::RunEvent::Ready => todo!(),
|
||||
// tauri::RunEvent::Resumed => todo!(),
|
||||
|
14
apps/desktop/src-tauri/src/setup/keyring.rs
Normal file
14
apps/desktop/src-tauri/src/setup/keyring.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_keyring::KeyringExt;
|
||||
|
||||
pub fn setup_keyring(app: &AppHandle) -> anyhow::Result<Option<String>> {
|
||||
Ok(if cfg!(debug_assertions) {
|
||||
None
|
||||
} else {
|
||||
Some(app.keyring().get_or_set_password(
|
||||
"kunkun",
|
||||
"db_key",
|
||||
uuid::Uuid::new_v4().to_string().as_str(),
|
||||
)?)
|
||||
})
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
pub mod clipboard;
|
||||
pub mod deeplink;
|
||||
pub mod keyring;
|
||||
pub mod stronghold;
|
||||
pub mod tray;
|
||||
pub mod window;
|
||||
|
12
apps/desktop/src-tauri/src/setup/stronghold.rs
Normal file
12
apps/desktop/src-tauri/src/setup/stronghold.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use tauri::{AppHandle, Manager};
|
||||
|
||||
pub fn setup_stronghold(app: &AppHandle) -> tauri::Result<()> {
|
||||
let salt_path = app
|
||||
.path()
|
||||
.app_local_data_dir()
|
||||
.expect("could not resolve app local data path")
|
||||
.join("salt.txt");
|
||||
app.plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?;
|
||||
|
||||
Ok(())
|
||||
}
|
@ -1,59 +1,20 @@
|
||||
use tauri::{is_dev, App, AppHandle, LogicalSize, Manager, Runtime, Size, WebviewWindow, Window};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use cocoa::appkit::{NSWindow, NSWindowButton, NSWindowStyleMask, NSWindowTitleVisibility};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use objc::runtime::YES;
|
||||
|
||||
pub trait WindowExt {
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_transparent_titlebar(&self, title_transparent: bool, remove_toolbar: bool);
|
||||
}
|
||||
|
||||
impl<R: Runtime> WindowExt for WebviewWindow<R> {
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_transparent_titlebar(&self, title_transparent: bool, remove_tool_bar: bool) {
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
|
||||
unsafe {
|
||||
let id = self.ns_window().unwrap() as cocoa::base::id;
|
||||
NSWindow::setTitlebarAppearsTransparent_(id, cocoa::base::YES);
|
||||
let mut style_mask = id.styleMask();
|
||||
style_mask.set(
|
||||
NSWindowStyleMask::NSFullSizeContentViewWindowMask,
|
||||
title_transparent,
|
||||
);
|
||||
|
||||
id.setStyleMask_(style_mask);
|
||||
|
||||
if remove_tool_bar {
|
||||
let close_button = id.standardWindowButton_(NSWindowButton::NSWindowCloseButton);
|
||||
let _: () = msg_send![close_button, setHidden: YES];
|
||||
let min_button =
|
||||
id.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton);
|
||||
let _: () = msg_send![min_button, setHidden: YES];
|
||||
let zoom_button = id.standardWindowButton_(NSWindowButton::NSWindowZoomButton);
|
||||
let _: () = msg_send![zoom_button, setHidden: YES];
|
||||
}
|
||||
|
||||
id.setTitleVisibility_(if title_transparent {
|
||||
NSWindowTitleVisibility::NSWindowTitleHidden
|
||||
} else {
|
||||
NSWindowTitleVisibility::NSWindowTitleVisible
|
||||
});
|
||||
|
||||
id.setTitlebarAppearsTransparent_(if title_transparent {
|
||||
cocoa::base::YES
|
||||
} else {
|
||||
cocoa::base::NO
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
use tauri::{AppHandle, Manager, Runtime};
|
||||
use tauri_plugin_jarvis::setup::window::WindowExt;
|
||||
|
||||
pub fn setup_window<R: Runtime>(app: &AppHandle<R>) {
|
||||
let window = app.get_webview_window("main").unwrap();
|
||||
#[cfg(target_os = "macos")]
|
||||
window.set_transparent_titlebar(true, true);
|
||||
{
|
||||
let main_win = app.get_webview_window("main").unwrap();
|
||||
main_win.set_transparent_titlebar(true, true);
|
||||
let splashscreen_win = app.get_webview_window("splashscreen").unwrap();
|
||||
splashscreen_win.set_transparent_titlebar(true, true);
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
// on linux or windows, set decorations to false
|
||||
let main_win = app.get_webview_window("main").unwrap();
|
||||
main_win
|
||||
.set_decorations(false)
|
||||
.expect("Failed to set decorations");
|
||||
}
|
||||
}
|
||||
|
@ -5,25 +5,39 @@
|
||||
"identifier": "sh.kunkun.desktop",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"devUrl": "http://localhost:1566",
|
||||
"beforeBuildCommand": "pnpm build",
|
||||
"frontendDist": "../build"
|
||||
},
|
||||
"app": {
|
||||
"macOSPrivateApi": true,
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"hiddenTitle": true,
|
||||
"url": "/app",
|
||||
"title": "Kunkun",
|
||||
"width": 800,
|
||||
"height": 600
|
||||
"label": "main",
|
||||
"visible": false,
|
||||
"height": 600,
|
||||
"decorations": true,
|
||||
"center": true
|
||||
},
|
||||
{
|
||||
"url": "/splashscreen",
|
||||
"visible": true,
|
||||
"label": "splashscreen",
|
||||
"center": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"bundle": {
|
||||
"createUpdaterArtifacts": true,
|
||||
"macOS": {
|
||||
"minimumSystemVersion": "10.15"
|
||||
},
|
||||
"fileAssociations": [
|
||||
{
|
||||
"ext": ["kunkun"],
|
||||
@ -43,9 +57,8 @@
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"endpoints": ["https://updater.kunkun.sh"],
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDc1NENCRjZFM0JBOEQ0ODMKUldTRDFLZzdicjlNZFhHS0ZKYk13WkdZUTFUM01LNjkvVW5Bb2x1SnB1R0crbFRuMnlRSlJ0STgK"
|
||||
"fs": {
|
||||
"requireLiteralLeadingDot": false
|
||||
},
|
||||
"deep-link": {
|
||||
"desktop": {
|
||||
|
11
apps/desktop/src-tauri/tauri.conf.publish.json
Normal file
11
apps/desktop/src-tauri/tauri.conf.publish.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"bundle": {
|
||||
"createUpdaterArtifacts": true
|
||||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"endpoints": ["https://updater.kunkun.sh"],
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDc1NENCRjZFM0JBOEQ0ODMKUldTRDFLZzdicjlNZFhHS0ZKYk13WkdZUTFUM01LNjkvVW5Bb2x1SnB1R0crbFRuMnlRSlJ0STgK"
|
||||
}
|
||||
}
|
||||
}
|
@ -3,73 +3,79 @@
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 0 0% 3.9%;
|
||||
--muted: 0 0% 96.1%;
|
||||
--muted-foreground: 0 0% 45.1%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 0 0% 3.9%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 0 0% 3.9%;
|
||||
--border: 0 0% 89.8%;
|
||||
--input: 0 0% 89.8%;
|
||||
--primary: 0 0% 9%;
|
||||
--primary-foreground: 0 0% 98%;
|
||||
--secondary: 0 0% 96.1%;
|
||||
--secondary-foreground: 0 0% 9%;
|
||||
--accent: 0 0% 96.1%;
|
||||
--accent-foreground: 0 0% 9%;
|
||||
--destructive: 0 72.2% 50.6%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--ring: 0 0% 3.9%;
|
||||
--radius: 0.5rem;
|
||||
--sidebar-background: 0 0% 98%;
|
||||
--sidebar-foreground: 240 5.3% 26.1%;
|
||||
--sidebar-primary: 240 5.9% 10%;
|
||||
--sidebar-primary-foreground: 0 0% 98%;
|
||||
--sidebar-accent: 240 4.8% 95.9%;
|
||||
--sidebar-accent-foreground: 240 5.9% 10%;
|
||||
--sidebar-border: 220 13% 91%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 0 0% 3.9%;
|
||||
--muted: 0 0% 96.1%;
|
||||
--muted-foreground: 0 0% 45.1%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 0 0% 3.9%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 0 0% 3.9%;
|
||||
--border: 0 0% 89.8%;
|
||||
--input: 0 0% 89.8%;
|
||||
--primary: 0 0% 9%;
|
||||
--primary-foreground: 0 0% 98%;
|
||||
--secondary: 0 0% 96.1%;
|
||||
--secondary-foreground: 0 0% 9%;
|
||||
--accent: 0 0% 96.1%;
|
||||
--accent-foreground: 0 0% 9%;
|
||||
--destructive: 0 72.2% 50.6%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--ring: 0 0% 3.9%;
|
||||
--radius: 0.5rem;
|
||||
|
||||
.dark {
|
||||
--background: 0 0% 3.9%;
|
||||
--foreground: 0 0% 98%;
|
||||
--muted: 0 0% 14.9%;
|
||||
--muted-foreground: 0 0% 63.9%;
|
||||
--popover: 0 0% 3.9%;
|
||||
--popover-foreground: 0 0% 98%;
|
||||
--card: 0 0% 3.9%;
|
||||
--card-foreground: 0 0% 98%;
|
||||
--border: 0 0% 14.9%;
|
||||
--input: 0 0% 14.9%;
|
||||
--primary: 0 0% 98%;
|
||||
--primary-foreground: 0 0% 9%;
|
||||
--secondary: 0 0% 14.9%;
|
||||
--secondary-foreground: 0 0% 98%;
|
||||
--accent: 0 0% 14.9%;
|
||||
--accent-foreground: 0 0% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--ring: 0 0% 83.1%;
|
||||
--sidebar-background: 240 5.9% 10%;
|
||||
--sidebar-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-primary: 224.3 76.3% 48%;
|
||||
--sidebar-primary-foreground: 0 0% 100%;
|
||||
--sidebar-accent: 240 3.7% 15.9%;
|
||||
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-border: 240 3.7% 15.9%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
--sidebar-background: 0 0% 98%;
|
||||
--sidebar-foreground: 240 5.3% 26.1%;
|
||||
--sidebar-primary: 240 5.9% 10%;
|
||||
--sidebar-primary-foreground: 0 0% 98%;
|
||||
--sidebar-accent: 240 4.8% 95.9%;
|
||||
--sidebar-accent-foreground: 240 5.9% 10%;
|
||||
--sidebar-border: 220 13% 91%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 0 0% 3.9%;
|
||||
--foreground: 0 0% 98%;
|
||||
--muted: 0 0% 14.9%;
|
||||
--muted-foreground: 0 0% 63.9%;
|
||||
--popover: 0 0% 3.9%;
|
||||
--popover-foreground: 0 0% 98%;
|
||||
--card: 0 0% 3.9%;
|
||||
--card-foreground: 0 0% 98%;
|
||||
--border: 0 0% 14.9%;
|
||||
--input: 0 0% 14.9%;
|
||||
--primary: 0 0% 98%;
|
||||
--primary-foreground: 0 0% 9%;
|
||||
--secondary: 0 0% 14.9%;
|
||||
--secondary-foreground: 0 0% 98%;
|
||||
--accent: 0 0% 14.9%;
|
||||
--accent-foreground: 0 0% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--ring: 0 0% 83.1%;
|
||||
|
||||
--sidebar-background: 240 5.9% 10%;
|
||||
--sidebar-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-primary: 224.3 76.3% 48%;
|
||||
--sidebar-primary-foreground: 0 0% 100%;
|
||||
--sidebar-accent: 240 3.7% 15.9%;
|
||||
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-border: 240 3.7% 15.9%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Kunkun Desktop App</title>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
<html lang="%paraglide.lang%" dir="%paraglide.textDirection%">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Kunkun Desktop App</title>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
6
apps/desktop/src/hooks.server.ts
Normal file
6
apps/desktop/src/hooks.server.ts
Normal file
@ -0,0 +1,6 @@
|
||||
// file initialized by the Paraglide-SvelteKit CLI - Feel free to edit it
|
||||
import { sequence } from "@sveltejs/kit/hooks"
|
||||
import { i18n } from "$lib/i18n"
|
||||
|
||||
// add your own hooks as part of the sequence here
|
||||
export const handle = sequence(i18n.handle())
|
4
apps/desktop/src/hooks.ts
Normal file
4
apps/desktop/src/hooks.ts
Normal file
@ -0,0 +1,4 @@
|
||||
// file initialized by the Paraglide-SvelteKit CLI - Feel free to edit it
|
||||
import { i18n } from "$lib/i18n"
|
||||
|
||||
export const reroute = i18n.reroute()
|
@ -1,34 +1,53 @@
|
||||
import { appConfig, appState, auth } from "@/stores"
|
||||
import { i18n } from "@/i18n"
|
||||
import { appConfig, appState, auth, extensions } from "@/stores"
|
||||
import { checkUpdateAndInstall } from "@/utils/updater"
|
||||
import { setTransparentTitlebar } from "@kksh/api/commands"
|
||||
import { IconEnum } from "@kksh/api/models"
|
||||
import type { BuiltinCmd } from "@kksh/ui/types"
|
||||
import { commandScore } from "@kksh/ui/utils"
|
||||
import { getVersion } from "@tauri-apps/api/app"
|
||||
import { appDataDir } from "@tauri-apps/api/path"
|
||||
import { WebviewWindow } from "@tauri-apps/api/webviewWindow"
|
||||
import { exit } from "@tauri-apps/plugin-process"
|
||||
import { dev } from "$app/environment"
|
||||
import { goto } from "$app/navigation"
|
||||
import Fuse from "fuse.js"
|
||||
import { toast } from "svelte-sonner"
|
||||
import { derived } from "svelte/store"
|
||||
import * as clipboard from "tauri-plugin-clipboard-api"
|
||||
import { open } from "tauri-plugin-shellx-api"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
|
||||
export const builtinCmds: BuiltinCmd[] = [
|
||||
export const rawBuiltinCmds: BuiltinCmd[] = [
|
||||
{
|
||||
name: "Store",
|
||||
iconifyIcon: "streamline:store-2-solid",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "streamline:store-2-solid"
|
||||
},
|
||||
description: "Go to Extension Store",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto("/extension/store")
|
||||
goto(i18n.resolveRoute("/app/extension/store"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Sign In",
|
||||
iconifyIcon: "mdi:login-variant",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "mdi:login-variant"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
goto("/auth")
|
||||
goto(i18n.resolveRoute("/app/auth"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Sign Out",
|
||||
iconifyIcon: "mdi:logout-variant",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "mdi:logout-variant"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
auth
|
||||
@ -39,7 +58,10 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
},
|
||||
{
|
||||
name: "Show Draggable Area",
|
||||
iconifyIcon: "mingcute:move-fill",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "mingcute:move-fill"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
// select all html elements with attribute data-tauri-drag-region
|
||||
@ -54,18 +76,54 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
}, 2_000)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Splashscreen (Dev)",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:skeleton"
|
||||
},
|
||||
description: "",
|
||||
flags: {
|
||||
dev: true
|
||||
},
|
||||
function: async () => {
|
||||
new WebviewWindow(`splashscreen`, {
|
||||
url: "/splashscreen"
|
||||
})
|
||||
appState.clearSearchTerm()
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "File Transfer",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "clarity:file-share-solid"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
goto(i18n.resolveRoute("/app/extension/file-transfer"))
|
||||
appState.clearSearchTerm()
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Add Dev Extension",
|
||||
iconifyIcon: "lineicons:dev",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "lineicons:dev",
|
||||
hexColor: "#0f0"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto("/settings/add-dev-extension")
|
||||
goto(i18n.resolveRoute("/app/settings/add-dev-extension"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Kunkun Version",
|
||||
iconifyIcon: "stash:version-solid",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "stash:version-solid"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
toast.success(`Kunkun Version: ${await getVersion()}`)
|
||||
@ -73,81 +131,187 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
},
|
||||
{
|
||||
name: "Set Dev Extension Path",
|
||||
iconifyIcon: "lineicons:dev",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "lineicons:dev",
|
||||
hexColor: "#0f0"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
// const appStateStore = useAppStateStore()
|
||||
appState.clearSearchTerm()
|
||||
goto("/settings/set-dev-ext-path")
|
||||
goto(i18n.resolveRoute("/app/settings/set-dev-ext-path"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Extension Window Troubleshooter",
|
||||
iconifyIcon: "material-symbols:window-outline",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:window-outline"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
// goto("/window-troubleshooter")
|
||||
const winLabel = `main:extension-window-troubleshooter-${uuidv4()}`
|
||||
console.log(winLabel)
|
||||
new WebviewWindow(winLabel, {
|
||||
url: "/troubleshooters/extension-window",
|
||||
url: "/app/troubleshooters/extension-window",
|
||||
title: "Extension Window Troubleshooter"
|
||||
})
|
||||
},
|
||||
keywords: ["extension", "window", "troubleshooter"]
|
||||
},
|
||||
{
|
||||
name: "Help (Install Deno)",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "simple-icons:deno"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto(i18n.resolveRoute("/app/help/deno-install"))
|
||||
},
|
||||
keywords: ["help", "deno", "install"]
|
||||
},
|
||||
{
|
||||
name: "Help (Install ffmpeg)",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "logos:ffmpeg-icon"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto(i18n.resolveRoute("/app/help/ffmpeg-install"))
|
||||
},
|
||||
keywords: ["help", "ffmpeg", "install"]
|
||||
},
|
||||
{
|
||||
name: "Help (Install homebrew)",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "devicon:homebrew"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto(i18n.resolveRoute("/app/help/brew-install"))
|
||||
},
|
||||
keywords: ["help", "brew", "install", "homebrew"]
|
||||
},
|
||||
{
|
||||
name: "On Boarding (Dev Only)",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "fluent-mdl2:onboarding"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto(i18n.resolveRoute("/app/help/onboarding"))
|
||||
},
|
||||
flags: {
|
||||
dev: true,
|
||||
developer: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Extension Permission Inspector",
|
||||
iconifyIcon: "hugeicons:inspect-code",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "hugeicons:inspect-code"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto("/extension/permission-inspector")
|
||||
}
|
||||
goto(i18n.resolveRoute("/app/extension/permission-inspector"))
|
||||
},
|
||||
keywords: ["extension"]
|
||||
},
|
||||
{
|
||||
name: "Extension Loading Troubleshooter",
|
||||
iconifyIcon: "material-symbols:troubleshoot",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:troubleshoot"
|
||||
},
|
||||
description: "",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto("/troubleshooters/extension-loading")
|
||||
}
|
||||
goto(i18n.resolveRoute("/app/troubleshooters/extension-loading"))
|
||||
},
|
||||
keywords: ["extension", "troubleshooter"]
|
||||
},
|
||||
{
|
||||
name: "ORM Troubleshooter",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:database"
|
||||
},
|
||||
description: "",
|
||||
flags: {
|
||||
developer: true,
|
||||
dev: true
|
||||
},
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto(i18n.resolveRoute("/app/troubleshooters/orm"))
|
||||
},
|
||||
keywords: ["extension", "troubleshooter", "database", "orm"]
|
||||
},
|
||||
{
|
||||
name: "Create Quicklink",
|
||||
iconifyIcon: "material-symbols:link",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:link"
|
||||
},
|
||||
description: "Create a Quicklink",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto("/extension/create-quick-link")
|
||||
goto(i18n.resolveRoute("/app/extension/create-quick-link"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Key Displayer",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:keyboard"
|
||||
},
|
||||
description: "Display the current key",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
const label = `main:extension:key-displayer-${uuidv4()}`
|
||||
new WebviewWindow(label, {
|
||||
url: "/app/extension/key-displayer",
|
||||
title: "Key Displayer",
|
||||
decorations: false,
|
||||
hiddenTitle: true,
|
||||
visible: false,
|
||||
alwaysOnTop: true,
|
||||
width: 200,
|
||||
height: 140
|
||||
})
|
||||
// setTransparentTitlebar(label)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Settings",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "solar:settings-linear"
|
||||
},
|
||||
description: "Open Settings",
|
||||
function: async () => {
|
||||
goto(i18n.resolveRoute("/app/settings"))
|
||||
appState.clearSearchTerm()
|
||||
}
|
||||
},
|
||||
// {
|
||||
// name: "Settings",
|
||||
// iconifyIcon: "solar:settings-linear",
|
||||
// description: "Open Settings",
|
||||
// function: async () => {
|
||||
// const windows = await getAllWebviewWindows()
|
||||
// const found = windows.find((w) => w.label === SettingsWindowLabel)
|
||||
// if (found) {
|
||||
// ElNotification.error("Settings Page is already open")
|
||||
// } else {
|
||||
// const win = await newSettingsPage()
|
||||
// setTimeout(() => {
|
||||
// // this is a backup, if window is not properly loaded,
|
||||
// // the show() will not be called within setting page, we call it here with a larger delay,
|
||||
// // at least the window will be shown
|
||||
// win.show()
|
||||
// }, 800)
|
||||
// }
|
||||
// const appStateStore = useAppStateStore()
|
||||
// appStateStore.setSearchTermSync("")
|
||||
// }
|
||||
// },
|
||||
{
|
||||
name: "Check Update",
|
||||
iconifyIcon: "material-symbols:update",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:update"
|
||||
},
|
||||
description: "Check for updates",
|
||||
function: async () => {
|
||||
checkUpdateAndInstall()
|
||||
@ -156,7 +320,10 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
},
|
||||
{
|
||||
name: "Check Beta Update",
|
||||
iconifyIcon: "material-symbols:update",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:update"
|
||||
},
|
||||
description: "Check for Beta updates",
|
||||
function: async () => {
|
||||
checkUpdateAndInstall({ beta: true })
|
||||
@ -165,23 +332,45 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
},
|
||||
{
|
||||
name: "Reload",
|
||||
iconifyIcon: "tabler:reload",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "tabler:reload"
|
||||
},
|
||||
description: "Reload this page",
|
||||
function: async () => {
|
||||
location.reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Reload Extensions",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "tabler:reload"
|
||||
},
|
||||
description: "Reload Extensions",
|
||||
function: async () => {
|
||||
extensions.init().then(() => {
|
||||
appState.clearSearchTerm()
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Dance",
|
||||
iconifyIcon: "mdi:dance-pole",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "mdi:dance-pole"
|
||||
},
|
||||
description: "Dance",
|
||||
function: async () => {
|
||||
goto("/dance")
|
||||
goto(i18n.resolveRoute("/app/dance"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Quit Kunkun",
|
||||
iconifyIcon: "emojione:cross-mark-button",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "emojione:cross-mark-button"
|
||||
},
|
||||
description: "Quit Kunkun",
|
||||
function: async () => {
|
||||
exit(0)
|
||||
@ -189,7 +378,10 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
},
|
||||
{
|
||||
name: "Toggle Dev Extension HMR",
|
||||
iconifyIcon: "ri:toggle-line",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "ri:toggle-line"
|
||||
},
|
||||
description: "Load dev extensions from their dev server URLs",
|
||||
function: async () => {
|
||||
appConfig.update((config) => {
|
||||
@ -202,9 +394,65 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
appState.clearSearchTerm()
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Clipboard History",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "mdi:clipboard-outline"
|
||||
},
|
||||
description: "Clipboard History",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
goto(i18n.resolveRoute("/app/extension/clipboard"))
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Pin Current Screenshot",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:screenshot-monitor-outline"
|
||||
},
|
||||
description: "Pin the current screenshot",
|
||||
function: async () => {
|
||||
appState.clearSearchTerm()
|
||||
if (!(await clipboard.hasImage())) {
|
||||
toast.error("No screenshot in clipboard")
|
||||
return
|
||||
}
|
||||
const window = new WebviewWindow(`main:pinned-screenshot-${uuidv4()}`, {
|
||||
url: "/app/extension/pin-screenshot",
|
||||
title: "Pinned Screenshot",
|
||||
hiddenTitle: true,
|
||||
titleBarStyle: "transparent",
|
||||
decorations: false,
|
||||
visible: false
|
||||
})
|
||||
setTimeout(() => {
|
||||
window.show().then(() => window.setFocus())
|
||||
}, 2_000)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "MDNS Debugger",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "material-symbols:wifi-find"
|
||||
},
|
||||
description: "MDNS Debugger",
|
||||
function: async () => {
|
||||
goto(i18n.resolveRoute("/app/troubleshooters/mdns-debugger"))
|
||||
},
|
||||
flags: {
|
||||
developer: true
|
||||
},
|
||||
keywords: ["mdns", "debugger", "troubleshooter"]
|
||||
},
|
||||
{
|
||||
name: "Toggle Hide On Blur",
|
||||
iconifyIcon: "ri:toggle-line",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "ri:toggle-line"
|
||||
},
|
||||
description: "Toggle Hide On Blur",
|
||||
function: async () => {
|
||||
appConfig.update((config) => {
|
||||
@ -216,5 +464,48 @@ export const builtinCmds: BuiltinCmd[] = [
|
||||
})
|
||||
appState.clearSearchTerm()
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Toggle Developer Mode",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "hugeicons:developer"
|
||||
},
|
||||
description: "Toggle Developer Mode",
|
||||
function: async () => {
|
||||
appConfig.update((config) => {
|
||||
toast.success(`Developer Mode toggled to: ${!config.developerMode}`)
|
||||
return { ...config, developerMode: !config.developerMode }
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Open App Data Dir",
|
||||
icon: {
|
||||
type: IconEnum.Iconify,
|
||||
value: "mdi:folder-open"
|
||||
},
|
||||
description: "Open App Data Dir",
|
||||
function: async () => {
|
||||
console.log(await appDataDir())
|
||||
open(await appDataDir())
|
||||
}
|
||||
}
|
||||
]
|
||||
].map((cmd) => ({ ...cmd, id: uuidv4() }))
|
||||
|
||||
export const fuse = new Fuse<BuiltinCmd>(rawBuiltinCmds, {
|
||||
includeScore: true,
|
||||
threshold: 0.2,
|
||||
keys: ["name"]
|
||||
})
|
||||
|
||||
export const builtinCmds = derived([appConfig, appState], ([$appConfig, $appState]) => {
|
||||
return $appState.searchTerm
|
||||
? fuse
|
||||
.search($appState.searchTerm)
|
||||
.map((result) => result.item)
|
||||
.filter(
|
||||
(cmd) => (!cmd.flags?.developer || $appConfig.developerMode) && (!cmd.flags?.dev || dev)
|
||||
)
|
||||
: rawBuiltinCmds
|
||||
})
|
||||
|
@ -1,12 +1,41 @@
|
||||
import { i18n } from "@/i18n"
|
||||
import { appState } from "@/stores"
|
||||
import { winExtMap } from "@/stores/winExtMap"
|
||||
import { helperAPI } from "@/utils/helper"
|
||||
import { paste } from "@/utils/hotkey"
|
||||
import { decideKkrpcSerialization } from "@/utils/kkrpc"
|
||||
import { sleep } from "@/utils/time"
|
||||
import { trimSlash } from "@/utils/url"
|
||||
import { constructExtensionSupportDir } from "@kksh/api"
|
||||
import { CustomUiCmd, ExtPackageJsonExtra, TemplateUiCmd } from "@kksh/api/models"
|
||||
import { launchNewExtWindow } from "@kksh/extension"
|
||||
import { spawnExtensionFileServer } from "@kksh/api/commands"
|
||||
import type { HeadlessCommand } from "@kksh/api/headless"
|
||||
import { CustomUiCmd, ExtPackageJsonExtra, HeadlessCmd, TemplateUiCmd } from "@kksh/api/models"
|
||||
import { constructJarvisServerAPIWithPermissions, type IApp } from "@kksh/api/ui"
|
||||
import { db } from "@kksh/drizzle"
|
||||
import { launchNewExtWindow, loadExtensionManifestFromDisk } from "@kksh/extension"
|
||||
import type { IKunkunFullServerAPI } from "@kunkunapi/src/api/server"
|
||||
import { convertFileSrc } from "@tauri-apps/api/core"
|
||||
import * as path from "@tauri-apps/api/path"
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window"
|
||||
import * as fs from "@tauri-apps/plugin-fs"
|
||||
import { info } from "@tauri-apps/plugin-log"
|
||||
import { platform } from "@tauri-apps/plugin-os"
|
||||
import { goto } from "$app/navigation"
|
||||
import { RPCChannel, WorkerParentIO } from "kkrpc/browser"
|
||||
import * as v from "valibot"
|
||||
|
||||
export const KunkunIframeExtParams = v.object({
|
||||
url: v.string(),
|
||||
cmdName: v.optional(v.string()),
|
||||
extPath: v.string()
|
||||
})
|
||||
export type KunkunIframeExtParams = v.InferOutput<typeof KunkunIframeExtParams>
|
||||
export const KunkunTemplateExtParams = v.object({
|
||||
url: v.optional(v.string()),
|
||||
extPath: v.string(),
|
||||
cmdName: v.string()
|
||||
})
|
||||
export type KunkunTemplateExtParams = v.InferOutput<typeof KunkunTemplateExtParams>
|
||||
|
||||
export async function createExtSupportDir(extPath: string) {
|
||||
const extSupportDir = await constructExtensionSupportDir(extPath)
|
||||
@ -15,16 +44,29 @@ export async function createExtSupportDir(extPath: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function setTemplateExtParams(extPath: string, cmdName: string, url?: string) {
|
||||
localStorage.setItem(
|
||||
"kunkun-template-ext-params",
|
||||
JSON.stringify({ extPath, cmdName, url } satisfies KunkunTemplateExtParams)
|
||||
)
|
||||
}
|
||||
|
||||
export async function onTemplateUiCmdSelect(
|
||||
ext: ExtPackageJsonExtra,
|
||||
cmd: TemplateUiCmd,
|
||||
{ isDev, hmr }: { isDev: boolean; hmr: boolean }
|
||||
) {
|
||||
await createExtSupportDir(ext.extPath)
|
||||
// console.log("onTemplateUiCmdSelect", ext, cmd, isDev, hmr)
|
||||
const url = `/extension/ui-worker?extPath=${encodeURIComponent(ext.extPath)}&cmdName=${encodeURIComponent(cmd.name)}`
|
||||
const url = `/app/extension/ui-worker?extPath=${encodeURIComponent(ext.extPath)}&cmdName=${encodeURIComponent(cmd.name)}`
|
||||
setTemplateExtParams(ext.extPath, cmd.name, url)
|
||||
if (cmd.window) {
|
||||
const winLabel = await winExtMap.registerExtensionWithWindow({ extPath: ext.extPath })
|
||||
const paramsStr = JSON.stringify({
|
||||
url,
|
||||
extPath: ext.extPath,
|
||||
cmdName: cmd.name
|
||||
} satisfies KunkunIframeExtParams)
|
||||
localStorage.setItem("kunkun-template-ext-params", paramsStr)
|
||||
const window = launchNewExtWindow(winLabel, url, cmd.window)
|
||||
window.onCloseRequested(async (event) => {
|
||||
await winExtMap.unregisterExtensionFromWindow(winLabel)
|
||||
@ -32,10 +74,81 @@ export async function onTemplateUiCmdSelect(
|
||||
} else {
|
||||
return winExtMap
|
||||
.registerExtensionWithWindow({ windowLabel: "main", extPath: ext.extPath })
|
||||
.then(() => goto(url))
|
||||
.then(() => goto(i18n.resolveRoute(url)))
|
||||
}
|
||||
}
|
||||
|
||||
export async function onHeadlessCmdSelect(
|
||||
ext: ExtPackageJsonExtra,
|
||||
cmd: HeadlessCmd,
|
||||
{ isDev, hmr }: { isDev: boolean; hmr: boolean }
|
||||
) {
|
||||
await createExtSupportDir(ext.extPath)
|
||||
// load the script in Web Worker
|
||||
const loadedExt = await loadExtensionManifestFromDisk(
|
||||
await path.join(ext.extPath, "package.json")
|
||||
)
|
||||
|
||||
const scriptPath = await path.join(loadedExt.extPath, cmd.main)
|
||||
const workerScript = await fs.readTextFile(scriptPath)
|
||||
const blob = new Blob([workerScript], { type: "application/javascript" })
|
||||
const blobURL = URL.createObjectURL(blob)
|
||||
const worker = new Worker(blobURL)
|
||||
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
|
||||
if (!extInfoInDB) {
|
||||
return
|
||||
}
|
||||
const serverAPI: IKunkunFullServerAPI = constructJarvisServerAPIWithPermissions(
|
||||
loadedExt.kunkun.permissions,
|
||||
loadedExt.extPath,
|
||||
{
|
||||
recordSpawnedProcess: async (pid: number) => {
|
||||
console.log("recordSpawnedProcess pid", pid)
|
||||
},
|
||||
getSpawnedProcesses: async () => {
|
||||
console.log("getSpawnedProcesses")
|
||||
return []
|
||||
},
|
||||
paste: async () => {
|
||||
await getCurrentWindow().hide()
|
||||
await sleep(200)
|
||||
return paste()
|
||||
}
|
||||
}
|
||||
)
|
||||
const serverAPI2 = {
|
||||
...serverAPI,
|
||||
iframeUi: undefined,
|
||||
helper: helperAPI,
|
||||
workerUi: undefined,
|
||||
db: new db.JarvisExtDB(extInfoInDB.extId),
|
||||
kv: new db.KV(extInfoInDB.extId),
|
||||
app: {
|
||||
language: () => Promise.resolve("en")
|
||||
} satisfies IApp
|
||||
}
|
||||
const io = new WorkerParentIO(worker)
|
||||
const kkrpcSerialization = decideKkrpcSerialization(loadedExt)
|
||||
info(
|
||||
`Establishing kkrpc connection for ${loadedExt.kunkun.identifier} with serialization: ${kkrpcSerialization}`
|
||||
)
|
||||
const rpc = new RPCChannel<typeof serverAPI2, HeadlessCommand>(io, {
|
||||
expose: serverAPI2,
|
||||
serialization: {
|
||||
version: kkrpcSerialization
|
||||
}
|
||||
})
|
||||
const workerAPI = rpc.getAPI()
|
||||
await workerAPI.load()
|
||||
}
|
||||
|
||||
function setIframeExtParams(extPath: string, url: string) {
|
||||
localStorage.setItem(
|
||||
"kunkun-iframe-ext-params",
|
||||
JSON.stringify({ url, extPath } satisfies KunkunIframeExtParams)
|
||||
)
|
||||
}
|
||||
|
||||
export async function onCustomUiCmdSelect(
|
||||
ext: ExtPackageJsonExtra,
|
||||
cmd: CustomUiCmd,
|
||||
@ -44,28 +157,53 @@ export async function onCustomUiCmdSelect(
|
||||
// console.log("onCustomUiCmdSelect", ext, cmd, isDev, hmr)
|
||||
await createExtSupportDir(ext.extPath)
|
||||
let url = cmd.main
|
||||
|
||||
if (hmr && isDev && cmd.devMain) {
|
||||
const useDevMain = hmr && isDev && cmd.devMain
|
||||
if (useDevMain) {
|
||||
url = cmd.devMain
|
||||
} else {
|
||||
url = decodeURIComponent(convertFileSrc(`${trimSlash(cmd.main)}`, "ext"))
|
||||
url = cmd.main.startsWith("http")
|
||||
? cmd.main
|
||||
: decodeURIComponent(convertFileSrc(`${trimSlash(cmd.main)}`, "ext"))
|
||||
}
|
||||
const url2 = `/extension/ui-iframe?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}`
|
||||
let url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}`
|
||||
// url2 = `/dev?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}`
|
||||
|
||||
setIframeExtParams(ext.extPath, url)
|
||||
if (cmd.window) {
|
||||
const winLabel = await winExtMap.registerExtensionWithWindow({
|
||||
extPath: ext.extPath,
|
||||
dist: cmd.dist
|
||||
})
|
||||
console.log("Launch new window, ", winLabel)
|
||||
if (platform() === "windows" && !useDevMain) {
|
||||
const addr = await spawnExtensionFileServer(winLabel)
|
||||
const newUrl = `http://${addr}`
|
||||
url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
|
||||
setIframeExtParams(ext.extPath, newUrl)
|
||||
}
|
||||
localStorage.setItem(
|
||||
"kunkun-iframe-ext-params",
|
||||
JSON.stringify({ url, extPath: ext.extPath } satisfies KunkunIframeExtParams)
|
||||
)
|
||||
const window = launchNewExtWindow(winLabel, url2, cmd.window)
|
||||
window.onCloseRequested(async (event) => {
|
||||
await winExtMap.unregisterExtensionFromWindow(winLabel)
|
||||
})
|
||||
} else {
|
||||
console.log("Launch main window")
|
||||
return winExtMap
|
||||
.registerExtensionWithWindow({ windowLabel: "main", extPath: ext.extPath, dist: cmd.dist })
|
||||
.then(() => goto(url2))
|
||||
const winLabel = await winExtMap.registerExtensionWithWindow({
|
||||
windowLabel: "main",
|
||||
extPath: ext.extPath,
|
||||
dist: cmd.dist
|
||||
})
|
||||
const _platform = platform()
|
||||
if ((_platform === "windows" || _platform === "linux") && !useDevMain) {
|
||||
const addr = await spawnExtensionFileServer(winLabel) // addr has format "127.0.0.1:<port>"
|
||||
console.log("Extension file server address: ", addr)
|
||||
const newUrl = `http://${addr}`
|
||||
url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
|
||||
setIframeExtParams(ext.extPath, newUrl)
|
||||
}
|
||||
goto(i18n.resolveRoute(url2))
|
||||
}
|
||||
appState.clearSearchTerm()
|
||||
}
|
||||
|
@ -1,12 +1,18 @@
|
||||
import { CmdTypeEnum, CustomUiCmd, ExtPackageJsonExtra, TemplateUiCmd } from "@kksh/api/models"
|
||||
import {
|
||||
CmdTypeEnum,
|
||||
CustomUiCmd,
|
||||
ExtPackageJsonExtra,
|
||||
HeadlessCmd,
|
||||
TemplateUiCmd
|
||||
} from "@kksh/api/models"
|
||||
import type { CommandLaunchers, OnExtCmdSelect } from "@kksh/ui/types"
|
||||
import * as v from "valibot"
|
||||
import { onCustomUiCmdSelect, onTemplateUiCmdSelect } from "./ext"
|
||||
import { onCustomUiCmdSelect, onHeadlessCmdSelect, onTemplateUiCmdSelect } from "./ext"
|
||||
import { onQuickLinkSelect } from "./quick-links"
|
||||
|
||||
const onExtCmdSelect: OnExtCmdSelect = (
|
||||
ext: ExtPackageJsonExtra,
|
||||
cmd: CustomUiCmd | TemplateUiCmd,
|
||||
cmd: CustomUiCmd | TemplateUiCmd | HeadlessCmd,
|
||||
{ isDev, hmr }: { isDev: boolean; hmr: boolean }
|
||||
) => {
|
||||
switch (cmd.type) {
|
||||
@ -16,6 +22,9 @@ const onExtCmdSelect: OnExtCmdSelect = (
|
||||
case CmdTypeEnum.UiWorker:
|
||||
onTemplateUiCmdSelect(ext, v.parse(TemplateUiCmd, cmd), { isDev, hmr })
|
||||
break
|
||||
case CmdTypeEnum.HeadlessWorker:
|
||||
onHeadlessCmdSelect(ext, v.parse(HeadlessCmd, cmd), { isDev, hmr })
|
||||
break
|
||||
default:
|
||||
console.error("Unknown command type", cmd.type)
|
||||
}
|
||||
|
@ -1,4 +1,27 @@
|
||||
import { getSystemCommands } from "@kksh/api/commands"
|
||||
import type { SysCommand } from "@kksh/api/models"
|
||||
import { commandScore } from "@kksh/ui/utils"
|
||||
import Fuse from "fuse.js"
|
||||
import { derived, readable } from "svelte/store"
|
||||
import { appState } from "../stores/appState"
|
||||
|
||||
export const systemCommands: SysCommand[] = getSystemCommands()
|
||||
export const systemCommands = getSystemCommands()
|
||||
|
||||
export const fuse = new Fuse<SysCommand>(systemCommands, {
|
||||
includeScore: true,
|
||||
threshold: 0.2,
|
||||
keys: ["name"]
|
||||
})
|
||||
|
||||
export const systemCommandsFiltered = derived(appState, ($appState) => {
|
||||
return $appState.searchTerm
|
||||
? fuse.search($appState.searchTerm).map((result) => result.item)
|
||||
: systemCommands
|
||||
})
|
||||
|
||||
// export const systemCommandsFiltered = derived(
|
||||
// [systemCommands, appState],
|
||||
// ([$systemCommands, $appState]) => {
|
||||
// return $systemCommands.filter((cmd) => commandScore(cmd.name, $appState.searchTerm) > 0.5)
|
||||
// }
|
||||
// )
|
||||
|
@ -1,9 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { listen, TauriEvent, type UnlistenFn } from "@tauri-apps/api/event"
|
||||
import { listen, TauriEvent, type EventCallback, type UnlistenFn } from "@tauri-apps/api/event"
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
|
||||
import { onDestroy, onMount, type Snippet } from "svelte"
|
||||
|
||||
let unlisteners: UnlistenFn[] = []
|
||||
type Payload = { paths: string[]; position: { x: number; y: number } }
|
||||
const {
|
||||
children,
|
||||
onEnter,
|
||||
@ -12,18 +13,19 @@
|
||||
onOver
|
||||
}: {
|
||||
children: Snippet
|
||||
onEnter?: (event: any) => void
|
||||
onDrop?: (event: any) => void
|
||||
onCancelled?: (event: any) => void
|
||||
onOver?: (event: any) => void
|
||||
onEnter?: EventCallback<Payload>
|
||||
onDrop?: EventCallback<{ paths: string[] }>
|
||||
onCancelled?: EventCallback<Payload>
|
||||
onOver?: EventCallback<void>
|
||||
} = $props()
|
||||
const appWin = getCurrentWebviewWindow()
|
||||
|
||||
onMount(async () => {
|
||||
if (onEnter) await appWin.listen(TauriEvent.DRAG_ENTER, onEnter)
|
||||
if (onDrop) await appWin.listen(TauriEvent.DRAG_DROP, onDrop)
|
||||
if (onCancelled) await appWin.listen(TauriEvent.DRAG_LEAVE, onCancelled)
|
||||
if (onOver) await appWin.listen(TauriEvent.DRAG_OVER, onOver)
|
||||
if (onEnter) unlisteners.push(await appWin.listen(TauriEvent.DRAG_ENTER, onEnter))
|
||||
if (onDrop)
|
||||
unlisteners.push(await appWin.listen<{ paths: string[] }>(TauriEvent.DRAG_DROP, onDrop))
|
||||
if (onCancelled) unlisteners.push(await appWin.listen(TauriEvent.DRAG_LEAVE, onCancelled))
|
||||
if (onOver) unlisteners.push(await appWin.listen(TauriEvent.DRAG_OVER, onOver))
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
|
@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import { appConfig, appState } from "@/stores"
|
||||
import { cn } from "@/utils"
|
||||
import { Button } from "@kksh/svelte5"
|
||||
import { BorderBeam, Constants, Layouts, TauriLink } from "@kksh/ui"
|
||||
import { goto } from "$app/navigation"
|
||||
import { ArrowLeftIcon, LoaderCircleIcon } from "lucide-svelte"
|
||||
import Dance from "../dance/dance.svelte"
|
||||
|
||||
let { class: className }: { class?: string } = $props()
|
||||
|
||||
function goHome() {
|
||||
appState.setFullScreenLoading(false)
|
||||
goto("/app")
|
||||
}
|
||||
</script>
|
||||
|
||||
<Layouts.Center class={cn("flex h-screen flex-col items-center justify-center", className)}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onclick={goHome}
|
||||
class={cn(Constants.CLASSNAMES.BACK_BUTTON, "absolute left-4 top-4")}
|
||||
data-flip-id={Constants.CLASSNAMES.BACK_BUTTON}
|
||||
>
|
||||
<ArrowLeftIcon class="size-4" />
|
||||
</Button>
|
||||
{#if $appConfig.loadingAnimation === "kunkun-dancing"}
|
||||
<!-- <DanceTransition delay={300} autoHide={false} show={!uiControl.iframeLoaded} /> -->
|
||||
<Dance class="absolute z-50 h-screen opacity-20" />
|
||||
{:else}
|
||||
<!-- <LoadingAnimation delay={300} autoHide={false} show={!uiControl.iframeLoaded} /> -->
|
||||
<LoaderCircleIcon class="h-24 w-24 animate-spin" />
|
||||
<span class="font-mono">Loading</span>
|
||||
{/if}
|
||||
<BorderBeam size={150} duration={12} />
|
||||
</Layouts.Center>
|
81
apps/desktop/src/lib/components/common/HotkeyInput.svelte
Normal file
81
apps/desktop/src/lib/components/common/HotkeyInput.svelte
Normal file
@ -0,0 +1,81 @@
|
||||
<script lang="ts">
|
||||
import { keyCodeToKey, keyCombToDisplay } from "@/utils/js"
|
||||
import { isShortcut } from "@/utils/key"
|
||||
import { Button, Input } from "@kksh/svelte5"
|
||||
import { cn } from "@kksh/svelte5/utils"
|
||||
import { onMount } from "svelte"
|
||||
|
||||
let {
|
||||
// keys = $bindable([]),
|
||||
class: className,
|
||||
// ref = $bindable(null),
|
||||
// recording = $bindable(false),
|
||||
onSubmit
|
||||
}: {
|
||||
// keys?: string[] | null
|
||||
class?: string
|
||||
// recording?: boolean
|
||||
// ref?: HTMLInputElement | null
|
||||
onSubmit?: (keys: string[]) => void
|
||||
} = $props()
|
||||
let keys = $state<string[]>([])
|
||||
let recording = $state(false)
|
||||
let savedShortcut = $state<Set<string> | null>(null)
|
||||
let keyCombination = $derived(
|
||||
savedShortcut !== null
|
||||
? keyCombToDisplay(Array.from(savedShortcut))
|
||||
: keyCombToDisplay(keys ?? [])
|
||||
)
|
||||
let inputRef = $state<HTMLInputElement | null>(null)
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
if (recording) {
|
||||
e.preventDefault()
|
||||
const newKeys = [...keys, keyCodeToKey(e.code)]
|
||||
keys = newKeys
|
||||
if (isShortcut(newKeys)) {
|
||||
// console.log("shortcut detected", newKeys)
|
||||
savedShortcut = new Set(newKeys)
|
||||
recording = false // stop recording
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onKeyUp(e: KeyboardEvent) {
|
||||
e.preventDefault()
|
||||
if (recording) {
|
||||
keys = keys.filter((k) => k !== keyCodeToKey(e.code))
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log(inputRef)
|
||||
inputRef?.focus()
|
||||
setTimeout(() => {
|
||||
inputRef?.focus()
|
||||
}, 100)
|
||||
})
|
||||
</script>
|
||||
|
||||
<form
|
||||
class="flex flex-col gap-1"
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault()
|
||||
onSubmit?.(Array.from(keys))
|
||||
}}
|
||||
>
|
||||
<!-- <pre>recording: {recording}</pre> -->
|
||||
<Input
|
||||
value={keyCombination}
|
||||
class={cn("w-full text-center", className)}
|
||||
onkeydown={onKeyDown}
|
||||
autofocus
|
||||
bind:ref={inputRef}
|
||||
onkeyup={onKeyUp}
|
||||
onfocus={() => {
|
||||
recording = true
|
||||
keys = []
|
||||
}}
|
||||
onblur={() => (recording = false)}
|
||||
/>
|
||||
<Button size="sm" type="submit" variant="outline">Submit</Button>
|
||||
</form>
|
@ -0,0 +1,49 @@
|
||||
<script lang="ts">
|
||||
import { cn } from "@/utils"
|
||||
import { keyCombToDisplay } from "@/utils/js"
|
||||
import { ButtonModule, Input, Label, Popover } from "@kksh/svelte5"
|
||||
import HotkeyInput from "./HotkeyInput.svelte"
|
||||
|
||||
let {
|
||||
class: className,
|
||||
savedHotkey,
|
||||
onSubmit
|
||||
}: { class?: string; savedHotkey: string[]; onSubmit: (keys: string[]) => void } = $props()
|
||||
let recording = $state(false)
|
||||
let keys = $state<string[]>([])
|
||||
function onRecordClicked() {
|
||||
keys = []
|
||||
recording = true
|
||||
}
|
||||
let open = $state(false)
|
||||
let inputRef = $state<HTMLInputElement | null>(null)
|
||||
</script>
|
||||
|
||||
<Popover.Root bind:open>
|
||||
<Popover.Trigger
|
||||
onclick={onRecordClicked}
|
||||
class={cn(ButtonModule.buttonVariants({ variant: "outline", size: "sm" }), className)}
|
||||
>
|
||||
<!-- <button>recording: {recording}</button> -->
|
||||
{#if savedHotkey.length === 0}
|
||||
<span>Record Hotkey</span>
|
||||
{:else}
|
||||
<span>{keyCombToDisplay(savedHotkey)}</span>
|
||||
{/if}
|
||||
</Popover.Trigger>
|
||||
<Popover.Content
|
||||
class="w-60"
|
||||
onOpenAutoFocus={(e: FocusEvent) => {
|
||||
e.preventDefault()
|
||||
console.log("inputRef", inputRef)
|
||||
// inputRef?.focus()
|
||||
}}
|
||||
>
|
||||
<HotkeyInput
|
||||
onSubmit={(keys) => {
|
||||
open = false
|
||||
onSubmit(keys)
|
||||
}}
|
||||
/>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
@ -0,0 +1,81 @@
|
||||
<script lang="ts">
|
||||
import { cn } from "@/utils"
|
||||
import { Button } from "@kksh/svelte5"
|
||||
import { Shiki } from "@kksh/ui"
|
||||
import { confirm } from "@tauri-apps/plugin-dialog"
|
||||
import { platform } from "@tauri-apps/plugin-os"
|
||||
import { toast } from "svelte-sonner"
|
||||
import { writeText } from "tauri-plugin-clipboard-api"
|
||||
import {
|
||||
executeBashScript,
|
||||
executePowershellScript,
|
||||
fixPathEnv,
|
||||
type ChildProcess
|
||||
} from "tauri-plugin-shellx-api"
|
||||
|
||||
let {
|
||||
code,
|
||||
autoInstallable,
|
||||
alreadyInstalled,
|
||||
lang,
|
||||
class: className,
|
||||
onSuccess
|
||||
}: {
|
||||
code: string
|
||||
autoInstallable?: boolean
|
||||
alreadyInstalled?: boolean
|
||||
lang: "bash" | "powershell"
|
||||
class?: string
|
||||
onSuccess?: () => void
|
||||
} = $props()
|
||||
|
||||
function copy() {
|
||||
return writeText(code).then(() => toast.info("Copied to clipboard", { description: code }))
|
||||
}
|
||||
|
||||
async function autoInstall() {
|
||||
let cmd: ChildProcess<string> | undefined
|
||||
if (alreadyInstalled) {
|
||||
const ans = await confirm("Already installed, do you really want to run this command?")
|
||||
if (!ans) return
|
||||
}
|
||||
try {
|
||||
toast.info("Installing...")
|
||||
if (platform() === "macos") {
|
||||
cmd = await executeBashScript(code)
|
||||
} else if (platform() === "windows") {
|
||||
cmd = await executePowershellScript(code)
|
||||
} else if (platform() === "linux") {
|
||||
cmd = await executeBashScript(code)
|
||||
} else {
|
||||
return toast.error("Unsupported platform")
|
||||
}
|
||||
if (cmd) {
|
||||
if (cmd.code === 0) {
|
||||
console.log(cmd.stdout)
|
||||
toast.success("Installed successfully", { description: `Status Code: ${cmd.code}` })
|
||||
onSuccess?.()
|
||||
} else {
|
||||
console.log(cmd.stdout)
|
||||
console.log(cmd.stderr)
|
||||
toast.error("Failed to install", { description: cmd.stderr })
|
||||
}
|
||||
} else {
|
||||
toast.error("Failed to install, Unknown Error")
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error("Failed to install", {
|
||||
description: error instanceof Error ? error.message : "Unknown Error"
|
||||
})
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class={cn("flex items-center gap-2", className)}>
|
||||
<Shiki class={cn("w-full overflow-x-scroll rounded-md p-1 px-2")} {code} {lang} />
|
||||
<Button class="" size="sm" variant="secondary" onclick={copy}>Copy</Button>
|
||||
<!-- <Button class="" size="sm" variant="secondary" onclick={autoInstall} disabled={!autoInstallable}>
|
||||
Auto Install
|
||||
</Button> -->
|
||||
</div>
|
@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import { goHome } from "@/utils/route"
|
||||
import { Button, Sidebar } from "@kksh/svelte5"
|
||||
import { Constants } from "@kksh/ui"
|
||||
import { ArrowLeftIcon } from "lucide-svelte"
|
||||
|
||||
const { useSidebar } = Sidebar
|
||||
const sidebar = useSidebar()
|
||||
</script>
|
||||
|
||||
<div class="fixed flex h-10 w-full items-center gap-2 pl-1 pt-1" data-tauri-drag-region>
|
||||
<Sidebar.Trigger class="z-50" />
|
||||
{#if sidebar.state === "collapsed"}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
class="z-50 {Constants.CLASSNAMES.BACK_BUTTON}"
|
||||
onclick={goHome}
|
||||
>
|
||||
<ArrowLeftIcon class="h-4 w-4" />
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="h-10"></div>
|
@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { setAppConfigContext } from "@/context"
|
||||
import { setAppStateContext } from "@/context/appState"
|
||||
import type { AppConfig, AppState } from "@kksh/types"
|
||||
import type { Snippet } from "svelte"
|
||||
import type { AppConfigState, AppState } from "@kksh/types"
|
||||
import { type Snippet } from "svelte"
|
||||
import type { Writable } from "svelte/store"
|
||||
|
||||
const {
|
||||
@ -10,7 +10,7 @@
|
||||
appState,
|
||||
children
|
||||
}: {
|
||||
appConfig: Writable<AppConfig>
|
||||
appConfig: Writable<AppConfigState>
|
||||
appState: Writable<AppState>
|
||||
children: Snippet<[]>
|
||||
} = $props()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user