@rightkit/onboarding 0.2.2 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +35 -61
  2. package/package.json +5 -4
package/README.md CHANGED
@@ -1,76 +1,50 @@
1
1
  # @rightkit/onboarding
2
2
 
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.
3
+ First-run onboarding framework for Right Suite apps. The legal agreement gate comes first, then ordered steps (permissions, model download, license or trial, and app-defined steps), with progress, skip and resume.
4
4
 
5
- ```tsx
6
- import { Onboarding } from "@rightkit/onboarding";
7
- import "@rightkit/onboarding/onboarding.css";
5
+ | Item | Value |
6
+ |---|---|
7
+ | Where it runs | App webview UI (React) |
8
+ | Rust pair | None |
9
+ | Version | see INDEX.md |
10
+ | License | MIT OR Apache-2.0 |
8
11
 
9
- <Onboarding settings={settings} legal={legal} permissions={permissions} models={models} license={license}
10
- onComplete={finish} onSkip={later} />
11
- ```
12
+ ## Entry points
12
13
 
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.
14
+ | Import | Contents |
15
+ |---|---|
16
+ | `@rightkit/onboarding` | `Onboarding`, `isLegalAccepted`, `onboardingStateKey`, `licenseStep`, `modelsStep`, `permissionsStep`; types from `types.ts`, `ModelsStepOptions` |
17
+ | `@rightkit/onboarding/onboarding.css` | Stylesheet |
16
18
 
17
- ## Props
19
+ ## Peer dependencies
18
20
 
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
- | `shouldAutoStart(entry, models)` | Choose which missing model auto-starts when the models step first opens (first `missing` entry returning true). Replaces `autoStartDownload`'s rule, including its "a model is already installed" guard. Once per mount, across re-renders and Back/Next. |
28
- | `onModelsStepEnter(ctx)` | Full control, called once when the step opens and the list has loaded: `ctx.models`, `ctx.start(id)`, `ctx.refresh()`. Replaces `shouldAutoStart` and `autoStartDownload`; a throw is shown in the step. |
29
- | `modelsIntro` | App copy shown at the top of the models step. |
30
- | `allowSkip` | Show "Set up later" (default `true`). |
31
- | `titlebar` | Node rendered in a strip along the top. |
32
- | `dragRegion` | Add `data-tauri-drag-region` to that strip on the setup steps (default `false`; height `--rk-onboarding-titlebar-h`, default 32px). Never rendered on the legal stage. |
33
- | `legalDragRegion` | Also render the drag region on the legal stage (default `false`; the legal gate has no strip, and `titlebar` content alone never adds the attribute). |
34
- | `legalReceipt` | `{ read(), write(record) }`: the app's own acceptance receipt. See below. |
21
+ | Peer | Range |
22
+ |---|---|
23
+ | `@rightkit/app-shell` | `>=0.2.0 <1` |
24
+ | `@rightkit/legal-ui` | `>=0.1.2 <1` |
25
+ | `react` | `>=18 <20` |
35
26
 
36
- ## App-owned legal receipt
27
+ ## Example
37
28
 
38
- An app that already persists its own acceptance receipt passes `legalReceipt` and keeps that store as the source of truth. `read()` runs on load (sync or async) and returns a `LegalAcceptanceRecord` (`version`, `documentsHash`, `acceptedAt`, `eligibilityBasis`) or `null`. Its result replaces any acceptance in the settings backend: `null`, a throw, or an incomplete record all mean "not accepted", so the gate shows. `requiredVersion` / `isAccepted` then evaluate against the app's receipt, and a receipt for another version re-prompts with `variant: "re-acceptance"`. On agree, `write(record)` is awaited first; if it throws, the gate shows its save-failure alert and nothing else is persisted.
29
+ Illustrative. The `settings`, `legal`, `permissions`, `models` and `license` values are app-provided adapters.
39
30
 
