@wow-two-beta/fe 0.0.31 → 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +7 -6
  2. package/dist/chunks/{AccountMenu.vue_vue_type_script_setup_true_lang-CG03MviN.js → AccountMenu.vue_vue_type_script_setup_true_lang-LEQUWCXJ.js} +7 -3
  3. package/dist/chunks/{AccountMenu.vue_vue_type_script_setup_true_lang-CG03MviN.js.map → AccountMenu.vue_vue_type_script_setup_true_lang-LEQUWCXJ.js.map} +1 -1
  4. package/dist/chunks/Alert.vue_vue_type_script_setup_true_lang-CoLxB2dM.js +155 -0
  5. package/dist/chunks/Alert.vue_vue_type_script_setup_true_lang-CoLxB2dM.js.map +1 -0
  6. package/dist/chunks/{FieldHelperText.vue_vue_type_script_setup_true_lang-B-G5rNMG.js → ColorSwatchPreview.vue_vue_type_script_setup_true_lang-Btd7KUEw.js} +70 -230
  7. package/dist/chunks/ColorSwatchPreview.vue_vue_type_script_setup_true_lang-Btd7KUEw.js.map +1 -0
  8. package/dist/chunks/{ErrorBoundary.vue_vue_type_script_setup_true_lang-Dv9wOZmk.js → ErrorBoundary.vue_vue_type_script_setup_true_lang-E72RRrNG.js} +87 -233
  9. package/dist/chunks/ErrorBoundary.vue_vue_type_script_setup_true_lang-E72RRrNG.js.map +1 -0
  10. package/dist/chunks/FieldHelperText.vue_vue_type_script_setup_true_lang-2IDI_JgQ.js +216 -0
  11. package/dist/chunks/FieldHelperText.vue_vue_type_script_setup_true_lang-2IDI_JgQ.js.map +1 -0
  12. package/dist/chunks/{KanbanCard.vue_vue_type_script_setup_true_lang-DKgIhFwh.js → KanbanCard.vue_vue_type_script_setup_true_lang-BrQFyOiU.js} +177 -223
  13. package/dist/chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BrQFyOiU.js.map +1 -0
  14. package/dist/chunks/{MasonryLayout.vue_vue_type_script_setup_true_lang-C5GpXgfl.js → MasonryLayout.vue_vue_type_script_setup_true_lang-BmWwoZrv.js} +29 -104
  15. package/dist/chunks/MasonryLayout.vue_vue_type_script_setup_true_lang-BmWwoZrv.js.map +1 -0
  16. package/dist/chunks/Navbar.variants-7DXJlilx.js +88 -0
  17. package/dist/chunks/Navbar.variants-7DXJlilx.js.map +1 -0
  18. package/dist/chunks/TypedConfirmField.vue_vue_type_script_setup_true_lang-DXCZlnlM.js +447 -0
  19. package/dist/chunks/TypedConfirmField.vue_vue_type_script_setup_true_lang-DXCZlnlM.js.map +1 -0
  20. package/dist/chunks/{LightboxModal.vue_vue_type_script_setup_true_lang-CP7Or4sf.js → TypedConfirmModal.vue_vue_type_script_setup_true_lang-CoIaH_xx.js} +299 -108
  21. package/dist/chunks/TypedConfirmModal.vue_vue_type_script_setup_true_lang-CoIaH_xx.js.map +1 -0
  22. package/dist/chunks/{MentionInput.vue_vue_type_script_setup_true_lang-D8Ja7QjX.js → UseTypedConfirmation-CvY2T4Up.js} +331 -582
  23. package/dist/chunks/UseTypedConfirmation-CvY2T4Up.js.map +1 -0
  24. package/dist/chunks/{index-CRV9gpyX.js → index-ou-qGNDu.js} +6 -3
  25. package/dist/chunks/index-ou-qGNDu.js.map +1 -0
  26. package/dist/foundation/http/ApiDecoderExtensions.d.ts +22 -0
  27. package/dist/foundation/http/ApiFailureExtensions.d.ts +22 -0
  28. package/dist/foundation/http/ProblemDetailsExtensions.d.ts +31 -0
  29. package/dist/foundation/http/index.d.ts +3 -0
  30. package/dist/foundation/http/index.js +93 -2
  31. package/dist/foundation/http/index.js.map +1 -1
  32. package/dist/foundation/themes/Theme.d.ts +7 -2
  33. package/dist/foundation/themes/index.js +1 -1
  34. package/dist/index.css +15 -9
  35. package/dist/index.js +657 -651
  36. package/dist/index.js.map +1 -1
  37. package/dist/presentation/display/index.js +158 -157
  38. package/dist/presentation/display/index.js.map +1 -1
  39. package/dist/presentation/feedback/index.js +43 -42
  40. package/dist/presentation/feedback/index.js.map +1 -1
  41. package/dist/presentation/forms/index.d.ts +1 -0
  42. package/dist/presentation/forms/index.js +139 -137
  43. package/dist/presentation/forms/tagsInput/TagsInput.vue.d.ts +1 -1
  44. package/dist/presentation/forms/typedConfirmField/TypedConfirmField.vue.d.ts +61 -0
  45. package/dist/presentation/forms/typedConfirmField/UseTypedConfirmation.d.ts +32 -0
  46. package/dist/presentation/forms/typedConfirmField/index.d.ts +2 -0
  47. package/dist/presentation/layout/index.js +34 -33
  48. package/dist/presentation/layout/index.js.map +1 -1
  49. package/dist/presentation/layout/navbar/Navbar.variants.d.ts +7 -1
  50. package/dist/presentation/nav/bottomNavMenu/BottomNavMenu.vue.d.ts +8 -0
  51. package/dist/presentation/nav/index.js +1 -1
  52. package/dist/presentation/overlays/index.d.ts +1 -0
  53. package/dist/presentation/overlays/index.js +6 -5
  54. package/dist/presentation/overlays/typedConfirmModal/TypedConfirmModal.vue.d.ts +64 -0
  55. package/dist/presentation/overlays/typedConfirmModal/index.d.ts +1 -0
  56. package/dist/themes.css +2 -0
  57. package/package.json +1 -1
  58. package/dist/chunks/ErrorBoundary.vue_vue_type_script_setup_true_lang-Dv9wOZmk.js.map +0 -1
  59. package/dist/chunks/FieldHelperText.vue_vue_type_script_setup_true_lang-B-G5rNMG.js.map +0 -1
  60. package/dist/chunks/KanbanCard.vue_vue_type_script_setup_true_lang-DKgIhFwh.js.map +0 -1
  61. package/dist/chunks/LightboxModal.vue_vue_type_script_setup_true_lang-CP7Or4sf.js.map +0 -1
  62. package/dist/chunks/ListboxPicker.variants-hiMcl66_.js +0 -44
  63. package/dist/chunks/ListboxPicker.variants-hiMcl66_.js.map +0 -1
  64. package/dist/chunks/MasonryLayout.vue_vue_type_script_setup_true_lang-C5GpXgfl.js.map +0 -1
  65. package/dist/chunks/MentionInput.vue_vue_type_script_setup_true_lang-D8Ja7QjX.js.map +0 -1
  66. package/dist/chunks/index-CRV9gpyX.js.map +0 -1
@@ -1,3 +1,5 @@
1
+ import { f as fieldIssues } from "../../chunks/FieldErrors-D_j6AF0Z.js";
2
+ import { a } from "../../chunks/FieldErrors-D_j6AF0Z.js";
1
3
  import { a as ApiFailureFactory, A as ApiError } from "../../chunks/ApiError-D_6igkXc.js";
2
4
  import { b } from "../../chunks/ApiError-D_6igkXc.js";
3
5
  import { R as ResultExtensions } from "../../chunks/ResultExtensions-B7dWH0FZ.js";
@@ -5,7 +7,65 @@ import { a as isTimeoutError, i as isAbortError } from "../../chunks/ErrorRecogn
5
7
  import { shouldRetry, computeRetryDelay } from "../resilience/index.js";
6
8
  import { c as combineRequestSignals, a as awaitRequest } from "../../chunks/RequestScope-Dh0CoWZg.js";
7
9
  import { b as b2 } from "../../chunks/RequestScope-Dh0CoWZg.js";
