@rightkit/onboarding 0.0.0-stage → 0.2.0

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-APACHE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adrian D'souza
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,42 @@
1
- # Temporary Holding Version
1
+ # @rightkit/onboarding
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
+ First-run onboarding framework for Right Suite apps: a legal agreement gate first, then ordered steps (permissions, model download, licence/trial, plus app-defined steps) with progress, skip and resume.
4
+
5
+ ```tsx
6
+ import { Onboarding } from "@rightkit/onboarding";
7
+ import "@rightkit/onboarding/onboarding.css";
8
+
9
+ <Onboarding settings={settings} legal={legal} permissions={permissions} models={models} license={license}
10
+ onComplete={finish} onSkip={later} />
11
+ ```
12
+
13
+ - `settings` is a `SettingsBackend`; progress is stored under the `onboarding.state` key.
14
+ - The agreement is enforced until accepted, regardless of the saved step index. Acceptance is stored as `legalAcceptance: { version, documentsHash, acceptedAt (UTC ISO), eligibilityBasis }`; legacy `legalAccepted: true` is still read.
15
+ - `onComplete` and `onSkip` run only after the state was saved. A rejected save is shown in an alert and neither callback runs.
16
+
17
+ ## Props
18
+
19
+ | Prop | Purpose |
20
+ | --- | --- |
21
+ | `requiredVersion` | Version the user must have accepted. A different or missing stored version re-prompts with the legal gate's `re-acceptance` variant. Legacy boolean acceptance is only re-prompted when this is set. |
22
+ | `isAccepted(state)` | Custom acceptance check; overrides `requiredVersion`. |
23
+ | `documentsHash` | Hash recorded with the acceptance (default: SHA-256 of document titles and URLs). |
24
+ | `beforeLegalGate()` | Awaited before the gate shows (e.g. size or reveal the window). The package does no window sizing itself. |
25
+ | `requireModel` | Continue/Finish on the models step wait for an installed model. |
26
+ | `autoStartDownload` | Start the first missing model download when the models step opens. |
27
+ | `modelsIntro` | App copy shown at the top of the models step. |
28
+ | `allowSkip` | Show "Set up later" (default `true`). |
29
+ | `titlebar` | Node rendered in a strip along the top. |
30
+ | `dragRegion` | Add `data-tauri-drag-region` to that strip (default `false`; height `--rk-onboarding-titlebar-h`, default 32px). |
31
+
32
+ ## Custom steps and readiness
33
+
34
+ A step may set `canContinue(context)`; Continue/Finish stay disabled while it returns `false` (optional `blockedHint` is shown). Steps with async readiness call `context.setReady(boolean)` from `render` and read `context.ready[stepId]`. Back is disabled on the first step after the agreement.
35
+
36
+ ## Models backend
37
+
38
+ `ModelsBackend.cancel` is optional; the Pause control appears only when it is supplied.
39
+
40
+ ## Tests
41
+
42
+ `pnpm exec vitest run` runs the jsdom unit tests (`src/*.test.tsx`) and the headless-Chrome e2e.
@@ -0,0 +1,5 @@
1
+ import type { OnboardingProps, PersistedOnboardingState } from "./types.js";
2
+ /** True when the stored acceptance satisfies the host's requirement. */
3
+ export declare function isLegalAccepted(state: PersistedOnboardingState, requiredVersion?: string, custom?: (state: PersistedOnboardingState) => boolean): boolean;
4
+ export declare function onboardingStateKey(): string;
5
+ export declare function Onboarding({ settings, legal, steps, permissions, models, license, onComplete, onSkip, className, requiredVersion, isAccepted, documentsHash, beforeLegalGate, requireModel, autoStartDownload, modelsIntro, allowSkip, titlebar, dragRegion }: OnboardingProps): import("react").JSX.Element;
@@ -0,0 +1,178 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { LegalGate } from "@rightkit/legal-ui";
4
+ import { Button } from "@rightkit/app-shell/react";
5
+ import { cx } from "./ui.js";
6
+ import { licenseStep, modelsStep, permissionsStep } from "./steps.js";
7
+ const KEY = "onboarding.state";
8
+ const INITIAL = { version: 1, currentStep: 0, completed: [], skipped: false, legalAccepted: false };
9
+ function readAcceptance(value) {
10
+ if (!value || typeof value !== "object")
11
+ return undefined;
12
+ const r = value;
13
+ if (typeof r.version !== "string" || typeof r.documentsHash !== "string" || typeof r.acceptedAt !== "string")
14
+ return undefined;
15
+ if (r.eligibilityBasis !== "individual" && r.eligibilityBasis !== "enterprise")
16
+ return undefined;
17
+ return { version: r.version, documentsHash: r.documentsHash, acceptedAt: r.acceptedAt, eligibilityBasis: r.eligibilityBasis };
18
+ }
19
+ function readState(value) {
20
+ if (!value || typeof value !== "object")
21
+ return INITIAL;
22
+ const candidate = value;
23
+ const legalAcceptance = readAcceptance(candidate.legalAcceptance);
24
+ return {
25
+ version: 1,
26
+ currentStep: typeof candidate.currentStep === "number" && candidate.currentStep >= 0 ? Math.floor(candidate.currentStep) : 0,
27
+ completed: Array.isArray(candidate.completed) ? candidate.completed.filter((x) => typeof x === "string") : [],
28
+ skipped: candidate.skipped === true,
29
+ legalAccepted: candidate.legalAccepted === true || legalAcceptance !== undefined,
30
+ eligibilityBasis: legalAcceptance?.eligibilityBasis ?? (candidate.eligibilityBasis === "individual" || candidate.eligibilityBasis === "enterprise" ? candidate.eligibilityBasis : undefined),
31
+ ...(legalAcceptance ? { legalAcceptance } : {}),
32
+ };
33
+ }
34
+ /** True when the stored acceptance satisfies the host's requirement. */
35
+ export function isLegalAccepted(state, requiredVersion, custom) {
36
+ if (custom)
37
+ return custom(state);
38
+ if (requiredVersion !== undefined)
39
+ return state.legalAcceptance?.version === requiredVersion;
40
+ return state.legalAccepted;
41
+ }
42
+ /** FNV-1a fallback when SubtleCrypto is unavailable. */
43
+ function fnv(text) {
44
+ let h = 0x811c9dc5;
45
+ for (let i = 0; i < text.length; i += 1) {
46
+ h ^= text.charCodeAt(i);
47
+ h = Math.imul(h, 0x01000193) >>> 0;
48
+ }
49
+ return `fnv1a:${h.toString(16).padStart(8, "0")}`;
50
+ }
51
+ async function hashDocuments(documents) {
52
+ const text = JSON.stringify(documents.map((d) => [d.title, d.url ?? ""]));
53
+ try {
54
+ const subtle = globalThis.crypto?.subtle;
55
+ if (subtle) {
56
+ const digest = await subtle.digest("SHA-256", new TextEncoder().encode(text));
57
+ return `sha256:${[...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
58
+ }
59
+ }
60
+ catch { /* fall through */ }
61
+ return fnv(text);
62
+ }
63
+ export function onboardingStateKey() { return KEY; }
64
+ function TitleStrip({ titlebar, dragRegion }) {
65
+ if (!titlebar && !dragRegion)
66
+ return null;
67
+ return _jsx("div", { className: "rk-onboarding__titlebar", "data-testid": "onboarding-titlebar", ...(dragRegion ? { "data-tauri-drag-region": "" } : {}), children: titlebar });
68
+ }
69
+ export function Onboarding({ settings, legal, steps = [], permissions, models, license, onComplete, onSkip, className, requiredVersion, isAccepted, documentsHash, beforeLegalGate, requireModel, autoStartDownload, modelsIntro, allowSkip = true, titlebar, dragRegion }) {
70
+ const [state, setState] = useState(null);
71
+ const [saving, setSaving] = useState(false);
72
+ const [error, setError] = useState(null);
73
+ const [readyMap, setReadyMap] = useState({});
74
+ const [gateCleared, setGateCleared] = useState(false);
75
+ /** Persists a patch; throws when the settings backend rejects it. */
76
+ const persist = useCallback(async (patch) => {
77
+ setSaving(true);
78
+ setError(null);
79
+ const next = { ...(state ?? INITIAL), ...patch };
80
+ try {
81
+ const snap = await settings.patch({ [KEY]: next });
82
+ setState(readState(snap.values[KEY]));
83
+ }
84
+ catch (e) {
85
+ setError(e instanceof Error ? e.message : String(e));
86
+ throw e;
87
+ }
88
+ finally {
89
+ setSaving(false);
90
+ }
91
+ }, [settings, state]);
92
+ /** Like `persist` but reports success as a boolean; the failure is already visible via `error`. */
93
+ const save = useCallback(async (patch) => {
94
+ try {
95
+ await persist(patch);
96
+ return true;
97
+ }
98
+ catch {
99
+ return false;
100
+ }
101
+ }, [persist]);
102
+ const saveStep = useCallback(async (patch) => { await save(patch); }, [save]);
103
+ useEffect(() => { let live = true; void settings.load().then((snapshot) => { if (live)
104
+ setState(readState(snapshot.values[KEY])); }, (e) => { if (live)
105
+ setError(e instanceof Error ? e.message : String(e)); }); return () => { live = false; }; }, [settings]);
106
+ const builtins = useMemo(() => [
107
+ { id: "legal", label: "Agreement", title: "Review agreement", skippable: false, render: () => _jsx("p", { className: "rk-onboarding__muted", children: "Agreement accepted." }) },
108
+ ...(permissions ? [permissionsStep(permissions)] : []),
109
+ ...(models ? [modelsStep(models, { required: requireModel, autoStartDownload, intro: modelsIntro })] : []),
110
+ ...(license ? [licenseStep(license)] : []),
111
+ ...steps,
112
+ ], [license, models, permissions, steps, requireModel, autoStartDownload, modelsIntro]);
113
+ const activeState = state ?? INITIAL;
114
+ const accepted = isLegalAccepted(activeState, requiredVersion, isAccepted);
115
+ const needsGate = state !== null && !accepted;
116
+ // The agreement gate does not depend on the saved step: until it is accepted, the active step is the first.
117
+ // Once accepted, the Agreement step (index 0) is never shown again when other steps exist.
118
+ const index = !accepted ? 0 : builtins.length > 1 ? Math.max(1, Math.min(activeState.currentStep, builtins.length - 1)) : 0;
119
+ const active = builtins[index];
120
+ const activeId = active?.id ?? "";
121
+ const setReady = useCallback((ready) => setReadyMap((m) => m[activeId] === ready ? m : { ...m, [activeId]: ready }), [activeId]);
122
+ useEffect(() => {
123
+ if (!needsGate) {
124
+ setGateCleared(false);
125
+ return;
126
+ }
127
+ if (gateCleared)
128
+ return;
129
+ let live = true;
130
+ void (async () => { try {
131
+ await beforeLegalGate?.();
132
+ }
133
+ catch (e) {
134
+ if (live)
135
+ setError(e instanceof Error ? e.message : String(e));
136
+ } if (live)
137
+ setGateCleared(true); })();
138
+ return () => { live = false; };
139
+ }, [needsGate, gateCleared, beforeLegalGate]);
140
+ const context = { state: activeState, settings, setState: saveStep, permissions, models, license, ready: readyMap, setReady };
141
+ const canContinue = active?.canContinue ? active.canContinue(context) : true;
142
+ const runCallback = async (callback) => {
143
+ try {
144
+ await callback?.();
145
+ }
146
+ catch (e) {
147
+ setError(e instanceof Error ? e.message : String(e));
148
+ }
149
+ };
150
+ const markAndMove = async (nextIndex, completedId) => {
151
+ const completed = completedId && !activeState.completed.includes(completedId) ? [...activeState.completed, completedId] : activeState.completed;
152
+ if (nextIndex >= builtins.length) {
153
+ if (await save({ completed, currentStep: Math.max(0, builtins.length - 1), skipped: false }))
154
+ await runCallback(onComplete);
155
+ return;
156
+ }
157
+ await save({ completed, currentStep: nextIndex, skipped: false });
158
+ };
159
+ if (error && !state)
160
+ return _jsxs("div", { className: cx("rk-onboarding", className), children: [_jsx("p", { className: "rk-onboarding__error", role: "alert", children: error }), _jsx(Button, { onClick: () => window.location.reload(), children: "Retry" })] });
161
+ if (!state || !active)
162
+ return _jsx("div", { className: cx("rk-onboarding", className), "aria-busy": "true", children: _jsx("p", { className: "rk-onboarding__muted", children: "Loading setup\u2026" }) });
163
+ if (needsGate) {
164
+ if (!gateCleared)
165
+ return _jsxs("div", { className: cx("rk-onboarding", className), "aria-busy": "true", children: [_jsx(TitleStrip, { titlebar: titlebar, dragRegion: dragRegion }), _jsx("p", { className: "rk-onboarding__muted", children: "Loading setup\u2026" })] });
166
+ const reacceptance = activeState.legalAccepted || activeState.legalAcceptance !== undefined;
167
+ return _jsxs("div", { className: cx("rk-onboarding rk-onboarding--legal", className), "data-testid": "onboarding-legal", "data-variant": reacceptance ? "re-acceptance" : "first-run", children: [_jsx(TitleStrip, { titlebar: titlebar, dragRegion: dragRegion }), _jsx(LegalGate, { ...legal, variant: reacceptance ? "re-acceptance" : "first-run", onQuit: () => void legal.onQuit?.(), onAgree: async ({ eligibilityBasis }) => {
168
+ const legalAcceptance = { version: requiredVersion ?? "1", documentsHash: documentsHash ?? await hashDocuments(legal.documents), acceptedAt: new Date().toISOString(), eligibilityBasis };
169
+ const progress = reacceptance ? {} : { completed: ["legal"], currentStep: builtins.length > 1 ? 1 : 0 };
170
+ await persist({ legalAccepted: true, eligibilityBasis, legalAcceptance, ...progress });
171
+ if (!reacceptance && builtins.length === 1)
172
+ await onComplete();
173
+ } })] });
174
+ }
175
+ const body = active.render(context);
176
+ return _jsxs("main", { className: cx("rk-onboarding", className), "data-testid": "onboarding", "data-step-id": active.id, children: [_jsx(TitleStrip, { titlebar: titlebar, dragRegion: dragRegion }), _jsxs("aside", { className: "rk-onboarding__rail", children: [_jsx("div", { className: "rk-onboarding__brand", children: legal.appName }), _jsx("nav", { "aria-label": "Setup progress", children: builtins.map((step, i) => _jsxs("button", { type: "button", className: cx("rk-onboarding__step", i === index && "is-active", activeState.completed.includes(step.id) && "is-done"), "aria-current": i === index ? "step" : undefined, disabled: i === 0 && builtins.length > 1, onClick: () => { if (i > 0 && (i <= index || canContinue))
177
+ void save({ currentStep: i }); }, children: [_jsx("span", { children: activeState.completed.includes(step.id) ? "✓" : i + 1 }), step.label] }, step.id)) })] }), _jsxs("section", { className: "rk-onboarding__main", children: [_jsxs("header", { children: [_jsxs("p", { className: "rk-onboarding__eyebrow", children: ["Step ", index + 1, " of ", builtins.length] }), _jsx("h1", { children: active.title }), active.description ? _jsx("p", { className: "rk-onboarding__description", children: active.description }) : null] }), _jsx("div", { className: "rk-onboarding__content", children: body }), error ? _jsx("p", { className: "rk-onboarding__error", role: "alert", children: error }) : null, _jsxs("footer", { children: [allowSkip ? _jsx(Button, { variant: "ghost", disabled: saving, onClick: () => { void save({ currentStep: index, skipped: true }).then((ok) => ok ? runCallback(onSkip) : undefined); }, children: "Set up later" }) : null, _jsx("span", { className: "rk-onboarding__hint", children: !canContinue && active.blockedHint ? active.blockedHint : null }), _jsx(Button, { variant: "secondary", disabled: index <= 1 || saving, onClick: () => void save({ currentStep: index - 1 }), children: "Back" }), _jsx(Button, { variant: "primary", disabled: saving || !canContinue, onClick: () => void markAndMove(index + 1, active.id), children: index === builtins.length - 1 ? "Finish setup" : "Continue" })] })] })] });
178
+ }
@@ -0,0 +1,4 @@
1
+ export { Onboarding, isLegalAccepted, onboardingStateKey } from "./Onboarding.js";
2
+ export { licenseStep, modelsStep, permissionsStep } from "./steps.js";
3
+ export type { ModelsStepOptions } from "./steps.js";
4
+ export type * from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Onboarding, isLegalAccepted, onboardingStateKey } from "./Onboarding.js";
2
+ export { licenseStep, modelsStep, permissionsStep } from "./steps.js";
@@ -0,0 +1,24 @@
1
+ import { type ReactNode } from "react";
2
+ import type { LicenseBackend, ModelsBackend, OnboardingStep, PermissionsBackend } from "./types.js";
3
+ export declare function permissionsStep(backend: PermissionsBackend, options?: {
4
+ label?: string;
5
+ title?: string;
6
+ description?: string;
7
+ }): OnboardingStep;
8
+ export interface ModelsStepOptions {
9
+ label?: string;
10
+ title?: string;
11
+ description?: string;
12
+ /** Continue/Finish wait until at least one model is installed. Default false. */
13
+ required?: boolean;
14
+ /** Start downloading the first missing model when the step opens. Default false. */
15
+ autoStartDownload?: boolean;
16
+ /** App copy rendered at the top of the step. */
17
+ intro?: ReactNode;
18
+ }
19
+ export declare function modelsStep(backend: ModelsBackend, options?: ModelsStepOptions): OnboardingStep;
20
+ export declare function licenseStep(backend: LicenseBackend, options?: {
21
+ label?: string;
22
+ title?: string;
23
+ description?: string;
24
+ }): OnboardingStep;
package/dist/steps.js ADDED
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { Button, Input, Badge } from "@rightkit/app-shell/react";
4
+ function ProgressBar({ value, label }) {
5
+ const pct = Math.max(0, Math.min(1, value));
6
+ return _jsx("div", { className: "rk-onboarding__progress", role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(pct * 100), children: _jsx("i", { style: { width: `${pct * 100}%` } }) });
7
+ }
8
+ const formatBytes = (n) => {
9
+ if (n === undefined)
10
+ return "";
11
+ const units = ["B", "KB", "MB", "GB", "TB"];
12
+ let value = n;
13
+ let unit = 0;
14
+ while (value >= 1000 && unit < units.length - 1) {
15
+ value /= 1000;
16
+ unit += 1;
17
+ }
18
+ return `${value >= 100 || unit === 0 ? Math.round(value) : value.toFixed(1)} ${units[unit]}`;
19
+ };
20
+ const permissionTone = (state) => state === "ready" ? "ok" : state === "denied" || state === "restricted" ? "bad" : state === "needed" ? "warn" : "neutral";
21
+ function PermissionsBody({ backend }) {
22
+ const [items, setItems] = useState([]);
23
+ const [busy, setBusy] = useState(null);
24
+ const [error, setError] = useState(null);
25
+ const reload = useCallback(() => backend.list().then(setItems, (e) => setError(e instanceof Error ? e.message : String(e))), [backend]);
26
+ useEffect(() => void reload(), [reload]);
27
+ return (_jsxs("div", { className: "rk-onboarding__card", "data-testid": "onboarding-permissions", children: [error ? _jsx("p", { className: "rk-onboarding__error", role: "alert", children: error }) : null, items.length === 0 && !error ? _jsx("p", { className: "rk-onboarding__muted", children: "Checking permissions\u2026" }) : null, items.map((item) => (_jsxs("div", { className: "rk-onboarding__row", "data-permission-id": item.id, children: [_jsxs("div", { children: [_jsx("strong", { children: item.label }), _jsx("p", { children: item.description ?? item.detail })] }), _jsxs("div", { className: "rk-onboarding__row-actions", children: [_jsx(Badge, { tone: permissionTone(item.state), children: item.state }), item.state === "needed" || item.state === "denied" ? (_jsx(Button, { size: "sm", variant: "secondary", disabled: busy === item.id, onClick: () => { setBusy(item.id); setError(null); void backend.request(item.id).then((next) => setItems((current) => current.map((x) => x.id === next.id ? next : x)), (e) => setError(e instanceof Error ? e.message : String(e))).finally(() => setBusy(null)); }, children: item.state === "denied" ? "Try again" : "Allow" })) : null] })] }, item.id)))] }));
28
+ }
29
+ export function permissionsStep(backend, options = {}) {
30
+ return { id: "permissions", label: options.label ?? "Permissions", title: options.title ?? "Allow what this app needs", description: options.description ?? "You can change these permissions later in System Settings.", skippable: true, render: () => _jsx(PermissionsBody, { backend: backend }) };
31
+ }
32
+ function ModelsBody({ backend, onReady, autoStartDownload, intro }) {
33
+ const [models, setModels] = useState([]);
34
+ const [loaded, setLoaded] = useState(false);
35
+ const [busy, setBusy] = useState(null);
36
+ const [error, setError] = useState(null);
37
+ const autoStarted = useRef(false);
38
+ const reload = useCallback(() => backend.list().then((list) => { setModels(list); setLoaded(true); }, (e) => setError(e instanceof Error ? e.message : String(e))), [backend]);
39
+ useEffect(() => {
40
+ void reload();
41
+ if (!backend.subscribe)
42
+ return;
43
+ let off;
44
+ let live = true;
45
+ void backend.subscribe((entry) => setModels((current) => current.some((m) => m.id === entry.id) ? current.map((m) => m.id === entry.id ? entry : m) : [...current, entry])).then((unsubscribe) => { if (live)
46
+ off = unsubscribe;
47
+ else
48
+ unsubscribe(); });
49
+ return () => { live = false; off?.(); };
50
+ }, [backend, reload]);
51
+ const hasInstalled = models.some((m) => m.state === "installed");
52
+ useEffect(() => { onReady?.(hasInstalled); }, [hasInstalled, onReady]);
53
+ const run = (id, request) => {
54
+ setBusy(id);
55
+ setError(null);
56
+ void request.then(reload, (e) => setError(e instanceof Error ? e.message : String(e))).finally(() => setBusy(null));
57
+ };
58
+ useEffect(() => {
59
+ if (!autoStartDownload || !loaded || autoStarted.current)
60
+ return;
61
+ autoStarted.current = true;
62
+ if (models.some((m) => m.state === "installed" || m.state === "downloading" || m.state === "verifying"))
63
+ return;
64
+ const first = models.find((m) => m.state === "missing");
65
+ if (first)
66
+ run(first.id, backend.install(first.id));
67
+ // run is intentionally omitted: it only closes over setters.
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ }, [autoStartDownload, loaded, models, backend]);
70
+ return (_jsxs("div", { className: "rk-onboarding__card", "data-testid": "onboarding-models", children: [intro ? _jsx("div", { className: "rk-onboarding__intro", "data-testid": "onboarding-models-intro", children: intro }) : null, error ? _jsx("p", { className: "rk-onboarding__error", role: "alert", children: error }) : null, models.map((model) => {
71
+ const progress = model.progress ?? (model.state === "installed" ? 1 : 0);
72
+ const active = model.state === "downloading" || model.state === "verifying";
73
+ const cancel = backend.cancel;
74
+ return _jsxs("div", { className: "rk-onboarding__row", "data-model-id": model.id, children: [_jsxs("div", { className: "rk-onboarding__grow", children: [_jsx("strong", { children: model.label }), _jsxs("p", { children: [model.description ?? "", model.sizeBytes ? ` · ${formatBytes(model.sizeBytes)}` : ""] }), active ? _jsx(ProgressBar, { value: progress, label: `${model.label} download` }) : null] }), _jsxs("div", { className: "rk-onboarding__row-actions", children: [_jsx(Badge, { tone: model.state === "installed" ? "ok" : model.state === "error" ? "bad" : "neutral", children: model.state }), model.state === "installed" ? null
75
+ : model.state === "error" ? _jsx(Button, { size: "sm", variant: "secondary", disabled: busy === model.id, onClick: () => run(model.id, backend.install(model.id)), children: "Retry" })
76
+ : active ? (cancel ? _jsx(Button, { size: "sm", variant: "secondary", disabled: busy === model.id, onClick: () => run(model.id, cancel.call(backend, model.id)), children: "Pause" }) : null)
77
+ : _jsx(Button, { size: "sm", variant: "secondary", disabled: busy === model.id, onClick: () => run(model.id, backend.install(model.id)), children: "Download" })] })] }, model.id);
78
+ }), models.length === 0 && !error ? _jsx("p", { className: "rk-onboarding__muted", children: "No models available." }) : null] }));
79
+ }
80
+ export function modelsStep(backend, options = {}) {
81
+ return {
82
+ id: "models", label: options.label ?? "Models", title: options.title ?? "Choose local models", description: options.description ?? "Downloads are verified before a model is activated.", skippable: true,
83
+ canContinue: options.required ? (ctx) => ctx.ready.models === true : undefined,
84
+ blockedHint: options.required ? "Download a model to continue." : undefined,
85
+ render: (ctx) => _jsx(ModelsBody, { backend: backend, onReady: ctx.setReady, autoStartDownload: options.autoStartDownload, intro: options.intro }),
86
+ };
87
+ }
88
+ function LicenseBody({ backend }) {
89
+ const [state, setState] = useState({ status: "none" });
90
+ const [key, setKey] = useState("");
91
+ const [busy, setBusy] = useState(false);
92
+ const [error, setError] = useState(null);
93
+ useEffect(() => void backend.load().then(setState, (e) => setError(e instanceof Error ? e.message : String(e))), [backend]);
94
+ const run = (fn) => { setBusy(true); setError(null); void fn().then(setState, (e) => setError(e instanceof Error ? e.message : String(e))).finally(() => setBusy(false)); };
95
+ return _jsxs("div", { className: "rk-onboarding__card", "data-testid": "onboarding-license", children: [_jsxs("div", { className: "rk-onboarding__license-state", children: [_jsx(Badge, { tone: state.status === "active" || state.status === "trial" ? "ok" : state.status === "expired" || state.status === "invalid" ? "bad" : "neutral", children: state.label ?? state.status }), _jsx("span", { children: state.detail ?? "You can continue without a licence." })] }), error ? _jsx("p", { className: "rk-onboarding__error", role: "alert", children: error }) : null, backend.activate ? _jsxs("form", { className: "rk-onboarding__form", onSubmit: (e) => { e.preventDefault(); if (key.trim())
96
+ run(() => backend.activate(key.trim())); }, children: [_jsx(Input, { "aria-label": "Licence key", placeholder: "Licence key", value: key, onChange: (e) => setKey(e.target.value), disabled: busy }), _jsx(Button, { size: "sm", variant: "primary", type: "submit", disabled: busy || !key.trim(), children: "Activate" })] }) : null, _jsxs("div", { className: "rk-onboarding__row-actions", children: [backend.startTrial ? _jsx(Button, { size: "sm", variant: "secondary", disabled: busy, onClick: () => run(() => backend.startTrial()), children: "Start trial" }) : null, backend.purchaseUrl ? _jsx(Button, { size: "sm", variant: "ghost", onClick: () => void backend.openExternal?.(backend.purchaseUrl), children: "View plans" }) : null] })] });
97
+ }
98
+ export function licenseStep(backend, options = {}) {
99
+ return { id: "license", label: options.label ?? "Licence", title: options.title ?? "Choose how you’ll use this app", description: options.description ?? "Activate a licence, start a trial, or continue with the free plan.", skippable: true, render: () => _jsx(LicenseBody, { backend: backend }) };
100
+ }
@@ -0,0 +1,139 @@
1
+ import type { ReactNode } from "react";
2
+ import type { LegalGateDocument, LegalGateProps, LegalGateTheme } from "@rightkit/legal-ui";
3
+ export type SettingsValues = Record<string, unknown>;
4
+ export interface SettingsSnapshot {
5
+ values: SettingsValues;
6
+ revision: number;
7
+ }
8
+ /** Structural port shared with @rightkit/settings-ui and rightkit-settings. */
9
+ export interface SettingsBackend {
10
+ load(): Promise<SettingsSnapshot>;
11
+ patch(patch: SettingsValues, expectedRevision?: number): Promise<SettingsSnapshot>;
12
+ subscribe?(handler: (keys: string[]) => void): Promise<() => void>;
13
+ }
14
+ export type PermissionState = "ready" | "needed" | "waiting" | "denied" | "restricted";
15
+ export interface PermissionStatus {
16
+ id: string;
17
+ label: string;
18
+ description?: string;
19
+ state: PermissionState;
20
+ detail?: string;
21
+ }
22
+ export interface PermissionsBackend {
23
+ list(): Promise<PermissionStatus[]>;
24
+ request(id: string): Promise<PermissionStatus>;
25
+ }
26
+ export type ModelState = "missing" | "installed" | "downloading" | "verifying" | "error";
27
+ export interface ModelEntry {
28
+ id: string;
29
+ label: string;
30
+ description?: string;
31
+ sizeBytes?: number;
32
+ state: ModelState;
33
+ progress?: number;
34
+ error?: {
35
+ code: string;
36
+ message: string;
37
+ };
38
+ }
39
+ export interface ModelsBackend {
40
+ list(): Promise<ModelEntry[]>;
41
+ install(id: string): Promise<void>;
42
+ /** Optional. The cancel/pause control is shown only when the backend supplies this. */
43
+ cancel?(id: string): Promise<void>;
44
+ subscribe?(handler: (entry: ModelEntry) => void): Promise<() => void>;
45
+ }
46
+ export interface LicenseState {
47
+ status: "none" | "trial" | "active" | "expired" | "invalid";
48
+ label?: string;
49
+ detail?: string;
50
+ tier?: string;
51
+ validUntil?: string | null;
52
+ }
53
+ export interface LicenseBackend {
54
+ load(): Promise<LicenseState>;
55
+ activate?(key: string): Promise<LicenseState>;
56
+ startTrial?(): Promise<LicenseState>;
57
+ purchaseUrl?: string;
58
+ openExternal?: (url: string) => void | Promise<void>;
59
+ }
60
+ export type EligibilityBasis = "individual" | "enterprise";
61
+ /** Full record of one legal acceptance, persisted so version changes can re-prompt. */
62
+ export interface LegalAcceptanceRecord {
63
+ version: string;
64
+ documentsHash: string;
65
+ /** UTC ISO-8601 timestamp (`Date#toISOString`). */
66
+ acceptedAt: string;
67
+ eligibilityBasis: EligibilityBasis;
68
+ }
69
+ export interface PersistedOnboardingState {
70
+ version: 1;
71
+ currentStep: number;
72
+ completed: string[];
73
+ skipped: boolean;
74
+ /** Legacy boolean, still written for older readers. Prefer `legalAcceptance`. */
75
+ legalAccepted: boolean;
76
+ /** Legacy mirror of `legalAcceptance.eligibilityBasis`. */
77
+ eligibilityBasis?: EligibilityBasis;
78
+ legalAcceptance?: LegalAcceptanceRecord;
79
+ }
80
+ export interface OnboardingStepContext {
81
+ state: PersistedOnboardingState;
82
+ settings: SettingsBackend;
83
+ setState: (next: Partial<PersistedOnboardingState>) => Promise<void>;
84
+ permissions?: PermissionsBackend;
85
+ models?: ModelsBackend;
86
+ license?: LicenseBackend;
87
+ /** Readiness reported by steps via `setReady`, keyed by step id. */
88
+ ready: Readonly<Record<string, boolean>>;
89
+ /** Reports whether the active step is ready (used by `canContinue`). Stable per step. */
90
+ setReady: (ready: boolean) => void;
91
+ }
92
+ export interface OnboardingStep {
93
+ id: string;
94
+ label: string;
95
+ title: string;
96
+ description?: string;
97
+ skippable?: boolean;
98
+ /** Continue/Finish stay disabled until this returns true. Default: always allowed. */
99
+ canContinue?: (context: OnboardingStepContext) => boolean;
100
+ /** Shown beside the disabled Continue/Finish button. */
101
+ blockedHint?: string;
102
+ render: (context: OnboardingStepContext) => ReactNode;
103
+ }
104
+ export interface LegalStepConfig extends Omit<LegalGateProps, "variant" | "onAgree" | "onQuit"> {
105
+ onQuit?: () => void;
106
+ }
107
+ export interface OnboardingProps {
108
+ settings: SettingsBackend;
109
+ legal: LegalStepConfig;
110
+ /** App-specific steps are appended after built-in steps, in supplied order. */
111
+ steps?: readonly OnboardingStep[];
112
+ permissions?: PermissionsBackend;
113
+ models?: ModelsBackend;
114
+ license?: LicenseBackend;
115
+ onComplete: () => void | Promise<void>;
116
+ onSkip?: () => void | Promise<void>;
117
+ className?: string;
118
+ /** Version the user must have accepted. A different (or missing) stored version re-prompts with `variant: "re-acceptance"`. */
119
+ requiredVersion?: string;
120
+ /** Custom acceptance check; takes precedence over `requiredVersion`. */
121
+ isAccepted?: (state: PersistedOnboardingState) => boolean;
122
+ /** Hash of the legal documents recorded with the acceptance. Default: hash of document titles and URLs. */
123
+ documentsHash?: string;
124
+ /** Runs (and is awaited) before the legal gate is shown, e.g. to resize or reveal the window. */
125
+ beforeLegalGate?: () => void | Promise<void>;
126
+ /** Require at least one downloaded model before Continue/Finish on the models step. Default false. */
127
+ requireModel?: boolean;
128
+ /** Start downloading the first missing model when the models step opens. Default false. */
129
+ autoStartDownload?: boolean;
130
+ /** App copy shown at the top of the models step. */
131
+ modelsIntro?: ReactNode;
132
+ /** Show "Set up later". Default true. */
133
+ allowSkip?: boolean;
134
+ /** Optional titlebar content rendered in a strip along the top. */
135
+ titlebar?: ReactNode;
136
+ /** Render a `data-tauri-drag-region` strip at the top. Default false. */
137
+ dragRegion?: boolean;
138
+ }
139
+ export type { LegalGateDocument, LegalGateTheme };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/ui.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const cx: (...parts: Array<string | false | null | undefined>) => string;
package/dist/ui.js ADDED
@@ -0,0 +1 @@
1
+ export const cx = (...parts) => parts.filter(Boolean).join(" ");
package/onboarding.css ADDED
@@ -0,0 +1,41 @@
1
+ /* @rightkit/onboarding — uses app-shell tokens and legal-ui's locked light gate. */
2
+ .rk-onboarding { position: relative; min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); background: var(--rk-plane, #fffcf5); color: var(--rk-ink, #231f1a); font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
3
+ .rk-onboarding *, .rk-onboarding *::before, .rk-onboarding *::after { box-sizing: border-box; }
4
+ .rk-onboarding__rail { display: flex; flex-direction: column; gap: 22px; padding: 28px 14px; background: var(--rk-chrome, #eee9df); border-right: .5px solid var(--rk-hairline, rgba(35,31,26,.11)); }
5
+ .rk-onboarding__brand { padding: 0 10px; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
6
+ .rk-onboarding__rail nav { display: grid; gap: 3px; }
7
+ .rk-onboarding__step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--rk-ink-2, #6b655c); font: inherit; text-align: left; cursor: pointer; }
8
+ .rk-onboarding__step span { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--rk-line-strong, rgba(35,31,26,.18)); border-radius: 50%; font-size: 11px; }
9
+ .rk-onboarding__step:hover { background: var(--rk-fill, rgba(35,31,26,.05)); color: var(--rk-ink); }
10
+ .rk-onboarding__step.is-active { background: var(--rk-sel, rgba(35,31,26,.06)); color: var(--rk-ink); font-weight: 600; }
11
+ .rk-onboarding__step.is-done span { border-color: var(--rk-ok, #1e7f3c); color: var(--rk-ok, #1e7f3c); }
12
+ .rk-onboarding__main { display: flex; flex-direction: column; min-width: 0; max-width: 840px; width: 100%; padding: 64px clamp(24px, 7vw, 88px) 32px; }
13
+ .rk-onboarding__main header { max-width: 620px; }
14
+ .rk-onboarding__eyebrow { margin: 0 0 8px; color: var(--rk-accent, #7040c4); font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
15
+ .rk-onboarding__main h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); line-height: 1.1; letter-spacing: -.025em; }
16
+ .rk-onboarding__description { margin: 10px 0 0; color: var(--rk-ink-2, #6b655c); font-size: 15px; max-width: 58ch; }
17
+ .rk-onboarding__content { flex: 1; padding: 30px 0; }
18
+ .rk-onboarding__card { display: grid; gap: 2px; max-width: 680px; padding: 6px 0; }
19
+ .rk-onboarding__card > p { color: var(--rk-ink-2, #6b655c); }
20
+ .rk-onboarding__row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: .5px solid var(--rk-hairline, rgba(35,31,26,.11)); }
21
+ .rk-onboarding__row:last-child { border-bottom: 0; }
22
+ .rk-onboarding__row p { margin: 3px 0 0; color: var(--rk-ink-2, #6b655c); font-size: 12.5px; }
23
+ .rk-onboarding__row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; flex: none; }
24
+ .rk-onboarding__grow { min-width: 0; flex: 1; }
25
+ .rk-onboarding__muted { color: var(--rk-ink-2, #6b655c); }
26
+ .rk-onboarding__error { color: var(--rk-bad, #c4001a); }
27
+ .rk-onboarding__state { color: var(--rk-ink-2, #6b655c); text-transform: capitalize; }
28
+ .rk-onboarding__progress { height: 6px; margin-top: 8px; border-radius: 99px; background: var(--rk-fill-3, rgba(35,31,26,.13)); overflow: hidden; }
29
+ .rk-onboarding__progress i { display: block; height: 100%; background: var(--rk-accent, #7040c4); }
30
+ .rk-onboarding__license-state { display: flex; align-items: center; gap: 10px; margin: 8px 0 18px; }
31
+ .rk-onboarding__license-state small { color: var(--rk-ink-2, #6b655c); }
32
+ .rk-onboarding__form { display: flex; gap: 8px; margin-bottom: 14px; }
33
+ .rk-onboarding__form .rk-input { flex: 1; }
34
+ .rk-onboarding footer { display: flex; align-items: center; gap: 8px; padding-top: 16px; border-top: .5px solid var(--rk-hairline, rgba(35,31,26,.11)); }
35
+ .rk-onboarding footer span { flex: 1; }
36
+ .rk-onboarding--legal { display: block; }
37
+ @media (max-width: 640px) { .rk-onboarding { grid-template-columns: 1fr; } .rk-onboarding__rail { padding: 18px 12px; border-right: 0; border-bottom: .5px solid var(--rk-hairline, rgba(35,31,26,.11)); } .rk-onboarding__rail nav { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rk-onboarding__main { padding: 34px 20px 24px; } .rk-onboarding__row { align-items: flex-start; flex-direction: column; gap: 10px; } .rk-onboarding__row-actions { justify-content: flex-start; } }
38
+ /* Optional window chrome strip (titlebar slot / data-tauri-drag-region). Height is app-tunable. */
39
+ .rk-onboarding__titlebar { position: absolute; inset: 0 0 auto 0; z-index: 2; display: flex; align-items: center; height: var(--rk-onboarding-titlebar-h, 32px); padding: 0 12px; }
40
+ .rk-onboarding__hint { color: var(--rk-ink-2, #6b655c); font-size: 12px; text-align: right; }
41
+ .rk-onboarding__intro { margin-bottom: 12px; color: var(--rk-ink-2, #6b655c); }
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@rightkit/onboarding",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "First-run onboarding framework: ordered steps, progress, skip/resume, legal gate first, permissions, model download and licence/trial steps.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./onboarding.css": "./onboarding.css"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "onboarding.css",
19
+ "README.md",
20
+ "LICENSE-MIT",
21
+ "LICENSE-APACHE"
22
+ ],
23
+ "sideEffects": [
24
+ "*.css"
25
+ ],
26
+ "peerDependencies": {
27
+ "@rightkit/app-shell": ">=0.2.0 <1",
28
+ "@rightkit/legal-ui": ">=0.1.2 <1",
29
+ "react": ">=18 <20"
30
+ },
31
+ "devDependencies": {
32
+ "@rightkit/app-shell": "0.2.0",
33
+ "@rightkit/legal-ui": "0.1.2",
34
+ "@testing-library/jest-dom": "^6.6.3",
35
+ "@testing-library/react": "^16.1.0",
36
+ "@testing-library/user-event": "^14.5.2",
37
+ "@types/react": "^19.0.0",
38
+ "@types/react-dom": "^19.0.0",
39
+ "jsdom": "^25.0.1",
40
+ "react": "^19.0.0",
41
+ "react-dom": "^19.0.0",
42
+ "typescript": "^5.7.0",
43
+ "vite": "^6.0.0",
44
+ "vitest": "^2.1.8"
45
+ },
46
+ "publishConfig": {
47
+ "registry": "https://registry.npmjs.org",
48
+ "access": "public"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/bogusyogi/claude.git",
53
+ "directory": "tools/rightkit/packages/onboarding"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc -p tsconfig.json",
57
+ "typecheck": "tsc -p tsconfig.json --noEmit",
58
+ "pretest": "pnpm --filter \"@rightkit/onboarding^...\" run build",
59
+ "test": "vitest run"
60
+ }
6
61
  }