Skip to content

Commit 033fd21

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 033fd21

9 files changed

Lines changed: 1257 additions & 10 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@v5
18+
19+
- uses: actions/setup-node@v5
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@v4
51+
with:
52+
name: dist
53+
path: dist
54+
retention-days: 7

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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-release-branch:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
ref: ${{ github.event.inputs.ref || github.ref }}
24+
fetch-depth: 0
25+
26+
- uses: actions/setup-node@v5
27+
with:
28+
node-version-file: .nvmrc
29+
cache: npm
30+
31+
- run: npm ci --ignore-scripts
32+
33+
- run: npm run build:lib
34+
35+
- name: Verify dist artifacts
36+
run: |
37+
test -f dist/virtual-keyboard.js
38+
test -f dist/virtual-keyboard.d.ts
39+
40+
- name: Publish prebuilt dist to release branch
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
set -eu
45+
SRC_SHA="$(git rev-parse HEAD)"
46+
TAG_NAME=""
47+
if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
48+
TAG_NAME="${GITHUB_REF#refs/tags/}"
49+
fi
50+
51+
git config user.name "github-actions[bot]"
52+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53+
54+
WORK="$(mktemp -d)"
55+
cp -r dist "$WORK/dist"
56+
cp package.json README.md "$WORK/" 2>/dev/null || true
57+
[ -f LICENSE ] && cp LICENSE "$WORK/"
58+
59+
cd "$WORK"
60+
git init -q -b release
61+
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
62+
git add -A
63+
git commit -q -m "release: prebuilt dist from ${SRC_SHA}${TAG_NAME:+ (${TAG_NAME})}"
64+
git push -f origin release
65+
66+
if [ -n "$TAG_NAME" ]; then
67+
git tag -f "${TAG_NAME}-release"
68+
git push -f origin "${TAG_NAME}-release"
69+
fi
70+
71+
- uses: actions/upload-artifact@v4
72+
with:
73+
name: dist-${{ github.ref_name }}
74+
path: dist

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ 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. Install it straight from GitHub:
10+
11+
```sh
12+
# prebuilt dist from the release branch (no build toolchain needed)
13+
npm install github:SoureCode/virtual-keyboard#release
14+
15+
# or pin to a tag — runs the `prepare` script to build on install
16+
npm install github:SoureCode/virtual-keyboard#v0.1.0
17+
```
18+
19+
Consumers need `git` plus either public-repo access or a PAT/SSH key with read access to the repo.
20+
21+
Then:
22+
23+
```ts
24+
import { VirtualKeyboard, terminalAdapter, nativeAdapter } from "@sourecode/virtual-keyboard";
25+
import "@sourecode/virtual-keyboard/style.css";
26+
```
27+
728
## Features
829

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

3556
```ts
36-
import { VirtualKeyboard, terminalAdapter } from "virtual-keyboard";
57+
import { VirtualKeyboard, terminalAdapter } from "@sourecode/virtual-keyboard";
3758

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

0 commit comments

Comments
 (0)