8
- import { a, f } from "../../chunks/FieldErrors-D_j6AF0Z.js";
10
+ const ProblemDetailsExtensions = {
11
+ /** @internal The longest server text shown when the caller sets no `maxLength`. */
12
+ MaxTextLength: 300,
13
+ /** @internal Control characters and bidirectional overrides, removed from server text. */
14
+ ControlCharacters: /[\p{Cc}‪-‮⁦-⁩]/gu,
15
+ /**
16
+ * Reads the problem-details body a failure carries — an `ApiFailure`, an `ApiError` or any `AppError` with a
17
+ * `problem` member — or `null` when it carries none.
18
+ */
19
+ of(failure) {
20
+ if (failure === null || typeof failure !== "object" || !("problem" in failure)) return null;
21
+ const problem = failure.problem;
22
+ return problem !== null && typeof problem === "object" && !Array.isArray(problem) ? problem : null;
23
+ },
24
+ /**
25
+ * Reads the text a person can read from a problem: the first field message (both the wow-two `errors` array and the
26
+ * ASP.NET `errors` map), else `detail`, else `title`. Each candidate loses control and bidirectional-override
27
+ * characters and the `strip` prefix,
28
+ * is trimmed, and is skipped when empty or longer than `maxLength`; `undefined` when none remains.
29
+ */
30
+ text(problem, options = {}) {
31
+ if (!problem) return void 0;
32
+ const maxLength = options.maxLength ?? ProblemDetailsExtensions.MaxTextLength;
33
+ const clean = (value) => {
34
+ if (typeof value !== "string") return void 0;
35
+ let text = value.replace(ProblemDetailsExtensions.ControlCharacters, "");
36
+ if (options.strip) text = text.replace(options.strip, "");
37
+ text = text.trim();
38
+ return text.length > 0 && text.length <= maxLength ? text : void 0;
39
+ };
40
+ if (options.fields !== false) {
41
+ for (const [property, issues] of Object.entries(fieldIssues({ problem }))) {
42
+ for (const issue of issues) {
43
+ const message = clean(issue.message);
44
+ if (message === void 0) continue;
45
+ const label = options.labels !== void 0 && Object.hasOwn(options.labels, property) ? options.labels[property] : void 0;
46
+ return label ? `${label}: ${message}` : message;
47
+ }
48
+ }
49
+ }
50
+ return clean(problem.detail) ?? clean(problem.title);
51
+ }
52
+ };
53
+ const ApiFailureExtensions = {
54
+ /**
55
+ * Describes why a request failed: the API's own problem text ({@link ProblemDetailsExtensions.text}), else
56
+ * `fallback`, else the failure's display-safe message. Takes an `ApiFailure`, an `ApiError` or any `AppError`;
57
+ * nothing yields `fallback`, or `''`. Use it where the API authors its problem text for people, as the be sdk's
58
+ * `AppError` messages are.
59
+ * ```ts
60
+ * const result = await reconcile(target);
61
+ * if (!result.ok) toast.danger(ApiFailureExtensions.reason(result.failure, { fallback: 'Reconcile failed.' }));
62
+ * ```
63
+ */
64
+ reason(failure, options = {}) {
65
+ if (!failure) return options.fallback ?? "";
66
+ return ProblemDetailsExtensions.text(ProblemDetailsExtensions.of(failure), options) ?? options.fallback ?? failure.message;
67
+ }
68
+ };
9
69
  const isJsonObject = (parsed) => parsed !== null && typeof parsed === "object" && !Array.isArray(parsed);
10
70
  const wowTwoEnvelope = {
11
71
  unwrap: (parsed, response) => isJsonObject(parsed) && Object.hasOwn(parsed, "data") ? ResultExtensions.ok(parsed["data"]) : ResultExtensions.fail(ApiFailureFactory.create("protocol", response)),
@@ -307,6 +367,34 @@ function createApiClient(options = {}) {
307
367
  delete: method("DELETE")
308
368
  };
309
369
  }
370
+ function isThenable(value) {
371
+ return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
372
+ }
373
+ const ApiDecoderExtensions = {
374
+ /**
375
+ * Wraps a Standard Schema — the SDK's own validators, zod, valibot, arktype — as an endpoint decoder. A payload the
376
+ * schema rejects is a `protocol` failure, so response diagnostics never become display text; its issues reach
377
+ * `onIssues` only. A schema that validates asynchronously throws a `TypeError`: wire decoding is synchronous.
378
+ * ```ts
379
+ * client.get('/api/codes', { decode: ApiDecoderExtensions.fromSchema(CodeListSchema) });
380
+ * ```
381
+ */
382
+ fromSchema(schema, options = {}) {
383
+ return (value) => {
384
+ const outcome = schema["~standard"].validate(value);
385
+ if (isThenable(outcome)) {
386
+ Promise.resolve(outcome).then(void 0, () => void 0);
387
+ throw new TypeError(
388
+ `ApiDecoderExtensions.fromSchema needs a synchronous schema; the ${schema["~standard"].vendor} schema returned a promise.`
389
+ );
390
+ }
391
+ if (outcome.issues === void 0)
392
+ return ResultExtensions.ok(outcome.value);
393
+ options.onIssues?.(outcome.issues);
394
+ return ResultExtensions.fail(ApiFailureFactory.create("protocol"));
395
+ };
396
+ }
397
+ };
310
398
  const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