40
- Mapping example for ScrapeRight's four-field `scraperight.legal-acceptance.v1` receipt (`legalAcceptanceVersion`, `legalAcceptedAt`, `legalEligibilityBasis`, `legalMaterialSha256`; pass `documentsHash={LEGAL_MATERIAL_SHA256}` so the hash round-trips):
31
+ ```tsx
32
+ import { Onboarding } from "@rightkit/onboarding";
33
+ import "@rightkit/onboarding/onboarding.css";
41
34
 
42
- ```ts
43
- const legalReceipt: LegalReceiptPort = {
44
- read() {
45
- const r = loadLegalAcceptance(); // reads localStorage "scraperight.legal-acceptance.v1"
46
- if (!r?.legalAcceptanceVersion || !r.legalAcceptedAt || !r.legalEligibilityBasis) return null;
47
- return {
48
- version: r.legalAcceptanceVersion,
49
- acceptedAt: r.legalAcceptedAt,
50
- eligibilityBasis: r.legalEligibilityBasis, // "individual" | "enterprise"
51
- documentsHash: r.legalMaterialSha256 ?? "",
52
- };
53
- },
54
- write(rec) {
55
- saveLegalAcceptance({
56
- legalAcceptanceVersion: rec.version,
57
- legalAcceptedAt: rec.acceptedAt, // UTC ISO, ends in Z
58
- legalEligibilityBasis: rec.eligibilityBasis,
59
- legalMaterialSha256: rec.documentsHash,
60
- });
61
- },
62
- };
63
- <Onboarding legalReceipt={legalReceipt} requiredVersion={REQUIRED_LEGAL_ACCEPTANCE_VERSION} documentsHash={LEGAL_MATERIAL_SHA256} ... />
35
+ <Onboarding
36
+ settings={settings} // SettingsBackend; progress saved under "onboarding.state"
37
+ legal={legal}
38
+ permissions={permissions}
39
+ models={models}
40
+ license={license}
41
+ onComplete={finish} // runs only after the state was saved
42
+ onSkip={later}
43
+ />
64
44
  ```
65
45
 
66
- ## Custom steps and readiness
67
-
68
- 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.
69
-
70
- ## Models backend
71
-
72
- `ModelsBackend.cancel` is optional; the Pause control appears only when it is supplied.
46
+ Acceptance is stored as `legalAcceptance: { version, documentsHash, acceptedAt, eligibilityBasis }`. An app that already keeps its own acceptance receipt can pass `legalReceipt` (`read()` and `write(record)`) and keep that store as the source of truth. Steps can set `canContinue(context)`.
73
47
 
74
- ## Tests
48
+ ## Known issues
75
49
 
76
- `pnpm exec vitest run` runs the jsdom unit tests (`src/*.test.tsx`) and the headless-Chrome e2e.
50
+ - Peer React is `<20`, while `doc-render`, `i18n`, `media-ui` and `pdf-ui` accept `<21` (npm audit 2026-10-08).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/onboarding",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "First-run onboarding framework: ordered steps, progress, skip/resume, legal gate first, permissions, model download and licence/trial steps.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -26,11 +26,12 @@
26
26
  "peerDependencies": {
27
27
  "@rightkit/app-shell": ">=0.2.0 <1",
28
28
  "@rightkit/legal-ui": ">=0.1.2 <1",
29
- "react": ">=18 <20"
29
+ "react": ">=18 <21"
30
30
  },
31
31
  "devDependencies": {
32
- "@rightkit/app-shell": "0.2.0",
33
- "@rightkit/legal-ui": "0.1.3",
32
+ "@rightkit/app-shell": "0.3.0",
33
+ "@rightkit/legal-ui": "0.2.0",
34
+ "@rightkit/qa": "0.4.0",
34
35
  "@testing-library/jest-dom": "^6.6.3",
35
36
  "@testing-library/react": "^16.1.0",
36
37
  "@testing-library/user-event": "^14.5.2",