@marktiderman/genesis-core 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{aggregate-v_r-nZbH.d.ts → aggregate-CUirs7ka.d.ts} +1 -1
  2. package/dist/{chunk-UNEZF3ZP.js → chunk-5PCGMSDX.js} +209 -28
  3. package/dist/chunk-5PCGMSDX.js.map +1 -0
  4. package/dist/{chunk-JNWTHDGF.js → chunk-AOIVTOHX.js} +3 -3
  5. package/dist/{chunk-JNWTHDGF.js.map → chunk-AOIVTOHX.js.map} +1 -1
  6. package/dist/{chunk-FBMKI22S.js → chunk-ATVK3VYS.js} +3 -3
  7. package/dist/{chunk-FBMKI22S.js.map → chunk-ATVK3VYS.js.map} +1 -1
  8. package/dist/{chunk-NOPS5EIH.js → chunk-CJ5V6JES.js} +5 -114
  9. package/dist/chunk-CJ5V6JES.js.map +1 -0
  10. package/dist/{chunk-TWLPC4S3.js → chunk-DJRT4DUF.js} +3 -3
  11. package/dist/{chunk-TWLPC4S3.js.map → chunk-DJRT4DUF.js.map} +1 -1
  12. package/dist/{chunk-WNOCPV4A.js → chunk-DTVYCATJ.js} +3 -3
  13. package/dist/{chunk-WNOCPV4A.js.map → chunk-DTVYCATJ.js.map} +1 -1
  14. package/dist/chunk-LYNIHY3F.js +115 -0
  15. package/dist/chunk-LYNIHY3F.js.map +1 -0
  16. package/dist/{chunk-6B4CN2TC.js → chunk-OCMYW2YE.js} +3 -3
  17. package/dist/{chunk-6B4CN2TC.js.map → chunk-OCMYW2YE.js.map} +1 -1
  18. package/dist/{chunk-AQX5HQD6.js → chunk-OTUTSAZD.js} +3 -3
  19. package/dist/{chunk-AQX5HQD6.js.map → chunk-OTUTSAZD.js.map} +1 -1
  20. package/dist/{chunk-KRRESUXT.js → chunk-PH25HOAL.js} +6 -6
  21. package/dist/{chunk-KRRESUXT.js.map → chunk-PH25HOAL.js.map} +1 -1
  22. package/dist/{chunk-XIBQ5BTZ.js → chunk-RZVLUUMY.js} +4 -4
  23. package/dist/{chunk-XIBQ5BTZ.js.map → chunk-RZVLUUMY.js.map} +1 -1
  24. package/dist/{chunk-2ORQLYVW.js → chunk-SMEG63MO.js} +4 -4
  25. package/dist/{chunk-2ORQLYVW.js.map → chunk-SMEG63MO.js.map} +1 -1
  26. package/dist/{chunk-YMFJLBIZ.js → chunk-UKJCF2CM.js} +3 -3
  27. package/dist/{chunk-YMFJLBIZ.js.map → chunk-UKJCF2CM.js.map} +1 -1
  28. package/dist/{chunk-K33LWVUF.js → chunk-UKWM32CG.js} +3 -3
  29. package/dist/{chunk-K33LWVUF.js.map → chunk-UKWM32CG.js.map} +1 -1
  30. package/dist/csv.d.ts +1 -1
  31. package/dist/errors.js +2 -1
  32. package/dist/form-types.d.ts +1 -1
  33. package/dist/headless/index.d.ts +1 -1
  34. package/dist/hooks/index.d.ts +4 -4
  35. package/dist/hooks/index.js +13 -12
  36. package/dist/hooks/mutation-mode.d.ts +1 -1
  37. package/dist/hooks/mutation-mode.js +3 -2
  38. package/dist/hooks/related-keys.d.ts +1 -1
  39. package/dist/hooks/use-aggregate.d.ts +2 -2
  40. package/dist/hooks/use-board-columns.d.ts +1 -1
  41. package/dist/hooks/use-capabilities.d.ts +1 -1
  42. package/dist/hooks/use-infinite-resource.d.ts +1 -1
  43. package/dist/hooks/use-link-options.d.ts +1 -1
  44. package/dist/hooks/use-list-state.d.ts +3 -3
  45. package/dist/hooks/use-list-state.js +5 -4
  46. package/dist/hooks/use-live.d.ts +1 -1
  47. package/dist/hooks/use-one.d.ts +1 -1
  48. package/dist/hooks/use-relation-label.d.ts +1 -1
  49. package/dist/hooks/use-resource-form.d.ts +1 -1
  50. package/dist/hooks/use-resource-form.js +4 -3
  51. package/dist/hooks/use-resource.d.ts +1 -1
  52. package/dist/hooks/use-resource.js +4 -3
  53. package/dist/hooks/use-segment-counts.d.ts +2 -2
  54. package/dist/hooks/use-segment-counts.js +5 -4
  55. package/dist/hooks/use-view-board.d.ts +2 -2
  56. package/dist/hooks/use-view-board.js +8 -7
  57. package/dist/hooks/use-view-calendar-range.d.ts +2 -2
  58. package/dist/hooks/use-view-calendar-range.js +6 -5
  59. package/dist/hooks/use-write.d.ts +1 -1
  60. package/dist/index.d.ts +8 -8
  61. package/dist/index.js +15 -14
  62. package/dist/index.js.map +1 -1
  63. package/dist/provider/index.d.ts +7 -378
  64. package/dist/provider/index.js +3 -2
  65. package/dist/{write-outcome-DuwfsnyO.d.ts → read-outcome-Cq0h2oAG.d.ts} +31 -2
  66. package/dist/resource-view/index.d.ts +4 -4
  67. package/dist/resource-view/index.js +5 -4
  68. package/dist/resource-view/index.js.map +1 -1
  69. package/dist/{saved-views-C45lRm7i.d.ts → saved-views-Bcox3blZ.d.ts} +2 -2
  70. package/dist/schema/index.d.ts +3 -4
  71. package/dist/supabase-provider-D5ditkHi.d.ts +465 -0
  72. package/dist/testing/index.d.ts +87 -3
  73. package/dist/testing/index.js +88 -1
  74. package/dist/testing/index.js.map +1 -1
  75. package/dist/{types-CiQY6hUy.d.ts → types-BnOCVJzm.d.ts} +1 -1
  76. package/dist/{types-BAhcze_-.d.ts → types-CBtBvGw0.d.ts} +1 -1
  77. package/package.json +1 -1
  78. package/dist/chunk-NOPS5EIH.js.map +0 -1
  79. package/dist/chunk-UNEZF3ZP.js.map +0 -1
  80. package/dist/read-outcome-BnboMYOV.d.ts +0 -30
@@ -1,5 +1,5 @@
1
1
  import { QueryKey } from '@tanstack/react-query';
2
- import { g as SubscribeParams, h as ResourceChangeEvent } from '../types-CiQY6hUy.js';
2
+ import { g as SubscribeParams, h as ResourceChangeEvent } from '../types-BnOCVJzm.js';
3
3
 
4
4
  /** How long a burst of change events is gathered into one refetch. */
5
5
  declare const DEFAULT_LIVE_DEBOUNCE_MS = 250;
@@ -1,5 +1,5 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
- import { a as FilterParam, B as BaseRecord, c as Identifier } from '../types-CiQY6hUy.js';
2
+ import { a as FilterParam, B as BaseRecord, c as Identifier } from '../types-BnOCVJzm.js';
3
3
  import { LiveOptions } from './use-live.js';
4
4
 
