kaafil-react-uikit 0.4.0 → 0.4.2
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/CHANGELOG.md +33 -2
- package/dist/admin/index.cjs +355 -353
- package/dist/admin/index.cjs.map +1 -1
- package/dist/admin/index.js +16 -14
- package/dist/admin/index.js.map +1 -1
- package/dist/{chunk-WPQB7JWS.js → chunk-3E2FN5JJ.js} +3 -3
- package/dist/{chunk-WPQB7JWS.js.map → chunk-3E2FN5JJ.js.map} +1 -1
- package/dist/{chunk-2XW5EIMS.cjs → chunk-3RZDHDEY.cjs} +17 -17
- package/dist/{chunk-2XW5EIMS.cjs.map → chunk-3RZDHDEY.cjs.map} +1 -1
- package/dist/chunk-62HCQWZL.cjs +12 -0
- package/dist/chunk-62HCQWZL.cjs.map +1 -0
- package/dist/{chunk-7G6IENKN.js → chunk-6FUVFVYY.js} +99 -6
- package/dist/chunk-6FUVFVYY.js.map +1 -0
- package/dist/{chunk-E6ER25BG.js → chunk-762SWUEG.js} +3 -3
- package/dist/{chunk-E6ER25BG.js.map → chunk-762SWUEG.js.map} +1 -1
- package/dist/{chunk-3N2EQ2KC.cjs → chunk-CK3L6Y43.cjs} +100 -4
- package/dist/chunk-CK3L6Y43.cjs.map +1 -0
- package/dist/{chunk-A7C74SJT.cjs → chunk-DI77H7ED.cjs} +83 -83
- package/dist/{chunk-A7C74SJT.cjs.map → chunk-DI77H7ED.cjs.map} +1 -1
- package/dist/{chunk-3BEQYIFU.js → chunk-EDLIJSMR.js} +5 -5
- package/dist/{chunk-3BEQYIFU.js.map → chunk-EDLIJSMR.js.map} +1 -1
- package/dist/{chunk-RBIEMGHT.js → chunk-ITGVRN2S.js} +3 -3
- package/dist/{chunk-RBIEMGHT.js.map → chunk-ITGVRN2S.js.map} +1 -1
- package/dist/{chunk-6BY2NPBZ.cjs → chunk-LO3GQFQ6.cjs} +4 -4
- package/dist/{chunk-6BY2NPBZ.cjs.map → chunk-LO3GQFQ6.cjs.map} +1 -1
- package/dist/{chunk-7356B6YS.cjs → chunk-QD4Z5DRT.cjs} +12 -12
- package/dist/{chunk-7356B6YS.cjs.map → chunk-QD4Z5DRT.cjs.map} +1 -1
- package/dist/{chunk-2LMFSKZU.js → chunk-QMUIZHJO.js} +510 -16
- package/dist/chunk-QMUIZHJO.js.map +1 -0
- package/dist/{chunk-KTEXDGAA.js → chunk-RW6TJMRK.js} +3 -3
- package/dist/{chunk-KTEXDGAA.js.map → chunk-RW6TJMRK.js.map} +1 -1
- package/dist/{chunk-XBLAVNP3.cjs → chunk-V6UQ6GIM.cjs} +551 -48
- package/dist/chunk-V6UQ6GIM.cjs.map +1 -0
- package/dist/chunk-XU7GP53M.js +10 -0
- package/dist/chunk-XU7GP53M.js.map +1 -0
- package/dist/{chunk-KETEED2T.cjs → chunk-XYIOM75D.cjs} +9 -9
- package/dist/{chunk-KETEED2T.cjs.map → chunk-XYIOM75D.cjs.map} +1 -1
- package/dist/core/index.cjs +153 -613
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +36 -1
- package/dist/core/index.d.ts +36 -1
- package/dist/core/index.js +21 -511
- package/dist/core/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/manager/index.cjs +239 -239
- package/dist/manager/index.js +6 -6
- package/dist/traveller/index.cjs +35 -35
- package/dist/traveller/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-2LMFSKZU.js.map +0 -1
- package/dist/chunk-3N2EQ2KC.cjs.map +0 -1
- package/dist/chunk-4QYI7TOF.cjs +0 -110
- package/dist/chunk-4QYI7TOF.cjs.map +0 -1
- package/dist/chunk-7G6IENKN.js.map +0 -1
- package/dist/chunk-CLHAJBJS.js +0 -105
- package/dist/chunk-CLHAJBJS.js.map +0 -1
- package/dist/chunk-XBLAVNP3.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useOfflineEngine } from './chunk-
|
|
2
|
-
import { useServerTime } from './chunk-
|
|
3
|
-
import { useKaafilClient, usePersona, isDevelopment, useOfflineEvent, useOfflineMutation, OfflineEngineContext } from './chunk-
|
|
1
|
+
import { useOfflineEngine } from './chunk-XU7GP53M.js';
|
|
2
|
+
import { useServerTime } from './chunk-ITGVRN2S.js';
|
|
3
|
+
import { useKaafilClient, usePersona, isDevelopment, useOfflineEvent, useOfflineMutation, OfflineEngineContext } from './chunk-6FUVFVYY.js';
|
|
4
4
|
import { SyncOpMethod } from 'kaafil-js/client';
|
|
5
5
|
import { useState, useCallback, useEffect, useContext } from 'react';
|
|
6
6
|
|
|
@@ -242,5 +242,5 @@ function useShareSnapshot(token, options) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
export { useShareForms, useShareSnapshot };
|
|
245
|
-
//# sourceMappingURL=chunk-
|
|
246
|
-
//# sourceMappingURL=chunk-
|
|
245
|
+
//# sourceMappingURL=chunk-EDLIJSMR.js.map
|
|
246
|
+
//# sourceMappingURL=chunk-EDLIJSMR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/hooks/useShareForms.ts","../src/core/hooks/useShareSnapshot.ts"],"names":["useState","useEffect"],"mappings":";;;;;;AA6LA,SAAS,gBAAA,CACP,OACA,UAAA,EACsB;AACtB,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,OAAO,aAAa,WAAA,GAAc,SAAA;AAAA,EACpC;AACA,EAAA,OAAO,KAAA,CAAM,MAAA,KAAW,CAAA,GAAI,YAAA,GAAe,gBAAA;AAC7C;AAEA,SAAS,iBAAA,CACP,OAAA,EACA,MAAA,EACA,QAAA,EACA,QAAA,EAC+E;AAC/E,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAO,EAAE,MAAA,EAAQ,mBAAA,EAAqB,EAAA,EAAI,YAAY,MAAA,EAAO;AAAA,EAC/D;AAIA,EAAA,MAAM,MAAA,GAAS,aAAa,MAAA,GAAY,EAAE,IAAI,QAAA,EAAU,IAAA,EAAM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QAAA,EAAU,MAAM,UAAA,EAAW;AACvD","file":"chunk-3BEQYIFU.js","sourcesContent":["'use client';\n\n// `08-core-hooks.md §3` (new row — `ShareFormsSection`'s `Backed by`,\n// `ui-kit/families/traveller/02-forms.md`, cited): the write-back half of\n// the traveller share surface. `forms` is the ONLY write-back section on\n// the whole share surface; every other section is read-only through\n// `useShareSnapshot()` alone. This hook wraps the four dedicated\n// `shareAuth`-only routes `share.forms.{list,render,save,submit}`\n// (`kaafil-js/src/resources/share.ts`, verified this session).\n//\n// ── WHY THIS HOOK DOES NOT ALSO CALL `useShareSnapshot()` ──────────────────\n//\n// `02-forms.md`'s `Backed by` field says the section's own `/core` hook\n// \"composes both\" — the snapshot (for `forms` section presence) and the\n// dedicated routes (for the actual list/render/save/submit). This file\n// deliberately does NOT reproduce the snapshot fetch: `ShareFormsSection`\n// (future work, not this file) is only ever mounted once its own call to\n// `useShareSnapshot(token)` has already confirmed `sections.has('forms')`\n// (`01-share-sections.md`'s registry-driven mount rule) — duplicating that\n// fetch here would be a second, redundant read of the same snapshot for no\n// new information, and this hook has nothing to add to a presence check it\n// does not own. What this file DOES independently reproduce is\n// `useShareSnapshot()`'s own persona gate and its `share.expired`/\n// `share.revoked` subscriptions (`08-core-hooks.md §0`: \"every domain hook\n// is capability-gated internally\" — the share-surface's equivalent gate is\n// the persona check, applied the same way every other hook in this catalog\n// applies its own).\n//\n// ── SPEC TENSION FLAGGED: \"cache-first\" vs. \"the dedicated routes\" ─────────\n//\n// `02-forms.md`'s `Offline` field says the list \"rides the scoped share\n// snapshot cache-first, same as every other section\", but its own `Backed\n// by` field says in the same breath that \"the actual form list/render/\n// save/submit calls ride the dedicated forms-share routes\" — and\n// `ShareSnapshotResponse`'s per-section shape (verified,\n// `useShareSnapshot.ts`) carries no registered `forms` array with\n// `fillState`/`opensAt`/`closesAt` fields; only `ShareFormsListResponse`\n// (`GET /api/v1/share/{token}/forms`) does. This file follows the more\n// specific, SDK-verified statement — a LIVE `share.forms.list()` call,\n// refreshable on demand — the same \"own live-fetch sub-state, not a\n// `snapshot.updated` subscription\" pattern `useRooming.ts`'s\n// `unassignedPool` already uses for an analogous non-delta read. Flagged\n// for the doc owner to resolve; not silently picked one way with no trace.\n//\n// ── `clientToken` IS NOT A HOOK-MINTED IDEMPOTENCY KEY ──────────────────────\n//\n// `ShareSaveFormRequest`/`ShareSubmitFormRequest` (verified,\n// `kaafil-js/openapi/openapi.json`) require a body-level `clientToken`\n// (16-255 chars) — the SDK's own comment on `share.ts` calls it \"this\n// route's own de-dupe key, distinct from the automatic `Idempotency-Key`\n// header\", and `modules/forms/FRD.md §4.1/§8` calls it \"a fixed\n// `clientToken` generated once at enqueue and reused on every retry\" —\n// i.e. exactly the write-once, replay-unchanged lifecycle hard rule #4\n// reserves for `OfflineEngine.enqueue()`'s own internal idempotency-key\n// minting. This hook does NOT invent a value for it (that would be exactly\n// the \"hook mints its own idempotency key\" anti-pattern hard rule #4\n// forbids, even though `clientToken` is a different field from the\n// transport `Idempotency-Key` header `enqueue()` mints separately and\n// automatically for every op, share writes included). Instead\n// `ShareFormWriteInput.clientToken` is a REQUIRED field the CALLER\n// supplies — a future `ShareFormsSection`/`ShareFormFillScreen` generates\n// one value per form-fill session (e.g. once, the first time a field is\n// touched) and passes the SAME value to every `save()`/`submit()` call for\n// that session, which is what makes retries of the SAME logical write\n// dedupe wire-side. This hook only ever forwards it into the body verbatim.\n//\n// ── REVOCATION DROPS QUEUED WRITES — A REAL SDK GAP, WORKED AROUND HERE ────\n//\n// `02-forms.md`'s `Offline` field: \"Revocation is different and has no\n// grace: a `REVOKED` token drops queued writes unsent and purges the local\n// copy immediately.\" Verified against `kaafil-js/src/offline/share.ts`\n// this session: `ShareGuard.invalidate()` treats `'expired'` and\n// `'revoked'` IDENTICALLY — it purges the read snapshot in both cases and\n// only PRESERVES (never drops) the outbox either way; nothing in\n// `kaafil-js` currently distinguishes \"grace-covered\" from \"unsent, drop\n// it\" at the outbox level. This is a genuine SDK/spec disagreement — see\n// this file's final report note. Rather than leave the spec's hard\n// requirement unmet, this hook enforces it locally on `share.revoked`,\n// riding the outbox's own existing `drop()` primitive (the identical call\n// `useConflicts()`'s `'keep-current'` resolution already makes) — this is\n// composing an existing primitive in reaction to an event, not a second\n// sync engine (hard rule #3): no retry ladder, no cache, no idempotency\n// logic is reimplemented here, only \"remove this op from the outbox\".\n\nimport type { KaafilClient, OutboxOp } from 'kaafil-js/client';\nimport { SyncOpMethod } from 'kaafil-js/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { isDevelopment } from '../internal/isDevelopment';\nimport { useKaafilClient } from './useKaafilClient';\nimport { useOfflineEngine } from './useOfflineEngine';\nimport { useOfflineEvent } from './useOfflineEvent';\nimport { useOfflineMutation } from './useOfflineMutation';\nimport { usePersona } from './usePersona';\nimport { useServerTime } from './useServerTime';\n\ntype ShareFormsClient = Pick<KaafilClient, 'share'>;\n\n/** One row of `GET /api/v1/share/{token}/forms` — `ShareFormsListResponse`\n * (verified, `kaafil-js/openapi/openapi.json`). Metadata only: no prefill,\n * no field list, no answers (`FRD:traveller-share §4.8`) — that detail\n * arrives only from `renderForm()` below. */\nexport interface ShareFormListItem {\n readonly formId: string;\n readonly key: string;\n readonly title: string;\n readonly phase: string;\n readonly required: boolean;\n readonly fillState: string;\n readonly opensAt: string | null;\n readonly closesAt: string | null;\n readonly responseStatus: string | null;\n readonly submittedAt: string | null;\n}\n\n/** One answer in a `save`/`submit` body — `ShareSaveFormRequest.answers[]`\n * / `ShareSubmitFormRequest.answers[]` (verified). */\nexport interface ShareFormAnswer {\n readonly fieldKey: string;\n readonly value: unknown;\n}\n\nexport interface ShareFormWriteInput {\n readonly formId: string;\n readonly answers: readonly ShareFormAnswer[];\n /** This route's own de-dupe key — REQUIRED by the wire schema. See this\n * file's header (\"`clientToken` IS NOT A HOOK-MINTED IDEMPOTENCY KEY\") —\n * the caller mints this once per form-fill session and reuses it across\n * every save/submit/retry of that session; this hook never generates it. */\n readonly clientToken: string;\n /** Group fill within the same `TripTraveller.partyId` — omit when the\n * token itself already scopes to a single traveller. */\n readonly travellerRef?: string;\n readonly startNew?: boolean;\n readonly isAnonymous?: boolean;\n}\n\nexport type ShareFormsListStatus = 'loading' | 'list-empty' | 'list-populated' | 'not-found';\n\n/**\n * The write-side status a `save()`/`submit()` call's tracked `OutboxOp`\n * resolves to. Deliberately excludes `'filling'` (`02-forms.md`'s own\n * `States` list also names it): `'filling'` is \"the traveller is editing\n * fields, no request in flight yet\" — a pure local UI mode with no\n * server/outbox signal behind it, so it belongs to the composite that owns\n * the form's field state, never to this hook, which only ever reflects\n * something async.\n */\nexport type ShareFormsWriteStatus =\n | 'idle'\n | 'saving'\n | 'submitting'\n | 'submitted'\n | 'conflicted'\n | 'subject-required'\n | 'queued-offline'\n | 'dropped-on-revoke';\n\nexport interface ShareFormsResult {\n readonly status: ShareFormsListStatus;\n /** `[]` in both the `'loading'` and the `'list-empty'` states — a\n * consumer distinguishes them via `status`, never via array emptiness\n * alone (`02-forms.md`'s `Gating`: an empty list is a NORMAL steady\n * state, never an error, never a placeholder). */\n readonly forms: readonly ShareFormListItem[];\n readonly serverTime: string | undefined;\n /** Re-runs `share.forms.list()`. A composite calls this after a\n * `submit()` lands, since submitting can change another form's\n * `fillState` (e.g. an any-phase trigger opening a follow-up form). */\n readonly refresh: () => Promise<void>;\n /** `GET /api/v1/share/{token}/forms/{formId}` — the fully-resolved,\n * ready-to-paint form (definition merged with any in-progress answers).\n * An open shape (`ShareRenderResponse` has no closed schema yet,\n * verified) — a live call, not cached, matching `save`/`submit`'s own\n * un-cached write path. */\n readonly renderForm: (\n formId: string,\n options?: { readonly travellerRef?: string },\n ) => Promise<Record<string, unknown>>;\n /** An in-progress save — no required-field validation server-side. */\n readonly save: (input: ShareFormWriteInput) => Promise<OutboxOp>;\n /** Finalizes the response — full validation, one transaction. */\n readonly submit: (input: ShareFormWriteInput) => Promise<OutboxOp>;\n /** The combined save/submit write status — see `ShareFormsWriteStatus`. */\n readonly writeStatus: ShareFormsWriteStatus;\n /** The most recently tracked save/submit `OutboxOp`, or `undefined`\n * before either has ever been called. */\n readonly writeOp: OutboxOp | undefined;\n}\n\nfunction deriveListStatus(\n forms: readonly ShareFormListItem[] | undefined,\n listFailed: boolean,\n): ShareFormsListStatus {\n if (forms === undefined) {\n return listFailed ? 'not-found' : 'loading';\n }\n return forms.length === 0 ? 'list-empty' : 'list-populated';\n}\n\nfunction deriveWriteStatus(\n revoked: boolean,\n saveOp: OutboxOp | undefined,\n submitOp: OutboxOp | undefined,\n isOnline: boolean,\n): { readonly status: ShareFormsWriteStatus; readonly op: OutboxOp | undefined } {\n if (revoked) {\n return { status: 'dropped-on-revoke', op: submitOp ?? saveOp };\n }\n // `submit` always takes precedence when both are in play — finishing a\n // submission is the more advanced, more important-to-surface state of\n // the two for the same form.\n const active = submitOp !== undefined ? { op: submitOp, kind: 'submit' as const } : undefined;\n const fallback =\n active ?? (saveOp !== undefined ? { op: saveOp, kind: 'save' as const } : undefined);\n if (fallback === undefined) {\n return { status: 'idle', op: undefined };\n }\n const { op, kind } = fallback;\n if (op.status === 'parked') {\n if (op.parkReason?.code === 'CONFLICT_VERSION') {\n return { status: 'conflicted', op };\n }\n if (op.parkReason?.code === 'SUBJECT_REQUIRED') {\n return { status: 'subject-required', op };\n }\n // Any other park reason (e.g. `ShareWriteGraceExpired` —\n // `kaafil-js/src/offline/share.ts`, a grace window that closed before\n // this op ever synced) reports the same as a still-queued offline\n // write: the honest \"still catching up\" framing until it is provably\n // gone (`02-forms.md`'s `Offline` field). A distinct terminal wording\n // for that specific park reason is `ShareFormsSection`'s own\n // presentation concern, not this hook's.\n return { status: 'queued-offline', op };\n }\n if (op.status === 'done') {\n return { status: kind === 'submit' ? 'submitted' : 'idle', op };\n }\n // pending or inflight.\n if (!isOnline) {\n return { status: 'queued-offline', op };\n }\n return { status: kind === 'submit' ? 'submitting' : 'saving', op };\n}\n\nexport function useShareForms(token: string): ShareFormsResult {\n const client = useKaafilClient() as ShareFormsClient;\n const persona = usePersona();\n const engine = useOfflineEngine();\n const { now, sinceLastSync } = useServerTime();\n // `now()` throws before this session's first `snapshot.updated` event —\n // see `useServerTime.ts`'s own \"CALLERS: guard the call site\" note. This\n // hook's writes stay legal without a stamp (see the `enqueuedAt` call\n // sites below), so the guard is \"can I use it\", never \"must I have it\".\n const serverTimeKnown = sinceLastSync !== undefined;\n\n const [forms, setForms] = useState<readonly ShareFormListItem[] | undefined>(undefined);\n const [serverTime, setServerTime] = useState<string | undefined>(undefined);\n const [listFailed, setListFailed] = useState(false);\n const [revoked, setRevoked] = useState(false);\n const [isOnline, setIsOnline] = useState(\n () => typeof navigator === 'undefined' || navigator.onLine,\n );\n\n const fetchList = useCallback(async (): Promise<void> => {\n try {\n const response = await client.share.forms.list({ token });\n setForms(response.items);\n setServerTime(response.meta.serverTime);\n setListFailed(false);\n } catch {\n // `GET .../forms` only ever fails `RESOURCE_NOT_FOUND` (`FRD:\n // traveller-share §4.1`'s route table, verified) — the share 404\n // carve-out means dark/cross-scope/genuinely-gone collapse to one\n // shape, same reasoning `useShareSnapshot()` applies to its own read.\n setListFailed(true);\n }\n }, [client, token]);\n\n useEffect(() => {\n if (persona !== 'share') {\n if (isDevelopment()) {\n throw new Error(\n 'useShareForms() was called from a manager/agencyAdmin session — ' +\n 'this hook is `share`-only (families/traveller/02-forms.md, `ShareFormsSection`).',\n );\n }\n return;\n }\n void fetchList();\n }, [persona, fetchList]);\n\n // A browser-level connectivity signal, same source `useOutboxStatus()`\n // reads (`kaafil-js`'s `OfflineEngine` exposes no queryable connectivity\n // flag of its own — see that hook's own header, verified again here).\n useEffect(() => {\n if (typeof window === 'undefined') {\n return;\n }\n const handleOnline = (): void => setIsOnline(true);\n const handleOffline = (): void => setIsOnline(false);\n window.addEventListener('online', handleOnline);\n window.addEventListener('offline', handleOffline);\n return () => {\n window.removeEventListener('online', handleOnline);\n window.removeEventListener('offline', handleOffline);\n };\n }, []);\n\n useOfflineEvent('share.revoked', () => {\n setRevoked(true);\n // See this file's header (\"REVOCATION DROPS QUEUED WRITES\"). Only this\n // token's own lane, and only ops still in play (a `'done'` op already\n // landed and has nothing left to drop).\n for (const op of engine.outbox.all()) {\n if (op.tripRef === token && (op.status === 'pending' || op.status === 'parked')) {\n void engine.outbox.drop(op.id);\n }\n }\n });\n\n const saveMutation = useOfflineMutation<ShareFormWriteInput>({\n tripRef: token,\n enqueue: (mutationEngine, input) => {\n const query =\n input.travellerRef !== undefined\n ? `?travellerRef=${encodeURIComponent(input.travellerRef)}`\n : '';\n return mutationEngine.enqueue({\n tripRef: token,\n method: SyncOpMethod.Post,\n path: `/api/v1/share/${token}/forms/${input.formId}/save${query}`,\n // Hardcoded literal, not imported: `OperationId` is not exported\n // from `kaafil-js/client`'s public surface (same reasoning\n // `useRooming.ts` documents). Value verified against\n // `kaafil-js/src/generated/security.ts` this session:\n // `OperationId.ShareSaveForm === 'shareSaveForm'`.\n operationId: 'shareSaveForm' as never,\n body: {\n answers: input.answers,\n clientToken: input.clientToken,\n ...(input.startNew !== undefined ? { startNew: input.startNew } : {}),\n ...(input.isAnonymous !== undefined ? { isAnonymous: input.isAnonymous } : {}),\n },\n // The server-anchored \"now\" this write was created at — never\n // `Date.now()`/`new Date()` (hard rule #6) — `EnqueueWriteOptions\n // .enqueuedAt`'s own doc comment: \"client-attested and only ever\n // used by the server to REFUSE\" (the 7-day post-expiry grace\n // check). Optional on the wire, and genuinely omitted here on a\n // cold session: `useServerTime().now()` throws before this\n // session's very first `snapshot.updated` event has landed (its\n // own documented behaviour, guarded at the call site exactly as\n // its header instructs) — a share write attempted in that narrow\n // window still enqueues durably, just without a client-attested\n // stamp for the server's grace check to read.\n ...(serverTimeKnown ? { enqueuedAt: now() } : {}),\n });\n },\n });\n\n const submitMutation = useOfflineMutation<ShareFormWriteInput>({\n tripRef: token,\n enqueue: (mutationEngine, input) => {\n const query =\n input.travellerRef !== undefined\n ? `?travellerRef=${encodeURIComponent(input.travellerRef)}`\n : '';\n return mutationEngine.enqueue({\n tripRef: token,\n method: SyncOpMethod.Post,\n path: `/api/v1/share/${token}/forms/${input.formId}/submit${query}`,\n operationId: 'shareSubmitForm' as never,\n body: {\n answers: input.answers,\n clientToken: input.clientToken,\n ...(input.startNew !== undefined ? { startNew: input.startNew } : {}),\n ...(input.isAnonymous !== undefined ? { isAnonymous: input.isAnonymous } : {}),\n },\n // See the identical `save` enqueue above for why this is guarded.\n ...(serverTimeKnown ? { enqueuedAt: now() } : {}),\n });\n },\n });\n\n const renderForm = useCallback(\n async (\n formId: string,\n options?: { readonly travellerRef?: string },\n ): Promise<Record<string, unknown>> => {\n const response = await client.share.forms.render({\n token,\n formId,\n ...(options?.travellerRef !== undefined ? { travellerRef: options.travellerRef } : {}),\n });\n return response;\n },\n [client, token],\n );\n\n const { status: writeStatus, op: writeOp } = deriveWriteStatus(\n revoked,\n saveMutation.op,\n submitMutation.op,\n isOnline,\n );\n\n return {\n status: deriveListStatus(forms, listFailed),\n forms: forms ?? [],\n serverTime,\n refresh: fetchList,\n renderForm,\n save: saveMutation.mutate,\n submit: submitMutation.mutate,\n writeStatus,\n writeOp,\n };\n}\n","'use client';\n\n// `08-core-hooks.md §3.1`. The single assembled read behind the whole\n// traveller share surface. Wraps `share.snapshot()` (verified `shareAuth`\n// -only in `security.ts` — no `apiKeyAuth` alternative exists for any\n// `share.*` operation), read cache-first from the snapshot once\n// `OfflineEngine`'s `share` option is configured.\n//\n// VERIFIED SHAPE (`openapi/openapi.json`'s `ShareSnapshotResponse`, this\n// session): a flat object with one property PER section key, each present\n// only when the link exposes it and data exists — never `null`, never an\n// empty placeholder — plus a `trip` echo (`name`/`startDate`/`endDate`/\n// `timezone`/`phase`) that is NOT one of the thirteen section flags\n// (`09-registries.md §5`). This hook builds `sections` by taking every own\n// key off the response except `trip` and `meta` — additive-safe against a\n// future 14th section key without needing this file to enumerate all\n// thirteen by name.\n//\n// `trip` and the server clock are surfaced as their OWN top-level fields on\n// `ShareSnapshotResult`, never folded into `sections`: every consumer of\n// `sections` (starting with `KaafilShareView`, which walks the map and\n// renders one composite per key) treats \"is this key present\" as \"should I\n// render a section for it\" — letting `trip`/`meta` leak into that map would\n// make the view try to mount a `<ShareTripSection>`/`<ShareMetaSection>`\n// that has never existed. But every traveller composite still needs BOTH:\n// `trip.timezone` is the one zone `DateDisplay`/`TimeDisplay` may legally\n// anchor to on this surface (never the device zone, never a fabricated\n// `'UTC'`), `trip.phase` lets a composite react to PRE_DEPARTURE/ON_TRIP/\n// POST_TRIP, and `meta.serverTime` is the only trusted \"now\" a share\n// composite may read without going through `useServerTime()` (hard rule\n// #6 — no `Date.now()`/`new Date()` in `src/core`). Hence: two extra return\n// fields, kept structurally apart from the section map they must never\n// pollute.\n\nimport type { KaafilClient } from 'kaafil-js/client';\nimport { useContext, useEffect, useState } from 'react';\nimport { OfflineEngineContext } from '../internal/contexts';\nimport { isDevelopment } from '../internal/isDevelopment';\nimport { useKaafilClient } from './useKaafilClient';\nimport { usePersona } from './usePersona';\n\nexport interface ShareSnapshotOptions {\n readonly travellerRef?: string;\n}\n\n// Derived from the SDK's own return type rather than hand-copied — this\n// stays correct for free if `kaafil-js` grows another `trip` field, instead\n// of silently drifting the way the old `'UTC'` constants did.\ntype ShareSnapshotResponse = Awaited<ReturnType<KaafilClient['share']['snapshot']>>;\n\n/** The trip echo every snapshot response carries — `name`/`startDate`/\n * `endDate` plus the two fields this hook used to throw away:\n * `timezone` (the IANA zone every traveller-facing render must anchor to)\n * and `phase` (server-computed `PRE_DEPARTURE`/`ON_TRIP`/`POST_TRIP`). */\nexport type ShareSnapshotTrip = ShareSnapshotResponse['trip'];\n\nexport interface ShareSnapshotResult {\n readonly status: 'loading' | 'ready' | 'expired' | 'revoked' | 'not-found';\n readonly sections: ReadonlyMap<string, unknown>;\n /** The snapshot's `trip` echo, or `undefined` before any response has\n * landed (mirrors `sections`' own \"empty until ready\" behaviour). NEVER a\n * section key — see this file's header. */\n readonly trip: ShareSnapshotTrip | undefined;\n /** `meta.serverTime` off the most recently landed snapshot response — the\n * only trusted clock a share composite may read (hard rule #6). Kept\n * separate from `useServerTime()`'s own stream (which advances off\n * `OfflineEngine`'s `snapshot.updated` event, not this hook's own fetch)\n * so a composite that only ever calls `useShareSnapshot()` still has a\n * real server stamp to compare against without also wiring the offline\n * engine's event stream. `undefined` before any response has landed. */\n readonly serverTime: string | undefined;\n}\n\nconst NON_SECTION_KEYS = new Set(['trip', 'meta']);\n\nexport function useShareSnapshot(\n token: string,\n options?: ShareSnapshotOptions,\n): ShareSnapshotResult {\n void options; // `travellerRef` narrows which subject-token rows the server\n // itself returns for a `travellerRef`-scoped share link — this hook has no\n // client-side use for it beyond passing the token through; the server does\n // the scoping (`09-registries.md §5`, `families/traveller/01-share-sections.md`, cited).\n\n const client = useKaafilClient();\n const persona = usePersona();\n const engine = useContext(OfflineEngineContext);\n const [sections, setSections] = useState<ReadonlyMap<string, unknown> | undefined>(undefined);\n const [trip, setTrip] = useState<ShareSnapshotTrip | undefined>(undefined);\n const [serverTime, setServerTime] = useState<string | undefined>(undefined);\n const [terminal, setTerminal] = useState<'expired' | 'revoked' | 'not-found' | undefined>(\n undefined,\n );\n\n useEffect(() => {\n if (persona !== 'share') {\n if (isDevelopment()) {\n throw new Error(\n 'useShareSnapshot() was called from a manager/agencyAdmin session — ' +\n 'this hook is `share`-only (08-core-hooks.md §3.1).',\n );\n }\n return;\n }\n\n let cancelled = false;\n async function load(): Promise<void> {\n try {\n const response = await client.share.snapshot({ token });\n if (cancelled) {\n return;\n }\n const map = new Map<string, unknown>();\n for (const [key, value] of Object.entries(response)) {\n if (!NON_SECTION_KEYS.has(key)) {\n map.set(key, value);\n }\n }\n setSections(map);\n setTrip(response.trip);\n setServerTime(response.meta.serverTime);\n } catch {\n // `06-capability-and-personas.md §9`: dark, cross-scope, and\n // genuinely-gone all collapse to the identical shape here — this\n // hook cannot and must not try to distinguish them, so any failure\n // to read the snapshot at all reports the same `'not-found'`.\n if (!cancelled) {\n setTerminal('not-found');\n }\n }\n }\n void load();\n\n if (engine === null) {\n return () => {\n cancelled = true;\n };\n }\n const unsubscribeExpired = engine.events.on('share.expired', () => setTerminal('expired'));\n const unsubscribeRevoked = engine.events.on('share.revoked', () => setTerminal('revoked'));\n return () => {\n cancelled = true;\n unsubscribeExpired();\n unsubscribeRevoked();\n };\n }, [client, persona, token, engine]);\n\n if (terminal !== undefined) {\n return { status: terminal, sections: sections ?? new Map(), trip, serverTime };\n }\n if (sections === undefined) {\n return { status: 'loading', sections: new Map(), trip: undefined, serverTime: undefined };\n }\n return { status: 'ready', sections, trip, serverTime };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/hooks/useShareForms.ts","../src/core/hooks/useShareSnapshot.ts"],"names":["useState","useEffect"],"mappings":";;;;;;AA6LA,SAAS,gBAAA,CACP,OACA,UAAA,EACsB;AACtB,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,OAAO,aAAa,WAAA,GAAc,SAAA;AAAA,EACpC;AACA,EAAA,OAAO,KAAA,CAAM,MAAA,KAAW,CAAA,GAAI,YAAA,GAAe,gBAAA;AAC7C;AAEA,SAAS,iBAAA,CACP,OAAA,EACA,MAAA,EACA,QAAA,EACA,QAAA,EAC+E;AAC/E,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAO,EAAE,MAAA,EAAQ,mBAAA,EAAqB,EAAA,EAAI,YAAY,MAAA,EAAO;AAAA,EAC/D;AAIA,EAAA,MAAM,MAAA,GAAS,aAAa,MAAA,GAAY,EAAE,IAAI,QAAA,EAAU,IAAA,EAAM,UAAkB,GAAI,MAAA;AACpF,EAAA,MAAM,QAAA,GACJ,WAAW,MAAA,KAAW,MAAA,GAAY,EAAE,EAAA,EAAI,MAAA,EAAQ,IAAA,EAAM,MAAA,EAAgB,GAAI,MAAA,CAAA;AAC5E,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,EAAA,EAAI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QACzB;AAAA,MACF;AAAA,IACF;AACA,IAAA,KAAK,IAAA,EAAK;AAEV,IAAA,IAAI,WAAW,IAAA,EAAM;AACnB,MAAA,OAAO,MAAM;AACX,QAAA,SAAA,GAAY,IAAA;AAAA,MACd,CAAA;AAAA,IACF;AACA,IAAA,MAAM,kBAAA,GAAqB,OAAO,MAAA,CAAO,EAAA,CAAG,iBAAiB,MAAM,WAAA,CAAY,SAAS,CAAC,CAAA;AACzF,IAAA,MAAM,kBAAA,GAAqB,OAAO,MAAA,CAAO,EAAA,CAAG,iBAAiB,MAAM,WAAA,CAAY,SAAS,CAAC,CAAA;AACzF,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,kBAAA,EAAmB;AACnB,MAAA,kBAAA,EAAmB;AAAA,IACrB,CAAA;AAAA,EACF,GAAG,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAA,EAAO,MAAM,CAAC,CAAA;AAEnC,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,EAAE,QAAQ,QAAA,EAAU,QAAA,EAAU,4BAAY,IAAI,GAAA,EAAI,EAAG,IAAA,EAAM,UAAA,EAAW;AAAA,EAC/E;AACA,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,QAAA,kBAAU,IAAI,KAAI,EAAG,IAAA,EAAM,MAAA,EAAW,UAAA,EAAY,MAAA,EAAU;AAAA,EAC1F;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,OAAA,EAAS,QAAA,EAAU,MAAM,UAAA,EAAW;AACvD","file":"chunk-EDLIJSMR.js","sourcesContent":["'use client';\n\n// `08-core-hooks.md §3` (new row — `ShareFormsSection`'s `Backed by`,\n// `ui-kit/families/traveller/02-forms.md`, cited): the write-back half of\n// the traveller share surface. `forms` is the ONLY write-back section on\n// the whole share surface; every other section is read-only through\n// `useShareSnapshot()` alone. This hook wraps the four dedicated\n// `shareAuth`-only routes `share.forms.{list,render,save,submit}`\n// (`kaafil-js/src/resources/share.ts`, verified this session).\n//\n// ── WHY THIS HOOK DOES NOT ALSO CALL `useShareSnapshot()` ──────────────────\n//\n// `02-forms.md`'s `Backed by` field says the section's own `/core` hook\n// \"composes both\" — the snapshot (for `forms` section presence) and the\n// dedicated routes (for the actual list/render/save/submit). This file\n// deliberately does NOT reproduce the snapshot fetch: `ShareFormsSection`\n// (future work, not this file) is only ever mounted once its own call to\n// `useShareSnapshot(token)` has already confirmed `sections.has('forms')`\n// (`01-share-sections.md`'s registry-driven mount rule) — duplicating that\n// fetch here would be a second, redundant read of the same snapshot for no\n// new information, and this hook has nothing to add to a presence check it\n// does not own. What this file DOES independently reproduce is\n// `useShareSnapshot()`'s own persona gate and its `share.expired`/\n// `share.revoked` subscriptions (`08-core-hooks.md §0`: \"every domain hook\n// is capability-gated internally\" — the share-surface's equivalent gate is\n// the persona check, applied the same way every other hook in this catalog\n// applies its own).\n//\n// ── SPEC TENSION FLAGGED: \"cache-first\" vs. \"the dedicated routes\" ─────────\n//\n// `02-forms.md`'s `Offline` field says the list \"rides the scoped share\n// snapshot cache-first, same as every other section\", but its own `Backed\n// by` field says in the same breath that \"the actual form list/render/\n// save/submit calls ride the dedicated forms-share routes\" — and\n// `ShareSnapshotResponse`'s per-section shape (verified,\n// `useShareSnapshot.ts`) carries no registered `forms` array with\n// `fillState`/`opensAt`/`closesAt` fields; only `ShareFormsListResponse`\n// (`GET /api/v1/share/{token}/forms`) does. This file follows the more\n// specific, SDK-verified statement — a LIVE `share.forms.list()` call,\n// refreshable on demand — the same \"own live-fetch sub-state, not a\n// `snapshot.updated` subscription\" pattern `useRooming.ts`'s\n// `unassignedPool` already uses for an analogous non-delta read. Flagged\n// for the doc owner to resolve; not silently picked one way with no trace.\n//\n// ── `clientToken` IS NOT A HOOK-MINTED IDEMPOTENCY KEY ──────────────────────\n//\n// `ShareSaveFormRequest`/`ShareSubmitFormRequest` (verified,\n// `kaafil-js/openapi/openapi.json`) require a body-level `clientToken`\n// (16-255 chars) — the SDK's own comment on `share.ts` calls it \"this\n// route's own de-dupe key, distinct from the automatic `Idempotency-Key`\n// header\", and `modules/forms/FRD.md §4.1/§8` calls it \"a fixed\n// `clientToken` generated once at enqueue and reused on every retry\" —\n// i.e. exactly the write-once, replay-unchanged lifecycle hard rule #4\n// reserves for `OfflineEngine.enqueue()`'s own internal idempotency-key\n// minting. This hook does NOT invent a value for it (that would be exactly\n// the \"hook mints its own idempotency key\" anti-pattern hard rule #4\n// forbids, even though `clientToken` is a different field from the\n// transport `Idempotency-Key` header `enqueue()` mints separately and\n// automatically for every op, share writes included). Instead\n// `ShareFormWriteInput.clientToken` is a REQUIRED field the CALLER\n// supplies — a future `ShareFormsSection`/`ShareFormFillScreen` generates\n// one value per form-fill session (e.g. once, the first time a field is\n// touched) and passes the SAME value to every `save()`/`submit()` call for\n// that session, which is what makes retries of the SAME logical write\n// dedupe wire-side. This hook only ever forwards it into the body verbatim.\n//\n// ── REVOCATION DROPS QUEUED WRITES — A REAL SDK GAP, WORKED AROUND HERE ────\n//\n// `02-forms.md`'s `Offline` field: \"Revocation is different and has no\n// grace: a `REVOKED` token drops queued writes unsent and purges the local\n// copy immediately.\" Verified against `kaafil-js/src/offline/share.ts`\n// this session: `ShareGuard.invalidate()` treats `'expired'` and\n// `'revoked'` IDENTICALLY — it purges the read snapshot in both cases and\n// only PRESERVES (never drops) the outbox either way; nothing in\n// `kaafil-js` currently distinguishes \"grace-covered\" from \"unsent, drop\n// it\" at the outbox level. This is a genuine SDK/spec disagreement — see\n// this file's final report note. Rather than leave the spec's hard\n// requirement unmet, this hook enforces it locally on `share.revoked`,\n// riding the outbox's own existing `drop()` primitive (the identical call\n// `useConflicts()`'s `'keep-current'` resolution already makes) — this is\n// composing an existing primitive in reaction to an event, not a second\n// sync engine (hard rule #3): no retry ladder, no cache, no idempotency\n// logic is reimplemented here, only \"remove this op from the outbox\".\n\nimport type { KaafilClient, OutboxOp } from 'kaafil-js/client';\nimport { SyncOpMethod } from 'kaafil-js/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { isDevelopment } from '../internal/isDevelopment';\nimport { useKaafilClient } from './useKaafilClient';\nimport { useOfflineEngine } from './useOfflineEngine';\nimport { useOfflineEvent } from './useOfflineEvent';\nimport { useOfflineMutation } from './useOfflineMutation';\nimport { usePersona } from './usePersona';\nimport { useServerTime } from './useServerTime';\n\ntype ShareFormsClient = Pick<KaafilClient, 'share'>;\n\n/** One row of `GET /api/v1/share/{token}/forms` — `ShareFormsListResponse`\n * (verified, `kaafil-js/openapi/openapi.json`). Metadata only: no prefill,\n * no field list, no answers (`FRD:traveller-share §4.8`) — that detail\n * arrives only from `renderForm()` below. */\nexport interface ShareFormListItem {\n readonly formId: string;\n readonly key: string;\n readonly title: string;\n readonly phase: string;\n readonly required: boolean;\n readonly fillState: string;\n readonly opensAt: string | null;\n readonly closesAt: string | null;\n readonly responseStatus: string | null;\n readonly submittedAt: string | null;\n}\n\n/** One answer in a `save`/`submit` body — `ShareSaveFormRequest.answers[]`\n * / `ShareSubmitFormRequest.answers[]` (verified). */\nexport interface ShareFormAnswer {\n readonly fieldKey: string;\n readonly value: unknown;\n}\n\nexport interface ShareFormWriteInput {\n readonly formId: string;\n readonly answers: readonly ShareFormAnswer[];\n /** This route's own de-dupe key — REQUIRED by the wire schema. See this\n * file's header (\"`clientToken` IS NOT A HOOK-MINTED IDEMPOTENCY KEY\") —\n * the caller mints this once per form-fill session and reuses it across\n * every save/submit/retry of that session; this hook never generates it. */\n readonly clientToken: string;\n /** Group fill within the same `TripTraveller.partyId` — omit when the\n * token itself already scopes to a single traveller. */\n readonly travellerRef?: string;\n readonly startNew?: boolean;\n readonly isAnonymous?: boolean;\n}\n\nexport type ShareFormsListStatus = 'loading' | 'list-empty' | 'list-populated' | 'not-found';\n\n/**\n * The write-side status a `save()`/`submit()` call's tracked `OutboxOp`\n * resolves to. Deliberately excludes `'filling'` (`02-forms.md`'s own\n * `States` list also names it): `'filling'` is \"the traveller is editing\n * fields, no request in flight yet\" — a pure local UI mode with no\n * server/outbox signal behind it, so it belongs to the composite that owns\n * the form's field state, never to this hook, which only ever reflects\n * something async.\n */\nexport type ShareFormsWriteStatus =\n | 'idle'\n | 'saving'\n | 'submitting'\n | 'submitted'\n | 'conflicted'\n | 'subject-required'\n | 'queued-offline'\n | 'dropped-on-revoke';\n\nexport interface ShareFormsResult {\n readonly status: ShareFormsListStatus;\n /** `[]` in both the `'loading'` and the `'list-empty'` states — a\n * consumer distinguishes them via `status`, never via array emptiness\n * alone (`02-forms.md`'s `Gating`: an empty list is a NORMAL steady\n * state, never an error, never a placeholder). */\n readonly forms: readonly ShareFormListItem[];\n readonly serverTime: string | undefined;\n /** Re-runs `share.forms.list()`. A composite calls this after a\n * `submit()` lands, since submitting can change another form's\n * `fillState` (e.g. an any-phase trigger opening a follow-up form). */\n readonly refresh: () => Promise<void>;\n /** `GET /api/v1/share/{token}/forms/{formId}` — the fully-resolved,\n * ready-to-paint form (definition merged with any in-progress answers).\n * An open shape (`ShareRenderResponse` has no closed schema yet,\n * verified) — a live call, not cached, matching `save`/`submit`'s own\n * un-cached write path. */\n readonly renderForm: (\n formId: string,\n options?: { readonly travellerRef?: string },\n ) => Promise<Record<string, unknown>>;\n /** An in-progress save — no required-field validation server-side. */\n readonly save: (input: ShareFormWriteInput) => Promise<OutboxOp>;\n /** Finalizes the response — full validation, one transaction. */\n readonly submit: (input: ShareFormWriteInput) => Promise<OutboxOp>;\n /** The combined save/submit write status — see `ShareFormsWriteStatus`. */\n readonly writeStatus: ShareFormsWriteStatus;\n /** The most recently tracked save/submit `OutboxOp`, or `undefined`\n * before either has ever been called. */\n readonly writeOp: OutboxOp | undefined;\n}\n\nfunction deriveListStatus(\n forms: readonly ShareFormListItem[] | undefined,\n listFailed: boolean,\n): ShareFormsListStatus {\n if (forms === undefined) {\n return listFailed ? 'not-found' : 'loading';\n }\n return forms.length === 0 ? 'list-empty' : 'list-populated';\n}\n\nfunction deriveWriteStatus(\n revoked: boolean,\n saveOp: OutboxOp | undefined,\n submitOp: OutboxOp | undefined,\n isOnline: boolean,\n): { readonly status: ShareFormsWriteStatus; readonly op: OutboxOp | undefined } {\n if (revoked) {\n return { status: 'dropped-on-revoke', op: submitOp ?? saveOp };\n }\n // `submit` always takes precedence when both are in play — finishing a\n // submission is the more advanced, more important-to-surface state of\n // the two for the same form.\n const active = submitOp !== undefined ? { op: submitOp, kind: 'submit' as const } : undefined;\n const fallback =\n active ?? (saveOp !== undefined ? { op: saveOp, kind: 'save' as const } : undefined);\n if (fallback === undefined) {\n return { status: 'idle', op: undefined };\n }\n const { op, kind } = fallback;\n if (op.status === 'parked') {\n if (op.parkReason?.code === 'CONFLICT_VERSION') {\n return { status: 'conflicted', op };\n }\n if (op.parkReason?.code === 'SUBJECT_REQUIRED') {\n return { status: 'subject-required', op };\n }\n // Any other park reason (e.g. `ShareWriteGraceExpired` —\n // `kaafil-js/src/offline/share.ts`, a grace window that closed before\n // this op ever synced) reports the same as a still-queued offline\n // write: the honest \"still catching up\" framing until it is provably\n // gone (`02-forms.md`'s `Offline` field). A distinct terminal wording\n // for that specific park reason is `ShareFormsSection`'s own\n // presentation concern, not this hook's.\n return { status: 'queued-offline', op };\n }\n if (op.status === 'done') {\n return { status: kind === 'submit' ? 'submitted' : 'idle', op };\n }\n // pending or inflight.\n if (!isOnline) {\n return { status: 'queued-offline', op };\n }\n return { status: kind === 'submit' ? 'submitting' : 'saving', op };\n}\n\nexport function useShareForms(token: string): ShareFormsResult {\n const client = useKaafilClient() as ShareFormsClient;\n const persona = usePersona();\n const engine = useOfflineEngine();\n const { now, sinceLastSync } = useServerTime();\n // `now()` throws before this session's first `snapshot.updated` event —\n // see `useServerTime.ts`'s own \"CALLERS: guard the call site\" note. This\n // hook's writes stay legal without a stamp (see the `enqueuedAt` call\n // sites below), so the guard is \"can I use it\", never \"must I have it\".\n const serverTimeKnown = sinceLastSync !== undefined;\n\n const [forms, setForms] = useState<readonly ShareFormListItem[] | undefined>(undefined);\n const [serverTime, setServerTime] = useState<string | undefined>(undefined);\n const [listFailed, setListFailed] = useState(false);\n const [revoked, setRevoked] = useState(false);\n const [isOnline, setIsOnline] = useState(\n () => typeof navigator === 'undefined' || navigator.onLine,\n );\n\n const fetchList = useCallback(async (): Promise<void> => {\n try {\n const response = await client.share.forms.list({ token });\n setForms(response.items);\n setServerTime(response.meta.serverTime);\n setListFailed(false);\n } catch {\n // `GET .../forms` only ever fails `RESOURCE_NOT_FOUND` (`FRD:\n // traveller-share §4.1`'s route table, verified) — the share 404\n // carve-out means dark/cross-scope/genuinely-gone collapse to one\n // shape, same reasoning `useShareSnapshot()` applies to its own read.\n setListFailed(true);\n }\n }, [client, token]);\n\n useEffect(() => {\n if (persona !== 'share') {\n if (isDevelopment()) {\n throw new Error(\n 'useShareForms() was called from a manager/agencyAdmin session — ' +\n 'this hook is `share`-only (families/traveller/02-forms.md, `ShareFormsSection`).',\n );\n }\n return;\n }\n void fetchList();\n }, [persona, fetchList]);\n\n // A browser-level connectivity signal, same source `useOutboxStatus()`\n // reads (`kaafil-js`'s `OfflineEngine` exposes no queryable connectivity\n // flag of its own — see that hook's own header, verified again here).\n useEffect(() => {\n if (typeof window === 'undefined') {\n return;\n }\n const handleOnline = (): void => setIsOnline(true);\n const handleOffline = (): void => setIsOnline(false);\n window.addEventListener('online', handleOnline);\n window.addEventListener('offline', handleOffline);\n return () => {\n window.removeEventListener('online', handleOnline);\n window.removeEventListener('offline', handleOffline);\n };\n }, []);\n\n useOfflineEvent('share.revoked', () => {\n setRevoked(true);\n // See this file's header (\"REVOCATION DROPS QUEUED WRITES\"). Only this\n // token's own lane, and only ops still in play (a `'done'` op already\n // landed and has nothing left to drop).\n for (const op of engine.outbox.all()) {\n if (op.tripRef === token && (op.status === 'pending' || op.status === 'parked')) {\n void engine.outbox.drop(op.id);\n }\n }\n });\n\n const saveMutation = useOfflineMutation<ShareFormWriteInput>({\n tripRef: token,\n enqueue: (mutationEngine, input) => {\n const query =\n input.travellerRef !== undefined\n ? `?travellerRef=${encodeURIComponent(input.travellerRef)}`\n : '';\n return mutationEngine.enqueue({\n tripRef: token,\n method: SyncOpMethod.Post,\n path: `/api/v1/share/${token}/forms/${input.formId}/save${query}`,\n // Hardcoded literal, not imported: `OperationId` is not exported\n // from `kaafil-js/client`'s public surface (same reasoning\n // `useRooming.ts` documents). Value verified against\n // `kaafil-js/src/generated/security.ts` this session:\n // `OperationId.ShareSaveForm === 'shareSaveForm'`.\n operationId: 'shareSaveForm' as never,\n body: {\n answers: input.answers,\n clientToken: input.clientToken,\n ...(input.startNew !== undefined ? { startNew: input.startNew } : {}),\n ...(input.isAnonymous !== undefined ? { isAnonymous: input.isAnonymous } : {}),\n },\n // The server-anchored \"now\" this write was created at — never\n // `Date.now()`/`new Date()` (hard rule #6) — `EnqueueWriteOptions\n // .enqueuedAt`'s own doc comment: \"client-attested and only ever\n // used by the server to REFUSE\" (the 7-day post-expiry grace\n // check). Optional on the wire, and genuinely omitted here on a\n // cold session: `useServerTime().now()` throws before this\n // session's very first `snapshot.updated` event has landed (its\n // own documented behaviour, guarded at the call site exactly as\n // its header instructs) — a share write attempted in that narrow\n // window still enqueues durably, just without a client-attested\n // stamp for the server's grace check to read.\n ...(serverTimeKnown ? { enqueuedAt: now() } : {}),\n });\n },\n });\n\n const submitMutation = useOfflineMutation<ShareFormWriteInput>({\n tripRef: token,\n enqueue: (mutationEngine, input) => {\n const query =\n input.travellerRef !== undefined\n ? `?travellerRef=${encodeURIComponent(input.travellerRef)}`\n : '';\n return mutationEngine.enqueue({\n tripRef: token,\n method: SyncOpMethod.Post,\n path: `/api/v1/share/${token}/forms/${input.formId}/submit${query}`,\n operationId: 'shareSubmitForm' as never,\n body: {\n answers: input.answers,\n clientToken: input.clientToken,\n ...(input.startNew !== undefined ? { startNew: input.startNew } : {}),\n ...(input.isAnonymous !== undefined ? { isAnonymous: input.isAnonymous } : {}),\n },\n // See the identical `save` enqueue above for why this is guarded.\n ...(serverTimeKnown ? { enqueuedAt: now() } : {}),\n });\n },\n });\n\n const renderForm = useCallback(\n async (\n formId: string,\n options?: { readonly travellerRef?: string },\n ): Promise<Record<string, unknown>> => {\n const response = await client.share.forms.render({\n token,\n formId,\n ...(options?.travellerRef !== undefined ? { travellerRef: options.travellerRef } : {}),\n });\n return response;\n },\n [client, token],\n );\n\n const { status: writeStatus, op: writeOp } = deriveWriteStatus(\n revoked,\n saveMutation.op,\n submitMutation.op,\n isOnline,\n );\n\n return {\n status: deriveListStatus(forms, listFailed),\n forms: forms ?? [],\n serverTime,\n refresh: fetchList,\n renderForm,\n save: saveMutation.mutate,\n submit: submitMutation.mutate,\n writeStatus,\n writeOp,\n };\n}\n","'use client';\n\n// `08-core-hooks.md §3.1`. The single assembled read behind the whole\n// traveller share surface. Wraps `share.snapshot()` (verified `shareAuth`\n// -only in `security.ts` — no `apiKeyAuth` alternative exists for any\n// `share.*` operation), read cache-first from the snapshot once\n// `OfflineEngine`'s `share` option is configured.\n//\n// VERIFIED SHAPE (`openapi/openapi.json`'s `ShareSnapshotResponse`, this\n// session): a flat object with one property PER section key, each present\n// only when the link exposes it and data exists — never `null`, never an\n// empty placeholder — plus a `trip` echo (`name`/`startDate`/`endDate`/\n// `timezone`/`phase`) that is NOT one of the thirteen section flags\n// (`09-registries.md §5`). This hook builds `sections` by taking every own\n// key off the response except `trip` and `meta` — additive-safe against a\n// future 14th section key without needing this file to enumerate all\n// thirteen by name.\n//\n// `trip` and the server clock are surfaced as their OWN top-level fields on\n// `ShareSnapshotResult`, never folded into `sections`: every consumer of\n// `sections` (starting with `KaafilShareView`, which walks the map and\n// renders one composite per key) treats \"is this key present\" as \"should I\n// render a section for it\" — letting `trip`/`meta` leak into that map would\n// make the view try to mount a `<ShareTripSection>`/`<ShareMetaSection>`\n// that has never existed. But every traveller composite still needs BOTH:\n// `trip.timezone` is the one zone `DateDisplay`/`TimeDisplay` may legally\n// anchor to on this surface (never the device zone, never a fabricated\n// `'UTC'`), `trip.phase` lets a composite react to PRE_DEPARTURE/ON_TRIP/\n// POST_TRIP, and `meta.serverTime` is the only trusted \"now\" a share\n// composite may read without going through `useServerTime()` (hard rule\n// #6 — no `Date.now()`/`new Date()` in `src/core`). Hence: two extra return\n// fields, kept structurally apart from the section map they must never\n// pollute.\n\nimport type { KaafilClient } from 'kaafil-js/client';\nimport { useContext, useEffect, useState } from 'react';\nimport { OfflineEngineContext } from '../internal/contexts';\nimport { isDevelopment } from '../internal/isDevelopment';\nimport { useKaafilClient } from './useKaafilClient';\nimport { usePersona } from './usePersona';\n\nexport interface ShareSnapshotOptions {\n readonly travellerRef?: string;\n}\n\n// Derived from the SDK's own return type rather than hand-copied — this\n// stays correct for free if `kaafil-js` grows another `trip` field, instead\n// of silently drifting the way the old `'UTC'` constants did.\ntype ShareSnapshotResponse = Awaited<ReturnType<KaafilClient['share']['snapshot']>>;\n\n/** The trip echo every snapshot response carries — `name`/`startDate`/\n * `endDate` plus the two fields this hook used to throw away:\n * `timezone` (the IANA zone every traveller-facing render must anchor to)\n * and `phase` (server-computed `PRE_DEPARTURE`/`ON_TRIP`/`POST_TRIP`). */\nexport type ShareSnapshotTrip = ShareSnapshotResponse['trip'];\n\nexport interface ShareSnapshotResult {\n readonly status: 'loading' | 'ready' | 'expired' | 'revoked' | 'not-found';\n readonly sections: ReadonlyMap<string, unknown>;\n /** The snapshot's `trip` echo, or `undefined` before any response has\n * landed (mirrors `sections`' own \"empty until ready\" behaviour). NEVER a\n * section key — see this file's header. */\n readonly trip: ShareSnapshotTrip | undefined;\n /** `meta.serverTime` off the most recently landed snapshot response — the\n * only trusted clock a share composite may read (hard rule #6). Kept\n * separate from `useServerTime()`'s own stream (which advances off\n * `OfflineEngine`'s `snapshot.updated` event, not this hook's own fetch)\n * so a composite that only ever calls `useShareSnapshot()` still has a\n * real server stamp to compare against without also wiring the offline\n * engine's event stream. `undefined` before any response has landed. */\n readonly serverTime: string | undefined;\n}\n\nconst NON_SECTION_KEYS = new Set(['trip', 'meta']);\n\nexport function useShareSnapshot(\n token: string,\n options?: ShareSnapshotOptions,\n): ShareSnapshotResult {\n void options; // `travellerRef` narrows which subject-token rows the server\n // itself returns for a `travellerRef`-scoped share link — this hook has no\n // client-side use for it beyond passing the token through; the server does\n // the scoping (`09-registries.md §5`, `families/traveller/01-share-sections.md`, cited).\n\n const client = useKaafilClient();\n const persona = usePersona();\n const engine = useContext(OfflineEngineContext);\n const [sections, setSections] = useState<ReadonlyMap<string, unknown> | undefined>(undefined);\n const [trip, setTrip] = useState<ShareSnapshotTrip | undefined>(undefined);\n const [serverTime, setServerTime] = useState<string | undefined>(undefined);\n const [terminal, setTerminal] = useState<'expired' | 'revoked' | 'not-found' | undefined>(\n undefined,\n );\n\n useEffect(() => {\n if (persona !== 'share') {\n if (isDevelopment()) {\n throw new Error(\n 'useShareSnapshot() was called from a manager/agencyAdmin session — ' +\n 'this hook is `share`-only (08-core-hooks.md §3.1).',\n );\n }\n return;\n }\n\n let cancelled = false;\n async function load(): Promise<void> {\n try {\n const response = await client.share.snapshot({ token });\n if (cancelled) {\n return;\n }\n const map = new Map<string, unknown>();\n for (const [key, value] of Object.entries(response)) {\n if (!NON_SECTION_KEYS.has(key)) {\n map.set(key, value);\n }\n }\n setSections(map);\n setTrip(response.trip);\n setServerTime(response.meta.serverTime);\n } catch {\n // `06-capability-and-personas.md §9`: dark, cross-scope, and\n // genuinely-gone all collapse to the identical shape here — this\n // hook cannot and must not try to distinguish them, so any failure\n // to read the snapshot at all reports the same `'not-found'`.\n if (!cancelled) {\n setTerminal('not-found');\n }\n }\n }\n void load();\n\n if (engine === null) {\n return () => {\n cancelled = true;\n };\n }\n const unsubscribeExpired = engine.events.on('share.expired', () => setTerminal('expired'));\n const unsubscribeRevoked = engine.events.on('share.revoked', () => setTerminal('revoked'));\n return () => {\n cancelled = true;\n unsubscribeExpired();\n unsubscribeRevoked();\n };\n }, [client, persona, token, engine]);\n\n if (terminal !== undefined) {\n return { status: terminal, sections: sections ?? new Map(), trip, serverTime };\n }\n if (sections === undefined) {\n return { status: 'loading', sections: new Map(), trip: undefined, serverTime: undefined };\n }\n return { status: 'ready', sections, trip, serverTime };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OfflineEngineContext } from './chunk-
|
|
1
|
+
import { OfflineEngineContext } from './chunk-6FUVFVYY.js';
|
|
2
2
|
import { useContext, useState, useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
var TICK_INTERVAL_MS = 1e3;
|
|
@@ -37,5 +37,5 @@ function useServerTime() {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export { useServerTime };
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-ITGVRN2S.js.map
|
|
41
|
+
//# sourceMappingURL=chunk-ITGVRN2S.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/hooks/useServerTime.ts"],"names":[],"mappings":";;;AA8BA,IAAM,gBAAA,GAAmB,GAAA;AAElB,SAAS,aAAA,GAA+B;AAC7C,EAAA,MAAM,MAAA,GAAS,WAAW,oBAAoB,CAAA;AAC9C,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAA6B,MAAS,CAAA;AAClF,EAAA,MAAM,iBAAA,GAAoB,OAA2B,MAAS,CAAA;AAC9D,EAAA,MAAM,GAAG,SAAS,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,WAAW,IAAA,EAAM;AACnB,MAAA;AAAA,IACF;AAKA,IAAA,MAAM,cAAc,MAAA,CAAO,MAAA,CAAO,EAAA,CAAG,kBAAA,EAAoB,CAAC,KAAA,KAAU;AASlE,MAAA,IAAI,KAAA,CAAM,eAAe,MAAA,EAAW;AAClC,QAAA;AAAA,MACF;AACA,MAAA,iBAAA,CAA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MAAM;AACd,IAAA,IAAI,WAAW,IAAA,EAAM;AACnB,MAAA;AAAA,IACF;AAKA,IAAA,MAAM,cAAc,MAAA,CAAO,MAAA,CAAO,EAAA,CAAG,kBAAA,EAAoB,CAAC,KAAA,KAAU;AASlE,MAAA,IAAI,KAAA,CAAM,eAAe,MAAA,EAAW;AAClC,QAAA;AAAA,MACF;AACA,MAAA,iBAAA,CAAkB,OAAA,GAAU,YAAY,GAAA,EAAI;AAC5C,MAAA,iBAAA,CAAkB,MAAM,UAAU,CAAA;AAAA,IACpC,CAAC,CAAA;AACD,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,EAAA,GAAK,YAAY,MAAM,SAAA,CAAU,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA,EAAG,gBAAgB,CAAA;AAC5E,IAAA,OAAO,MAAM,cAAc,EAAE,CAAA;AAAA,EAC/B,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAS,GAAA,GAAc;AACrB,IAAA,IAAI,cAAA,KAAmB,MAAA,IAAa,iBAAA,CAAkB,OAAA,KAAY,MAAA,EAAW;AAY3E,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OAEF;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,WAAA,CAAY,GAAA,EAAI,GAAI,iBAAA,CAAkB,OAAA;AACxD,IAAA,OAAO,IAAI,KAAK,IAAA,CAAK,KAAA,CAAM,cAAc,CAAA,GAAI,SAAS,EAAE,WAAA,EAAY;AAAA,EACtE;AAEA,EAAA,OAAO,EAAE,GAAA,EAAK,aAAA,EAAe,cAAA,EAAe;AAC9C","file":"chunk-ITGVRN2S.js","sourcesContent":["'use client';\n\n// `08-core-hooks.md §1.6`. The single place that turns the stream of\n// `meta.serverTime` stamps into a usable clock, so no composite reads\n// `meta.serverTime` off an individual response by hand.\n//\n// Hard rule #6 (\"Zero `Date.now()`/`new Date()` local getters in\n// `src/core`\") bans exactly the two calls that fabricate \"now\" from the\n// local wall clock: `Date.now()` and no-argument `new Date()`. This file\n// never calls either. Advancing a SERVER-supplied timestamp by an elapsed\n// delta necessarily needs SOME measure of \"how much local time passed\" —\n// this file measures that with `performance.now()`, a monotonic clock with\n// no relationship to wall-clock \"now\" (it cannot be read as a date, only as\n// a duration), and applies the delta with `new Date(<epoch-ms>)` /\n// `Date.parse(<iso-string>)` — both single-argument forms that operate on a\n// value already anchored to `meta.serverTime`, never on the local clock.\n\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport { OfflineEngineContext } from '../internal/contexts';\n\nexport interface ServerTimeApi {\n now: () => string;\n sinceLastSync: string | undefined;\n}\n\n/** Re-renders any hook consumer often enough for a mounted countdown to look\n * live, without pretending the underlying value moved forward on its own\n * merits (`08-core-hooks.md §1.6`'s sandbox time-travel caveat: this timer\n * forces a re-render, it never advances the stamp past what the last real\n * response justified). */\nconst TICK_INTERVAL_MS = 1000;\n\nexport function useServerTime(): ServerTimeApi {\n const engine = useContext(OfflineEngineContext);\n const [lastServerTime, setLastServerTime] = useState<string | undefined>(undefined);\n const observedAtPerfRef = useRef<number | undefined>(undefined);\n const [, forceTick] = useState(0);\n\n useEffect(() => {\n if (engine === null) {\n return;\n }\n // `snapshot.updated` is the one event in `OfflineEventMap` that carries\n // `serverTime` (`kaafil-js/src/offline/events.ts`, verified this\n // session) — the engine's other five events do not, so this is the only\n // subscription this hook can build without inventing a stamp.\n const unsubscribe = engine.events.on('snapshot.updated', (event) => {\n // `serverTime` is ABSENT on a change that never involved the server —\n // an optimistic create painted while offline, or an op the host\n // discarded (`kaafil-js/src/offline/events.ts`). Those are real snapshot\n // changes and a list must repaint for them, but they carry no reading,\n // and taking `undefined` here would erase the last real one this\n // session had: `now()` would start throwing again mid-session, on a\n // device that HAS heard from the server, because the manager ticked\n // something off out of signal.\n if (event.serverTime === undefined) {\n return;\n }\n observedAtPerfRef.current = performance.now();\n setLastServerTime(event.serverTime);\n });\n return unsubscribe;\n }, [engine]);\n\n useEffect(() => {\n const id = setInterval(() => forceTick((tick) => tick + 1), TICK_INTERVAL_MS);\n return () => clearInterval(id);\n }, []);\n\n function now(): string {\n if (lastServerTime === undefined || observedAtPerfRef.current === undefined) {\n // No response has ever landed in this session yet. Fabricating a\n // value from the local wall clock is exactly what hard rule #6\n // forbids — this is the one case this hook cannot silently satisfy\n // its own non-optional return type, so it says so loudly instead.\n // CALLERS: this is a real, expected window — React runs an effect\n // (which is how this hook's own subscription above starts) strictly\n // AFTER the render that needs `now()`'s result has already committed,\n // so a component's very FIRST render can hit this throw even when\n // wired up correctly. Guard the call site, matching\n // `useStaleness.ts`'s own precedent, rather than reaching for a\n // device-clock fallback here (hard rule #6 forbids exactly that).\n throw new Error(\n 'useServerTime().now() was called before any response carrying meta.serverTime ' +\n 'had been observed — there is no server timestamp yet to advance from.',\n );\n }\n const elapsedMs = performance.now() - observedAtPerfRef.current;\n return new Date(Date.parse(lastServerTime) + elapsedMs).toISOString();\n }\n\n return { now, sinceLastSync: lastServerTime };\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCK3L6Y43_cjs = require('./chunk-CK3L6Y43.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
|
|
6
6
|
var TICK_INTERVAL_MS = 1e3;
|
|
7
7
|
function useServerTime() {
|
|
8
|
-
const engine = react.useContext(
|
|
8
|
+
const engine = react.useContext(chunkCK3L6Y43_cjs.OfflineEngineContext);
|
|
9
9
|
const [lastServerTime, setLastServerTime] = react.useState(void 0);
|
|
10
10
|
const observedAtPerfRef = react.useRef(void 0);
|
|
11
11
|
const [, forceTick] = react.useState(0);
|
|
@@ -39,5 +39,5 @@ function useServerTime() {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
exports.useServerTime = useServerTime;
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-LO3GQFQ6.cjs.map
|
|
43
|
+
//# sourceMappingURL=chunk-LO3GQFQ6.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/hooks/useServerTime.ts"],"names":["useContext","OfflineEngineContext","useState","useRef","useEffect"],"mappings":";;;;;AA8BA,IAAM,gBAAA,GAAmB,GAAA;AAElB,SAAS,aAAA,GAA+B;AAC7C,EAAA,MAAM,MAAA,GAASA,iBAAWC,sCAAoB,CAAA;AAC9C,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAIC,eAA6B,MAAS,CAAA;AAClF,EAAA,MAAM,iBAAA,GAAoBC,aAA2B,MAAS,CAAA;AAC9D,EAAA,MAAM,GAAG,SAAS,CAAA,GAAID,eAAS,CAAC,CAAA;AAEhC,EAAAE,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,WAAW,IAAA,EAAM;AACnB,MAAA;AAAA,IACF;AAKA,IAAA,MAAM,cAAc,MAAA,CAAO,MAAA,CAAO,EAAA,CAAG,kBAAA,EAAoB,CAAC,KAAA,KAAU;AASlE,MAAA,IAAI,KAAA,CAAM,eAAe,MAAA,EAAW;AAClC,QAAA;AAAA,MACF;AACA,MAAA,iBAAA,CAAkB,OAAA,GAAU,YAAY,GAAA,EAAI;AAC5C,MAAA,iBAAA,CAAkB,MAAM,UAAU,CAAA;AAAA,IACpC,CAAC,CAAA;AACD,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,EAAA,GAAK,YAAY,MAAM,SAAA,CAAU,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA,EAAG,gBAAgB,CAAA;AAC5E,IAAA,OAAO,MAAM,cAAc,EAAE,CAAA;AAAA,EAC/B,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAS,GAAA,GAAc;AACrB,IAAA,IAAI,cAAA,KAAmB,MAAA,IAAa,iBAAA,CAAkB,OAAA,KAAY,MAAA,EAAW;AAY3E,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OAEF;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,WAAA,CAAY,GAAA,EAAI,GAAI,iBAAA,CAAkB,OAAA;AACxD,IAAA,OAAO,IAAI,KAAK,IAAA,CAAK,KAAA,CAAM,cAAc,CAAA,GAAI,SAAS,EAAE,WAAA,EAAY;AAAA,EACtE;AAEA,EAAA,OAAO,EAAE,GAAA,EAAK,aAAA,EAAe,cAAA,EAAe;AAC9C","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/core/hooks/useServerTime.ts"],"names":["useContext","OfflineEngineContext","useState","useRef","useEffect"],"mappings":";;;;;AA8BA,IAAM,gBAAA,GAAmB,GAAA;AAElB,SAAS,aAAA,GAA+B;AAC7C,EAAA,MAAM,MAAA,GAASA,iBAAWC,sCAAoB,CAAA;AAC9C,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAIC,eAA6B,MAAS,CAAA;AAClF,EAAA,MAAM,iBAAA,GAAoBC,aAA2B,MAAS,CAAA;AAC9D,EAAA,MAAM,GAAG,SAAS,CAAA,GAAID,eAAS,CAAC,CAAA;AAEhC,EAAAE,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,WAAW,IAAA,EAAM;AACnB,MAAA;AAAA,IACF;AAKA,IAAA,MAAM,cAAc,MAAA,CAAO,MAAA,CAAO,EAAA,CAAG,kBAAA,EAAoB,CAAC,KAAA,KAAU;AASlE,MAAA,IAAI,KAAA,CAAM,eAAe,MAAA,EAAW;AAClC,QAAA;AAAA,MACF;AACA,MAAA,iBAAA,CAAkB,OAAA,GAAU,YAAY,GAAA,EAAI;AAC5C,MAAA,iBAAA,CAAkB,MAAM,UAAU,CAAA;AAAA,IACpC,CAAC,CAAA;AACD,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,EAAA,GAAK,YAAY,MAAM,SAAA,CAAU,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA,EAAG,gBAAgB,CAAA;AAC5E,IAAA,OAAO,MAAM,cAAc,EAAE,CAAA;AAAA,EAC/B,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAS,GAAA,GAAc;AACrB,IAAA,IAAI,cAAA,KAAmB,MAAA,IAAa,iBAAA,CAAkB,OAAA,KAAY,MAAA,EAAW;AAY3E,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OAEF;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,WAAA,CAAY,GAAA,EAAI,GAAI,iBAAA,CAAkB,OAAA;AACxD,IAAA,OAAO,IAAI,KAAK,IAAA,CAAK,KAAA,CAAM,cAAc,CAAA,GAAI,SAAS,EAAE,WAAA,EAAY;AAAA,EACtE;AAEA,EAAA,OAAO,EAAE,GAAA,EAAK,aAAA,EAAe,cAAA,EAAe;AAC9C","file":"chunk-LO3GQFQ6.cjs","sourcesContent":["'use client';\n\n// `08-core-hooks.md §1.6`. The single place that turns the stream of\n// `meta.serverTime` stamps into a usable clock, so no composite reads\n// `meta.serverTime` off an individual response by hand.\n//\n// Hard rule #6 (\"Zero `Date.now()`/`new Date()` local getters in\n// `src/core`\") bans exactly the two calls that fabricate \"now\" from the\n// local wall clock: `Date.now()` and no-argument `new Date()`. This file\n// never calls either. Advancing a SERVER-supplied timestamp by an elapsed\n// delta necessarily needs SOME measure of \"how much local time passed\" —\n// this file measures that with `performance.now()`, a monotonic clock with\n// no relationship to wall-clock \"now\" (it cannot be read as a date, only as\n// a duration), and applies the delta with `new Date(<epoch-ms>)` /\n// `Date.parse(<iso-string>)` — both single-argument forms that operate on a\n// value already anchored to `meta.serverTime`, never on the local clock.\n\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport { OfflineEngineContext } from '../internal/contexts';\n\nexport interface ServerTimeApi {\n now: () => string;\n sinceLastSync: string | undefined;\n}\n\n/** Re-renders any hook consumer often enough for a mounted countdown to look\n * live, without pretending the underlying value moved forward on its own\n * merits (`08-core-hooks.md §1.6`'s sandbox time-travel caveat: this timer\n * forces a re-render, it never advances the stamp past what the last real\n * response justified). */\nconst TICK_INTERVAL_MS = 1000;\n\nexport function useServerTime(): ServerTimeApi {\n const engine = useContext(OfflineEngineContext);\n const [lastServerTime, setLastServerTime] = useState<string | undefined>(undefined);\n const observedAtPerfRef = useRef<number | undefined>(undefined);\n const [, forceTick] = useState(0);\n\n useEffect(() => {\n if (engine === null) {\n return;\n }\n // `snapshot.updated` is the one event in `OfflineEventMap` that carries\n // `serverTime` (`kaafil-js/src/offline/events.ts`, verified this\n // session) — the engine's other five events do not, so this is the only\n // subscription this hook can build without inventing a stamp.\n const unsubscribe = engine.events.on('snapshot.updated', (event) => {\n // `serverTime` is ABSENT on a change that never involved the server —\n // an optimistic create painted while offline, or an op the host\n // discarded (`kaafil-js/src/offline/events.ts`). Those are real snapshot\n // changes and a list must repaint for them, but they carry no reading,\n // and taking `undefined` here would erase the last real one this\n // session had: `now()` would start throwing again mid-session, on a\n // device that HAS heard from the server, because the manager ticked\n // something off out of signal.\n if (event.serverTime === undefined) {\n return;\n }\n observedAtPerfRef.current = performance.now();\n setLastServerTime(event.serverTime);\n });\n return unsubscribe;\n }, [engine]);\n\n useEffect(() => {\n const id = setInterval(() => forceTick((tick) => tick + 1), TICK_INTERVAL_MS);\n return () => clearInterval(id);\n }, []);\n\n function now(): string {\n if (lastServerTime === undefined || observedAtPerfRef.current === undefined) {\n // No response has ever landed in this session yet. Fabricating a\n // value from the local wall clock is exactly what hard rule #6\n // forbids — this is the one case this hook cannot silently satisfy\n // its own non-optional return type, so it says so loudly instead.\n // CALLERS: this is a real, expected window — React runs an effect\n // (which is how this hook's own subscription above starts) strictly\n // AFTER the render that needs `now()`'s result has already committed,\n // so a component's very FIRST render can hit this throw even when\n // wired up correctly. Guard the call site, matching\n // `useStaleness.ts`'s own precedent, rather than reaching for a\n // device-clock fallback here (hard rule #6 forbids exactly that).\n throw new Error(\n 'useServerTime().now() was called before any response carrying meta.serverTime ' +\n 'had been observed — there is no server timestamp yet to advance from.',\n );\n }\n const elapsedMs = performance.now() - observedAtPerfRef.current;\n return new Date(Date.parse(lastServerTime) + elapsedMs).toISOString();\n }\n\n return { now, sinceLastSync: lastServerTime };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCK3L6Y43_cjs = require('./chunk-CK3L6Y43.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
|
|
@@ -103,7 +103,7 @@ function SystemScreenFrame({
|
|
|
103
103
|
icon,
|
|
104
104
|
style
|
|
105
105
|
}) {
|
|
106
|
-
const persona =
|
|
106
|
+
const persona = chunkCK3L6Y43_cjs.usePersona();
|
|
107
107
|
const headingRef = react.useRef(null);
|
|
108
108
|
const headingId = react.useId();
|
|
109
109
|
const layout = persona === "manager" ? "takeover" : "contained";
|
|
@@ -116,7 +116,7 @@ function SystemScreenFrame({
|
|
|
116
116
|
className: "kf-system-screen",
|
|
117
117
|
"data-block": block,
|
|
118
118
|
"data-layout": layout,
|
|
119
|
-
style:
|
|
119
|
+
style: chunkCK3L6Y43_cjs.tokenStyle(style),
|
|
120
120
|
role: "status",
|
|
121
121
|
"aria-live": "polite",
|
|
122
122
|
"aria-labelledby": headingId,
|
|
@@ -137,7 +137,7 @@ function LockedTripScreen({
|
|
|
137
137
|
components,
|
|
138
138
|
style
|
|
139
139
|
}) {
|
|
140
|
-
const { t } =
|
|
140
|
+
const { t } = chunkCK3L6Y43_cjs.useKaafilChrome();
|
|
141
141
|
const Override = components?.LockedTripScreenUI;
|
|
142
142
|
if (Override !== void 0) return /* @__PURE__ */ jsxRuntime.jsx(Override, {});
|
|
143
143
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -161,7 +161,7 @@ function LockedTripScreen({
|
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
function NotFoundScreen({ onGoBack, components, style }) {
|
|
164
|
-
const { t } =
|
|
164
|
+
const { t } = chunkCK3L6Y43_cjs.useKaafilChrome();
|
|
165
165
|
const Override = components?.NotFoundScreenUI;
|
|
166
166
|
if (Override !== void 0) return /* @__PURE__ */ jsxRuntime.jsx(Override, {});
|
|
167
167
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -182,8 +182,8 @@ function OfflineFallbackScreen({
|
|
|
182
182
|
components,
|
|
183
183
|
style
|
|
184
184
|
}) {
|
|
185
|
-
const { t } =
|
|
186
|
-
const { isOnline } =
|
|
185
|
+
const { t } = chunkCK3L6Y43_cjs.useKaafilChrome();
|
|
186
|
+
const { isOnline } = chunkCK3L6Y43_cjs.useOutboxStatus();
|
|
187
187
|
const Override = components?.OfflineFallbackScreenUI;
|
|
188
188
|
if (Override !== void 0) return /* @__PURE__ */ jsxRuntime.jsx(Override, {});
|
|
189
189
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -209,8 +209,8 @@ function PlanLockedScreen({
|
|
|
209
209
|
components,
|
|
210
210
|
style
|
|
211
211
|
}) {
|
|
212
|
-
const { t } =
|
|
213
|
-
const capabilities =
|
|
212
|
+
const { t } = chunkCK3L6Y43_cjs.useKaafilChrome();
|
|
213
|
+
const capabilities = chunkCK3L6Y43_cjs.useCapabilities([capabilityKey]);
|
|
214
214
|
const Override = components?.PlanLockedScreenUI;
|
|
215
215
|
if (Override !== void 0) return /* @__PURE__ */ jsxRuntime.jsx(Override, {});
|
|
216
216
|
const status = capabilities.get(capabilityKey)?.status;
|
|
@@ -244,7 +244,7 @@ function SessionExpiredScreen({
|
|
|
244
244
|
components,
|
|
245
245
|
style
|
|
246
246
|
}) {
|
|
247
|
-
const { t } =
|
|
247
|
+
const { t } = chunkCK3L6Y43_cjs.useKaafilChrome();
|
|
248
248
|
const [pending, setPending] = react.useState(false);
|
|
249
249
|
const [failure, setFailure] = react.useState(void 0);
|
|
250
250
|
const Override = components?.SessionExpiredScreenUI;
|
|
@@ -290,5 +290,5 @@ exports.NotFoundScreen = NotFoundScreen;
|
|
|
290
290
|
exports.OfflineFallbackScreen = OfflineFallbackScreen;
|
|
291
291
|
exports.PlanLockedScreen = PlanLockedScreen;
|
|
292
292
|
exports.SessionExpiredScreen = SessionExpiredScreen;
|
|
293
|
-
//# sourceMappingURL=chunk-
|
|
294
|
-
//# sourceMappingURL=chunk-
|
|
293
|
+
//# sourceMappingURL=chunk-QD4Z5DRT.cjs.map
|
|
294
|
+
//# sourceMappingURL=chunk-QD4Z5DRT.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/system-screens/BootErrorScreen.tsx","../src/shared/system-screens/internal/SystemScreenFrame.tsx","../src/shared/system-screens/LockedTripScreen.tsx","../src/shared/system-screens/NotFoundScreen.tsx","../src/shared/system-screens/OfflineFallbackScreen.tsx","../src/shared/system-screens/PlanLockedScreen.tsx","../src/shared/system-screens/SessionExpiredScreen.tsx"],"names":["useState","jsx","jsxs","usePersona","useRef","useId","useEffect","tokenStyle","useKaafilChrome","useOutboxStatus","Fragment","useCapabilities"],"mappings":";;;;;;AAgEA,IAAM,IAAA,GAAkD;AAAA,EACtD,cAAA,EACE,yFAAA;AAAA,EACF,mBAAA,EACE,sFAAA;AAAA,EACF,kBAAA,EAAoB,+EAAA;AAAA,EACpB,YAAA,EAAc,2EAAA;AAAA,EACd,IAAA,EAAM,gGAAA;AAAA,EACN,OAAA,EAAS;AACX,CAAA;AAEA,IAAM,KAAA,GAAuB;AAAA,EAC3B,SAAA,EAAW,YAAA;AAAA,EACX,aAAA,EAAe,OAAA;AAAA,EACf,YAAA,EAAc,MAAA;AAAA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AA;AAAA,UACV,QAAA,EAAU,OAAA;AAAA,UACV,OAAA,EAAS,MAAM,KAAK,cAAA,EAAe;AAAA,UAElC,QAAA,EAAA,CAAA;AAAA,YACC,UACI,0CAAA,GACA;AAAA;AACN;AAAA;AACF;AAAA,GAEJ;AAEJ","file":"chunk-7356B6YS.cjs","sourcesContent":["'use client';\n\n// `shared/01-system-screens.md §BootErrorScreen`.\n//\n// ── THE ONE SCREEN THAT CANNOT ASSUME ANYTHING ───────────────────────────\n//\n// It renders when `<KaafilUIKitProvider>` itself never opened, mounted by\n// the integrator's own error boundary around it. That means:\n//\n// · NO `I18nShell` → no `t()`. The copy below is ENGLISH ONLY, and that\n// is the spec's own DELTA, not an oversight.\n// · NO `ThemeShell` → no resolved tokens.\n// · NO `usePersona` → the credential never opened, so there is no\n// resolved persona to fork a presentation on. This is\n// the ONE screen in the tier that ships a single\n// rendering for every mounting context, including the\n// share surface — `public`'s richer reading layout\n// depends on shells that did not run.\n// · NO hook of any kind. There is no context above it to read.\n//\n// ── WHY IT CARRIES INLINE STYLES, WHICH NOTHING ELSE HERE DOES ───────────\n//\n// The stylesheet is OPT-IN (`import \"kaafil-react-uikit/styles\"`), so this\n// screen may render with no CSS whatsoever — and it is the one screen whose\n// entire job is explaining a total failure. Unstyled black-on-white text is\n// a poor way to do that, and a token reference resolves to nothing when the\n// ladder never loaded.\n//\n// So every node carries BOTH: an inline style that works with zero CSS, and\n// a `.kf-boot-error-screen__*` class so a host that DID load the stylesheet\n// can restyle it. The literals below are deliberate and must not be\n// \"corrected\" into `var(--kf-*)` — doing so silently breaks the only case\n// this screen exists for. dx-05 governs `src/styles/components/**` and does\n// not reach here, which is consistent rather than a loophole: the rule\n// exists so a stylesheet cannot shadow a token, and this file is not one.\n\nimport type { CSSProperties, ReactNode } from 'react';\nimport { useState } from 'react';\n\n/** The same failure modes `<KaafilSessionProbe/>` distinguishes, plus the\n * honest sixth for anything unclassifiable. */\nexport type BootFailureMode =\n | 'endpoint-401'\n | 'wrong-environment'\n | 'test-key-on-live'\n | 'clock-skew'\n | 'cors'\n | 'unknown';\n\nexport interface BootErrorScreenProps {\n readonly failureMode?: BootFailureMode;\n /** The underlying error's message. Rendered behind a disclosure, never\n * inline in the primary copy — it is developer-facing. */\n readonly detail?: string;\n /** Remounts the entire provider tree; some boot failures (a `kf_test_`\n * key shipped to production) cannot be fixed by retrying at all, which\n * is why this is optional. */\n readonly onRetry?: () => void;\n readonly components?: { readonly BootErrorScreenUI?: () => ReactNode };\n}\n\n/** English-only by contract — see this file's header. Each line says what\n * an integrator can actually DO, because the audience for a boot failure is\n * whoever wired the provider, not an end user. */\nconst COPY: Readonly<Record<BootFailureMode, string>> = {\n 'endpoint-401':\n 'The API key or session token was rejected. Check the credential the provider was given.',\n 'wrong-environment':\n 'This credential belongs to a different environment than the endpoint it was sent to.',\n 'test-key-on-live': 'A test key was used against live. Retrying will not help — swap the key.',\n 'clock-skew': \"This device's clock is too far from the server's for a token to validate.\",\n cors: 'The browser blocked the request before it was sent. This origin is not allowlisted on the API.',\n unknown: 'Kaafil could not start. The detail below may say why.',\n};\n\nconst PANEL: CSSProperties = {\n boxSizing: 'border-box',\n maxInlineSize: '32rem',\n marginInline: 'auto',\n marginBlock: '3rem',\n padding: '1.5rem',\n border: '1px solid #e3ded7',\n borderRadius: '10px',\n background: '#ffffff',\n color: '#1c1917',\n fontFamily: 'system-ui, -apple-system, Segoe UI, Roboto, sans-serif',\n fontSize: '0.875rem',\n lineHeight: 1.5,\n};\n\nconst TITLE: CSSProperties = { margin: '0 0 0.5rem', fontSize: '1rem', fontWeight: 600 };\nconst BODY: CSSProperties = { margin: '0 0 1rem', color: '#57534e' };\nconst CODE: CSSProperties = {\n display: 'block',\n overflowX: 'auto',\n marginBlockStart: '0.5rem',\n padding: '0.75rem',\n borderRadius: '6px',\n background: '#f5f5f4',\n color: '#44403c',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: '0.75rem',\n whiteSpace: 'pre-wrap',\n};\nconst BUTTON: CSSProperties = {\n padding: '0.5rem 1rem',\n border: '0',\n borderRadius: '8px',\n background: '#1c1917',\n color: '#ffffff',\n fontSize: '0.8125rem',\n fontWeight: 500,\n cursor: 'pointer',\n};\nconst TOGGLE: CSSProperties = {\n marginBlockStart: '1rem',\n color: '#78716c',\n fontSize: '0.75rem',\n cursor: 'pointer',\n};\n\nexport function BootErrorScreen({\n failureMode = 'unknown',\n detail,\n onRetry,\n components,\n}: BootErrorScreenProps): ReactNode {\n const [showDetail, setShowDetail] = useState(false);\n const Override = components?.BootErrorScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <div className=\"kf-boot-error-screen\" style={PANEL} role=\"alert\">\n <h1 className=\"kf-boot-error-screen__title\" style={TITLE}>\n Kaafil could not start\n </h1>\n <p className=\"kf-boot-error-screen__body\" style={BODY}>\n {COPY[failureMode]}\n </p>\n\n {onRetry === undefined ? null : (\n <button\n type=\"button\"\n className=\"kf-boot-error-screen__retry\"\n style={BUTTON}\n onClick={onRetry}\n >\n Try again\n </button>\n )}\n\n {detail === undefined || detail === '' ? null : (\n <div className=\"kf-boot-error-screen__detail\">\n {/* A disclosure rather than always-on: the message is the\n * underlying error's, which can be long and is not the first\n * thing a reader needs. */}\n <button\n type=\"button\"\n className=\"kf-boot-error-screen__detail-toggle\"\n style={{ ...TOGGLE, background: 'none', border: 0, padding: 0 }}\n aria-expanded={showDetail}\n onClick={() => setShowDetail((open) => !open)}\n >\n {showDetail ? 'Hide technical detail' : 'Show technical detail'}\n </button>\n {showDetail ? (\n <code className=\"kf-boot-error-screen__detail-text\" style={CODE}>\n {detail}\n </code>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n","'use client';\n\n// The one frame the five context-reading system screens share.\n//\n// ── THE PRESENTATION FORK IS REAL, AND IT IS NOT A PROP ───────────────────\n//\n// `shared/01-system-screens.md` records a `Presentation notes by mounting\n// context` field on every screen: an `admin`-family mount is a CONTAINED\n// CARD inside the host's own CRM page, a `manager`-family mount is a\n// FULL-VIEWPORT takeover with its primary action reachable without\n// scrolling. The spec is explicit that this is a genuine layout-model fork\n// (`03-layer-contract.md §5` level 3), not a spacing difference — and\n// equally explicit that it is ONE component, never two named variants.\n//\n// It is derived from `usePersona()`, never from a prop. Hard rule #7: no\n// `persona` prop and no `mode` prop exists anywhere, and dx-07 fails the\n// build on either. The credential decides.\n//\n// ── WHY THIS IS A FRAME AND NOT AN ATOM ──────────────────────────────────\n//\n// The spec's `Composes` rows name `EmptyState`/`Button`/`Banner` atoms from\n// `atomic/*`. Those do not exist: the v2 rebuild ships no shared\n// `/primitives` layer, by decision — each family owns whatever atoms it\n// needs. So these five screens share a FRAME (the layout fork, the focus\n// move, the announcement) and own their own content, rather than depending\n// on a primitives package this package deliberately does not have.\n\nimport type { ReactNode } from 'react';\nimport { useEffect, useId, useRef } from 'react';\nimport { usePersona } from '../../../core/hooks/usePersona.js';\nimport type { KaafilTokenOverrides } from '../../../primitives/internal/tokenStyle.js';\nimport { tokenStyle } from '../../../primitives/internal/tokenStyle.js';\n\nexport interface SystemScreenFrameProps {\n /** BEM block name — each screen owns its own, so a host can target one\n * without catching the rest (`.kf-session-expired-screen__*`). */\n readonly block: string;\n readonly title: string;\n readonly body: ReactNode;\n /** Rendered below the body. On a field mount this is what the sticky\n * action region holds. */\n readonly actions?: ReactNode;\n /** An error/context line above the title. */\n readonly banner?: ReactNode;\n readonly icon?: ReactNode;\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function SystemScreenFrame({\n block,\n title,\n body,\n actions,\n banner,\n icon,\n style,\n}: SystemScreenFrameProps): ReactNode {\n const persona = usePersona();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const headingId = useId();\n\n // A field mount owns the whole screen; a desk mount is embedded beside the\n // host's own nav and must not consume the viewport (briefing §27.7).\n // `traveller` takes the contained treatment too — only `OfflineFallback`\n // and `BootError` reach the public surface, and neither should black out\n // a document a host has embedded.\n const layout = persona === 'manager' ? 'takeover' : 'contained';\n\n // FOCUS MOVES TO THE HEADING on mount. This is a full state replacement,\n // not an overlay — there is no opener to return focus to, so the\n // overlay-focus contract (`12-accessibility.md §3`) does not apply and the\n // heading is the correct landing point. Without this a keyboard or screen\n // reader user gets no signal that the page became something else and Tab\n // keeps walking whatever is still behind it.\n useEffect(() => {\n headingRef.current?.focus();\n }, []);\n\n return (\n <div\n className=\"kf-system-screen\"\n data-block={block}\n data-layout={layout}\n style={tokenStyle(style)}\n // A significant, infrequent state change — announced politely rather\n // than assertively, since the focus move above already carries the\n // urgency and `assertive` would interrupt whatever is mid-sentence.\n role=\"status\"\n aria-live=\"polite\"\n aria-labelledby={headingId}\n >\n <div className={`kf-system-screen__panel ${block}`}>\n {icon === undefined ? null : (\n <span className=\"kf-system-screen__glyph\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {banner === undefined ? null : <div className=\"kf-system-screen__banner\">{banner}</div>}\n {/* `tabIndex={-1}` so the effect above can focus it — a heading is\n * not focusable by default and focusing the panel instead would\n * draw the accent ring around the entire card. */}\n <h1 ref={headingRef} id={headingId} tabIndex={-1} className=\"kf-system-screen__title\">\n {title}\n </h1>\n <div className=\"kf-system-screen__body\">{body}</div>\n {actions === undefined ? null : <div className=\"kf-system-screen__actions\">{actions}</div>}\n </div>\n </div>\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §LockedTripScreen`.\n//\n// The destination for a WRITE-ONLY deep link into a closed-out trip — a\n// \"record this collection\" push sent before the trip closed, a bookmarked\n// mutation route. Mounting the flow it points at would show a form whose\n// one action can only ever answer `423`.\n//\n// BACKED BY NOTHING, and that is the discipline rather than a gap. This\n// screen never calls `closeout.get`/`useCloseout` to learn the trip is\n// locked: the caller already knows (its own write would 423, or the link's\n// own metadata carried the LOCKED stage). Checking again here would be a\n// second gate — \"check the resolved state before render, never\n// render-then-catch\", applied to lock state instead of capability darkness.\n//\n// LINKS to Closing Day, never mounts it. No unlock control appears here or\n// anywhere else at any layer (hard rule #21): the desk locks, the CRM\n// reopens.\n\nimport type { ReactNode } from 'react';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface LockedTripScreenProps {\n /** For context and for building the link's destination — never used to\n * fetch anything. */\n readonly tripRef: string;\n /** What the dead-end link would have done (\"Record a collection\"), from\n * whatever metadata came with it. Absent means the generic sentence: this\n * screen invents no explanation of its own. */\n readonly intendedAction?: string;\n /** The host's own navigation to wherever it mounts Closing Day. A screen\n * never navigates itself. */\n readonly onGoToClosingDay: (tripRef: string) => void;\n readonly components?: { readonly LockedTripScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function LockedTripScreen({\n tripRef,\n intendedAction,\n onGoToClosingDay,\n components,\n style,\n}: LockedTripScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const Override = components?.LockedTripScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <SystemScreenFrame\n block=\"kf-locked-trip-screen\"\n title={t('chrome.systemScreens.lockedTrip.title')}\n banner={\n intendedAction === undefined\n ? t('chrome.systemScreens.lockedTrip.genericAction')\n : t('chrome.systemScreens.lockedTrip.namedAction').replace('{action}', intendedAction)\n }\n body={<p>{t('chrome.systemScreens.lockedTrip.body')}</p>}\n {...(style !== undefined ? { style } : {})}\n actions={\n <button\n type=\"button\"\n className=\"kf-system-screen__primary\"\n onClick={() => onGoToClosingDay(tripRef)}\n >\n {t('chrome.systemScreens.lockedTrip.action')}\n </button>\n }\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §NotFoundScreen`.\n//\n// A route-level 404 for a `manager`/`agencyAdmin` mount: a bookmarked\n// `tripRef` from another agency, a deep link to a deleted entity, a stale\n// notification pointing at a now-cross-tenant resource.\n//\n// NOT THE TRAVELLER'S 404, and this is load-bearing rather than an\n// oversight. A dead share token is `ShareEndedScreen`'s `not-found`\n// variant, which must stay 404-shaped — no heading, no divider, no\n// distinguishing DOM signal (hard rule #20, enforced by dx-15). Rendering\n// THIS screen on the share surface would leak that the token was once real.\n// It is therefore never re-exported from `/traveller`.\n//\n// BACKED BY NOTHING, by design. It renders on a 404 that some mounted\n// flow's own hook already surfaced; it performs no second fetch to\n// \"double-check\" what the flow already learned.\n\nimport type { ReactNode } from 'react';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface NotFoundScreenProps {\n /** The host's own \"back\" navigation. Optional — a host that reached this\n * with no history to return to simply gets no button, which is more\n * honest than one that goes nowhere. */\n readonly onGoBack?: () => void;\n readonly components?: { readonly NotFoundScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function NotFoundScreen({ onGoBack, components, style }: NotFoundScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const Override = components?.NotFoundScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <SystemScreenFrame\n block=\"kf-not-found-screen\"\n title={t('chrome.systemScreens.notFound.title')}\n // Deliberately does not speculate about WHY. \"Deleted, or belongs to\n // another agency, or you mistyped it\" are three different sentences\n // and this screen cannot tell which is true — naming one would be a\n // guess presented as a diagnosis.\n body={<p>{t('chrome.systemScreens.notFound.body')}</p>}\n {...(style !== undefined ? { style } : {})}\n {...(onGoBack !== undefined\n ? {\n actions: (\n <button type=\"button\" className=\"kf-system-screen__primary\" onClick={onGoBack}>\n {t('chrome.systemScreens.notFound.action')}\n </button>\n ),\n }\n : {})}\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §OfflineFallbackScreen`.\n//\n// The device has nothing cached AND no connectivity — a manager opening a\n// trip for the first time at a trailhead before ever syncing, a desk\n// session losing the network before its first pull, a share link opened\n// with zero signal before the first snapshot.\n//\n// THE ONLY ONE OF THE SIX THE TRAVELLER SURFACE SHARES besides\n// `BootErrorScreen`, and it is safe there precisely because it discloses\n// nothing: \"there is no connection\" is true of any URL and leaks nothing\n// about whether this token was ever real. That is what separates it from\n// `ShareEndedScreen`'s dead-token cases, which are about a token's\n// VALIDITY and must stay 404-shaped (hard rule #20).\n//\n// SESSION STATE OUTRANKS THIS. An offline device whose credential has also\n// expired shows `SessionExpiredScreen`, not this — re-authentication is the\n// blocking concern regardless of connectivity, and a caller composing both\n// should check session first.\n\nimport type { ReactNode } from 'react';\nimport { useOutboxStatus } from '../../core/hooks/useOutboxStatus.js';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface OfflineFallbackScreenProps {\n /** Present on a trip-scoped mount; absent on the share surface. Context\n * only — this screen fetches nothing. */\n readonly tripRef?: string;\n /** Present on a share mount instead of `tripRef`. */\n readonly token?: string;\n /** The host's own retry — typically remounting whatever failed. */\n readonly onRetry?: () => void;\n readonly components?: { readonly OfflineFallbackScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function OfflineFallbackScreen({\n onRetry,\n components,\n style,\n}: OfflineFallbackScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const { isOnline } = useOutboxStatus();\n const Override = components?.OfflineFallbackScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <SystemScreenFrame\n block=\"kf-offline-fallback-screen\"\n title={t('chrome.systemScreens.offlineFallback.title')}\n body={\n <>\n <p>{t('chrome.systemScreens.offlineFallback.body')}</p>\n {/* Connectivity came back while this was on screen. Said rather\n * than acted on: this screen does not refetch or navigate on its\n * own, because whatever failed is the caller's to retry — but\n * leaving a stale \"you are offline\" up while the bars are back is\n * the thing that makes an app feel broken. */}\n {isOnline ? (\n <p data-tone=\"ok\">{t('chrome.systemScreens.offlineFallback.backOnline')}</p>\n ) : null}\n </>\n }\n {...(style !== undefined ? { style } : {})}\n {...(onRetry !== undefined\n ? {\n actions: (\n <button type=\"button\" className=\"kf-system-screen__primary\" onClick={onRetry}>\n {t('chrome.systemScreens.offlineFallback.action')}\n </button>\n ),\n }\n : {})}\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §PlanLockedScreen`.\n//\n// The takeover a STANDALONE route (no surrounding tab bar) renders when its\n// destination module is flag-dark. Admin-only: entitlement is a desk\n// concern, a manager's flows are always mounted inside a tab set where a\n// flag-dark tab renders its own inline view, and the share surface has no\n// upsell copy at all (its flag-dark case is 404-shaped).\n//\n// ── A SPEC FIELD THAT HAS NO WIRE SOURCE ─────────────────────────────────\n//\n// The spec splits the CTA by `details.reason` into `'agency'` (the agency's\n// own plan) vs `'partner-ceiling'` (the partner's tier caps it), so the\n// right person is sent to the right queue. `CapabilityRow` carries no such\n// field — `06-capability-and-personas.md §6` point 2 fixes it as \"four\n// booleans, no `reason` string\", and `capability.types.ts` says so too.\n//\n// So the reason is an OPTIONAL PROP, supplied by whatever the caller saw\n// (a refusal's own `details`), and `onUpgradeRequest` is called with\n// `undefined` when nobody knows. Defaulting it to `'agency'` would have\n// been a guess routed to a real support queue — the host can decide what to\n// do with \"unknown\" far better than this screen can invent an answer.\n\nimport type { ReactNode } from 'react';\nimport { useCapabilities } from '../../core/hooks/useCapabilities.js';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport type PlanLockedReason = 'agency' | 'partner-ceiling';\n\nexport interface PlanLockedScreenProps {\n /** The capability this route was headed for. Read for its own triple\n * only — never exhaustively switched on (`§6` point 5's open-set rule). */\n readonly capabilityKey: string;\n /** The host's own upsell/support flow — Kaafil has no in-product upgrade\n * path to hand off to. `undefined` means the wire did not say which\n * queue this belongs in; see this file's header. */\n readonly onUpgradeRequest: (reason: PlanLockedReason | undefined) => void;\n /** Supplied by the caller when it saw a refusal that named one. */\n readonly reason?: PlanLockedReason;\n readonly components?: { readonly PlanLockedScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function PlanLockedScreen({\n capabilityKey,\n onUpgradeRequest,\n reason,\n components,\n style,\n}: PlanLockedScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const capabilities = useCapabilities([capabilityKey]);\n const Override = components?.PlanLockedScreenUI;\n if (Override !== undefined) return <Override />;\n\n // Read, never re-derived: `status` is resolved once in `/core` and this\n // screen reads it rather than recombining the booleans itself\n // (`06-capability-and-personas.md §6` point 2).\n const status = capabilities.get(capabilityKey)?.status;\n\n return (\n <SystemScreenFrame\n block=\"kf-plan-locked-screen\"\n title={t('chrome.systemScreens.planLocked.title')}\n body={\n <>\n <p>\n {t(\n reason === 'partner-ceiling'\n ? 'chrome.systemScreens.planLocked.bodyPartnerCeiling'\n : 'chrome.systemScreens.planLocked.body',\n )}\n </p>\n {/* A route that reached this screen for a capability that is NOT\n * flag-dark is a caller bug, and saying so beats rendering upsell\n * copy over a module that is merely data-dark or simply lit. */}\n {status === 'flag-dark' ? null : (\n <p data-tone=\"warn\">{t('chrome.systemScreens.planLocked.notFlagDark')}</p>\n )}\n </>\n }\n {...(style !== undefined ? { style } : {})}\n actions={\n <button\n type=\"button\"\n className=\"kf-system-screen__primary\"\n onClick={() => onUpgradeRequest(reason)}\n >\n {t('chrome.systemScreens.planLocked.action')}\n </button>\n }\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §SessionExpiredScreen`.\n//\n// Renders exactly when `useSession().status === 'expired'` — the open\n// credential's silent refresh has exhausted itself. Re-authentication is\n// routed through the HOST's own login; Kaafil has no login page to redirect\n// to, which is why `onReauthenticate` is required and has no default.\n//\n// DOES NOT retry any token call itself. A broken credential means the\n// host's own user is not authenticated and must re-authenticate through the\n// host's own flow — obtaining fresh tokens is `SessionShell`'s concern on\n// the NEXT successful mount, not this screen's on the current broken one.\n//\n// DOES NOT inspect which credential kind expired beyond the resolved\n// persona (`00-decisions.md` U-003 forecloses reading a JWT at any layer\n// above `SessionShell`).\n\nimport type { ReactNode } from 'react';\nimport { useState } from 'react';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface SessionExpiredScreenProps {\n /** The host's own re-auth entry point. Required: there is no default\n * action, because Kaafil has no login page of its own. */\n readonly onReauthenticate: (returnTo?: string) => void | Promise<void>;\n /** Threaded back to `onReauthenticate` UNEXAMINED. This screen never\n * interprets it, builds a URL from it, or hands it to a router — it\n * exists purely so the host's own flow can restore the right destination\n * afterwards. */\n readonly returnTo?: string;\n readonly components?: { readonly SessionExpiredScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function SessionExpiredScreen({\n onReauthenticate,\n returnTo,\n components,\n style,\n}: SessionExpiredScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const [pending, setPending] = useState(false);\n // The host's own auth failure reason is not something Kaafil can\n // classify, so the rejection's own message is shown verbatim.\n const [failure, setFailure] = useState<string | undefined>(undefined);\n\n const Override = components?.SessionExpiredScreenUI;\n if (Override !== undefined) return <Override />;\n\n async function reauthenticate(): Promise<void> {\n setPending(true);\n setFailure(undefined);\n try {\n await onReauthenticate(returnTo);\n } catch (error) {\n setFailure(error instanceof Error ? error.message : String(error));\n } finally {\n setPending(false);\n }\n }\n\n return (\n <SystemScreenFrame\n block=\"kf-session-expired-screen\"\n title={t('chrome.systemScreens.sessionExpired.title')}\n body={<p>{t('chrome.systemScreens.sessionExpired.body')}</p>}\n {...(failure !== undefined ? { banner: <span data-tone=\"warn\">{failure}</span> } : {})}\n {...(style !== undefined ? { style } : {})}\n actions={\n <button\n type=\"button\"\n className=\"kf-system-screen__primary\"\n disabled={pending}\n onClick={() => void reauthenticate()}\n >\n {t(\n pending\n ? 'chrome.systemScreens.sessionExpired.busy'\n : 'chrome.systemScreens.sessionExpired.action',\n )}\n </button>\n }\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/shared/system-screens/BootErrorScreen.tsx","../src/shared/system-screens/internal/SystemScreenFrame.tsx","../src/shared/system-screens/LockedTripScreen.tsx","../src/shared/system-screens/NotFoundScreen.tsx","../src/shared/system-screens/OfflineFallbackScreen.tsx","../src/shared/system-screens/PlanLockedScreen.tsx","../src/shared/system-screens/SessionExpiredScreen.tsx"],"names":["useState","jsx","jsxs","usePersona","useRef","useId","useEffect","tokenStyle","useKaafilChrome","useOutboxStatus","Fragment","useCapabilities"],"mappings":";;;;;;AAgEA,IAAM,IAAA,GAAkD;AAAA,EACtD,cAAA,EACE,yFAAA;AAAA,EACF,mBAAA,EACE,sFAAA;AAAA,EACF,kBAAA,EAAoB,+EAAA;AAAA,EACpB,YAAA,EAAc,2EAAA;AAAA,EACd,IAAA,EAAM,gGAAA;AAAA,EACN,OAAA,EAAS;AACX,CAAA;AAEA,IAAM,KAAA,GAAuB;AAAA,EAC3B,SAAA,EAAW,YAAA;AAAA,EACX,aAAA,EAAe,OAAA;AAAA,EACf,YAAA,EAAc,MAAA;AAAA,EACd,WAAA,EAAa,MAAA;AAAA,EACb,OAAA,EAAS,QAAA;AAAA,EACT,MAAA,EAAQ,mBAAA;AAAA,EACR,YAAA,EAAc,MAAA;AAAA,EACd,UAAA,EAAY,SAAA;AAAA,EACZ,KAAA,EAAO,SAAA;AAAA,EACP,UAAA,EAAY,wDAAA;AAAA,EACZ,QAAA,EAAU,UAAA;AAAA,EACV,UAAA,EAAY;AACd,CAAA;AAEA,IAAM,QAAuB,EAAE,MAAA,EAAQ,cAAc,QAAA,EAAU,MAAA,EAAQ,YAAY,GAAA,EAAI;AACvF,IAAM,IAAA,GAAsB,EAAE,MAAA,EAAQ,UAAA,EAAY,OAAO,SAAA,EAAU;AACnE,IAAM,IAAA,GAAsB;AAAA,EAC1B,OAAA,EAAS,OAAA;AAAA,EACT,SAAA,EAAW,MAAA;AAAA,EACX,gBAAA,EAA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AAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,IACnE,CAAA,SAAE;AACA,MAAA,UAAA,CAAW,KAAK,CAAA;AAAA,IAClB;AAAA,EACF;AAEA,EAAA,uBACEA,cAAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAM,2BAAA;AAAA,MACN,KAAA,EAAO,EAAE,2CAA2C,CAAA;AAAA,MACpD,sBAAMA,cAAAA,CAAC,GAAA,EAAA,EAAG,QAAA,EAAA,CAAA,CAAE,0CAA0C,CAAA,EAAE,CAAA;AAAA,MACvD,GAAI,OAAA,KAAY,MAAA,GAAY,EAAE,MAAA,kBAAQA,cAAAA,CAAC,MAAA,EAAA,EAAK,WAAA,EAAU,MAAA,EAAQ,QAAA,EAAA,OAAA,EAAQ,CAAA,KAAY,EAAC;AAAA,MACnF,GAAI,KAAA,KAAU,MAAA,GAAY,EAAE,KAAA,KAAU,EAAC;AAAA,MACxC,yBACEA,cAAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,SAAA,EAAU,2BAAA;AAAA,UACV,QAAA,EAAU,OAAA;AAAA,UACV,OAAA,EAAS,MAAM,KAAK,cAAA,EAAe;AAAA,UAElC,QAAA,EAAA,CAAA;AAAA,YACC,UACI,0CAAA,GACA;AAAA;AACN;AAAA;AACF;AAAA,GAEJ;AAEJ","file":"chunk-QD4Z5DRT.cjs","sourcesContent":["'use client';\n\n// `shared/01-system-screens.md §BootErrorScreen`.\n//\n// ── THE ONE SCREEN THAT CANNOT ASSUME ANYTHING ───────────────────────────\n//\n// It renders when `<KaafilUIKitProvider>` itself never opened, mounted by\n// the integrator's own error boundary around it. That means:\n//\n// · NO `I18nShell` → no `t()`. The copy below is ENGLISH ONLY, and that\n// is the spec's own DELTA, not an oversight.\n// · NO `ThemeShell` → no resolved tokens.\n// · NO `usePersona` → the credential never opened, so there is no\n// resolved persona to fork a presentation on. This is\n// the ONE screen in the tier that ships a single\n// rendering for every mounting context, including the\n// share surface — `public`'s richer reading layout\n// depends on shells that did not run.\n// · NO hook of any kind. There is no context above it to read.\n//\n// ── WHY IT CARRIES INLINE STYLES, WHICH NOTHING ELSE HERE DOES ───────────\n//\n// The stylesheet is OPT-IN (`import \"kaafil-react-uikit/styles\"`), so this\n// screen may render with no CSS whatsoever — and it is the one screen whose\n// entire job is explaining a total failure. Unstyled black-on-white text is\n// a poor way to do that, and a token reference resolves to nothing when the\n// ladder never loaded.\n//\n// So every node carries BOTH: an inline style that works with zero CSS, and\n// a `.kf-boot-error-screen__*` class so a host that DID load the stylesheet\n// can restyle it. The literals below are deliberate and must not be\n// \"corrected\" into `var(--kf-*)` — doing so silently breaks the only case\n// this screen exists for. dx-05 governs `src/styles/components/**` and does\n// not reach here, which is consistent rather than a loophole: the rule\n// exists so a stylesheet cannot shadow a token, and this file is not one.\n\nimport type { CSSProperties, ReactNode } from 'react';\nimport { useState } from 'react';\n\n/** The same failure modes `<KaafilSessionProbe/>` distinguishes, plus the\n * honest sixth for anything unclassifiable. */\nexport type BootFailureMode =\n | 'endpoint-401'\n | 'wrong-environment'\n | 'test-key-on-live'\n | 'clock-skew'\n | 'cors'\n | 'unknown';\n\nexport interface BootErrorScreenProps {\n readonly failureMode?: BootFailureMode;\n /** The underlying error's message. Rendered behind a disclosure, never\n * inline in the primary copy — it is developer-facing. */\n readonly detail?: string;\n /** Remounts the entire provider tree; some boot failures (a `kf_test_`\n * key shipped to production) cannot be fixed by retrying at all, which\n * is why this is optional. */\n readonly onRetry?: () => void;\n readonly components?: { readonly BootErrorScreenUI?: () => ReactNode };\n}\n\n/** English-only by contract — see this file's header. Each line says what\n * an integrator can actually DO, because the audience for a boot failure is\n * whoever wired the provider, not an end user. */\nconst COPY: Readonly<Record<BootFailureMode, string>> = {\n 'endpoint-401':\n 'The API key or session token was rejected. Check the credential the provider was given.',\n 'wrong-environment':\n 'This credential belongs to a different environment than the endpoint it was sent to.',\n 'test-key-on-live': 'A test key was used against live. Retrying will not help — swap the key.',\n 'clock-skew': \"This device's clock is too far from the server's for a token to validate.\",\n cors: 'The browser blocked the request before it was sent. This origin is not allowlisted on the API.',\n unknown: 'Kaafil could not start. The detail below may say why.',\n};\n\nconst PANEL: CSSProperties = {\n boxSizing: 'border-box',\n maxInlineSize: '32rem',\n marginInline: 'auto',\n marginBlock: '3rem',\n padding: '1.5rem',\n border: '1px solid #e3ded7',\n borderRadius: '10px',\n background: '#ffffff',\n color: '#1c1917',\n fontFamily: 'system-ui, -apple-system, Segoe UI, Roboto, sans-serif',\n fontSize: '0.875rem',\n lineHeight: 1.5,\n};\n\nconst TITLE: CSSProperties = { margin: '0 0 0.5rem', fontSize: '1rem', fontWeight: 600 };\nconst BODY: CSSProperties = { margin: '0 0 1rem', color: '#57534e' };\nconst CODE: CSSProperties = {\n display: 'block',\n overflowX: 'auto',\n marginBlockStart: '0.5rem',\n padding: '0.75rem',\n borderRadius: '6px',\n background: '#f5f5f4',\n color: '#44403c',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: '0.75rem',\n whiteSpace: 'pre-wrap',\n};\nconst BUTTON: CSSProperties = {\n padding: '0.5rem 1rem',\n border: '0',\n borderRadius: '8px',\n background: '#1c1917',\n color: '#ffffff',\n fontSize: '0.8125rem',\n fontWeight: 500,\n cursor: 'pointer',\n};\nconst TOGGLE: CSSProperties = {\n marginBlockStart: '1rem',\n color: '#78716c',\n fontSize: '0.75rem',\n cursor: 'pointer',\n};\n\nexport function BootErrorScreen({\n failureMode = 'unknown',\n detail,\n onRetry,\n components,\n}: BootErrorScreenProps): ReactNode {\n const [showDetail, setShowDetail] = useState(false);\n const Override = components?.BootErrorScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <div className=\"kf-boot-error-screen\" style={PANEL} role=\"alert\">\n <h1 className=\"kf-boot-error-screen__title\" style={TITLE}>\n Kaafil could not start\n </h1>\n <p className=\"kf-boot-error-screen__body\" style={BODY}>\n {COPY[failureMode]}\n </p>\n\n {onRetry === undefined ? null : (\n <button\n type=\"button\"\n className=\"kf-boot-error-screen__retry\"\n style={BUTTON}\n onClick={onRetry}\n >\n Try again\n </button>\n )}\n\n {detail === undefined || detail === '' ? null : (\n <div className=\"kf-boot-error-screen__detail\">\n {/* A disclosure rather than always-on: the message is the\n * underlying error's, which can be long and is not the first\n * thing a reader needs. */}\n <button\n type=\"button\"\n className=\"kf-boot-error-screen__detail-toggle\"\n style={{ ...TOGGLE, background: 'none', border: 0, padding: 0 }}\n aria-expanded={showDetail}\n onClick={() => setShowDetail((open) => !open)}\n >\n {showDetail ? 'Hide technical detail' : 'Show technical detail'}\n </button>\n {showDetail ? (\n <code className=\"kf-boot-error-screen__detail-text\" style={CODE}>\n {detail}\n </code>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n","'use client';\n\n// The one frame the five context-reading system screens share.\n//\n// ── THE PRESENTATION FORK IS REAL, AND IT IS NOT A PROP ───────────────────\n//\n// `shared/01-system-screens.md` records a `Presentation notes by mounting\n// context` field on every screen: an `admin`-family mount is a CONTAINED\n// CARD inside the host's own CRM page, a `manager`-family mount is a\n// FULL-VIEWPORT takeover with its primary action reachable without\n// scrolling. The spec is explicit that this is a genuine layout-model fork\n// (`03-layer-contract.md §5` level 3), not a spacing difference — and\n// equally explicit that it is ONE component, never two named variants.\n//\n// It is derived from `usePersona()`, never from a prop. Hard rule #7: no\n// `persona` prop and no `mode` prop exists anywhere, and dx-07 fails the\n// build on either. The credential decides.\n//\n// ── WHY THIS IS A FRAME AND NOT AN ATOM ──────────────────────────────────\n//\n// The spec's `Composes` rows name `EmptyState`/`Button`/`Banner` atoms from\n// `atomic/*`. Those do not exist: the v2 rebuild ships no shared\n// `/primitives` layer, by decision — each family owns whatever atoms it\n// needs. So these five screens share a FRAME (the layout fork, the focus\n// move, the announcement) and own their own content, rather than depending\n// on a primitives package this package deliberately does not have.\n\nimport type { ReactNode } from 'react';\nimport { useEffect, useId, useRef } from 'react';\nimport { usePersona } from '../../../core/hooks/usePersona.js';\nimport type { KaafilTokenOverrides } from '../../../primitives/internal/tokenStyle.js';\nimport { tokenStyle } from '../../../primitives/internal/tokenStyle.js';\n\nexport interface SystemScreenFrameProps {\n /** BEM block name — each screen owns its own, so a host can target one\n * without catching the rest (`.kf-session-expired-screen__*`). */\n readonly block: string;\n readonly title: string;\n readonly body: ReactNode;\n /** Rendered below the body. On a field mount this is what the sticky\n * action region holds. */\n readonly actions?: ReactNode;\n /** An error/context line above the title. */\n readonly banner?: ReactNode;\n readonly icon?: ReactNode;\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function SystemScreenFrame({\n block,\n title,\n body,\n actions,\n banner,\n icon,\n style,\n}: SystemScreenFrameProps): ReactNode {\n const persona = usePersona();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const headingId = useId();\n\n // A field mount owns the whole screen; a desk mount is embedded beside the\n // host's own nav and must not consume the viewport (briefing §27.7).\n // `traveller` takes the contained treatment too — only `OfflineFallback`\n // and `BootError` reach the public surface, and neither should black out\n // a document a host has embedded.\n const layout = persona === 'manager' ? 'takeover' : 'contained';\n\n // FOCUS MOVES TO THE HEADING on mount. This is a full state replacement,\n // not an overlay — there is no opener to return focus to, so the\n // overlay-focus contract (`12-accessibility.md §3`) does not apply and the\n // heading is the correct landing point. Without this a keyboard or screen\n // reader user gets no signal that the page became something else and Tab\n // keeps walking whatever is still behind it.\n useEffect(() => {\n headingRef.current?.focus();\n }, []);\n\n return (\n <div\n className=\"kf-system-screen\"\n data-block={block}\n data-layout={layout}\n style={tokenStyle(style)}\n // A significant, infrequent state change — announced politely rather\n // than assertively, since the focus move above already carries the\n // urgency and `assertive` would interrupt whatever is mid-sentence.\n role=\"status\"\n aria-live=\"polite\"\n aria-labelledby={headingId}\n >\n <div className={`kf-system-screen__panel ${block}`}>\n {icon === undefined ? null : (\n <span className=\"kf-system-screen__glyph\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {banner === undefined ? null : <div className=\"kf-system-screen__banner\">{banner}</div>}\n {/* `tabIndex={-1}` so the effect above can focus it — a heading is\n * not focusable by default and focusing the panel instead would\n * draw the accent ring around the entire card. */}\n <h1 ref={headingRef} id={headingId} tabIndex={-1} className=\"kf-system-screen__title\">\n {title}\n </h1>\n <div className=\"kf-system-screen__body\">{body}</div>\n {actions === undefined ? null : <div className=\"kf-system-screen__actions\">{actions}</div>}\n </div>\n </div>\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §LockedTripScreen`.\n//\n// The destination for a WRITE-ONLY deep link into a closed-out trip — a\n// \"record this collection\" push sent before the trip closed, a bookmarked\n// mutation route. Mounting the flow it points at would show a form whose\n// one action can only ever answer `423`.\n//\n// BACKED BY NOTHING, and that is the discipline rather than a gap. This\n// screen never calls `closeout.get`/`useCloseout` to learn the trip is\n// locked: the caller already knows (its own write would 423, or the link's\n// own metadata carried the LOCKED stage). Checking again here would be a\n// second gate — \"check the resolved state before render, never\n// render-then-catch\", applied to lock state instead of capability darkness.\n//\n// LINKS to Closing Day, never mounts it. No unlock control appears here or\n// anywhere else at any layer (hard rule #21): the desk locks, the CRM\n// reopens.\n\nimport type { ReactNode } from 'react';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface LockedTripScreenProps {\n /** For context and for building the link's destination — never used to\n * fetch anything. */\n readonly tripRef: string;\n /** What the dead-end link would have done (\"Record a collection\"), from\n * whatever metadata came with it. Absent means the generic sentence: this\n * screen invents no explanation of its own. */\n readonly intendedAction?: string;\n /** The host's own navigation to wherever it mounts Closing Day. A screen\n * never navigates itself. */\n readonly onGoToClosingDay: (tripRef: string) => void;\n readonly components?: { readonly LockedTripScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function LockedTripScreen({\n tripRef,\n intendedAction,\n onGoToClosingDay,\n components,\n style,\n}: LockedTripScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const Override = components?.LockedTripScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <SystemScreenFrame\n block=\"kf-locked-trip-screen\"\n title={t('chrome.systemScreens.lockedTrip.title')}\n banner={\n intendedAction === undefined\n ? t('chrome.systemScreens.lockedTrip.genericAction')\n : t('chrome.systemScreens.lockedTrip.namedAction').replace('{action}', intendedAction)\n }\n body={<p>{t('chrome.systemScreens.lockedTrip.body')}</p>}\n {...(style !== undefined ? { style } : {})}\n actions={\n <button\n type=\"button\"\n className=\"kf-system-screen__primary\"\n onClick={() => onGoToClosingDay(tripRef)}\n >\n {t('chrome.systemScreens.lockedTrip.action')}\n </button>\n }\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §NotFoundScreen`.\n//\n// A route-level 404 for a `manager`/`agencyAdmin` mount: a bookmarked\n// `tripRef` from another agency, a deep link to a deleted entity, a stale\n// notification pointing at a now-cross-tenant resource.\n//\n// NOT THE TRAVELLER'S 404, and this is load-bearing rather than an\n// oversight. A dead share token is `ShareEndedScreen`'s `not-found`\n// variant, which must stay 404-shaped — no heading, no divider, no\n// distinguishing DOM signal (hard rule #20, enforced by dx-15). Rendering\n// THIS screen on the share surface would leak that the token was once real.\n// It is therefore never re-exported from `/traveller`.\n//\n// BACKED BY NOTHING, by design. It renders on a 404 that some mounted\n// flow's own hook already surfaced; it performs no second fetch to\n// \"double-check\" what the flow already learned.\n\nimport type { ReactNode } from 'react';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface NotFoundScreenProps {\n /** The host's own \"back\" navigation. Optional — a host that reached this\n * with no history to return to simply gets no button, which is more\n * honest than one that goes nowhere. */\n readonly onGoBack?: () => void;\n readonly components?: { readonly NotFoundScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function NotFoundScreen({ onGoBack, components, style }: NotFoundScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const Override = components?.NotFoundScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <SystemScreenFrame\n block=\"kf-not-found-screen\"\n title={t('chrome.systemScreens.notFound.title')}\n // Deliberately does not speculate about WHY. \"Deleted, or belongs to\n // another agency, or you mistyped it\" are three different sentences\n // and this screen cannot tell which is true — naming one would be a\n // guess presented as a diagnosis.\n body={<p>{t('chrome.systemScreens.notFound.body')}</p>}\n {...(style !== undefined ? { style } : {})}\n {...(onGoBack !== undefined\n ? {\n actions: (\n <button type=\"button\" className=\"kf-system-screen__primary\" onClick={onGoBack}>\n {t('chrome.systemScreens.notFound.action')}\n </button>\n ),\n }\n : {})}\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §OfflineFallbackScreen`.\n//\n// The device has nothing cached AND no connectivity — a manager opening a\n// trip for the first time at a trailhead before ever syncing, a desk\n// session losing the network before its first pull, a share link opened\n// with zero signal before the first snapshot.\n//\n// THE ONLY ONE OF THE SIX THE TRAVELLER SURFACE SHARES besides\n// `BootErrorScreen`, and it is safe there precisely because it discloses\n// nothing: \"there is no connection\" is true of any URL and leaks nothing\n// about whether this token was ever real. That is what separates it from\n// `ShareEndedScreen`'s dead-token cases, which are about a token's\n// VALIDITY and must stay 404-shaped (hard rule #20).\n//\n// SESSION STATE OUTRANKS THIS. An offline device whose credential has also\n// expired shows `SessionExpiredScreen`, not this — re-authentication is the\n// blocking concern regardless of connectivity, and a caller composing both\n// should check session first.\n\nimport type { ReactNode } from 'react';\nimport { useOutboxStatus } from '../../core/hooks/useOutboxStatus.js';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface OfflineFallbackScreenProps {\n /** Present on a trip-scoped mount; absent on the share surface. Context\n * only — this screen fetches nothing. */\n readonly tripRef?: string;\n /** Present on a share mount instead of `tripRef`. */\n readonly token?: string;\n /** The host's own retry — typically remounting whatever failed. */\n readonly onRetry?: () => void;\n readonly components?: { readonly OfflineFallbackScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function OfflineFallbackScreen({\n onRetry,\n components,\n style,\n}: OfflineFallbackScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const { isOnline } = useOutboxStatus();\n const Override = components?.OfflineFallbackScreenUI;\n if (Override !== undefined) return <Override />;\n\n return (\n <SystemScreenFrame\n block=\"kf-offline-fallback-screen\"\n title={t('chrome.systemScreens.offlineFallback.title')}\n body={\n <>\n <p>{t('chrome.systemScreens.offlineFallback.body')}</p>\n {/* Connectivity came back while this was on screen. Said rather\n * than acted on: this screen does not refetch or navigate on its\n * own, because whatever failed is the caller's to retry — but\n * leaving a stale \"you are offline\" up while the bars are back is\n * the thing that makes an app feel broken. */}\n {isOnline ? (\n <p data-tone=\"ok\">{t('chrome.systemScreens.offlineFallback.backOnline')}</p>\n ) : null}\n </>\n }\n {...(style !== undefined ? { style } : {})}\n {...(onRetry !== undefined\n ? {\n actions: (\n <button type=\"button\" className=\"kf-system-screen__primary\" onClick={onRetry}>\n {t('chrome.systemScreens.offlineFallback.action')}\n </button>\n ),\n }\n : {})}\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §PlanLockedScreen`.\n//\n// The takeover a STANDALONE route (no surrounding tab bar) renders when its\n// destination module is flag-dark. Admin-only: entitlement is a desk\n// concern, a manager's flows are always mounted inside a tab set where a\n// flag-dark tab renders its own inline view, and the share surface has no\n// upsell copy at all (its flag-dark case is 404-shaped).\n//\n// ── A SPEC FIELD THAT HAS NO WIRE SOURCE ─────────────────────────────────\n//\n// The spec splits the CTA by `details.reason` into `'agency'` (the agency's\n// own plan) vs `'partner-ceiling'` (the partner's tier caps it), so the\n// right person is sent to the right queue. `CapabilityRow` carries no such\n// field — `06-capability-and-personas.md §6` point 2 fixes it as \"four\n// booleans, no `reason` string\", and `capability.types.ts` says so too.\n//\n// So the reason is an OPTIONAL PROP, supplied by whatever the caller saw\n// (a refusal's own `details`), and `onUpgradeRequest` is called with\n// `undefined` when nobody knows. Defaulting it to `'agency'` would have\n// been a guess routed to a real support queue — the host can decide what to\n// do with \"unknown\" far better than this screen can invent an answer.\n\nimport type { ReactNode } from 'react';\nimport { useCapabilities } from '../../core/hooks/useCapabilities.js';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport type PlanLockedReason = 'agency' | 'partner-ceiling';\n\nexport interface PlanLockedScreenProps {\n /** The capability this route was headed for. Read for its own triple\n * only — never exhaustively switched on (`§6` point 5's open-set rule). */\n readonly capabilityKey: string;\n /** The host's own upsell/support flow — Kaafil has no in-product upgrade\n * path to hand off to. `undefined` means the wire did not say which\n * queue this belongs in; see this file's header. */\n readonly onUpgradeRequest: (reason: PlanLockedReason | undefined) => void;\n /** Supplied by the caller when it saw a refusal that named one. */\n readonly reason?: PlanLockedReason;\n readonly components?: { readonly PlanLockedScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function PlanLockedScreen({\n capabilityKey,\n onUpgradeRequest,\n reason,\n components,\n style,\n}: PlanLockedScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const capabilities = useCapabilities([capabilityKey]);\n const Override = components?.PlanLockedScreenUI;\n if (Override !== undefined) return <Override />;\n\n // Read, never re-derived: `status` is resolved once in `/core` and this\n // screen reads it rather than recombining the booleans itself\n // (`06-capability-and-personas.md §6` point 2).\n const status = capabilities.get(capabilityKey)?.status;\n\n return (\n <SystemScreenFrame\n block=\"kf-plan-locked-screen\"\n title={t('chrome.systemScreens.planLocked.title')}\n body={\n <>\n <p>\n {t(\n reason === 'partner-ceiling'\n ? 'chrome.systemScreens.planLocked.bodyPartnerCeiling'\n : 'chrome.systemScreens.planLocked.body',\n )}\n </p>\n {/* A route that reached this screen for a capability that is NOT\n * flag-dark is a caller bug, and saying so beats rendering upsell\n * copy over a module that is merely data-dark or simply lit. */}\n {status === 'flag-dark' ? null : (\n <p data-tone=\"warn\">{t('chrome.systemScreens.planLocked.notFlagDark')}</p>\n )}\n </>\n }\n {...(style !== undefined ? { style } : {})}\n actions={\n <button\n type=\"button\"\n className=\"kf-system-screen__primary\"\n onClick={() => onUpgradeRequest(reason)}\n >\n {t('chrome.systemScreens.planLocked.action')}\n </button>\n }\n />\n );\n}\n","'use client';\n\n// `shared/01-system-screens.md §SessionExpiredScreen`.\n//\n// Renders exactly when `useSession().status === 'expired'` — the open\n// credential's silent refresh has exhausted itself. Re-authentication is\n// routed through the HOST's own login; Kaafil has no login page to redirect\n// to, which is why `onReauthenticate` is required and has no default.\n//\n// DOES NOT retry any token call itself. A broken credential means the\n// host's own user is not authenticated and must re-authenticate through the\n// host's own flow — obtaining fresh tokens is `SessionShell`'s concern on\n// the NEXT successful mount, not this screen's on the current broken one.\n//\n// DOES NOT inspect which credential kind expired beyond the resolved\n// persona (`00-decisions.md` U-003 forecloses reading a JWT at any layer\n// above `SessionShell`).\n\nimport type { ReactNode } from 'react';\nimport { useState } from 'react';\nimport { useKaafilChrome } from '../../core/shells/I18nShell.js';\nimport type { KaafilTokenOverrides } from '../../primitives/internal/tokenStyle.js';\nimport { SystemScreenFrame } from './internal/SystemScreenFrame';\n\nexport interface SessionExpiredScreenProps {\n /** The host's own re-auth entry point. Required: there is no default\n * action, because Kaafil has no login page of its own. */\n readonly onReauthenticate: (returnTo?: string) => void | Promise<void>;\n /** Threaded back to `onReauthenticate` UNEXAMINED. This screen never\n * interprets it, builds a URL from it, or hands it to a router — it\n * exists purely so the host's own flow can restore the right destination\n * afterwards. */\n readonly returnTo?: string;\n readonly components?: { readonly SessionExpiredScreenUI?: () => ReactNode };\n readonly style?: KaafilTokenOverrides;\n}\n\nexport function SessionExpiredScreen({\n onReauthenticate,\n returnTo,\n components,\n style,\n}: SessionExpiredScreenProps): ReactNode {\n const { t } = useKaafilChrome();\n const [pending, setPending] = useState(false);\n // The host's own auth failure reason is not something Kaafil can\n // classify, so the rejection's own message is shown verbatim.\n const [failure, setFailure] = useState<string | undefined>(undefined);\n\n const Override = components?.SessionExpiredScreenUI;\n if (Override !== undefined) return <Override />;\n\n async function reauthenticate(): Promise<void> {\n setPending(true);\n setFailure(undefined);\n try {\n await onReauthenticate(returnTo);\n } catch (error) {\n setFailure(error instanceof Error ? error.message : String(error));\n } finally {\n setPending(false);\n }\n }\n\n return (\n <SystemScreenFrame\n block=\"kf-session-expired-screen\"\n title={t('chrome.systemScreens.sessionExpired.title')}\n body={<p>{t('chrome.systemScreens.sessionExpired.body')}</p>}\n {...(failure !== undefined ? { banner: <span data-tone=\"warn\">{failure}</span> } : {})}\n {...(style !== undefined ? { style } : {})}\n actions={\n <button\n type=\"button\"\n className=\"kf-system-screen__primary\"\n disabled={pending}\n onClick={() => void reauthenticate()}\n >\n {t(\n pending\n ? 'chrome.systemScreens.sessionExpired.busy'\n : 'chrome.systemScreens.sessionExpired.action',\n )}\n </button>\n }\n />\n );\n}\n"]}
|