@kitr/kit-mobile 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Platon Podkopov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # @kitr/kit-mobile
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Mobile kit.** Start the app kit as an installable PWA and a Capacitor shell with native lifecycle hooks.
4
+
5
+ ```sh
6
+ pnpm dlx kitr new my-app --kit mobile
7
+ ```
8
+
9
+ Read the guide at https://kitr.dev/docs/cli.
10
+
11
+ Part of [kitr](https://kitr.dev), the TypeScript framework where everything is an add-on. MIT licensed.
package/dist/kitr.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { AddContext } from "@kitr/core/package";
2
+ /**
3
+ * `kitr new --kit mobile`: The app kit as an installable PWA and a Capacitor shell: online state, install prompt, native lifecycle hooks.
4
+ */
5
+ declare const _default: {
6
+ readonly name: "mobile";
7
+ readonly kind: "kit";
8
+ readonly kit: {
9
+ readonly description: "The app kit as an installable PWA and a Capacitor shell: online state, install prompt, native lifecycle hooks.";
10
+ readonly platforms: {
11
+ readonly site: {
12
+ readonly type: "web";
13
+ readonly options: {
14
+ readonly mode: "spa";
15
+ readonly pwa: true;
16
+ };
17
+ };
18
+ readonly phone: {
19
+ readonly type: "mobile";
20
+ };
21
+ };
22
+ readonly packages: ["http", "forms", "table", "state", "tailwind", "theme", "toast", "auth", "storage", "mocks", "testing", "devtools", "platform"];
23
+ readonly components: ["icon", "button", "input", "label", "card", "form", "data-table", "page-header", "empty-state", "theme-toggle", "app-shell", "badge"];
24
+ readonly files: (ctx: AddContext, name: string) => void;
25
+ };
26
+ };
27
+ export { _default as default };
package/dist/kitr.js ADDED
@@ -0,0 +1,194 @@
1
+ import { definePackage, displayName, writeTemplate } from "@kitr/core/package";
2
+ // src/kitr.ts
3
+ /** The Capacitor plugins the device packages (`native`, `notifications`, `files`, `secure-storage`, `updater`) drive on a phone. */
4
+ const devicePlugins = [
5
+ "@capacitor/clipboard",
6
+ "@capacitor/share",
7
+ "@capacitor/haptics",
8
+ "@capacitor/geolocation",
9
+ "@capacitor/local-notifications",
10
+ "@capacitor/push-notifications",
11
+ "@capacitor/filesystem",
12
+ "@capawesome/capacitor-file-picker",
13
+ "@aparajita/capacitor-secure-storage",
14
+ "@capawesome/capacitor-app-update"
15
+ ];
16
+ const files = (ctx, name) => {
17
+ const brand = displayName(name);
18
+ ctx.deps.add(...devicePlugins);
19
+ writeTemplate(ctx, "app/document.tsx", `import { HeadContent, Outlet, Scripts } from '@kitr/router'
20
+ import { ThemeScript } from '@kitr/theme'
21
+ import css from '#app/styles/app.css?url'
22
+ import { PwaUpdate } from '#app/components/pwa-update'
23
+
24
+ /** Head tags for every page: viewport for notched screens, the web app manifest. */
25
+ export function head() {
26
+ return {
27
+ meta: [
28
+ { charSet: 'utf-8' },
29
+ { name: 'viewport', content: 'width=device-width, initial-scale=1, viewport-fit=cover' },
30
+ { name: 'apple-mobile-web-app-capable', content: 'yes' },
31
+ ],
32
+ links: [{ rel: 'stylesheet', href: css }, { rel: 'manifest', href: '/manifest.webmanifest' }],
33
+ }
34
+ }
35
+
36
+ /** The HTML shell: one page for the browser, the installed PWA and the Capacitor WebView. */
37
+ export function RootDocument() {
38
+ return (
39
+ <html lang="en" suppressHydrationWarning>
40
+ <head>
41
+ <ThemeScript />
42
+ <HeadContent />
43
+ </head>
44
+ <body className="min-h-screen bg-background text-foreground antialiased">
45
+ <Outlet />
46
+ <PwaUpdate />
47
+ <Scripts />
48
+ </body>
49
+ </html>
50
+ )
51
+ }
52
+ `);
53
+ writeTemplate(ctx, "app/components/pwa-update.tsx", `import { useServiceWorker } from '@kitr/web/client'
54
+
55
+ /** Registers the service worker and shows a one-line banner when a new version is waiting. */
56
+ export function PwaUpdate() {
57
+ const sw = useServiceWorker()
58
+ if (!sw.needRefresh) return null
59
+ return (
60
+ <div role="status" className="fixed bottom-4 right-4 rounded-md bg-foreground px-3 py-2 text-sm text-background shadow">
61
+ A new version is available.{' '}
62
+ <button type="button" className="underline" onClick={() => sw.update()}>
63
+ Reload
64
+ </button>
65
+ </div>
66
+ )
67
+ }
68
+ `);
69
+ writeTemplate(ctx, "app/pages/home.tsx", `import { useAppState, useBackButton, useOnline, usePlatform } from '@kitr/platform/react'
70
+ import { useInstallPrompt } from '@kitr/web/client'
71
+ import { useCallback, useState } from 'react'
72
+ import { Badge } from '#components/ui/badge'
73
+ import { Button } from '#components/ui/button'
74
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '#components/ui/card'
75
+ import { PageHeader } from '#components/ui/page-header'
76
+
77
+ /**
78
+ * One page, three homes: the browser, the installed PWA, and the Capacitor shell on iOS/Android.
79
+ * Everything below works in all three; \`@kitr/platform\` answers the same way everywhere.
80
+ */
81
+ export default function HomePage() {
82
+ const platform = usePlatform()
83
+ const online = useOnline()
84
+ const install = useInstallPrompt()
85
+ const active = useAppState()
86
+ const [backPresses, setBackPresses] = useState(0)
87
+ useBackButton(useCallback(() => setBackPresses((n) => n + 1), []))
88
+
89
+ return (
90
+ <main className="mx-auto max-w-lg p-4 pb-[env(safe-area-inset-bottom)]">
91
+ <PageHeader
92
+ title="${brand}"
93
+ description="Platform-aware without user-agent sniffing."
94
+ actions={<Badge variant="secondary">{platform.type} · {platform.os}</Badge>}
95
+ />
96
+ <div className="grid gap-4">
97
+ <Card>
98
+ <CardHeader>
99
+ <CardTitle>Connectivity</CardTitle>
100
+ <CardDescription>\`useOnline()\` tracks the online and offline events.</CardDescription>
101
+ </CardHeader>
102
+ <CardContent>
103
+ <Badge variant={online ? 'default' : 'destructive'}>{online ? 'Online' : 'Offline'}</Badge>
104
+ </CardContent>
105
+ </Card>
106
+ <Card>
107
+ <CardHeader>
108
+ <CardTitle>Install</CardTitle>
109
+ <CardDescription>
110
+ The manifest and service worker come from the web platform's pwa option in kitrrc.ts; \`useInstallPrompt()\` wraps the browser prompt.
111
+ </CardDescription>
112
+ </CardHeader>
113
+ <CardContent className="flex items-center gap-3">
114
+ <Button disabled={!install.canInstall} onClick={() => install.install()}>
115
+ Add to home screen
116
+ </Button>
117
+ <span className="text-sm text-muted-foreground">
118
+ {install.installed
119
+ ? 'Installed.'
120
+ : install.canInstall
121
+ ? 'Ready to install.'
122
+ : platform.native
123
+ ? 'Running inside the native shell.'
124
+ : 'Open in a browser that supports installation.'}
125
+ </span>
126
+ </CardContent>
127
+ </Card>
128
+ <Card>
129
+ <CardHeader>
130
+ <CardTitle>Native lifecycle</CardTitle>
131
+ <CardDescription>Only wired up inside Capacitor; harmless on the web.</CardDescription>
132
+ </CardHeader>
133
+ <CardContent className="grid gap-1 text-sm text-muted-foreground">
134
+ <p>App state: {active ? 'active' : 'background'}</p>
135
+ <p>Hardware back button presses: {backPresses}</p>
136
+ </CardContent>
137
+ </Card>
138
+ </div>
139
+ </main>
140
+ )
141
+ }
142
+ `);
143
+ };
144
+ /**
145
+ * `kitr new --kit mobile`: The app kit as an installable PWA and a Capacitor shell: online state, install prompt, native lifecycle hooks.
146
+ */
147
+ var kitr_default = definePackage({
148
+ name: "mobile",
149
+ kind: "kit",
150
+ kit: {
151
+ description: "The app kit as an installable PWA and a Capacitor shell: online state, install prompt, native lifecycle hooks.",
152
+ platforms: {
153
+ site: {
154
+ type: "web",
155
+ options: {
156
+ mode: "spa",
157
+ pwa: true
158
+ }
159
+ },
160
+ phone: { type: "mobile" }
161
+ },
162
+ packages: [
163
+ "http",
164
+ "forms",
165
+ "table",
166
+ "state",
167
+ "tailwind",
168
+ "theme",
169
+ "toast",
170
+ "auth",
171
+ "storage",
172
+ "mocks",
173
+ "testing",
174
+ "devtools",
175
+ "platform"
176
+ ],
177
+ components: [
178
+ "icon",
179
+ "button",
180
+ "input",
181
+ "label",
182
+ "card",
183
+ "form",
184
+ "data-table",
185
+ "page-header",
186
+ "empty-state",
187
+ "theme-toggle",
188
+ "app-shell",
189
+ "badge"
190
+ ],
191
+ files
192
+ }
193
+ });
194
+ export { kitr_default as default };
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@kitr/kit-mobile",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.1",
4
+ "description": "kitr new --kit mobile: The app kit as an installable PWA and a Capacitor shell: online state, install prompt, native lifecycle hooks.",
5
+ "kitr": {
6
+ "name": "mobile",
7
+ "title": "Mobile kit",
8
+ "summary": "Start the app kit as an installable PWA and a Capacitor shell with native lifecycle hooks.",
9
+ "category": "kits",
10
+ "runsOn": "both",
11
+ "kind": "kit",
12
+ "setup": "./kitr"
13
+ },
14
+ "type": "module",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/kitrjs/kitr.git",
19
+ "directory": "packages/kit-mobile"
20
+ },
21
+ "homepage": "https://kitr.dev/docs/cli",
22
+ "bugs": "https://github.com/kitrjs/kitr/issues",
23
+ "sideEffects": false,
24
+ "exports": {
25
+ "./kitr": {
26
+ "types": "./dist/kitr.d.ts",
27
+ "default": "./dist/kitr.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "keywords": [
35
+ "kitr",
36
+ "kitr-package",
37
+ "kitr-kit"
38
+ ],
39
+ "dependencies": {
40
+ "@kitr/core": "0.2.1"
41
+ },
42
+ "devDependencies": {
43
+ "tsdown": "^0.23.7",
44
+ "typescript": "^5.9.3",
45
+ "@types/node": "^22.19.0"
46
+ },
47
+ "scripts": {
48
+ "build": "tsdown",
49
+ "typecheck": "tsc -p tsconfig.json"
50
+ }
6
51
  }