Feature: Headless Command (#44)
Some checks are pending
CI / build-test (macos-14) (push) Waiting to run
CI / build-test (ubuntu-24.04) (push) Waiting to run
CI / build-test (windows-latest) (push) Waiting to run

* chore: add check-types

* refactor: api package file structure update

* feat: add headless worker extension API

* feat: add HeadlessCmd to manifest schema

* feat: make each type of cmds optional in manifest

There may be more types of cmds in the future, this makes backward compatibility easier.

* feat: implement headless extension command in app

A demo cmd implemented as well.

* refactor: move api package's API server files

* refactor: reformat all
This commit is contained in:
Huakun Shen 2025-01-05 21:12:56 -05:00 committed by GitHub
parent d3f18e6618
commit f89cf8fe6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 698 additions and 604 deletions

View file

@ -7,7 +7,7 @@ async function build() {
try {
// await $`bun build --minify --target=browser --outdir=./dist ./src/index.ts`
const output = await Bun.build({
entrypoints: ["./src/index.ts"],
entrypoints: ["./src/index.ts", "./src/headless.ts"],
outdir: "./dist",
minify: true,
target: "browser"

View file

@ -80,6 +80,17 @@
"main": "dist/index.js",
"cmds": []
}
],
"headlessCmds": [
{
"name": "Demo Headless Command",
"main": "dist/headless.js",
"cmds": [],
"icon": {
"type": "iconify",
"value": "mdi:head-remove-outline"
}
}
]
},
"scripts": {

View file

@ -0,0 +1,10 @@
import { expose, HeadlessWorkerExtension, toast } from "@kksh/api/headless"
class DemoHeadlessExt extends HeadlessWorkerExtension {
load(): Promise<void> {
console.log("Demo Headless Extension Loaded")
toast.info("Demo Headless Extension Loaded")
return Promise.resolve()
}
}
expose(new DemoHeadlessExt())