Skip to content

Commit 522737f

Browse files
committed
Add library build and GitHub install support
- Rename package to @sourecode/virtual-keyboard, add exports/files/repo metadata - Add vite.lib.config.ts + tsconfig.lib.json for library build with rolled-up .d.ts - Add src/keyboard/index.ts barrel re-exporting VirtualKeyboard and adapters - Add CI workflow (build + smoke test) and release workflow (publish prebuilt dist to release branch on tag) - Document github-install flow in README
1 parent ccc4e48 commit 522737f

10 files changed

Lines changed: 1234 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build-lib:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- uses: actions/setup-node@v6
20+
with:
21+
node-version-file: .nvmrc
22+
cache: npm
23+
24+
- run: npm ci --ignore-scripts
25+
26+
- run: npm run typecheck
27+
28+
- run: npm run build:lib
29+
30+
- name: Verify dist artifacts
31+
run: |
32+
test -f dist/virtual-keyboard.js
33+
test -f dist/virtual-keyboard.d.ts
34+
35+
- name: Smoke test ESM entry
36+
run: |
37+
node -e '
38+
globalThis.HTMLElement = class {};
39+
globalThis.customElements = { define() {} };
40+
import("./dist/virtual-keyboard.js").then(m => {
41+
const keys = Object.keys(m);
42+
console.log("exports:", keys);
43+
const missing = ["VirtualKeyboard","terminalAdapter","nativeAdapter"].filter(k => !keys.includes(k));
44+
if (missing.length) { console.error("missing:", missing); process.exit(1); }
45+
})'
46+
47+
- name: Smoke test npm pack
48+
run: npm pack --dry-run
49+
50+
- uses: actions/upload-artifact@v7
51+
with:
52+
name: dist
53+
path: dist
54+
retention-days: 7

.github/workflows/deploy.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ jobs:
1818
build:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v6
2222

23-
- uses: actions/setup-node@v5
23+
- uses: actions/setup-node@v6
2424
with:
2525
node-version-file: .nvmrc
2626
cache: npm
2727

2828
- id: pages
29-
uses: actions/configure-pages@v5
29+
uses: actions/configure-pages@v6
3030

3131
- run: npm ci
3232

33-
- uses: actions/cache@v4
33+
- uses: actions/cache@v5
3434
with:
3535
path: public/v86
3636
key: v86-assets-${{ hashFiles('scripts/fetch-v86-assets.mjs') }}
@@ -39,7 +39,7 @@ jobs:
3939
env:
4040
BASE_PATH: ${{ steps.pages.outputs.base_path }}
4141

42-
- uses: actions/upload-pages-artifact@v4
42+
- uses: actions/upload-pages-artifact@v5
4343
with:
4444
path: dist
4545

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: "Git ref (tag or commit SHA) to build from"
11+
required: true
12+
default: "master"
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v6
22+
with:
23+
ref: ${{ github.event.inputs.ref || github.ref }}
24+
25+
- uses: actions/setup-node@v6
26+
with:
27+
node-version-file: .nvmrc
28+
cache: npm
29+
30+
- run: npm ci --ignore-scripts
31+
32+
- run: npm run build:lib
33+
34+
- name: Pack npm tarball
35+
id: pack
36+
run: |
37+
file=$(npm pack --silent)
38+
echo "file=$file" >> "$GITHUB_OUTPUT"
39+
40+
- name: Create GitHub Release with tarball
41+
if: startsWith(github.ref, 'refs/tags/')
42+
env:
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: gh release create "$GITHUB_REF_NAME" "${{ steps.pack.outputs.file }}" --notes ""

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ A framework-agnostic on-screen keyboard as a web component. Drops into any page
44

55
**Live demo**: https://sourecode.github.io/virtual-keyboard/
66

7+
## Install (without npmjs)
8+
9+
This package is not published to the npm registry. Each tagged release publishes an `npm pack` tarball as a GitHub Release asset. Install it directly:
10+
11+
```sh
12+
npm install https://github.com/SoureCode/virtual-keyboard/releases/download/v0.1.0/sourecode-virtual-keyboard-0.1.0.tgz
13+
```
14+
15+
Or install from the git tag — the `prepare` script will build on install:
16+
17+
```sh
18+
npm install github:SoureCode/virtual-keyboard#v0.1.0
19+
```
20+
21+
Consumers of the git-install path need `git` plus either public-repo access or a PAT/SSH key with read access to the repo.
22+
23+
Then:
24+
25+
```ts
26+
import { VirtualKeyboard, terminalAdapter, nativeAdapter } from "@sourecode/virtual-keyboard";
27+
import "@sourecode/virtual-keyboard/style.css";
28+
```
29+
730
## Features
831

932
- Custom element `<virtual-keyboard>`, all styles scoped in Shadow DOM — zero global footprint
@@ -33,7 +56,7 @@ A framework-agnostic on-screen keyboard as a web component. Drops into any page
3356
### Switching the output target
3457

3558
```ts
36-
import { VirtualKeyboard, terminalAdapter } from "virtual-keyboard";
59+
import { VirtualKeyboard, terminalAdapter } from "@sourecode/virtual-keyboard";
3760

3861
const kb = document.querySelector("virtual-keyboard")!;
3962
kb.setAdapter(terminalAdapter((data) => term.paste(data)));

0 commit comments

Comments
 (0)