311
399
  function toWarning(value) {
312
400
  if (!isRecord(value)) return null;
@@ -330,14 +418,17 @@ function decodeWarned(decodeData) {
330
418
  export {
331
419
  AntiforgeryDefaults,
332
420
  AntiforgeryExtensions,
421
+ ApiDecoderExtensions,
333
422
  ApiError,
334
423
  b as ApiFailureCode,
424
+ ApiFailureExtensions,
335
425
  ApiFailureFactory,
426
+ ProblemDetailsExtensions,
336
427
  createApiClient,
337
428
  b2 as createRequestScope,
338
429
  decodeWarned,
339
430
  a as fieldErrors,
340
- f as fieldIssues,
431
+ fieldIssues,
341
432
  rawEnvelope,
342
433
  wowTwoEnvelope
343
434
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/foundation/http/Envelope.ts","../../../src/foundation/http/Antiforgery.ts","../../../src/foundation/http/CreateApiClient.ts","../../../src/foundation/http/WarnedEnvelope.ts"],"sourcesContent":["import { ResultExtensions, type Result } from '../results';\nimport { ApiFailureFactory, type ApiFailure } from './ApiFailure';\n\nconst isJsonObject = (parsed: unknown): parsed is Record<string, unknown> =>\n parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed);\n\n/** Declares success-envelope decoding and non-success transport diagnostics. */\nexport interface ResponseEnvelope {\n readonly unwrap: (parsed: unknown, response: Response) => Result<unknown, ApiFailure>;\n readonly toFailure: (parsed: unknown, response: Response) => ApiFailure;\n}\n\n/** Requires a JSON object with its own data member. */\nexport const wowTwoEnvelope: ResponseEnvelope = {\n unwrap: (parsed, response) =>\n isJsonObject(parsed) && Object.hasOwn(parsed, 'data')\n ? ResultExtensions.ok(parsed['data'])\n : ResultExtensions.fail(ApiFailureFactory.create('protocol', response)),\n toFailure: (parsed, response) => ApiFailureFactory.create('http', response, isJsonObject(parsed) ? parsed : null),\n};\n\n/** Leaves un-enveloped JSON values unchanged. */\nexport const rawEnvelope: ResponseEnvelope = {\n unwrap: (parsed) => ResultExtensions.ok(parsed),\n toFailure: (_parsed, response) => ApiFailureFactory.create('http', response),\n};\n","import type { ApiFailure } from './ApiFailure';\n\n/**\n * Configures the antiforgery token a cookie-authenticated client echoes on unsafe requests — the browser half of\n * the backend SDK's SPA antiforgery, which issues the token in a readable cookie on every safe request.\n */\nexport interface ApiAntiforgeryOptions {\n /** The readable cookie the server issues the token in. Default `XSRF-TOKEN`. */\n readonly cookieName?: string;\n /** The request header the token is echoed in. Default `X-XSRF-TOKEN`. */\n readonly headerName?: string;\n /**\n * A safe path whose response reissues the token. A write rejected for a stale token — one issued before a\n * sign-in or sign-out — reads it once, then retries with the fresh token. Omitted, a rejection is returned.\n */\n readonly refreshPath?: string;\n /** Recognizes the server's antiforgery rejection; default: a 400 whose problem `code` names it. */\n readonly isRejection?: (failure: ApiFailure) => boolean;\n}\n\n/** Holds the defaults the backend SDK's SPA antiforgery uses. */\nexport const AntiforgeryDefaults = {\n cookieName: 'XSRF-TOKEN',\n headerName: 'X-XSRF-TOKEN',\n rejectionCode: 'AntiforgeryValidationFailed',\n} as const;\n\n/** Holds the request methods that carry an antiforgery token. */\nconst UnsafeMethods = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);\n\n/** Extends requests with the antiforgery token echo. */\nexport const AntiforgeryExtensions = {\n /** Whether a request method changes state and must echo the token. */\n isUnsafe(method: string | undefined): boolean {\n return UnsafeMethods.has((method ?? 'GET').toUpperCase());\n },\n\n /** Reads the current token from the readable cookie; `null` without a document or before the server issued one. */\n readToken(cookieName: string = AntiforgeryDefaults.cookieName): string | null {\n if (typeof document === 'undefined') return null;\n for (const part of document.cookie.split(';')) {\n const separator = part.indexOf('=');\n if (separator < 0 || part.slice(0, separator).trim() !== cookieName) continue;\n const value = part.slice(separator + 1).trim();\n try {\n return value ? decodeURIComponent(value) : null;\n } catch {\n return value || null;\n }\n }\n return null;\n },\n\n /** Recognizes the backend SDK's antiforgery rejection: a 400 whose problem `code` names it. */\n isRejection(failure: ApiFailure): boolean {\n return failure.status === 400 && failure.problem?.['code'] === AntiforgeryDefaults.rejectionCode;\n },\n} as const;\n","import { isAbortError, isTimeoutError } from '../errors';\nimport { computeRetryDelay, shouldRetry, type RetryPolicy } from '../resilience';\nimport { ResultExtensions, type Result } from '../results';\nimport { AntiforgeryDefaults, AntiforgeryExtensions, type ApiAntiforgeryOptions } from './Antiforgery';\nimport { ApiError } from './ApiError';\nimport type { ApiJsonCodec } from './ApiJsonCodec';\nimport { ApiFailureFactory, type ApiFailure } from './ApiFailure';\nimport { wowTwoEnvelope, type ResponseEnvelope } from './Envelope';\nimport { awaitRequest, combineRequestSignals, type RequestScope, type RequestSnapshot } from './RequestScope';\n\nexport type ApiQueryParams = Record<string, unknown>;\nexport type ApiDecoder<T> = (value: unknown) => Result<T, ApiFailure>;\nexport interface ApiRequestInit {\n readonly query?: ApiQueryParams;\n readonly body?: unknown;\n readonly signal?: AbortSignal | null;\n readonly headers?: HeadersInit;\n readonly unwrap?: boolean;\n readonly method?: string;\n /** Overrides the client's JSON codec for this request. `null` selects native JSON. */\n readonly json?: ApiJsonCodec | null;\n}\nexport interface ApiEmptyRequestInit extends ApiRequestInit {\n readonly response: 'empty';\n}\nexport interface ApiTextRequestInit extends ApiRequestInit {\n readonly response: 'text';\n}\nexport interface ApiBlobRequestInit extends ApiRequestInit {\n readonly response: 'blob';\n}\nexport interface ApiArrayBufferRequestInit extends ApiRequestInit {\n readonly response: 'arrayBuffer';\n}\nexport interface ApiJsonRequestInit<T> extends ApiRequestInit {\n readonly response?: 'json';\n readonly decode: ApiDecoder<T>;\n}\nexport interface ApiClientOptions {\n readonly baseUrl?: string;\n readonly getAuthToken?: () => string | null | Promise<string | null>;\n readonly credentials?: RequestCredentials;\n /** Receives a current-session 401; when it invalidates `scope`, this request resolves cancelled. */\n readonly onUnauthorized?: (failure: ApiFailure, origin?: RequestSnapshot) => void;\n /** Explicit session lifetime; captures once before credentials, retries and response decoding. */\n readonly scope?: RequestScope;\n readonly defaultHeaders?: HeadersInit;\n readonly envelope?: ResponseEnvelope;\n readonly retry?: RetryPolicy | false;\n readonly fetch?: typeof globalThis.fetch;\n /** Overrides request/response JSON conversion, including non-success diagnostics. Native JSON is the default. */\n readonly json?: ApiJsonCodec;\n /** Echoes the readable antiforgery cookie on unsafe requests, refreshing a stale token once when a path is given. */\n readonly antiforgery?: ApiAntiforgeryOptions;\n}\n/** Typed payloads require a decoder; an empty response must be requested explicitly. */\nexport interface ApiMethod {\n (path: string, init: ApiEmptyRequestInit): Promise<Result<void, ApiFailure>>;\n (path: string, init: ApiTextRequestInit): Promise<Result<string, ApiFailure>>;\n (path: string, init: ApiBlobRequestInit): Promise<Result<Blob, ApiFailure>>;\n (path: string, init: ApiArrayBufferRequestInit): Promise<Result<ArrayBuffer, ApiFailure>>;\n <T>(path: string, init: ApiJsonRequestInit<T>): Promise<Result<T, ApiFailure>>;\n (path: string, init?: ApiRequestInit): Promise<Result<unknown, ApiFailure>>;\n}\n/** A decoded successful response together with immutable metadata at the integration edge. */\nexport interface ApiResponseValue<T> {\n readonly value: T;\n readonly status: number;\n readonly headers: Readonly<Record<string, string>>;\n readonly url: string;\n}\n/** Detailed response overloads preserve each payload type without exposing a consumed Response body. */\nexport interface ApiDetailedMethod {\n (path: string, init: ApiEmptyRequestInit): Promise<Result<ApiResponseValue<void>, ApiFailure>>;\n (path: string, init: ApiTextRequestInit): Promise<Result<ApiResponseValue<string>, ApiFailure>>;\n (path: string, init: ApiBlobRequestInit): Promise<Result<ApiResponseValue<Blob>, ApiFailure>>;\n (path: string, init: ApiArrayBufferRequestInit): Promise<Result<ApiResponseValue<ArrayBuffer>, ApiFailure>>;\n <T>(path: string, init: ApiJsonRequestInit<T>): Promise<Result<ApiResponseValue<T>, ApiFailure>>;\n (path: string, init?: ApiRequestInit): Promise<Result<ApiResponseValue<unknown>, ApiFailure>>;\n}\nexport interface ApiDetailedClient {\n readonly get: ApiDetailedMethod;\n readonly post: ApiDetailedMethod;\n readonly put: ApiDetailedMethod;\n readonly patch: ApiDetailedMethod;\n readonly delete: ApiDetailedMethod;\n readonly request: ApiDetailedMethod;\n}\nexport interface ApiClient {\n readonly detailed: ApiDetailedClient;\n readonly get: ApiMethod;\n readonly post: ApiMethod;\n readonly put: ApiMethod;\n readonly patch: ApiMethod;\n readonly delete: ApiMethod;\n readonly request: ApiMethod;\n}\ninterface RequestOptions extends ApiRequestInit {\n readonly response?: 'json' | 'empty' | 'text' | 'blob' | 'arrayBuffer';\n readonly decode?: ApiDecoder<unknown>;\n}\nfunction buildQueryString(query: ApiQueryParams): string {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n for (const item of Array.isArray(value) ? value : [value]) {\n if (item != null) params.append(key, String(item));\n }\n }\n return params.toString();\n}\nfunction interruption(signal?: AbortSignal | null, error?: unknown): ApiFailure | undefined {\n if (isTimeoutError(error) || (signal?.aborted && isTimeoutError(signal.reason)))\n return ApiFailureFactory.create('timeout');\n if (signal?.aborted || isAbortError(error)) return ApiFailureFactory.create('cancelled');\n return undefined;\n}\n/** Wakes immediately on cancellation; the request loop returns its typed outcome. */\nfunction wait(ms: number, signal?: AbortSignal | null): Promise<void> {\n return new Promise((resolve) => {\n if (signal?.aborted) {\n resolve();\n return;\n }\n const finish = (): void => {\n clearTimeout(timer);\n signal?.removeEventListener('abort', finish);\n resolve();\n };\n const timer = setTimeout(finish, ms);\n signal?.addEventListener('abort', finish, { once: true });\n });\n}\n/** Returns expected transport/protocol failures; application decoder bugs still throw. */\nexport function createApiClient(options: ApiClientOptions = {}): ApiClient {\n const {\n baseUrl = '',\n getAuthToken,\n credentials,\n defaultHeaders,\n envelope = wowTwoEnvelope,\n retry = false,\n antiforgery,\n } = options;\n /** Reads the antiforgery refresh path once, so a stale token is replaced before the one retry. */\n const refreshAntiforgery = async (signal: AbortSignal): Promise<void> => {\n if (!antiforgery?.refreshPath) return;\n try {\n await awaitRequest(\n () =>\n (options.fetch ?? globalThis.fetch)(`${baseUrl}${antiforgery.refreshPath}`, {\n method: 'GET',\n cache: 'no-store',\n signal,\n ...(credentials !== undefined ? { credentials } : {}),\n }),\n signal,\n );\n } catch {\n // The retry reports the outcome; a failed refresh leaves the rejection to surface.\n }\n };\n const attemptOnce = async (\n url: string,\n init: RequestOptions,\n body: BodyInit | undefined,\n hasJsonBody: boolean,\n json: ApiJsonCodec | undefined,\n token: string | null,\n ): Promise<Result<ApiResponseValue<unknown>, ApiFailure>> => {\n const cancelled = interruption(init.signal);\n if (cancelled) return ResultExtensions.fail(cancelled);\n const headers = new Headers({\n Accept: init.response === undefined || init.response === 'json' ? 'application/json' : '*/*',\n });\n if (hasJsonBody) headers.set('Content-Type', 'application/json');\n if (defaultHeaders) new Headers(defaultHeaders).forEach((value, key) => headers.set(key, value));\n if (token != null) headers.set('Authorization', `Bearer ${token}`);\n if (antiforgery && AntiforgeryExtensions.isUnsafe(init.method)) {\n const xsrf = AntiforgeryExtensions.readToken(antiforgery.cookieName ?? AntiforgeryDefaults.cookieName);\n if (xsrf != null) headers.set(antiforgery.headerName ?? AntiforgeryDefaults.headerName, xsrf);\n }\n if (init.headers) new Headers(init.headers).forEach((value, key) => headers.set(key, value));\n let response: Response;\n try {\n response = await awaitRequest(\n () =>\n (options.fetch ?? globalThis.fetch)(url, {\n method: init.method ?? 'GET',\n headers,\n signal: init.signal ?? null,\n ...(credentials !== undefined ? { credentials } : {}),\n ...(body !== undefined ? { body } : {}),\n }),\n init.signal,\n );\n } catch (error) {\n return ResultExtensions.fail(interruption(init.signal, error) ?? ApiFailureFactory.create('transport'));\n }\n const success = (value: unknown): Result<ApiResponseValue<unknown>, ApiFailure> =>\n ResultExtensions.ok({\n value,\n status: response.status,\n headers: Object.freeze(Object.fromEntries(response.headers)),\n url: response.url,\n });\n if (!response.ok) {\n let diagnostics: unknown;\n let diagnosticText = '';\n try {\n diagnosticText = await awaitRequest(() => response.text(), init.signal);\n } catch (error) {\n const aborted = interruption(init.signal, error);\n if (aborted) return ResultExtensions.fail(aborted);\n // Reading optional diagnostics must not hide the HTTP status.\n }\n if (diagnosticText !== '') {\n if (json) {\n const decoded = json.parse(diagnosticText);\n if (decoded.ok) diagnostics = decoded.value;\n } else {\n try {\n diagnostics = JSON.parse(diagnosticText);\n } catch {\n /* Malformed optional diagnostics do not change the HTTP failure. */\n }\n }\n }\n const aborted = interruption(init.signal);\n return ResultExtensions.fail(aborted ?? envelope.toFailure(diagnostics, response));\n }\n if (init.response === 'blob' || init.response === 'arrayBuffer') {\n try {\n const value = await awaitRequest<Blob | ArrayBuffer>(\n () => (init.response === 'blob' ? response.blob() : response.arrayBuffer()),\n init.signal,\n );\n const aborted = interruption(init.signal);\n return aborted ? ResultExtensions.fail(aborted) : success(value);\n } catch (error) {\n return ResultExtensions.fail(\n interruption(init.signal, error) ?? ApiFailureFactory.create('transport', response),\n );\n }\n }\n let text: string;\n try {\n text = await awaitRequest(() => response.text(), init.signal);\n } catch (error) {\n return ResultExtensions.fail(interruption(init.signal, error) ?? ApiFailureFactory.create('transport', response));\n }\n const aborted = interruption(init.signal);\n if (aborted) return ResultExtensions.fail(aborted);\n if (init.response === 'empty')\n return text === '' ? success(undefined) : ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n if (init.response === 'text') return success(text);\n if (text === '' || !/^application\\/(?:[\\w.-]+\\+)?json(?:;|$)/i.test(response.headers.get('Content-Type') ?? ''))\n return ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n let parsed: unknown;\n if (json) {\n const decoded = json.parse(text);\n const interrupted = interruption(init.signal);\n if (interrupted) return ResultExtensions.fail(interrupted);\n if (!decoded.ok) return ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n parsed = decoded.value;\n } else {\n try {\n parsed = JSON.parse(text);\n } catch {\n return ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n }\n }\n const payload = init.unwrap === false ? ResultExtensions.ok(parsed) : envelope.unwrap(parsed, response);\n if (!payload.ok) return payload;\n const decoded = init.decode ? init.decode(payload.value) : payload;\n const interrupted = interruption(init.signal);\n return interrupted ? ResultExtensions.fail(interrupted) : decoded.ok ? success(decoded.value) : decoded;\n };\n /** Sends one attempt and tags its failure with the endpoint, so a report or log names it without the transport. */\n const attempt = async (\n url: string,\n init: RequestOptions,\n body: BodyInit | undefined,\n hasJsonBody: boolean,\n json: ApiJsonCodec | undefined,\n token: string | null,\n ): Promise<Result<ApiResponseValue<unknown>, ApiFailure>> => {\n const result = await attemptOnce(url, init, body, hasJsonBody, json, token);\n if (result.ok) return result;\n const request = { method: (init.method ?? 'GET').toUpperCase(), url: url.split(/[?#]/u)[0] ?? url };\n return ResultExtensions.fail({ ...result.failure, request });\n };\n const execute = async (\n path: string,\n requested: RequestOptions,\n ): Promise<Result<ApiResponseValue<unknown>, ApiFailure>> => {\n const origin = options.scope?.capture();\n const combined = combineRequestSignals(requested.signal, origin?.signal);\n const init = { ...requested, signal: combined.signal };\n try {\n const cancelled = interruption(init.signal);\n if (cancelled) return ResultExtensions.fail(cancelled);\n const query = init.query ? buildQueryString(init.query) : '';\n const url = `${baseUrl}${path}${query ? (path.includes('?') ? '&' : '?') + query : ''}`;\n const isFormData = typeof FormData !== 'undefined' && init.body instanceof FormData;\n const json = init.json === undefined ? options.json : (init.json ?? undefined);\n let body: BodyInit | undefined;\n if (init.body !== undefined && !isFormData && json) {\n const encoded = json.stringify(init.body);\n const interrupted = interruption(init.signal);\n if (interrupted) return ResultExtensions.fail(interrupted);\n if (!encoded.ok) return ResultExtensions.fail(ApiFailureFactory.create('validation'));\n body = encoded.value;\n } else\n body = init.body === undefined ? undefined : isFormData ? (init.body as FormData) : JSON.stringify(init.body);\n let token: string | null;\n try {\n token = getAuthToken ? await awaitRequest(getAuthToken, init.signal) : null;\n } catch (error) {\n const aborted = interruption(init.signal, error);\n if (aborted) return ResultExtensions.fail(aborted);\n throw error;\n }\n let retries = 0;\n let previousDelayMs = 0;\n let refreshedAntiforgery = false;\n for (;;) {\n const result = await attempt(url, init, body, init.body !== undefined && !isFormData, json, token);\n const aborted = interruption(init.signal);\n if (aborted) return ResultExtensions.fail(aborted);\n if (result.ok) return result;\n const failure = result.failure;\n if (\n antiforgery?.refreshPath &&\n !refreshedAntiforgery &&\n AntiforgeryExtensions.isUnsafe(init.method) &&\n (antiforgery.isRejection ?? AntiforgeryExtensions.isRejection)(failure)\n ) {\n refreshedAntiforgery = true;\n await refreshAntiforgery(init.signal);\n const interrupted = interruption(init.signal);\n if (interrupted) return ResultExtensions.fail(interrupted);\n continue;\n }\n const retryable = failure.code === 'http' || failure.code === 'transport';\n const idempotent = ['GET', 'HEAD', 'OPTIONS'].includes((init.method ?? 'GET').toUpperCase());\n if (retry !== false && retryable && idempotent && shouldRetry(retry, retries, failure.status)) {\n const attemptNumber = retries + 1;\n const delayMs = computeRetryDelay(retry, attemptNumber, previousDelayMs);\n retry.onRetry?.({ attempt: attemptNumber, error: new ApiError(failure), status: failure.status, delayMs });\n await wait(delayMs, init.signal);\n retries = attemptNumber;\n previousDelayMs = delayMs;\n continue;\n }\n if (failure.status === 401 && (!origin || origin.isCurrent())) {\n options.onUnauthorized?.(failure, origin);\n // A 401 that ended its own session resolves cancelled, like every other request of that session.\n const ended = interruption(init.signal);\n if (ended) return ResultExtensions.fail(ended);\n }\n return result;\n }\n } finally {\n combined.dispose();\n }\n };\n const detailedMethod = (verb?: string): ApiDetailedMethod => {\n const send = (path: string, init: RequestOptions = {}) => execute(path, verb ? { ...init, method: verb } : init);\n return send as ApiDetailedMethod;\n };\n const method = (verb?: string): ApiMethod => {\n function send(path: string, init: ApiEmptyRequestInit): Promise<Result<void, ApiFailure>>;\n function send(path: string, init: ApiTextRequestInit): Promise<Result<string, ApiFailure>>;\n function send(path: string, init: ApiBlobRequestInit): Promise<Result<Blob, ApiFailure>>;\n function send(path: string, init: ApiArrayBufferRequestInit): Promise<Result<ArrayBuffer, ApiFailure>>;\n function send<T>(path: string, init: ApiJsonRequestInit<T>): Promise<Result<T, ApiFailure>>;\n function send(path: string, init?: ApiRequestInit): Promise<Result<unknown, ApiFailure>>;\n function send(path: string, init: RequestOptions = {}): Promise<Result<unknown, ApiFailure>> {\n return execute(path, verb ? { ...init, method: verb } : init).then((result) =>\n result.ok ? ResultExtensions.ok(result.value.value) : result,\n );\n }\n return send;\n };\n return {\n detailed: {\n request: detailedMethod(),\n get: detailedMethod('GET'),\n post: detailedMethod('POST'),\n put: detailedMethod('PUT'),\n patch: detailedMethod('PATCH'),\n delete: detailedMethod('DELETE'),\n },\n request: method(),\n get: method('GET'),\n post: method('POST'),\n put: method('PUT'),\n patch: method('PATCH'),\n delete: method('DELETE'),\n };\n}\n","import { ResultExtensions } from '../results';\nimport { ApiFailureFactory } from './ApiFailure';\nimport type { ApiDecoder } from './CreateApiClient';\nimport type { ApiWarned, ApiWarning } from './models/ApiWarning';\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\n/** Reads one warning; `null` when a required member is not text. */\nfunction toWarning(value: unknown): ApiWarning | null {\n if (!isRecord(value)) return null;\n const { property, message, code, severity } = value;\n if (typeof property !== 'string' || typeof message !== 'string' || typeof code !== 'string') return null;\n return { property, message, code, severity: typeof severity === 'string' ? severity : 'warning' };\n}\n\n/**\n * Builds a decoder for a `{ data, warnings }` success envelope — the backend SDK's `ApiResponse<T>.Ok(data, warnings)`.\n * Request it with `unwrap: false`, so the decoder sees the whole envelope; a missing `warnings` reads as none.\n * ```ts\n * client.post('/api/codes', { body, unwrap: false, decode: decodeWarned(decodeCode) });\n * ```\n */\nexport function decodeWarned<T>(decodeData: ApiDecoder<T>): ApiDecoder<ApiWarned<T>> {\n return (value) => {\n if (!isRecord(value) || !Object.hasOwn(value, 'data'))\n return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n const raw = value['warnings'] ?? [];\n if (!Array.isArray(raw)) return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n const warnings = raw.map(toWarning);\n if (warnings.some((warning) => warning === null))\n return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n const data = decodeData(value['data']);\n return data.ok ? ResultExtensions.ok({ data: data.value, warnings: warnings as ReadonlyArray<ApiWarning> }) : data;\n };\n}\n"],"names":["aborted","decoded","interrupted"],"mappings":";;;;;;;;AAGA,MAAM,eAAe,CAAC,WACpB,WAAW,QAAQ,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM;AASjE,MAAM,iBAAmC;AAAA,EAC9C,QAAQ,CAAC,QAAQ,aACf,aAAa,MAAM,KAAK,OAAO,OAAO,QAAQ,MAAM,IAChD,iBAAiB,GAAG,OAAO,MAAM,CAAC,IAClC,iBAAiB,KAAK,kBAAkB,OAAO,YAAY,QAAQ,CAAC;AAAA,EAC1E,WAAW,CAAC,QAAQ,aAAa,kBAAkB,OAAO,QAAQ,UAAU,aAAa,MAAM,IAAI,SAAS,IAAI;AAClH;AAGO,MAAM,cAAgC;AAAA,EAC3C,QAAQ,CAAC,WAAW,iBAAiB,GAAG,MAAM;AAAA,EAC9C,WAAW,CAAC,SAAS,aAAa,kBAAkB,OAAO,QAAQ,QAAQ;AAC7E;ACJO,MAAM,sBAAsB;A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Aa,WAAW,WAAW,UAAA;AACxF;AASO,SAAS,aAAgB,YAAqD;AACnF,SAAO,CAAC,UAAU;AAChB,QAAI,CAAC,SAAS,KAAK,KAAK,CAAC,OAAO,OAAO,OAAO,MAAM;AAClD,aAAO,iBAAiB,KAAK,kBAAkB,OAAO,UAAU,CAAC;AACnE,UAAM,MAAM,MAAM,UAAU,KAAK,CAAA;AACjC,QAAI,CAAC,MAAM,QAAQ,GAAG,EAAG,QAAO,iBAAiB,KAAK,kBAAkB,OAAO,UAAU,CAAC;AAC1F,UAAM,WAAW,IAAI,IAAI,SAAS;AAClC,QAAI,SAAS,KAAK,CAAC,YAAY,YAAY,IAAI;AAC7C,aAAO,iBAAiB,KAAK,kBAAkB,OAAO,UAAU,CAAC;AACnE,UAAM,OAAO,WAAW,MAAM,MAAM,CAAC;AACrC,WAAO,KAAK,KAAK,iBAAiB,GAAG,EAAE,MAAM,KAAK,OAAO,SAAA,CAAiD,IAAI;AAAA,EAChH;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/foundation/http/ProblemDetailsExtensions.ts","../../../src/foundation/http/ApiFailureExtensions.ts","../../../src/foundation/http/Envelope.ts","../../../src/foundation/http/Antiforgery.ts","../../../src/foundation/http/CreateApiClient.ts","../../../src/foundation/http/ApiDecoderExtensions.ts","../../../src/foundation/http/WarnedEnvelope.ts"],"sourcesContent":["import { fieldIssues } from './FieldErrors';\nimport type { ProblemDetails } from './models/ProblemDetails';\n\n/** Defines how display text is read from a problem-details body. */\nexport interface ProblemTextOptions {\n /** Reads the first field message before `detail` and `title`. Default `true`. */\n readonly fields?: boolean;\n\n /** The display label per field property; a labelled field message reads `{label}: {message}`. */\n readonly labels?: Readonly<Record<string, string>>;\n\n /** The longest text shown; longer text reads as diagnostics and is skipped. Default 300. */\n readonly maxLength?: number;\n\n /** A prefix a reader should not see (`/^Deployment rejected: /`); removed before the length check. */\n readonly strip?: RegExp;\n}\n\n/** Extends `ProblemDetails` with the reads a failure message needs. */\nexport const ProblemDetailsExtensions = {\n /** @internal The longest server text shown when the caller sets no `maxLength`. */\n MaxTextLength: 300,\n\n /** @internal Control characters and bidirectional overrides, removed from server text. */\n ControlCharacters: /[\\p{Cc}‪-‮⁦-⁩]/gu,\n\n /**\n * Reads the problem-details body a failure carries — an `ApiFailure`, an `ApiError` or any `AppError` with a\n * `problem` member — or `null` when it carries none.\n */\n of(failure: unknown): Readonly<ProblemDetails> | null {\n if (failure === null || typeof failure !== 'object' || !('problem' in failure)) return null;\n const problem: unknown = failure.problem;\n return problem !== null && typeof problem === 'object' && !Array.isArray(problem)\n ? (problem as Readonly<ProblemDetails>)\n : null;\n },\n\n /**\n * Reads the text a person can read from a problem: the first field message (both the wow-two `errors` array and the\n * ASP.NET `errors` map), else `detail`, else `title`. Each candidate loses control and bidirectional-override\n * characters and the `strip` prefix,\n * is trimmed, and is skipped when empty or longer than `maxLength`; `undefined` when none remains.\n */\n text(problem: Readonly<ProblemDetails> | null | undefined, options: ProblemTextOptions = {}): string | undefined {\n if (!problem) return undefined;\n\n const maxLength = options.maxLength ?? ProblemDetailsExtensions.MaxTextLength;\n const clean = (value: unknown): string | undefined => {\n if (typeof value !== 'string') return undefined;\n let text = value.replace(ProblemDetailsExtensions.ControlCharacters, '');\n if (options.strip) text = text.replace(options.strip, '');\n text = text.trim();\n return text.length > 0 && text.length <= maxLength ? text : undefined;\n };\n\n if (options.fields !== false) {\n for (const [property, issues] of Object.entries(fieldIssues({ problem }))) {\n for (const issue of issues) {\n const message = clean(issue.message);\n if (message === undefined) continue;\n const label =\n options.labels !== undefined && Object.hasOwn(options.labels, property)\n ? options.labels[property]\n : undefined;\n return label ? `${label}: ${message}` : message;\n }\n }\n }\n\n return clean(problem.detail) ?? clean(problem.title);\n },\n} as const;\n","import type { AppError } from '../results';\nimport type { ApiError } from './ApiError';\nimport { ProblemDetailsExtensions, type ProblemTextOptions } from './ProblemDetailsExtensions';\n\n/** Defines how a failure's reason is read. */\nexport interface FailureReasonOptions extends ProblemTextOptions {\n /** The text used when the API sent no readable problem text. Default the failure's own display-safe message. */\n readonly fallback?: string;\n}\n\n/** Extends `ApiFailure` with the sentence a person reads. */\nexport const ApiFailureExtensions = {\n /**\n * Describes why a request failed: the API's own problem text ({@link ProblemDetailsExtensions.text}), else\n * `fallback`, else the failure's display-safe message. Takes an `ApiFailure`, an `ApiError` or any `AppError`;\n * nothing yields `fallback`, or `''`. Use it where the API authors its problem text for people, as the be sdk's\n * `AppError` messages are.\n * ```ts\n * const result = await reconcile(target);\n * if (!result.ok) toast.danger(ApiFailureExtensions.reason(result.failure, { fallback: 'Reconcile failed.' }));\n * ```\n */\n reason(failure: AppError | ApiError | null | undefined, options: FailureReasonOptions = {}): string {\n if (!failure) return options.fallback ?? '';\n return (\n ProblemDetailsExtensions.text(ProblemDetailsExtensions.of(failure), options) ??\n options.fallback ??\n failure.message\n );\n },\n} as const;\n","import { ResultExtensions, type Result } from '../results';\nimport { ApiFailureFactory, type ApiFailure } from './ApiFailure';\n\nconst isJsonObject = (parsed: unknown): parsed is Record<string, unknown> =>\n parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed);\n\n/** Declares success-envelope decoding and non-success transport diagnostics. */\nexport interface ResponseEnvelope {\n readonly unwrap: (parsed: unknown, response: Response) => Result<unknown, ApiFailure>;\n readonly toFailure: (parsed: unknown, response: Response) => ApiFailure;\n}\n\n/** Requires a JSON object with its own data member. */\nexport const wowTwoEnvelope: ResponseEnvelope = {\n unwrap: (parsed, response) =>\n isJsonObject(parsed) && Object.hasOwn(parsed, 'data')\n ? ResultExtensions.ok(parsed['data'])\n : ResultExtensions.fail(ApiFailureFactory.create('protocol', response)),\n toFailure: (parsed, response) => ApiFailureFactory.create('http', response, isJsonObject(parsed) ? parsed : null),\n};\n\n/** Leaves un-enveloped JSON values unchanged. */\nexport const rawEnvelope: ResponseEnvelope = {\n unwrap: (parsed) => ResultExtensions.ok(parsed),\n toFailure: (_parsed, response) => ApiFailureFactory.create('http', response),\n};\n","import type { ApiFailure } from './ApiFailure';\n\n/**\n * Configures the antiforgery token a cookie-authenticated client echoes on unsafe requests — the browser half of\n * the backend SDK's SPA antiforgery, which issues the token in a readable cookie on every safe request.\n */\nexport interface ApiAntiforgeryOptions {\n /** The readable cookie the server issues the token in. Default `XSRF-TOKEN`. */\n readonly cookieName?: string;\n /** The request header the token is echoed in. Default `X-XSRF-TOKEN`. */\n readonly headerName?: string;\n /**\n * A safe path whose response reissues the token. A write rejected for a stale token — one issued before a\n * sign-in or sign-out — reads it once, then retries with the fresh token. Omitted, a rejection is returned.\n */\n readonly refreshPath?: string;\n /** Recognizes the server's antiforgery rejection; default: a 400 whose problem `code` names it. */\n readonly isRejection?: (failure: ApiFailure) => boolean;\n}\n\n/** Holds the defaults the backend SDK's SPA antiforgery uses. */\nexport const AntiforgeryDefaults = {\n cookieName: 'XSRF-TOKEN',\n headerName: 'X-XSRF-TOKEN',\n rejectionCode: 'AntiforgeryValidationFailed',\n} as const;\n\n/** Holds the request methods that carry an antiforgery token. */\nconst UnsafeMethods = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);\n\n/** Extends requests with the antiforgery token echo. */\nexport const AntiforgeryExtensions = {\n /** Whether a request method changes state and must echo the token. */\n isUnsafe(method: string | undefined): boolean {\n return UnsafeMethods.has((method ?? 'GET').toUpperCase());\n },\n\n /** Reads the current token from the readable cookie; `null` without a document or before the server issued one. */\n readToken(cookieName: string = AntiforgeryDefaults.cookieName): string | null {\n if (typeof document === 'undefined') return null;\n for (const part of document.cookie.split(';')) {\n const separator = part.indexOf('=');\n if (separator < 0 || part.slice(0, separator).trim() !== cookieName) continue;\n const value = part.slice(separator + 1).trim();\n try {\n return value ? decodeURIComponent(value) : null;\n } catch {\n return value || null;\n }\n }\n return null;\n },\n\n /** Recognizes the backend SDK's antiforgery rejection: a 400 whose problem `code` names it. */\n isRejection(failure: ApiFailure): boolean {\n return failure.status === 400 && failure.problem?.['code'] === AntiforgeryDefaults.rejectionCode;\n },\n} as const;\n","import { isAbortError, isTimeoutError } from '../errors';\nimport { computeRetryDelay, shouldRetry, type RetryPolicy } from '../resilience';\nimport { ResultExtensions, type Result } from '../results';\nimport { AntiforgeryDefaults, AntiforgeryExtensions, type ApiAntiforgeryOptions } from './Antiforgery';\nimport { ApiError } from './ApiError';\nimport type { ApiJsonCodec } from './ApiJsonCodec';\nimport { ApiFailureFactory, type ApiFailure } from './ApiFailure';\nimport { wowTwoEnvelope, type ResponseEnvelope } from './Envelope';\nimport { awaitRequest, combineRequestSignals, type RequestScope, type RequestSnapshot } from './RequestScope';\n\nexport type ApiQueryParams = Record<string, unknown>;\nexport type ApiDecoder<T> = (value: unknown) => Result<T, ApiFailure>;\nexport interface ApiRequestInit {\n readonly query?: ApiQueryParams;\n readonly body?: unknown;\n readonly signal?: AbortSignal | null;\n readonly headers?: HeadersInit;\n readonly unwrap?: boolean;\n readonly method?: string;\n /** Overrides the client's JSON codec for this request. `null` selects native JSON. */\n readonly json?: ApiJsonCodec | null;\n}\nexport interface ApiEmptyRequestInit extends ApiRequestInit {\n readonly response: 'empty';\n}\nexport interface ApiTextRequestInit extends ApiRequestInit {\n readonly response: 'text';\n}\nexport interface ApiBlobRequestInit extends ApiRequestInit {\n readonly response: 'blob';\n}\nexport interface ApiArrayBufferRequestInit extends ApiRequestInit {\n readonly response: 'arrayBuffer';\n}\nexport interface ApiJsonRequestInit<T> extends ApiRequestInit {\n readonly response?: 'json';\n readonly decode: ApiDecoder<T>;\n}\nexport interface ApiClientOptions {\n readonly baseUrl?: string;\n readonly getAuthToken?: () => string | null | Promise<string | null>;\n readonly credentials?: RequestCredentials;\n /** Receives a current-session 401; when it invalidates `scope`, this request resolves cancelled. */\n readonly onUnauthorized?: (failure: ApiFailure, origin?: RequestSnapshot) => void;\n /** Explicit session lifetime; captures once before credentials, retries and response decoding. */\n readonly scope?: RequestScope;\n readonly defaultHeaders?: HeadersInit;\n readonly envelope?: ResponseEnvelope;\n readonly retry?: RetryPolicy | false;\n readonly fetch?: typeof globalThis.fetch;\n /** Overrides request/response JSON conversion, including non-success diagnostics. Native JSON is the default. */\n readonly json?: ApiJsonCodec;\n /** Echoes the readable antiforgery cookie on unsafe requests, refreshing a stale token once when a path is given. */\n readonly antiforgery?: ApiAntiforgeryOptions;\n}\n/** Typed payloads require a decoder; an empty response must be requested explicitly. */\nexport interface ApiMethod {\n (path: string, init: ApiEmptyRequestInit): Promise<Result<void, ApiFailure>>;\n (path: string, init: ApiTextRequestInit): Promise<Result<string, ApiFailure>>;\n (path: string, init: ApiBlobRequestInit): Promise<Result<Blob, ApiFailure>>;\n (path: string, init: ApiArrayBufferRequestInit): Promise<Result<ArrayBuffer, ApiFailure>>;\n <T>(path: string, init: ApiJsonRequestInit<T>): Promise<Result<T, ApiFailure>>;\n (path: string, init?: ApiRequestInit): Promise<Result<unknown, ApiFailure>>;\n}\n/** A decoded successful response together with immutable metadata at the integration edge. */\nexport interface ApiResponseValue<T> {\n readonly value: T;\n readonly status: number;\n readonly headers: Readonly<Record<string, string>>;\n readonly url: string;\n}\n/** Detailed response overloads preserve each payload type without exposing a consumed Response body. */\nexport interface ApiDetailedMethod {\n (path: string, init: ApiEmptyRequestInit): Promise<Result<ApiResponseValue<void>, ApiFailure>>;\n (path: string, init: ApiTextRequestInit): Promise<Result<ApiResponseValue<string>, ApiFailure>>;\n (path: string, init: ApiBlobRequestInit): Promise<Result<ApiResponseValue<Blob>, ApiFailure>>;\n (path: string, init: ApiArrayBufferRequestInit): Promise<Result<ApiResponseValue<ArrayBuffer>, ApiFailure>>;\n <T>(path: string, init: ApiJsonRequestInit<T>): Promise<Result<ApiResponseValue<T>, ApiFailure>>;\n (path: string, init?: ApiRequestInit): Promise<Result<ApiResponseValue<unknown>, ApiFailure>>;\n}\nexport interface ApiDetailedClient {\n readonly get: ApiDetailedMethod;\n readonly post: ApiDetailedMethod;\n readonly put: ApiDetailedMethod;\n readonly patch: ApiDetailedMethod;\n readonly delete: ApiDetailedMethod;\n readonly request: ApiDetailedMethod;\n}\nexport interface ApiClient {\n readonly detailed: ApiDetailedClient;\n readonly get: ApiMethod;\n readonly post: ApiMethod;\n readonly put: ApiMethod;\n readonly patch: ApiMethod;\n readonly delete: ApiMethod;\n readonly request: ApiMethod;\n}\ninterface RequestOptions extends ApiRequestInit {\n readonly response?: 'json' | 'empty' | 'text' | 'blob' | 'arrayBuffer';\n readonly decode?: ApiDecoder<unknown>;\n}\nfunction buildQueryString(query: ApiQueryParams): string {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n for (const item of Array.isArray(value) ? value : [value]) {\n if (item != null) params.append(key, String(item));\n }\n }\n return params.toString();\n}\nfunction interruption(signal?: AbortSignal | null, error?: unknown): ApiFailure | undefined {\n if (isTimeoutError(error) || (signal?.aborted && isTimeoutError(signal.reason)))\n return ApiFailureFactory.create('timeout');\n if (signal?.aborted || isAbortError(error)) return ApiFailureFactory.create('cancelled');\n return undefined;\n}\n/** Wakes immediately on cancellation; the request loop returns its typed outcome. */\nfunction wait(ms: number, signal?: AbortSignal | null): Promise<void> {\n return new Promise((resolve) => {\n if (signal?.aborted) {\n resolve();\n return;\n }\n const finish = (): void => {\n clearTimeout(timer);\n signal?.removeEventListener('abort', finish);\n resolve();\n };\n const timer = setTimeout(finish, ms);\n signal?.addEventListener('abort', finish, { once: true });\n });\n}\n/** Returns expected transport/protocol failures; application decoder bugs still throw. */\nexport function createApiClient(options: ApiClientOptions = {}): ApiClient {\n const {\n baseUrl = '',\n getAuthToken,\n credentials,\n defaultHeaders,\n envelope = wowTwoEnvelope,\n retry = false,\n antiforgery,\n } = options;\n /** Reads the antiforgery refresh path once, so a stale token is replaced before the one retry. */\n const refreshAntiforgery = async (signal: AbortSignal): Promise<void> => {\n if (!antiforgery?.refreshPath) return;\n try {\n await awaitRequest(\n () =>\n (options.fetch ?? globalThis.fetch)(`${baseUrl}${antiforgery.refreshPath}`, {\n method: 'GET',\n cache: 'no-store',\n signal,\n ...(credentials !== undefined ? { credentials } : {}),\n }),\n signal,\n );\n } catch {\n // The retry reports the outcome; a failed refresh leaves the rejection to surface.\n }\n };\n const attemptOnce = async (\n url: string,\n init: RequestOptions,\n body: BodyInit | undefined,\n hasJsonBody: boolean,\n json: ApiJsonCodec | undefined,\n token: string | null,\n ): Promise<Result<ApiResponseValue<unknown>, ApiFailure>> => {\n const cancelled = interruption(init.signal);\n if (cancelled) return ResultExtensions.fail(cancelled);\n const headers = new Headers({\n Accept: init.response === undefined || init.response === 'json' ? 'application/json' : '*/*',\n });\n if (hasJsonBody) headers.set('Content-Type', 'application/json');\n if (defaultHeaders) new Headers(defaultHeaders).forEach((value, key) => headers.set(key, value));\n if (token != null) headers.set('Authorization', `Bearer ${token}`);\n if (antiforgery && AntiforgeryExtensions.isUnsafe(init.method)) {\n const xsrf = AntiforgeryExtensions.readToken(antiforgery.cookieName ?? AntiforgeryDefaults.cookieName);\n if (xsrf != null) headers.set(antiforgery.headerName ?? AntiforgeryDefaults.headerName, xsrf);\n }\n if (init.headers) new Headers(init.headers).forEach((value, key) => headers.set(key, value));\n let response: Response;\n try {\n response = await awaitRequest(\n () =>\n (options.fetch ?? globalThis.fetch)(url, {\n method: init.method ?? 'GET',\n headers,\n signal: init.signal ?? null,\n ...(credentials !== undefined ? { credentials } : {}),\n ...(body !== undefined ? { body } : {}),\n }),\n init.signal,\n );\n } catch (error) {\n return ResultExtensions.fail(interruption(init.signal, error) ?? ApiFailureFactory.create('transport'));\n }\n const success = (value: unknown): Result<ApiResponseValue<unknown>, ApiFailure> =>\n ResultExtensions.ok({\n value,\n status: response.status,\n headers: Object.freeze(Object.fromEntries(response.headers)),\n url: response.url,\n });\n if (!response.ok) {\n let diagnostics: unknown;\n let diagnosticText = '';\n try {\n diagnosticText = await awaitRequest(() => response.text(), init.signal);\n } catch (error) {\n const aborted = interruption(init.signal, error);\n if (aborted) return ResultExtensions.fail(aborted);\n // Reading optional diagnostics must not hide the HTTP status.\n }\n if (diagnosticText !== '') {\n if (json) {\n const decoded = json.parse(diagnosticText);\n if (decoded.ok) diagnostics = decoded.value;\n } else {\n try {\n diagnostics = JSON.parse(diagnosticText);\n } catch {\n /* Malformed optional diagnostics do not change the HTTP failure. */\n }\n }\n }\n const aborted = interruption(init.signal);\n return ResultExtensions.fail(aborted ?? envelope.toFailure(diagnostics, response));\n }\n if (init.response === 'blob' || init.response === 'arrayBuffer') {\n try {\n const value = await awaitRequest<Blob | ArrayBuffer>(\n () => (init.response === 'blob' ? response.blob() : response.arrayBuffer()),\n init.signal,\n );\n const aborted = interruption(init.signal);\n return aborted ? ResultExtensions.fail(aborted) : success(value);\n } catch (error) {\n return ResultExtensions.fail(\n interruption(init.signal, error) ?? ApiFailureFactory.create('transport', response),\n );\n }\n }\n let text: string;\n try {\n text = await awaitRequest(() => response.text(), init.signal);\n } catch (error) {\n return ResultExtensions.fail(interruption(init.signal, error) ?? ApiFailureFactory.create('transport', response));\n }\n const aborted = interruption(init.signal);\n if (aborted) return ResultExtensions.fail(aborted);\n if (init.response === 'empty')\n return text === '' ? success(undefined) : ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n if (init.response === 'text') return success(text);\n if (text === '' || !/^application\\/(?:[\\w.-]+\\+)?json(?:;|$)/i.test(response.headers.get('Content-Type') ?? ''))\n return ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n let parsed: unknown;\n if (json) {\n const decoded = json.parse(text);\n const interrupted = interruption(init.signal);\n if (interrupted) return ResultExtensions.fail(interrupted);\n if (!decoded.ok) return ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n parsed = decoded.value;\n } else {\n try {\n parsed = JSON.parse(text);\n } catch {\n return ResultExtensions.fail(ApiFailureFactory.create('protocol', response));\n }\n }\n const payload = init.unwrap === false ? ResultExtensions.ok(parsed) : envelope.unwrap(parsed, response);\n if (!payload.ok) return payload;\n const decoded = init.decode ? init.decode(payload.value) : payload;\n const interrupted = interruption(init.signal);\n return interrupted ? ResultExtensions.fail(interrupted) : decoded.ok ? success(decoded.value) : decoded;\n };\n /** Sends one attempt and tags its failure with the endpoint, so a report or log names it without the transport. */\n const attempt = async (\n url: string,\n init: RequestOptions,\n body: BodyInit | undefined,\n hasJsonBody: boolean,\n json: ApiJsonCodec | undefined,\n token: string | null,\n ): Promise<Result<ApiResponseValue<unknown>, ApiFailure>> => {\n const result = await attemptOnce(url, init, body, hasJsonBody, json, token);\n if (result.ok) return result;\n const request = { method: (init.method ?? 'GET').toUpperCase(), url: url.split(/[?#]/u)[0] ?? url };\n return ResultExtensions.fail({ ...result.failure, request });\n };\n const execute = async (\n path: string,\n requested: RequestOptions,\n ): Promise<Result<ApiResponseValue<unknown>, ApiFailure>> => {\n const origin = options.scope?.capture();\n const combined = combineRequestSignals(requested.signal, origin?.signal);\n const init = { ...requested, signal: combined.signal };\n try {\n const cancelled = interruption(init.signal);\n if (cancelled) return ResultExtensions.fail(cancelled);\n const query = init.query ? buildQueryString(init.query) : '';\n const url = `${baseUrl}${path}${query ? (path.includes('?') ? '&' : '?') + query : ''}`;\n const isFormData = typeof FormData !== 'undefined' && init.body instanceof FormData;\n const json = init.json === undefined ? options.json : (init.json ?? undefined);\n let body: BodyInit | undefined;\n if (init.body !== undefined && !isFormData && json) {\n const encoded = json.stringify(init.body);\n const interrupted = interruption(init.signal);\n if (interrupted) return ResultExtensions.fail(interrupted);\n if (!encoded.ok) return ResultExtensions.fail(ApiFailureFactory.create('validation'));\n body = encoded.value;\n } else\n body = init.body === undefined ? undefined : isFormData ? (init.body as FormData) : JSON.stringify(init.body);\n let token: string | null;\n try {\n token = getAuthToken ? await awaitRequest(getAuthToken, init.signal) : null;\n } catch (error) {\n const aborted = interruption(init.signal, error);\n if (aborted) return ResultExtensions.fail(aborted);\n throw error;\n }\n let retries = 0;\n let previousDelayMs = 0;\n let refreshedAntiforgery = false;\n for (;;) {\n const result = await attempt(url, init, body, init.body !== undefined && !isFormData, json, token);\n const aborted = interruption(init.signal);\n if (aborted) return ResultExtensions.fail(aborted);\n if (result.ok) return result;\n const failure = result.failure;\n if (\n antiforgery?.refreshPath &&\n !refreshedAntiforgery &&\n AntiforgeryExtensions.isUnsafe(init.method) &&\n (antiforgery.isRejection ?? AntiforgeryExtensions.isRejection)(failure)\n ) {\n refreshedAntiforgery = true;\n await refreshAntiforgery(init.signal);\n const interrupted = interruption(init.signal);\n if (interrupted) return ResultExtensions.fail(interrupted);\n continue;\n }\n const retryable = failure.code === 'http' || failure.code === 'transport';\n const idempotent = ['GET', 'HEAD', 'OPTIONS'].includes((init.method ?? 'GET').toUpperCase());\n if (retry !== false && retryable && idempotent && shouldRetry(retry, retries, failure.status)) {\n const attemptNumber = retries + 1;\n const delayMs = computeRetryDelay(retry, attemptNumber, previousDelayMs);\n retry.onRetry?.({ attempt: attemptNumber, error: new ApiError(failure), status: failure.status, delayMs });\n await wait(delayMs, init.signal);\n retries = attemptNumber;\n previousDelayMs = delayMs;\n continue;\n }\n if (failure.status === 401 && (!origin || origin.isCurrent())) {\n options.onUnauthorized?.(failure, origin);\n // A 401 that ended its own session resolves cancelled, like every other request of that session.\n const ended = interruption(init.signal);\n if (ended) return ResultExtensions.fail(ended);\n }\n return result;\n }\n } finally {\n combined.dispose();\n }\n };\n const detailedMethod = (verb?: string): ApiDetailedMethod => {\n const send = (path: string, init: RequestOptions = {}) => execute(path, verb ? { ...init, method: verb } : init);\n return send as ApiDetailedMethod;\n };\n const method = (verb?: string): ApiMethod => {\n function send(path: string, init: ApiEmptyRequestInit): Promise<Result<void, ApiFailure>>;\n function send(path: string, init: ApiTextRequestInit): Promise<Result<string, ApiFailure>>;\n function send(path: string, init: ApiBlobRequestInit): Promise<Result<Blob, ApiFailure>>;\n function send(path: string, init: ApiArrayBufferRequestInit): Promise<Result<ArrayBuffer, ApiFailure>>;\n function send<T>(path: string, init: ApiJsonRequestInit<T>): Promise<Result<T, ApiFailure>>;\n function send(path: string, init?: ApiRequestInit): Promise<Result<unknown, ApiFailure>>;\n function send(path: string, init: RequestOptions = {}): Promise<Result<unknown, ApiFailure>> {\n return execute(path, verb ? { ...init, method: verb } : init).then((result) =>\n result.ok ? ResultExtensions.ok(result.value.value) : result,\n );\n }\n return send;\n };\n return {\n detailed: {\n request: detailedMethod(),\n get: detailedMethod('GET'),\n post: detailedMethod('POST'),\n put: detailedMethod('PUT'),\n patch: detailedMethod('PATCH'),\n delete: detailedMethod('DELETE'),\n },\n request: method(),\n get: method('GET'),\n post: method('POST'),\n put: method('PUT'),\n patch: method('PATCH'),\n delete: method('DELETE'),\n };\n}\n","import { ResultExtensions } from '../results';\nimport type { StandardSchemaV1 } from '../validators/StandardSchema';\nimport { ApiFailureFactory } from './ApiFailure';\nimport type { ApiDecoder } from './CreateApiClient';\n\n/** Defines the options of a decoder built from a schema. */\nexport interface ApiSchemaDecoderOptions {\n /**\n * Receives the issues of a payload the schema rejected — a log line's input, never display text. The decoder\n * still returns its `protocol` failure.\n */\n readonly onIssues?: (issues: ReadonlyArray<StandardSchemaV1.Issue>) => void;\n}\n\n/** @internal Whether a schema result is a promise, which a synchronous decoder cannot wait for. */\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as PromiseLike<unknown>).then === 'function'\n );\n}\n\n/** Extends `ApiDecoder` with decoders built from validation schemas. */\nexport const ApiDecoderExtensions = {\n /**\n * Wraps a Standard Schema — the SDK's own validators, zod, valibot, arktype — as an endpoint decoder. A payload the\n * schema rejects is a `protocol` failure, so response diagnostics never become display text; its issues reach\n * `onIssues` only. A schema that validates asynchronously throws a `TypeError`: wire decoding is synchronous.\n * ```ts\n * client.get('/api/codes', { decode: ApiDecoderExtensions.fromSchema(CodeListSchema) });\n * ```\n */\n fromSchema<TSchema extends StandardSchemaV1>(\n schema: TSchema,\n options: ApiSchemaDecoderOptions = {},\n ): ApiDecoder<StandardSchemaV1.InferOutput<TSchema>> {\n return (value) => {\n const outcome = schema['~standard'].validate(value);\n if (isThenable(outcome)) {\n // Settle the abandoned validation quietly; the caller learns of the misuse from the throw below.\n Promise.resolve(outcome).then(undefined, () => undefined);\n throw new TypeError(\n `ApiDecoderExtensions.fromSchema needs a synchronous schema; the ${schema['~standard'].vendor} schema returned a promise.`,\n );\n }\n if (outcome.issues === undefined)\n return ResultExtensions.ok(outcome.value as StandardSchemaV1.InferOutput<TSchema>);\n options.onIssues?.(outcome.issues);\n return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n };\n },\n} as const;\n","import { ResultExtensions } from '../results';\nimport { ApiFailureFactory } from './ApiFailure';\nimport type { ApiDecoder } from './CreateApiClient';\nimport type { ApiWarned, ApiWarning } from './models/ApiWarning';\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\n/** Reads one warning; `null` when a required member is not text. */\nfunction toWarning(value: unknown): ApiWarning | null {\n if (!isRecord(value)) return null;\n const { property, message, code, severity } = value;\n if (typeof property !== 'string' || typeof message !== 'string' || typeof code !== 'string') return null;\n return { property, message, code, severity: typeof severity === 'string' ? severity : 'warning' };\n}\n\n/**\n * Builds a decoder for a `{ data, warnings }` success envelope — the backend SDK's `ApiResponse<T>.Ok(data, warnings)`.\n * Request it with `unwrap: false`, so the decoder sees the whole envelope; a missing `warnings` reads as none.\n * ```ts\n * client.post('/api/codes', { body, unwrap: false, decode: decodeWarned(decodeCode) });\n * ```\n */\nexport function decodeWarned<T>(decodeData: ApiDecoder<T>): ApiDecoder<ApiWarned<T>> {\n return (value) => {\n if (!isRecord(value) || !Object.hasOwn(value, 'data'))\n return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n const raw = value['warnings'] ?? [];\n if (!Array.isArray(raw)) return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n const warnings = raw.map(toWarning);\n if (warnings.some((warning) => warning === null))\n return ResultExtensions.fail(ApiFailureFactory.create('protocol'));\n const data = decodeData(value['data']);\n return data.ok ? ResultExtensions.ok({ data: data.value, warnings: warnings as ReadonlyArray<ApiWarning> }) : data;\n };\n}\n"],"names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AK;AAGrE,SAAS,UAAU,OAAmC;AACpD,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,QAAM,EAAE,UAAU,SAAS,MAAM,aAAa;AAC9C,MAAI,OAAO,aAAa,YAAY,OAAO,YAAY,YAAY,OAAO,SAAS,SAAU,QAAO;AACpG,SAAO,EAAE,UAAU,SAAS,MAAM,UAAU,OAAO,aAAa,WAAW,WAAW,UAAA;AACxF;AASO,SAAS,aAAgB,YAAqD;AACnF,SAAO,CAAC,UAAU;AAChB,QAAI,CAAC,SAAS,KAAK,KAAK,CAAC,OAAO,OAAO,OAAO,MAAM;AAClD,aAAO,iBAAiB,KAAK,kBAAkB,OAAO,UAAU,CAAC;AACnE,UAAM,MAAM,MAAM,UAAU,KAAK,CAAA;AACjC,QAAI,CAAC,MAAM,QAAQ,GAAG,EAAG,QAAO,iBAAiB,KAAK,kBAAkB,OAAO,UAAU,CAAC;AAC1F,UAAM,WAAW,IAAI,IAAI,SAAS;AAClC,QAAI,SAAS,KAAK,CAAC,YAAY,YAAY,IAAI;AAC7C,aAAO,iBAAiB,KAAK,kBAAkB,OAAO,UAAU,CAAC;AACnE,UAAM,OAAO,WAAW,MAAM,MAAM,CAAC;AACrC,WAAO,KAAK,KAAK,iBAAiB,GAAG,EAAE,MAAM,KAAK,OAAO,SAAA,CAAiD,IAAI;AAAA,EAChH;AACF;"}
@@ -62,10 +62,15 @@ export interface ThemeGlassTokens {
62
62
  readonly saturate?: string;
63
63
  /** The hairline colour between glass and content (`--glass-edge`). */
64
64
  readonly edge?: string;
65
- /** The inset top highlight colour (`--glass-highlight`); the emitter adds it to both shadows as a 1px line. */
65
+ /** The inset top highlight colour (`--glass-highlight`); the emitter adds it to every shadow as a 1px line. */
66
66
  readonly highlight?: string;
67
- /** The chrome's outer shadow (`--glass-shadow`). */
67
+ /** The chrome's outer shadow, cast down from a top bar (`--glass-shadow`). */
68
68
  readonly shadow?: string;
69
+ /**
70
+ * The bottom bar's outer shadow, cast up over the page (`--glass-bottom-shadow`) — a negative y offset, the
71
+ * mirror of `shadow`.
72
+ */
73
+ readonly bottomShadow?: string;
69
74
  /** The menus' outer shadow (`--glass-menu-shadow`). */
70
75
  readonly menuShadow?: string;
71
76
  }
@@ -1,5 +1,5 @@
1
1
  import { O, d, b, a, i, n, o, e, p, f, r } from "../../chunks/ReadableForeground-CgfzP7Tl.js";
2
- import { A, a as a2, b as b2, N, S, c, d as d2, T, e as e2, f as f2, g, h, j, k, l, m, n as n2, o as o2, p as p2, q, r as r2, s, t, v, u } from "../../chunks/index-CRV9gpyX.js";
2
+ import { A, a as a2, b as b2, N, S, c, d as d2, T, e as e2, f as f2, g, h, j, k, l, m, n as n2, o as o2, p as p2, q, r as r2, s, t, v, u } from "../../chunks/index-ou-qGNDu.js";
3
3
  export {
4
4
  A as AaText,
5
5
  a2 as AaUi,
package/dist/index.css CHANGED
@@ -432,15 +432,16 @@ body {
432
432
  *
433
433
  * The strength is a set of custom properties. A theme sets them in its `.theme-{id}` blocks (`Theme.glass`); an
434
434
  * app may also set them on any subtree. Unset, every surface keeps the SDK's own glass:
435
- * --glass-fill chrome fill; unset, the card at 75% (`surface-glass`) or the popover at 70% (`glass`)
436
- * --glass-side-fill sidebar fill; unset, --glass-fill
437
- * --glass-menu-fill menu fill; unset, --glass-fill, else the popover at 70%
438
- * --glass-blur backdrop blur radius; default 12px
439
- * --glass-saturate backdrop saturation; default 100%
440
- * --glass-edge hairline between glass and content, as `border-glass-edge`; unset, --color-border
441
- * --glass-highlight inset top highlight a theme adds to both shadows; default transparent
442
- * --glass-shadow chrome shadow, as `shadow-(--glass-shadow)`; default none
443
- * --glass-menu-shadow menu shadow, as `shadow-(--glass-menu-shadow)`; default Tailwind's `shadow-lg`
435
+ * --glass-fill chrome fill; unset, the card at 75% (`surface-glass`) or the popover at 70% (`glass`)
436
+ * --glass-side-fill sidebar fill; unset, --glass-fill
437
+ * --glass-menu-fill menu fill; unset, --glass-fill, else the popover at 70%
438
+ * --glass-blur backdrop blur radius; default 12px
439
+ * --glass-saturate backdrop saturation; default 100%
440
+ * --glass-edge hairline between glass and content, as `border-glass-edge`; unset, --color-border
441
+ * --glass-highlight inset top highlight a theme adds to every shadow; default transparent
442
+ * --glass-shadow chrome shadow cast down from a top bar, as `shadow-(--glass-shadow)`; default none
443
+ * --glass-bottom-shadow bottom-bar shadow cast up over the page, as `shadow-(--glass-bottom-shadow)`; default none
444
+ * --glass-menu-shadow menu shadow, as `shadow-(--glass-menu-shadow)`; default Tailwind's `shadow-lg`
444
445
  * The `glass` and `glass-outline` surface variants read --glass-fill, --glass-blur and --glass-saturate; the
445
446
  * `glass-side` and `glass-menu` variants paint the two materials, the menu one with its edge and shadow.
446
447
  * ------------------------------------------------------------------------- */
@@ -466,6 +467,11 @@ body {
466
467
  inherits: true;
467
468
  initial-value: 0 0 #0000;
468
469
  }
470
+ @property --glass-bottom-shadow {
471
+ syntax: '*';
472
+ inherits: true;
473
+ initial-value: 0 0 #0000;
474
+ }
469
475
  @property --glass-menu-shadow {
470
476
  syntax: '*';
471
477
  inherits: true;