mirror of
https://github.com/PR0M3TH3AN/bitlogin.git
synced 2026-11-07 05:51:25 +00:00
widget: ship generated type declarations + typed element/events
Integrators had to read the demo to learn the API: the package built via vite with no .d.ts and no types field, so @bitlogin/widget and @bitlogin/widget/session resolved to `any`. Emit declarations from source (tsconfig.types.json -> dist-types, build:types wired into build) and point the package types/exports conditions at them, for both the root and the /session entry. Generated, so they can't drift from the implementation. Add the type surface integrators actually want: - HTMLElementTagNameMap["bitlogin-auth"], so querySelector/createElement return the typed element. - Typed addEventListener/removeEventListener overloads (declaration-merged interface) for the bitlogin-* events. - Exported event-detail types and BitLoginEventMap (src/events.ts), matching element.ts's dispatchEvent shapes. Verified with a consumer conformance typecheck (typed detail with no cast, typed element methods, readCachedSession return type). README gains a "TypeScript" section. Addresses the ".d.ts / documented API surface" item of the Tessera integration feedback (docs/TODO.md). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01BXQCvJPA6sVSQ5j8uBd9bB
This commit is contained in:
1 parent
1b39e0f60c
commit
5ae41ed9db
7 files changed
+154
-6
No files matched your search
@@ -6,12 +6,20 @@
|
||||
"type": "module",
|
||||
"description": "BitLogin embeddable login widget: a <bitlogin-auth> custom element plus a window.nostr NIP-07-compatible provider, backed by a dedicated crypto Web Worker.",
|
||||
"main": "./dist/bitlogin.js",
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/bitlogin.js",
|
||||
"./session": "./dist/bitlogin-session.js"
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"default": "./dist/bitlogin.js"
|
||||
},
|
||||
"./session": {
|
||||
"types": "./dist-types/session.d.ts",
|
||||
"default": "./dist/bitlogin-session.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"build": "vite build && npm run build:types",
|
||||
"build:types": "tsc -p tsconfig.types.json",
|
||||
"dev": "vite build --watch",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user