5
5
  interface UseOneOptions {
@@ -1,4 +1,4 @@
1
- import { D as DataProvider, f as FieldReference, c as Identifier } from '../types-CiQY6hUy.js';
1
+ import { D as DataProvider, f as FieldReference, c as Identifier } from '../types-BnOCVJzm.js';
2
2
 
3
3
  interface UseRelationLabelOptions {
4
4
  /** The linked row's field that names it. Default: the linked resource's `labelField` (`describe`). */
@@ -1,5 +1,5 @@
1
1
  import { UseFormReturn } from 'react-hook-form';
2
- import { i as ResourceFormFieldDef, I as InvalidationKey } from '../types-CiQY6hUy.js';
2
+ import { i as ResourceFormFieldDef, I as InvalidationKey } from '../types-BnOCVJzm.js';
3
3
  import { W as WriteConflict } from '../write-state-DVC4Yq9T.js';
4
4
  import { MutationModeOptions } from './mutation-mode.js';
5
5
  import '@tanstack/react-query';
@@ -1,8 +1,8 @@
1
- export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-FBMKI22S.js';
1
+ export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-ATVK3VYS.js';
2
2
  import '../chunk-RVWKVD5Q.js';
3
3
  import '../chunk-LKRJB632.js';
4
4
  import '../chunk-QJOKZZKY.js';
5
- import '../chunk-AQX5HQD6.js';
5
+ import '../chunk-OTUTSAZD.js';
6
6
  import '../chunk-7NUL32W7.js';
7
7
  import '../chunk-MMMC37AP.js';
8
8
  import '../chunk-AJGVLF37.js';
@@ -12,7 +12,8 @@ import '../chunk-OIZNABG4.js';
12
12
  import '../chunk-J54XXKQD.js';
13
13
  import '../chunk-4PTQYT5J.js';
14
14
  import '../chunk-AUVKRXRC.js';
15
- import '../chunk-NOPS5EIH.js';
15
+ import '../chunk-CJ5V6JES.js';
16
+ import '../chunk-LYNIHY3F.js';
16
17
  import '../chunk-HUNGCTRA.js';
17
18
  import '../chunk-RYEXWQFD.js';
18
19
  import '../chunk-WLDSIQJ2.js';
@@ -1,5 +1,5 @@
1
1
  import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
2
- import { S as SortParam, a as FilterParam, I as InvalidationKey, L as ListResult, b as ListParams, c as Identifier, B as BaseRecord } from '../types-CiQY6hUy.js';
2
+ import { S as SortParam, a as FilterParam, I as InvalidationKey, L as ListResult, b as ListParams, c as Identifier, B as BaseRecord } from '../types-BnOCVJzm.js';
3
3
  import { MutationModeOptions } from './mutation-mode.js';
4
4
  import { LiveOptions } from './use-live.js';
5
5
 
@@ -1,5 +1,5 @@
1
- export { useResource } from '../chunk-6B4CN2TC.js';
2
- import '../chunk-AQX5HQD6.js';
1
+ export { useResource } from '../chunk-OCMYW2YE.js';
2
+ import '../chunk-OTUTSAZD.js';
3
3
  import '../chunk-7NUL32W7.js';
4
4
  import '../chunk-MMMC37AP.js';
5
5
  import '../chunk-AJGVLF37.js';
@@ -9,7 +9,8 @@ import '../chunk-OIZNABG4.js';
9
9
  import '../chunk-J54XXKQD.js';
10
10
  import '../chunk-4PTQYT5J.js';
11
11
  import '../chunk-AUVKRXRC.js';
12
- import '../chunk-NOPS5EIH.js';
12
+ import '../chunk-CJ5V6JES.js';
13
+ import '../chunk-LYNIHY3F.js';
13
14
  import '../chunk-HUNGCTRA.js';
14
15
  import '../chunk-RYEXWQFD.js';
15
16
  import '../chunk-WLDSIQJ2.js';
@@ -1,5 +1,5 @@
1
- import { R as ResourceContract, a as FilterParam } from '../types-CiQY6hUy.js';
2
- import { R as ResourceView } from '../types-BAhcze_-.js';
1
+ import { R as ResourceContract, a as FilterParam } from '../types-BnOCVJzm.js';
2
+ import { R as ResourceView } from '../types-CBtBvGw0.js';
3
3
  import '../status-BXRokZD9.js';
4
4
  import '../viewer-oOk0ZZk9.js';
5
5
  import 'react';
@@ -1,7 +1,7 @@
1
- export { useSegmentCounts } from '../chunk-K33LWVUF.js';
2
- import '../chunk-XIBQ5BTZ.js';
1
+ export { useSegmentCounts } from '../chunk-UKWM32CG.js';
2
+ import '../chunk-RZVLUUMY.js';
3
3
  import '../chunk-OZYF55E3.js';
4
- import '../chunk-AQX5HQD6.js';
4
+ import '../chunk-OTUTSAZD.js';
5
5
  import '../chunk-MMMC37AP.js';
6
6
  import '../chunk-AJGVLF37.js';
7
7
  import '../chunk-2IGAUXYH.js';
@@ -11,7 +11,8 @@ import '../chunk-4PTQYT5J.js';
11
11
  import '../chunk-5ASUMG6K.js';
12
12
  import '../chunk-AUVKRXRC.js';
13
13
  import '../chunk-WXENWPWP.js';
14
- import '../chunk-NOPS5EIH.js';
14
+ import '../chunk-CJ5V6JES.js';
15
+ import '../chunk-LYNIHY3F.js';
15
16
  import '../chunk-HUNGCTRA.js';
16
17
  import '../chunk-RYEXWQFD.js';
17
18
  import '../chunk-WLDSIQJ2.js';
@@ -1,6 +1,6 @@
1
- import { a as FilterParam, B as BaseRecord, R as ResourceContract, e as DataRow } from '../types-CiQY6hUy.js';
1
+ import { a as FilterParam, B as BaseRecord, R as ResourceContract, e as DataRow } from '../types-BnOCVJzm.js';
2
2
  import { W as WriteConflict } from '../write-state-DVC4Yq9T.js';
3
- import { V as ViewBoard, a as ViewTone, R as ResourceView } from '../types-BAhcze_-.js';
3
+ import { V as ViewBoard, a as ViewTone, R as ResourceView } from '../types-CBtBvGw0.js';
4
4
  import { LiveOptions } from './use-live.js';
5
5
  import { UseResourceOptions } from './use-resource.js';
6
6
  import '../status-BXRokZD9.js';
@@ -1,14 +1,14 @@
1
- export { useViewBoard } from '../chunk-KRRESUXT.js';
2
- import '../chunk-JNWTHDGF.js';
1
+ export { useViewBoard } from '../chunk-PH25HOAL.js';
2
+ import '../chunk-AOIVTOHX.js';
3
3
  import '../chunk-BNKP2H7J.js';
4
- import '../chunk-YMFJLBIZ.js';
4
+ import '../chunk-UKJCF2CM.js';
5
5
  import '../chunk-KV2HW4G4.js';
6
6
  import '../chunk-6JOWGO2X.js';
7
- import '../chunk-XIBQ5BTZ.js';
7
+ import '../chunk-RZVLUUMY.js';
8
8
  import '../chunk-OZYF55E3.js';
9
9
  import '../chunk-LKRJB632.js';
10
- import '../chunk-6B4CN2TC.js';
11
- import '../chunk-AQX5HQD6.js';
10
+ import '../chunk-OCMYW2YE.js';
11
+ import '../chunk-OTUTSAZD.js';
12
12
  import '../chunk-7NUL32W7.js';
13
13
  import '../chunk-6VNM6KAX.js';
14
14
  import '../chunk-MMMC37AP.js';
@@ -21,7 +21,8 @@ import '../chunk-4PTQYT5J.js';
21
21
  import '../chunk-5ASUMG6K.js';
22
22
  import '../chunk-AUVKRXRC.js';
23
23
  import '../chunk-WXENWPWP.js';
24
- import '../chunk-NOPS5EIH.js';
24
+ import '../chunk-CJ5V6JES.js';
25
+ import '../chunk-LYNIHY3F.js';
25
26
  import '../chunk-HUNGCTRA.js';
26
27
  import '../chunk-RYEXWQFD.js';
27
28
  import '../chunk-WLDSIQJ2.js';
@@ -1,6 +1,6 @@
1
- import { a as FilterParam, R as ResourceContract, e as DataRow } from '../types-CiQY6hUy.js';
1
+ import { a as FilterParam, R as ResourceContract, e as DataRow } from '../types-BnOCVJzm.js';
2
2
  import { Day } from '../dates.js';
3
- import { R as ResourceView } from '../types-BAhcze_-.js';
3
+ import { R as ResourceView } from '../types-CBtBvGw0.js';
4
4
  import { LiveOptions } from './use-live.js';
5
5
  import '../status-BXRokZD9.js';
6
6
  import '../viewer-oOk0ZZk9.js';
@@ -1,9 +1,9 @@
1
- export { CALENDAR_LIMIT, useViewCalendarRange } from '../chunk-2ORQLYVW.js';
2
- import '../chunk-YMFJLBIZ.js';
1
+ export { CALENDAR_LIMIT, useViewCalendarRange } from '../chunk-SMEG63MO.js';
2
+ import '../chunk-UKJCF2CM.js';
3
3
  import '../chunk-KV2HW4G4.js';
4
- import '../chunk-XIBQ5BTZ.js';
4
+ import '../chunk-RZVLUUMY.js';
5
5
  import '../chunk-OZYF55E3.js';
6
- import '../chunk-AQX5HQD6.js';
6
+ import '../chunk-OTUTSAZD.js';
7
7
  import '../chunk-MMMC37AP.js';
8
8
  import '../chunk-AJGVLF37.js';
9
9
  import '../chunk-6SHGMEA6.js';
@@ -14,7 +14,8 @@ import '../chunk-4PTQYT5J.js';
14
14
  import '../chunk-5ASUMG6K.js';
15
15
  import '../chunk-AUVKRXRC.js';
16
16
  import '../chunk-WXENWPWP.js';
17
- import '../chunk-NOPS5EIH.js';
17
+ import '../chunk-CJ5V6JES.js';
18
+ import '../chunk-LYNIHY3F.js';
18
19
  import '../chunk-HUNGCTRA.js';
19
20
  import '../chunk-RYEXWQFD.js';
20
21
  import '../chunk-WLDSIQJ2.js';
@@ -1,5 +1,5 @@
1
1
  import { QueryClient, MutationOptions } from '@tanstack/react-query';
2
- import { I as InvalidationKey } from '../types-CiQY6hUy.js';
2
+ import { I as InvalidationKey } from '../types-BnOCVJzm.js';
3
3
 
4
4
  declare const WRITE_FAILED = "That didn't work. Try again.";
5
5
  interface UseWriteOptions<A, R> {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { b as ListParams, c as Identifier } from './types-CiQY6hUy.js';
2
- export { k as AggregateMetric, A as AggregateParams, d as AggregateResult, n as ArrayFilter, j as AuditEntry, B as BaseRecord, o as BulkChange, p as BulkResult, C as ControlHint, q as CountMode, r as CreateParams, s as CreateResult, D as DataProvider, e as DataRow, t as DeleteParams, u as DeleteResult, v as FieldPermissions, f as FieldReference, F as FieldSchema, w as FieldType, x as FilterOperator, a as FilterParam, G as GetManyParams, y as GetManyResult, z as GetOneParams, E as GetOneResult, H as HistoryParams, J as ImportParams, I as InvalidationKey, L as ListResult, N as NullFilter, K as PaginationParam, P as ProviderCapabilities, M as RangeFilter, O as RecordComment, Q as ResourceAccess, h as ResourceChangeEvent, R as ResourceContract, i as ResourceFormFieldDef, T as ResourceRelation, U as ResourceSchema, V as ResourceSummary, m as RowAction, X as RowFailure, l as RowOf, Y as ScalarFilter, Z as SelectOption, S as SortParam, _ as StorageType, g as SubscribeParams, $ as UpdateParams, a0 as UpdateResult, a1 as VersionField, a2 as WidgetHint, W as WriteEvent, a3 as defineResource, a4 as fieldControl } from './types-CiQY6hUy.js';
3
- export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from './aggregate-v_r-nZbH.js';
4
- export { D as DataWriteError, a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, W as WriteOutcome, i as isDataWriteError } from './write-outcome-DuwfsnyO.js';
5
- export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, SourceArgsContext, SourcePages, SupabaseClient, SupabaseClientInput, SupabaseProviderOptions, SupabaseRealtimeChannel, SupabaseRealtimePayload, SupabaseResourceConfig, SupabaseUpdateContext, SupabaseWriteContext, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
6
- export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from './read-outcome-BnboMYOV.js';
1
+ import { b as ListParams, c as Identifier } from './types-BnOCVJzm.js';
2
+ export { k as AggregateMetric, A as AggregateParams, d as AggregateResult, n as ArrayFilter, j as AuditEntry, B as BaseRecord, o as BulkChange, p as BulkResult, q as ControlHint, C as CountMode, r as CreateParams, s as CreateResult, D as DataProvider, e as DataRow, t as DeleteParams, u as DeleteResult, v as FieldPermissions, f as FieldReference, F as FieldSchema, w as FieldType, x as FilterOperator, a as FilterParam, G as GetManyParams, y as GetManyResult, z as GetOneParams, E as GetOneResult, H as HistoryParams, J as ImportParams, I as InvalidationKey, L as ListResult, N as NullFilter, K as PaginationParam, P as ProviderCapabilities, M as RangeFilter, O as RecordComment, Q as ResourceAccess, h as ResourceChangeEvent, R as ResourceContract, i as ResourceFormFieldDef, T as ResourceRelation, U as ResourceSchema, V as ResourceSummary, m as RowAction, X as RowFailure, l as RowOf, Y as ScalarFilter, Z as SelectOption, S as SortParam, _ as StorageType, g as SubscribeParams, $ as UpdateParams, a0 as UpdateResult, a1 as VersionField, a2 as WidgetHint, W as WriteEvent, a3 as defineResource, a4 as fieldControl } from './types-BnOCVJzm.js';
3
+ export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from './aggregate-CUirs7ka.js';
4
+ export { D as DataReadError, a as DataReadErrorOptions, b as DataWriteError, c as DataWriteErrorOptions, N as NO_ROWS_MATCHED, R as ReadOutcome, W as WriteOutcome, i as isDataReadError, d as isDataWriteError, r as readFailureMessage } from './read-outcome-Cq0h2oAG.js';
5
+ export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, callRpc, createMockProvider, createOrAdopt, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
6
+ export { F as FunctionCall, R as ResourceWrites, S as SourceArgsContext, a as SourcePages, b as SupabaseClient, c as SupabaseClientInput, d as SupabaseProviderOptions, e as SupabaseRealtimeChannel, f as SupabaseRealtimePayload, g as SupabaseResourceConfig, h as SupabaseUpdateContext, i as SupabaseWriteContext, T as TableAccess, j as createSupabaseProvider } from './supabase-provider-D5ditkHi.js';
7
7
  export { S as StorageAdapter } from './types-DKcxHXxq.js';
8
8
  export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './storage/index.js';
9
9
  export { UpdateOptions, UseResourceOptions, UseResourceReturn, useResource } from './hooks/use-resource.js';
@@ -40,11 +40,11 @@ export { c as APPEARANCES, d as AppearancePreferenceSource, e as DENSITIES, G as
40
40
  import * as react from 'react';
41
41
  import { ReactNode } from 'react';
42
42
  import './types-CsKSAKqs.js';
43
- import './types-BAhcze_-.js';
43
+ import './types-CBtBvGw0.js';
44
44
  import './status-BXRokZD9.js';
45
45
  import './gallery/index.js';
46
46
  import './dates.js';
47
- import './saved-views-C45lRm7i.js';
47
+ import './saved-views-Bcox3blZ.js';
48
48
  import 'react-hook-form';
49
49
 
50
50
  /** Who and when a key is for. `viewer` is required; null means signed out. */
package/dist/index.js CHANGED
@@ -1,30 +1,30 @@
1
1
  import './chunk-XCX2TRBL.js';
2
- export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from './chunk-UNEZF3ZP.js';
3
- export { WorkspaceScope, rememberedWorkspaceId, useWorkspace } from './chunk-TWLPC4S3.js';
4
- export { useSegmentCounts } from './chunk-K33LWVUF.js';
5
- export { useViewBoard } from './chunk-KRRESUXT.js';
6
- import './chunk-JNWTHDGF.js';
2
+ export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from './chunk-5PCGMSDX.js';
3
+ export { WorkspaceScope, rememberedWorkspaceId, useWorkspace } from './chunk-DJRT4DUF.js';
4
+ export { useSegmentCounts } from './chunk-UKWM32CG.js';
5
+ export { useViewBoard } from './chunk-PH25HOAL.js';
6
+ import './chunk-AOIVTOHX.js';
7
7
  export { defineResource, fieldControl } from './chunk-BNKP2H7J.js';
8
- export { CALENDAR_LIMIT, useViewCalendarRange } from './chunk-2ORQLYVW.js';
9
- import './chunk-YMFJLBIZ.js';
8
+ export { CALENDAR_LIMIT, useViewCalendarRange } from './chunk-SMEG63MO.js';
9
+ import './chunk-UKJCF2CM.js';
10
10
  export { decodeRecordKey, encodeRecordKey, keyFields } from './chunk-KV2HW4G4.js';
11
11
  export { useWizard } from './chunk-7KOLYF27.js';
12
12
  export { WRITE_FAILED, useWrite } from './chunk-NQFIAULD.js';
13
13
  export { useLinkOptions } from './chunk-JF7FXSQB.js';
14
- export { useListState } from './chunk-WNOCPV4A.js';
14
+ export { useListState } from './chunk-DTVYCATJ.js';
15
15
  import './chunk-MZVFOTAE.js';
16
16
  import './chunk-6JOWGO2X.js';
17
- export { ViewerScope, clearViewerCache, scopeClock, useOptionalViewerScope, useViewer, useViewerScope } from './chunk-XIBQ5BTZ.js';
17
+ export { ViewerScope, clearViewerCache, scopeClock, useOptionalViewerScope, useViewer, useViewerScope } from './chunk-RZVLUUMY.js';
18
18
  export { NO_VIEWER } from './chunk-OZYF55E3.js';
19
19
  import { usePersistedUiState } from './chunk-5KLIFJYG.js';
20
20
  export { usePersistedUiState } from './chunk-5KLIFJYG.js';
21
21
  export { loadRelationLabel, relationNamingField, useRelationLabel } from './chunk-ZKLB2HB5.js';
22
- export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-FBMKI22S.js';
22
+ export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-ATVK3VYS.js';
23
23
  export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from './chunk-RVWKVD5Q.js';
24
24
  export { writeConflict } from './chunk-LKRJB632.js';
25
25
  export { useOne } from './chunk-QJOKZZKY.js';
26
- export { useResource } from './chunk-6B4CN2TC.js';
27
- export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './chunk-AQX5HQD6.js';
26
+ export { useResource } from './chunk-OCMYW2YE.js';
27
+ export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './chunk-OTUTSAZD.js';
28
28
  import './chunk-7NUL32W7.js';
29
29
  export { useAggregate } from './chunk-4POVYF6P.js';
30
30
  export { BOARD_NONE, BOARD_PAGE, boardColumnFilter, useBoardColumns } from './chunk-6VNM6KAX.js';
@@ -43,8 +43,9 @@ import './chunk-BDPRWVFW.js';
43
43
  export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from './chunk-5ASUMG6K.js';
44
44
  import './chunk-AUVKRXRC.js';
45
45
  import './chunk-WXENWPWP.js';
46
- import { reportError } from './chunk-NOPS5EIH.js';
47
- export { classifyError, defaultErrorReporter, errorMessages, fieldErrorsFromPostgrest, getErrorReporter, readOutcomeFromCode, reportError, setErrorReporter, toDataWriteError, writeOutcomeFromCode } from './chunk-NOPS5EIH.js';
46
+ import { reportError } from './chunk-CJ5V6JES.js';
47
+ export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './chunk-CJ5V6JES.js';
48
+ export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from './chunk-LYNIHY3F.js';
48
49
  export { DataReadError, isDataReadError, readFailureMessage } from './chunk-HUNGCTRA.js';
49
50
  export { titleCase } from './chunk-RYEXWQFD.js';
50
51
  export { DataWriteError, NO_ROWS_MATCHED, isDataWriteError } from './chunk-WLDSIQJ2.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/appearance.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGO,SAAS,2BAAA,CAA4B,UAAA,GAA8C,EAAC,EAA0B;AACnH,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,IAAA,IAAQ,EAAC;AACjC,EAAA,IAAI,IAAA,CAAK,UAAA,KAAe,MAAA,IAAa,CAAC,aAAa,IAAA,CAAK,UAAU,CAAA,EAAG,QAAA,CAAS,KAAK,CAAA,wBAAA,EAA2B,WAAA,CAAY,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACtI,EAAA,IAAI,IAAA,CAAK,OAAA,KAAY,MAAA,IAAa,CAAC,UAAU,IAAA,CAAK,OAAO,CAAA,EAAG,QAAA,CAAS,KAAK,CAAA,qBAAA,EAAwB,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACxH,EAAA,IAAI,UAAA,CAAW,KAAA,KAAU,OAA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BAA4B,CAAA;AAChD","file":"index.js","sourcesContent":["\"use client\";\n/**\n * Appearance preferences (ADR 0024): who sets a person's appearance (light, dark or system) and\n * density (compact, comfortable, spacious).\n *\n * Both are the person's. An app can lock either one; an organization can set a default for its\n * people; an app theme sets the default under that; Genesis's own default is last:\n *\n * app lock > person > organization default > theme default > Genesis default\n *\n * `resolveAppearancePreferences` is that order as a pure function. `defineAppearancePreferences`\n * declares an app's lock, defaults and where a person's choice is kept: a store (an adapter the\n * app backs with its own server table, so the choice follows the person to every device), with\n * the device's storage (`useStorage()`) as a copy and the fallback. `AppearancePreferencesProvider`\n * serves it to the tree: genesis-ui's `AppearanceProvider` (light and dark) and `AppShell`\n * (density) read it when it is there, and work as before when it isn't.\n *\n * Brand is not here: an organization sets its brand (`WorkspaceTheme.brand`), and the app sets\n * the theme per area.\n */\nimport { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { usePersistedUiState } from \"./hooks/use-persisted-ui-state\";\nimport { reportError } from \"./errors\";\nimport {\n APPEARANCES,\n DENSITIES,\n isAppearance,\n isDensity,\n resolveAppearancePreferences,\n toAppearancePreferenceValues,\n type Appearance,\n type AppearancePreferenceLayers,\n type AppearancePreferenceValues,\n type Density,\n type ResolvedAppearancePreferences,\n} from \"./appearance-values\";\n\n/**\n * Where a person's appearance preferences are kept: an adapter an app backs with its own server\n * table (a `profiles` row, say), so the choice follows the person. `read` may be async; return\n * null when the person has chosen nothing. `subscribe` (optional) reports a change made elsewhere.\n *\n * @stability Beta\n */\nexport interface AppearancePreferencesStore {\n read(): AppearancePreferenceValues | null | undefined | Promise<AppearancePreferenceValues | null | undefined>;\n /**\n * Save the person's values. Writes are sent one at a time, in order, and a write that a newer\n * one replaces before it starts is skipped. `context.previous` is what the store last answered\n * or accepted (null for nothing yet), so a store can write conditionally (compare and set) and\n * refuse a write made from a stale copy by throwing: `onWriteError` hears it.\n */\n write(values: AppearancePreferenceValues, context: AppearanceWriteContext): void | Promise<void>;\n subscribe?(onChange: (values: AppearancePreferenceValues | null) => void): () => void;\n}\n\n/** What a store's `write` is told beside the values. @stability Beta */\nexport interface AppearanceWriteContext {\n /** The values the store last read or accepted; null when it has none yet. */\n readonly previous: AppearancePreferenceValues | null;\n}\n\n/** What `defineAppearancePreferences` accepts. */\nexport interface AppearancePreferencesDefinition {\n /** Where the person's choice is kept beyond this device. Unset: the device only. */\n store?: AppearancePreferencesStore;\n /** The device copy's storage key (`useStorage()`). Default `genesis-appearance`. */\n storageKey?: string;\n /** Values the app fixes: nobody below can change them. */\n lock?: AppearancePreferenceValues;\n /**\n * Hears a store write that failed (offline, refused, a conditional write that lost), with the\n * values it tried to save. The device keeps the choice for this visit; the next successful read\n * of the store (another visit, another device) wins over it. Default: the\n * error goes to `reportError`.\n */\n onWriteError?: (error: unknown, values: AppearancePreferenceValues) => void;\n}\n\n/** A defined appearance-preferences setup. */\nexport interface AppearancePreferences {\n readonly store?: AppearancePreferencesStore;\n readonly storageKey: string;\n readonly lock: Readonly<AppearancePreferenceValues>;\n readonly onWriteError?: (error: unknown, values: AppearancePreferenceValues) => void;\n}\n\n/**\n * Declare where a person's appearance and density are kept and what the app locks. Checks the\n * lock and returns it frozen; throws on a value that isn't an appearance or a density.\n *\n * ```ts\n * export const appearance = defineAppearancePreferences({\n * store: {\n * read: () => api.myPreferences(), // { appearance: \"dark\", density: \"compact\" }\n * write: (values) => api.saveMyPreferences(values),\n * },\n * lock: { density: \"comfortable\" },\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineAppearancePreferences(definition: AppearancePreferencesDefinition = {}): AppearancePreferences {\n const problems: string[] = [];\n const lock = definition.lock ?? {};\n if (lock.appearance !== undefined && !isAppearance(lock.appearance)) problems.push(`lock.appearance: one of ${APPEARANCES.join(\", \")}`);\n if (lock.density !== undefined && !isDensity(lock.density)) problems.push(`lock.density: one of ${DENSITIES.join(\", \")}`);\n if (definition.store && (typeof definition.store.read !== \"function\" || typeof definition.store.write !== \"function\"))\n problems.push(\"store: an object with read() and write()\");\n if (definition.storageKey !== undefined && (typeof definition.storageKey !== \"string\" || !definition.storageKey.trim()))\n problems.push(\"storageKey: a non-empty string\");\n if (definition.onWriteError !== undefined && typeof definition.onWriteError !== \"function\") problems.push(\"onWriteError: a function\");\n if (problems.length) throw new Error(`defineAppearancePreferences: ${problems.join(\"; \")}`);\n return Object.freeze({\n ...(definition.store ? { store: definition.store } : {}),\n ...(definition.onWriteError ? { onWriteError: definition.onWriteError } : {}),\n storageKey: definition.storageKey ?? \"genesis-appearance\",\n lock: Object.freeze(toAppearancePreferenceValues(lock)),\n });\n}\n\n/** What `useAppearancePreferences` returns. */\nexport interface UseAppearancePreferencesReturn extends ResolvedAppearancePreferences {\n /** The person's own choice (the store's, else this device's), before the order is applied. */\n person: AppearancePreferenceValues;\n /** Which values the app has locked. */\n locked: { appearance: boolean; density: boolean };\n /**\n * Every layer as given, for a component with a default of its own to put in the order\n * (`AppShell` puts its `options.density` under the theme's).\n */\n layers: AppearancePreferenceLayers;\n /** False until the store's first read has answered. */\n ready: boolean;\n /** Save the person's appearance (`undefined` clears it back to the defaults). Ignored when locked. */\n setAppearance(appearance: Appearance | undefined): void;\n /** Save the person's density (`undefined` clears it). Ignored when locked. */\n setDensity(density: Density | undefined): void;\n}\n\nconst AppearancePreferencesContext = createContext<UseAppearancePreferencesReturn | null>(null);\n\nconst FORMAT = {\n parse: (raw: string) => {\n try {\n return toAppearancePreferenceValues(JSON.parse(raw));\n } catch {\n return undefined;\n }\n },\n};\nconst NONE: AppearancePreferenceValues = {};\n\nexport interface AppearancePreferencesProviderProps {\n /** From `defineAppearancePreferences`. Default: this device only, nothing locked. */\n preferences?: AppearancePreferences;\n /** The active organization's defaults (`resolveWorkspaceAppearance(workspace)`). */\n organization?: AppearancePreferenceValues | undefined;\n /** The app theme's defaults. */\n theme?: AppearancePreferenceValues | undefined;\n /** Hears a failed store write (wins over the definition's `onWriteError`). */\n onWriteError?: ((error: unknown, values: AppearancePreferenceValues) => void) | undefined;\n children: ReactNode;\n}\n\nconst DEVICE_ONLY = defineAppearancePreferences();\n\n/**\n * Serves a person's appearance and density to the tree, resolved in the written order. Reads the\n * store once on mount (and on its `subscribe`), keeps a copy on the device, and writes both when\n * the person changes a value.\n *\n * @stability Beta\n */\nexport function AppearancePreferencesProvider({ preferences = DEVICE_ONLY, organization, theme, onWriteError, children }: AppearancePreferencesProviderProps) {\n const { store, storageKey, lock } = preferences;\n const [device, setDevice] = usePersistedUiState<AppearancePreferenceValues>(storageKey, NONE, FORMAT);\n const [stored, setStored] = useState<AppearancePreferenceValues | null | undefined>(undefined);\n const [ready, setReady] = useState(!store);\n const latestStore = useRef(store);\n latestStore.current = store;\n // The first read settles before any write goes out: choices made while it's in flight wait here as\n // patches, then go out merged onto what the store said, with that as `previous`.\n const firstRead = useRef<\"pending\" | \"settled\">(store ? \"pending\" : \"settled\");\n const waiting = useRef<AppearancePreferenceValues | null>(null);\n // How many newer values the store has given since a read started (a write it accepted, or a\n // value its `subscribe` delivered): a read that started before one is older than it.\n const writesDone = useRef(0);\n // Which store the queue and its writes belong to: a store change drops what was waiting for the\n // old one, and an old write that completes afterwards changes nothing here.\n const generation = useRef(0);\n // What the store last answered or accepted, for a conditional write.\n const confirmed = useRef<AppearancePreferenceValues | null>(null);\n // One write at a time, in order; the newest waiting write replaces an older waiting one.\n // One write at a time per store: each store generation gets its own queue, so a store never\n // waits behind the last one's write. What waits is a patch (the person's choices), merged onto\n // the store's latest confirmed values when it goes out, so a newer value from another device\n // isn't overwritten by a stale snapshot.\n type Queue = { running: boolean; next: { patch: AppearancePreferenceValues; generation: number } | null };\n const queue = useRef<Queue>({ running: false, next: null });\n const deviceSetter = useRef(setDevice);\n deviceSetter.current = setDevice;\n const writeErrorHandler = useRef(onWriteError ?? preferences.onWriteError);\n writeErrorHandler.current = onWriteError ?? preferences.onWriteError;\n\n useEffect(() => {\n generation.current += 1;\n // What waited for the last store isn't this one's to write: neither a queued write nor a\n // choice held while that store's first read was out (the device keeps its copy).\n queue.current = { running: false, next: null };\n waiting.current = null;\n // What the last store confirmed isn't this one's `previous`: a conditional write to the new\n // store must start from what it says (its read), or from nothing.\n confirmed.current = null;\n if (!store) return;\n let active = true;\n firstRead.current = \"pending\";\n const writesAtStart = writesDone.current;\n // Choices made meanwhile go out now: merged onto what the store said, or onto this device's.\n const release = (base: AppearancePreferenceValues | null) => {\n firstRead.current = \"settled\";\n const patch = waiting.current;\n waiting.current = null;\n if (!patch) return;\n const merged = toAppearancePreferenceValues({ ...(base ?? {}), ...patch });\n setStored(merged);\n deviceSetter.current(Object.keys(merged).length ? merged : undefined);\n queue.current.next = { patch: merged, generation: generation.current };\n void drainRef.current();\n };\n Promise.resolve()\n .then(() => store.read())\n .then(\n (values) => {\n if (!active) return;\n const read = values ? toAppearancePreferenceValues(values) : null;\n // A read older than an accepted write or a delivered value says nothing new: drop it, and\n // put a held patch onto the newest values instead.\n const fresh = writesDone.current === writesAtStart;\n if (fresh) {\n confirmed.current = read;\n if (!waiting.current) {\n setStored(read);\n // The device keeps a copy of what the store said, for the next visit's first paint.\n if (read) deviceSetter.current(Object.keys(read).length ? read : undefined);\n }\n }\n release(fresh ? read : confirmed.current);\n setReady(true);\n },\n (error: unknown) => {\n // A store that can't be read leaves the device's copy in charge.\n reportError(error, \"core:appearance-preferences\");\n if (!active) return;\n release(deviceRef.current);\n setReady(true);\n },\n );\n const unsubscribe = store.subscribe?.((values) => {\n if (!active) return;\n const next = values ? toAppearancePreferenceValues(values) : null;\n confirmed.current = next;\n writesDone.current += 1;\n // The store's values are the baseline; a choice still held for the first read stays on top,\n // shown and kept on the device, until it goes out.\n const shown = waiting.current ? toAppearancePreferenceValues({ ...(next ?? {}), ...waiting.current }) : next;\n setStored(shown);\n if (shown) deviceSetter.current(Object.keys(shown).length ? shown : undefined);\n });\n return () => {\n active = false;\n unsubscribe?.();\n };\n }, [store]);\n\n // The store's answer is the person's choice; the device's copy fills in until it comes, and\n // when there is no store.\n const person = useMemo<AppearancePreferenceValues>(() => ({ ...device, ...(stored ?? {}) }), [device, stored]);\n const deviceRef = useRef(device);\n deviceRef.current = device;\n\n const drain = useCallback(async () => {\n const q = queue.current;\n if (q.running) return;\n q.running = true;\n try {\n while (q.next) {\n const { patch, generation: owner } = q.next;\n q.next = null;\n const target = latestStore.current;\n if (!target) break;\n // Queued for a store that has since been replaced: not this one's to write.\n if (owner !== generation.current) continue;\n const values = toAppearancePreferenceValues({ ...(confirmed.current ?? {}), ...patch });\n try {\n // Newer values the store's subscription delivers while this write is out win over it.\n const freshAtStart = writesDone.current;\n await target.write(values, { previous: confirmed.current });\n // The store changed while it was out: the new one's state isn't this write's.\n if (owner !== generation.current) continue;\n if (writesDone.current === freshAtStart) confirmed.current = values;\n writesDone.current += 1;\n } catch (error: unknown) {\n const handler = writeErrorHandler.current;\n if (handler) handler(error, values);\n else reportError(error, \"core:appearance-preferences\");\n }\n }\n } finally {\n q.running = false;\n }\n }, []);\n const drainRef = useRef(drain);\n drainRef.current = drain;\n\n const save = useCallback(\n (patch: AppearancePreferenceValues) => {\n // An undefined value in the patch clears that key: the spread sets it, and the check drops it.\n const next = toAppearancePreferenceValues({ ...person, ...patch });\n setDevice(Object.keys(next).length ? next : undefined);\n if (latestStore.current) {\n setStored(next);\n if (firstRead.current === \"pending\") {\n // Not yet: the patch waits for the store's answer, so nothing it holds is overwritten.\n waiting.current = { ...(waiting.current ?? {}), ...patch };\n return;\n }\n const q = queue.current;\n // Kept raw: an undefined value (a cleared choice) must survive to clear the key on write.\n q.next = { patch: { ...(q.next?.generation === generation.current ? q.next.patch : {}), ...patch }, generation: generation.current };\n void drain();\n }\n },\n [person, setDevice, drain],\n );\n\n const value = useMemo<UseAppearancePreferencesReturn>(() => {\n const layers: AppearancePreferenceLayers = { lock, person, organization, theme };\n const resolved = resolveAppearancePreferences(layers);\n const locked = { appearance: lock.appearance !== undefined, density: lock.density !== undefined };\n return {\n ...resolved,\n person,\n locked,\n layers,\n ready,\n setAppearance: (appearance) => {\n if (!locked.appearance) save({ appearance });\n },\n setDensity: (density) => {\n if (!locked.density) save({ density });\n },\n };\n }, [lock, person, organization, theme, ready, save]);\n\n return <AppearancePreferencesContext.Provider value={value}>{children}</AppearancePreferencesContext.Provider>;\n}\n\n/**\n * The person's appearance and density, resolved, with setters. Throws outside an\n * `AppearancePreferencesProvider`; a component that works with or without one reads\n * `useOptionalAppearancePreferences`.\n *\n * @stability Beta\n */\nexport function useAppearancePreferences(): UseAppearancePreferencesReturn {\n const value = useContext(AppearancePreferencesContext);\n if (!value) throw new Error(\"useAppearancePreferences: no AppearancePreferencesProvider above this component.\");\n return value;\n}\n\n/**\n * Like `useAppearancePreferences`, but null outside a provider: for a component (a shell, a\n * theme provider) that keeps its own behaviour when an app hasn't set preferences up.\n *\n * @stability Beta\n */\nexport function useOptionalAppearancePreferences(): UseAppearancePreferencesReturn | null {\n return useContext(AppearancePreferencesContext);\n}\n"]}
1
+ {"version":3,"sources":["../src/appearance.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGO,SAAS,2BAAA,CAA4B,UAAA,GAA8C,EAAC,EAA0B;AACnH,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,IAAA,IAAQ,EAAC;AACjC,EAAA,IAAI,IAAA,CAAK,UAAA,KAAe,MAAA,IAAa,CAAC,aAAa,IAAA,CAAK,UAAU,CAAA,EAAG,QAAA,CAAS,KAAK,CAAA,wBAAA,EAA2B,WAAA,CAAY,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACtI,EAAA,IAAI,IAAA,CAAK,OAAA,KAAY,MAAA,IAAa,CAAC,UAAU,IAAA,CAAK,OAAO,CAAA,EAAG,QAAA,CAAS,KAAK,CAAA,qBAAA,EAAwB,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACxH,EAAA,I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GAA0E;AACxF,EAAA,OAAO,WAAW,4BAA4B,CAAA;AAChD","file":"index.js","sourcesContent":["\"use client\";\n/**\n * Appearance preferences (ADR 0024): who sets a person's appearance (light, dark or system) and\n * density (compact, comfortable, spacious).\n *\n * Both are the person's. An app can lock either one; an organization can set a default for its\n * people; an app theme sets the default under that; Genesis's own default is last:\n *\n * app lock > person > organization default > theme default > Genesis default\n *\n * `resolveAppearancePreferences` is that order as a pure function. `defineAppearancePreferences`\n * declares an app's lock, defaults and where a person's choice is kept: a store (an adapter the\n * app backs with its own server table, so the choice follows the person to every device), with\n * the device's storage (`useStorage()`) as a copy and the fallback. `AppearancePreferencesProvider`\n * serves it to the tree: genesis-ui's `AppearanceProvider` (light and dark) and `AppShell`\n * (density) read it when it is there, and work as before when it isn't.\n *\n * Brand is not here: an organization sets its brand (`WorkspaceTheme.brand`), and the app sets\n * the theme per area.\n */\nimport { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { usePersistedUiState } from \"./hooks/use-persisted-ui-state\";\nimport { reportError } from \"./errors\";\nimport {\n APPEARANCES,\n DENSITIES,\n isAppearance,\n isDensity,\n resolveAppearancePreferences,\n toAppearancePreferenceValues,\n type Appearance,\n type AppearancePreferenceLayers,\n type AppearancePreferenceValues,\n type Density,\n type ResolvedAppearancePreferences,\n} from \"./appearance-values\";\n\n/**\n * Where a person's appearance preferences are kept: an adapter an app backs with its own server\n * table (a `profiles` row, say), so the choice follows the person. `read` may be async; return\n * null when the person has chosen nothing. `subscribe` (optional) reports a change made elsewhere.\n *\n * @stability Beta\n */\nexport interface AppearancePreferencesStore {\n read(): AppearancePreferenceValues | null | undefined | Promise<AppearancePreferenceValues | null | undefined>;\n /**\n * Save the person's values. Writes are sent one at a time, in order, and a write that a newer\n * one replaces before it starts is skipped. `context.previous` is what the store last answered\n * or accepted (null for nothing yet), so a store can write conditionally (compare and set) and\n * refuse a write made from a stale copy by throwing: `onWriteError` hears it.\n */\n write(values: AppearancePreferenceValues, context: AppearanceWriteContext): void | Promise<void>;\n subscribe?(onChange: (values: AppearancePreferenceValues | null) => void): () => void;\n}\n\n/** What a store's `write` is told beside the values. @stability Beta */\nexport interface AppearanceWriteContext {\n /** The values the store last read or accepted; null when it has none yet. */\n readonly previous: AppearancePreferenceValues | null;\n}\n\n/** What `defineAppearancePreferences` accepts. */\nexport interface AppearancePreferencesDefinition {\n /** Where the person's choice is kept beyond this device. Unset: the device only. */\n store?: AppearancePreferencesStore;\n /** The device copy's storage key (`useStorage()`). Default `genesis-appearance`. */\n storageKey?: string;\n /** Values the app fixes: nobody below can change them. */\n lock?: AppearancePreferenceValues;\n /**\n * Hears a store write that failed (offline, refused, a conditional write that lost), with the\n * values it tried to save. The device keeps the choice for this visit; the next successful read\n * of the store (another visit, another device) wins over it. Default: the\n * error goes to `reportError`.\n */\n onWriteError?: (error: unknown, values: AppearancePreferenceValues) => void;\n}\n\n/** A defined appearance-preferences setup. */\nexport interface AppearancePreferences {\n readonly store?: AppearancePreferencesStore;\n readonly storageKey: string;\n readonly lock: Readonly<AppearancePreferenceValues>;\n readonly onWriteError?: (error: unknown, values: AppearancePreferenceValues) => void;\n}\n\n/**\n * Declare where a person's appearance and density are kept and what the app locks. Checks the\n * lock and returns it frozen; throws on a value that isn't an appearance or a density.\n *\n * ```ts\n * export const appearance = defineAppearancePreferences({\n * store: {\n * read: () => api.myPreferences(), // { appearance: \"dark\", density: \"compact\" }\n * write: (values) => api.saveMyPreferences(values),\n * },\n * lock: { density: \"comfortable\" },\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineAppearancePreferences(definition: AppearancePreferencesDefinition = {}): AppearancePreferences {\n const problems: string[] = [];\n const lock = definition.lock ?? {};\n if (lock.appearance !== undefined && !isAppearance(lock.appearance)) problems.push(`lock.appearance: one of ${APPEARANCES.join(\", \")}`);\n if (lock.density !== undefined && !isDensity(lock.density)) problems.push(`lock.density: one of ${DENSITIES.join(\", \")}`);\n if (definition.store && (typeof definition.store.read !== \"function\" || typeof definition.store.write !== \"function\"))\n problems.push(\"store: an object with read() and write()\");\n if (definition.storageKey !== undefined && (typeof definition.storageKey !== \"string\" || !definition.storageKey.trim()))\n problems.push(\"storageKey: a non-empty string\");\n if (definition.onWriteError !== undefined && typeof definition.onWriteError !== \"function\") problems.push(\"onWriteError: a function\");\n if (problems.length) throw new Error(`defineAppearancePreferences: ${problems.join(\"; \")}`);\n return Object.freeze({\n ...(definition.store ? { store: definition.store } : {}),\n ...(definition.onWriteError ? { onWriteError: definition.onWriteError } : {}),\n storageKey: definition.storageKey ?? \"genesis-appearance\",\n lock: Object.freeze(toAppearancePreferenceValues(lock)),\n });\n}\n\n/** What `useAppearancePreferences` returns. */\nexport interface UseAppearancePreferencesReturn extends ResolvedAppearancePreferences {\n /** The person's own choice (the store's, else this device's), before the order is applied. */\n person: AppearancePreferenceValues;\n /** Which values the app has locked. */\n locked: { appearance: boolean; density: boolean };\n /**\n * Every layer as given, for a component with a default of its own to put in the order\n * (`AppShell` puts its `options.density` under the theme's).\n */\n layers: AppearancePreferenceLayers;\n /** False until the store's first read has answered. */\n ready: boolean;\n /** Save the person's appearance (`undefined` clears it back to the defaults). Ignored when locked. */\n setAppearance(appearance: Appearance | undefined): void;\n /** Save the person's density (`undefined` clears it). Ignored when locked. */\n setDensity(density: Density | undefined): void;\n}\n\nconst AppearancePreferencesContext = createContext<UseAppearancePreferencesReturn | null>(null);\n\nconst FORMAT = {\n parse: (raw: string) => {\n try {\n return toAppearancePreferenceValues(JSON.parse(raw));\n } catch {\n return undefined;\n }\n },\n};\nconst NONE: AppearancePreferenceValues = {};\n\nexport interface AppearancePreferencesProviderProps {\n /** From `defineAppearancePreferences`. Default: this device only, nothing locked. */\n preferences?: AppearancePreferences;\n /** The active organization's defaults (`resolveWorkspaceAppearance(workspace)`). */\n organization?: AppearancePreferenceValues | undefined;\n /** The app theme's defaults. */\n theme?: AppearancePreferenceValues | undefined;\n /** Hears a failed store write (wins over the definition's `onWriteError`). */\n onWriteError?: ((error: unknown, values: AppearancePreferenceValues) => void) | undefined;\n children: ReactNode;\n}\n\nconst DEVICE_ONLY = defineAppearancePreferences();\n\n/**\n * Serves a person's appearance and density to the tree, resolved in the written order. Reads the\n * store once on mount (and on its `subscribe`), keeps a copy on the device, and writes both when\n * the person changes a value.\n *\n * @stability Beta\n */\nexport function AppearancePreferencesProvider({ preferences = DEVICE_ONLY, organization, theme, onWriteError, children }: AppearancePreferencesProviderProps) {\n const { store, storageKey, lock } = preferences;\n const [device, setDevice] = usePersistedUiState<AppearancePreferenceValues>(storageKey, NONE, FORMAT);\n const [stored, setStored] = useState<AppearancePreferenceValues | null | undefined>(undefined);\n const [ready, setReady] = useState(!store);\n const latestStore = useRef(store);\n latestStore.current = store;\n // The first read settles before any write goes out: choices made while it's in flight wait here as\n // patches, then go out merged onto what the store said, with that as `previous`.\n const firstRead = useRef<\"pending\" | \"settled\">(store ? \"pending\" : \"settled\");\n const waiting = useRef<AppearancePreferenceValues | null>(null);\n // How many newer values the store has given since a read started (a write it accepted, or a\n // value its `subscribe` delivered): a read that started before one is older than it.\n const writesDone = useRef(0);\n // Which store the queue and its writes belong to: a store change drops what was waiting for the\n // old one, and an old write that completes afterwards changes nothing here.\n const generation = useRef(0);\n // What the store last answered or accepted, for a conditional write.\n const confirmed = useRef<AppearancePreferenceValues | null>(null);\n // One write at a time, in order; the newest waiting write replaces an older waiting one.\n // One write at a time per store: each store generation gets its own queue, so a store never\n // waits behind the last one's write. What waits is a patch (the person's choices), merged onto\n // the store's latest confirmed values when it goes out, so a newer value from another device\n // isn't overwritten by a stale snapshot.\n type Queue = { running: boolean; next: { patch: AppearancePreferenceValues; generation: number } | null };\n const queue = useRef<Queue>({ running: false, next: null });\n const deviceSetter = useRef(setDevice);\n deviceSetter.current = setDevice;\n const writeErrorHandler = useRef(onWriteError ?? preferences.onWriteError);\n writeErrorHandler.current = onWriteError ?? preferences.onWriteError;\n\n useEffect(() => {\n generation.current += 1;\n // What waited for the last store isn't this one's to write: neither a queued write nor a\n // choice held while that store's first read was out (the device keeps its copy).\n queue.current = { running: false, next: null };\n waiting.current = null;\n // What the last store confirmed isn't this one's `previous`: a conditional write to the new\n // store must start from what it says (its read), or from nothing.\n confirmed.current = null;\n if (!store) return;\n let active = true;\n firstRead.current = \"pending\";\n const writesAtStart = writesDone.current;\n // Choices made meanwhile go out now: merged onto what the store said, or onto this device's.\n const release = (base: AppearancePreferenceValues | null) => {\n firstRead.current = \"settled\";\n const patch = waiting.current;\n waiting.current = null;\n if (!patch) return;\n const merged = toAppearancePreferenceValues({ ...(base ?? {}), ...patch });\n setStored(merged);\n deviceSetter.current(Object.keys(merged).length ? merged : undefined);\n queue.current.next = { patch: merged, generation: generation.current };\n void drainRef.current();\n };\n Promise.resolve()\n .then(() => store.read())\n .then(\n (values) => {\n if (!active) return;\n const read = values ? toAppearancePreferenceValues(values) : null;\n // A read older than an accepted write or a delivered value says nothing new: drop it, and\n // put a held patch onto the newest values instead.\n const fresh = writesDone.current === writesAtStart;\n if (fresh) {\n confirmed.current = read;\n if (!waiting.current) {\n setStored(read);\n // The device keeps a copy of what the store said, for the next visit's first paint.\n if (read) deviceSetter.current(Object.keys(read).length ? read : undefined);\n }\n }\n release(fresh ? read : confirmed.current);\n setReady(true);\n },\n (error: unknown) => {\n // A store that can't be read leaves the device's copy in charge.\n reportError(error, \"core:appearance-preferences\");\n if (!active) return;\n release(deviceRef.current);\n setReady(true);\n },\n );\n const unsubscribe = store.subscribe?.((values) => {\n if (!active) return;\n const next = values ? toAppearancePreferenceValues(values) : null;\n confirmed.current = next;\n writesDone.current += 1;\n // The store's values are the baseline; a choice still held for the first read stays on top,\n // shown and kept on the device, until it goes out.\n const shown = waiting.current ? toAppearancePreferenceValues({ ...(next ?? {}), ...waiting.current }) : next;\n setStored(shown);\n if (shown) deviceSetter.current(Object.keys(shown).length ? shown : undefined);\n });\n return () => {\n active = false;\n unsubscribe?.();\n };\n }, [store]);\n\n // The store's answer is the person's choice; the device's copy fills in until it comes, and\n // when there is no store.\n const person = useMemo<AppearancePreferenceValues>(() => ({ ...device, ...(stored ?? {}) }), [device, stored]);\n const deviceRef = useRef(device);\n deviceRef.current = device;\n\n const drain = useCallback(async () => {\n const q = queue.current;\n if (q.running) return;\n q.running = true;\n try {\n while (q.next) {\n const { patch, generation: owner } = q.next;\n q.next = null;\n const target = latestStore.current;\n if (!target) break;\n // Queued for a store that has since been replaced: not this one's to write.\n if (owner !== generation.current) continue;\n const values = toAppearancePreferenceValues({ ...(confirmed.current ?? {}), ...patch });\n try {\n // Newer values the store's subscription delivers while this write is out win over it.\n const freshAtStart = writesDone.current;\n await target.write(values, { previous: confirmed.current });\n // The store changed while it was out: the new one's state isn't this write's.\n if (owner !== generation.current) continue;\n if (writesDone.current === freshAtStart) confirmed.current = values;\n writesDone.current += 1;\n } catch (error: unknown) {\n const handler = writeErrorHandler.current;\n if (handler) handler(error, values);\n else reportError(error, \"core:appearance-preferences\");\n }\n }\n } finally {\n q.running = false;\n }\n }, []);\n const drainRef = useRef(drain);\n drainRef.current = drain;\n\n const save = useCallback(\n (patch: AppearancePreferenceValues) => {\n // An undefined value in the patch clears that key: the spread sets it, and the check drops it.\n const next = toAppearancePreferenceValues({ ...person, ...patch });\n setDevice(Object.keys(next).length ? next : undefined);\n if (latestStore.current) {\n setStored(next);\n if (firstRead.current === \"pending\") {\n // Not yet: the patch waits for the store's answer, so nothing it holds is overwritten.\n waiting.current = { ...(waiting.current ?? {}), ...patch };\n return;\n }\n const q = queue.current;\n // Kept raw: an undefined value (a cleared choice) must survive to clear the key on write.\n q.next = { patch: { ...(q.next?.generation === generation.current ? q.next.patch : {}), ...patch }, generation: generation.current };\n void drain();\n }\n },\n [person, setDevice, drain],\n );\n\n const value = useMemo<UseAppearancePreferencesReturn>(() => {\n const layers: AppearancePreferenceLayers = { lock, person, organization, theme };\n const resolved = resolveAppearancePreferences(layers);\n const locked = { appearance: lock.appearance !== undefined, density: lock.density !== undefined };\n return {\n ...resolved,\n person,\n locked,\n layers,\n ready,\n setAppearance: (appearance) => {\n if (!locked.appearance) save({ appearance });\n },\n setDensity: (density) => {\n if (!locked.density) save({ density });\n },\n };\n }, [lock, person, organization, theme, ready, save]);\n\n return <AppearancePreferencesContext.Provider value={value}>{children}</AppearancePreferencesContext.Provider>;\n}\n\n/**\n * The person's appearance and density, resolved, with setters. Throws outside an\n * `AppearancePreferencesProvider`; a component that works with or without one reads\n * `useOptionalAppearancePreferences`.\n *\n * @stability Beta\n */\nexport function useAppearancePreferences(): UseAppearancePreferencesReturn {\n const value = useContext(AppearancePreferencesContext);\n if (!value) throw new Error(\"useAppearancePreferences: no AppearancePreferencesProvider above this component.\");\n return value;\n}\n\n/**\n * Like `useAppearancePreferences`, but null outside a provider: for a component (a shell, a\n * theme provider) that keeps its own behaviour when an app hasn't set preferences up.\n *\n * @stability Beta\n */\nexport function useOptionalAppearancePreferences(): UseAppearancePreferencesReturn | null {\n return useContext(AppearancePreferencesContext);\n}\n"]}