@xnetjs/react 0.12.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { Q as QueryFilter, a as QueryStatus, F as FlatNode, b as QueryPlanSummary } from './useQuery-D7ajycrc.js';
2
2
  export { i as FlattenNodeOptions, M as MigrationWarning, c as QueryListResult, d as QuerySingleResult, S as SortDirection, f as flattenNode, e as flattenNodes, h as flattenNodesWithSchemaCheck, g as flattenUnknownSchemaNode, u as useQuery } from './useQuery-D7ajycrc.js';
3
3
  export { ErrorBoundary, ErrorBoundaryProps, InfiniteQueryFilter, InfiniteQueryPage, InfiniteQueryResult, MutateCreate, MutateDelete, MutateOp, MutateRestore, MutateUpdate, OfflineIndicator, OfflineIndicatorProps, PresenceUser, SyncStatus, UseIdentityResult, UseMutateResult, UseNodeOptions, UseNodeResult, useIdentity, useInfiniteQuery, useIsOffline, useMutate, useNode } from './core.js';
4
- import { U as UseTaskProjectionSyncResult, T as TaskProjectionInput, a as TaskTreeItem } from './experimental-B2FrBnkV.js';
5
- export { A as AddCommentOptions, a0 as AddReactionOptions, bm as AuthErrorScreen, aP as AuthTraceSummary, bl as AuthenticatingScreen, r as CommentNode, C as CommentThread, F as CommentVisibility, ad as CreateMessageRequestOptions, b7 as DemoBanner, b8 as DemoBannerProps, bb as DemoDataExpiredScreen, be as DemoLimits, bd as DemoModeState, b9 as DemoQuotaIndicator, ba as DemoQuotaIndicatorProps, bf as DemoUsage, b2 as DiscoveredPeer, aU as FileRef, ae as FirstContactAdmission, af as FirstContactDecision, ag as FirstContactDecisionInput, G as FirstContactMode, ah as FirstContactVisibility, aK as GrantConsentSummary, aL as GrantInput, bp as HubConnectScreen, aX as HubSearchOptions, aY as HubSearchResult, aZ as HubSearchState, b3 as HubStatusIndicator, bo as ImportIdentityScreen, I as InteractionPermission, ai as MessageRequestNode, aj as MessageRequestProperties, ak as MessageRequestStatus, M as ModeratedCommentNode, H as ModeratedCommentThread, J as ModerationFilterOptions, K as ModerationLabelSummary, bA as OnboardingContextValue, bD as OnboardingEvent, bj as OnboardingFlow, bB as OnboardingFlowProps, bE as OnboardingMachineContext, bh as OnboardingProvider, bz as OnboardingProviderProps, bF as OnboardingReducerState, bC as OnboardingState, P as PageTaskInput, e as PageTaskReferenceInput, bI as PageTasksPanel, bJ as PageTasksPanelProps, bW as PluginRegistryContext, L as PublicInteractionMode, N as PublicInteractionPolicySnapshot, O as PublicInteractionSurface, Q as PublicModerationMode, bv as QUICK_START_TEMPLATES, bG as QuickStartTemplate, a1 as ReactionCounterSnapshot, a2 as ReactionNode, a3 as ReactionType, bq as ReadyScreen, a$ as RemoteSchemaDefinition, b0 as RemoteSchemaState, R as ReplyContext, bQ as SecurityContextActions, bP as SecurityContextState, bR as SecurityContextValue, bM as SecurityProvider, bS as SecurityProviderProps, b4 as Skeleton, b6 as SkeletonProps, br as SmartWelcome, bs as SyncProgressOverlay, bH as SyncProgressOverlayProps, bK as TaskCollectionEmbed, bL as TaskCollectionEmbedProps, j as TaskProjectionHost, i as TaskProjectionReferenceInput, bn as UnsupportedBrowserScreen, aw as UseAuditOptions, av as UseAuditResult, aQ as UseAuthTraceResult, aS as UseBackupReturn, aA as UseBlameResult, aH as UseCanEditResult, aF as UseCanResult, p as UseCommentsOptions, q as UseCommentsResult, ay as UseDiffResult, aV as UseFileUploadReturn, b as UseFindOptions, c as UseFindResult, aM as UseGrantsResult, aq as UseHistoryResult, al as UseMessageRequestsOptions, am as UseMessageRequestsResult, S as UseModeratedThreadOptions, f as UsePageTaskSyncOptions, g as UsePageTaskSyncResult, a4 as UsePolicyFilteredReactionCountersOptions, a5 as UsePolicyFilteredReactionCountersResult, bU as UseSecurityOptions, bV as UseSecurityResult, k as UseTaskProjectionSyncOptions, m as UseTasksOptions, n as UseTasksResult, at as UseUndoOptions, as as UseUndoResult, aC as UseVerificationResult, V as UseVisibleCommentsOptions, W as UseVisibleCommentsResult, bk as WelcomeScreen, by as copyToClipboard, a7 as createConversationKey, bu as createInitialState, a8 as createMessageRequestProperties, v as createModerationLabelIndex, Y as createReactionCounterSnapshot, Z as dedupeReactions, aI as describeGrantConsent, w as evaluateCommentModeration, a9 as evaluateFirstContactDecision, x as evaluateInteractionPermission, aa as findLatestMessageRequest, bw as getPlatformAuthName, ab as hasAcceptedContact, b5 as injectSkeletonStyles, _ as isReactionVisible, y as moderateThread, bt as onboardingReducer, z as selectActiveInteractionPolicy, B as selectPublicInteractionMode, aN as summarizeAuthTrace, ac as summarizeMessageRequest, D as summarizeModerationLabel, E as summarizePublicInteractionPolicy, $ as summarizeReactionNode, bx as truncateDid, au as useAudit, aO as useAuthTrace, aR as useBackup, az as useBlame, aE as useCan, aG as useCanEdit, c7 as useCommand, c0 as useCommands, an as useCommentCount, ao as useCommentCounts, o as useComments, b_ as useContributions, bc as useDemoMode, ax as useDiff, c4 as useEditorExtensions, c5 as useEditorExtensionsSafe, aT as useFileUpload, u as useFind, aJ as useGrants, ap as useHistory, aW as useHubSearch, aD as useHubStatus, c3 as useImporters, a6 as useMessageRequests, t as useModeratedThread, bi as useOnboarding, d as usePageTaskSync, b1 as usePeerDiscovery, bX as usePluginRegistry, bY as usePluginRegistryOptional, bZ as usePlugins, X as usePolicyFilteredReactionCounters, a_ as useRemoteSchema, bT as useSecurity, bN as useSecurityContext, bO as useSecurityContextOptional, c2 as useSidebarItems, c1 as useSlashCommands, bg as useSyncManager, h as useTaskProjectionSync, l as useTasks, ar as useUndo, aB as useVerification, c6 as useView, b$ as useViews, s as useVisibleComments } from './experimental-B2FrBnkV.js';
6
- import { SchemaIRI, Schema, SavedViewDescriptor, DefinedSchema, PropertyBuilder, QueryASTOrderBy, QueryASTPage, QueryASTValidationResult, QueryASTPlannerGate, QueryASTAggregateExecution, ExternalReferenceProvider, SavedViewFeedLayout, SavedViewFeedDensity, FieldType, FieldConfig, ViewType, FilterGroup, SortConfig, RowHeight, SummaryFunction, FormViewConfig, FormFieldRule, CellValue, FormSubmissionMeta } from '@xnetjs/data';
4
+ import { U as UseTaskProjectionSyncResult, T as TaskProjectionInput, a as TaskTreeItem } from './experimental-DyPoZcJT.js';
5
+ export { A as AddCommentOptions, a0 as AddReactionOptions, bm as AuthErrorScreen, aP as AuthTraceSummary, bl as AuthenticatingScreen, r as CommentNode, C as CommentThread, F as CommentVisibility, ad as CreateMessageRequestOptions, b7 as DemoBanner, b8 as DemoBannerProps, bb as DemoDataExpiredScreen, be as DemoLimits, bd as DemoModeState, b9 as DemoQuotaIndicator, ba as DemoQuotaIndicatorProps, bf as DemoUsage, b2 as DiscoveredPeer, aU as FileRef, ae as FirstContactAdmission, af as FirstContactDecision, ag as FirstContactDecisionInput, G as FirstContactMode, ah as FirstContactVisibility, aK as GrantConsentSummary, aL as GrantInput, bp as HubConnectScreen, aX as HubSearchOptions, aY as HubSearchResult, aZ as HubSearchState, b3 as HubStatusIndicator, bo as ImportIdentityScreen, I as InteractionPermission, c8 as MergedEditorContributions, ai as MessageRequestNode, aj as MessageRequestProperties, ak as MessageRequestStatus, M as ModeratedCommentNode, H as ModeratedCommentThread, J as ModerationFilterOptions, K as ModerationLabelSummary, bA as OnboardingContextValue, bD as OnboardingEvent, bj as OnboardingFlow, bB as OnboardingFlowProps, bE as OnboardingMachineContext, bh as OnboardingProvider, bz as OnboardingProviderProps, bF as OnboardingReducerState, bC as OnboardingState, P as PageTaskInput, e as PageTaskReferenceInput, bI as PageTasksPanel, bJ as PageTasksPanelProps, bW as PluginRegistryContext, L as PublicInteractionMode, N as PublicInteractionPolicySnapshot, O as PublicInteractionSurface, Q as PublicModerationMode, bv as QUICK_START_TEMPLATES, bG as QuickStartTemplate, a1 as ReactionCounterSnapshot, a2 as ReactionNode, a3 as ReactionType, bq as ReadyScreen, a$ as RemoteSchemaDefinition, b0 as RemoteSchemaState, R as ReplyContext, bQ as SecurityContextActions, bP as SecurityContextState, bR as SecurityContextValue, bM as SecurityProvider, bS as SecurityProviderProps, b4 as Skeleton, b6 as SkeletonProps, br as SmartWelcome, bs as SyncProgressOverlay, bH as SyncProgressOverlayProps, bK as TaskCollectionEmbed, bL as TaskCollectionEmbedProps, j as TaskProjectionHost, i as TaskProjectionReferenceInput, bn as UnsupportedBrowserScreen, aw as UseAuditOptions, av as UseAuditResult, aQ as UseAuthTraceResult, aS as UseBackupReturn, aA as UseBlameResult, aH as UseCanEditResult, aF as UseCanResult, p as UseCommentsOptions, q as UseCommentsResult, ay as UseDiffResult, aV as UseFileUploadReturn, b as UseFindOptions, c as UseFindResult, aM as UseGrantsResult, aq as UseHistoryResult, al as UseMessageRequestsOptions, am as UseMessageRequestsResult, S as UseModeratedThreadOptions, f as UsePageTaskSyncOptions, g as UsePageTaskSyncResult, a4 as UsePolicyFilteredReactionCountersOptions, a5 as UsePolicyFilteredReactionCountersResult, bU as UseSecurityOptions, bV as UseSecurityResult, k as UseTaskProjectionSyncOptions, m as UseTasksOptions, n as UseTasksResult, at as UseUndoOptions, as as UseUndoResult, aC as UseVerificationResult, V as UseVisibleCommentsOptions, W as UseVisibleCommentsResult, bk as WelcomeScreen, by as copyToClipboard, a7 as createConversationKey, bu as createInitialState, a8 as createMessageRequestProperties, v as createModerationLabelIndex, Y as createReactionCounterSnapshot, Z as dedupeReactions, aI as describeGrantConsent, w as evaluateCommentModeration, a9 as evaluateFirstContactDecision, x as evaluateInteractionPermission, aa as findLatestMessageRequest, bw as getPlatformAuthName, ab as hasAcceptedContact, b5 as injectSkeletonStyles, _ as isReactionVisible, c7 as mergeEditorContributions, y as moderateThread, bt as onboardingReducer, z as selectActiveInteractionPolicy, B as selectPublicInteractionMode, aN as summarizeAuthTrace, ac as summarizeMessageRequest, D as summarizeModerationLabel, E as summarizePublicInteractionPolicy, $ as summarizeReactionNode, bx as truncateDid, au as useAudit, aO as useAuthTrace, aR as useBackup, az as useBlame, aE as useCan, aG as useCanEdit, ca as useCommand, c0 as useCommands, an as useCommentCount, ao as useCommentCounts, o as useComments, b_ as useContributions, bc as useDemoMode, ax as useDiff, c4 as useEditorExtensions, c5 as useEditorExtensionsSafe, aT as useFileUpload, u as useFind, aJ as useGrants, ap as useHistory, aW as useHubSearch, aD as useHubStatus, c3 as useImporters, c6 as useMergedEditorContributions, a6 as useMessageRequests, t as useModeratedThread, bi as useOnboarding, d as usePageTaskSync, b1 as usePeerDiscovery, bX as usePluginRegistry, bY as usePluginRegistryOptional, bZ as usePlugins, X as usePolicyFilteredReactionCounters, a_ as useRemoteSchema, bT as useSecurity, bN as useSecurityContext, bO as useSecurityContextOptional, c2 as useSidebarItems, c1 as useSlashCommands, bg as useSyncManager, h as useTaskProjectionSync, l as useTasks, ar as useUndo, aB as useVerification, c9 as useView, b$ as useViews, s as useVisibleComments } from './experimental-DyPoZcJT.js';
6
+ import { SchemaIRI, Schema, SavedViewDescriptor, DefinedSchema, PropertyBuilder, QueryASTOrderBy, QueryASTPage, QueryASTValidationResult, QueryASTPlannerGate, QueryASTAggregateExecution, ExternalReferenceProvider, SavedViewFeedLayout, SavedViewFeedDensity, FieldType, FieldConfig, ViewType, FilterGroup, SortConfig, RowHeight, SummaryFunction, FormViewConfig, FormFieldRule, CellValue, FormSubmissionMeta, NodeId, NodeState } from '@xnetjs/data';
7
7
  export { ColumnConfig, ColumnDefinition, ColumnType, SavedViewFeedDensity, SavedViewFeedLayout, ViewConfig, ViewType } from '@xnetjs/data';
8
8
  import { QueryExecutionMode, QuerySourcePreference, QuerySearchFilter, QueryPageInfo, QueryMetadata } from '@xnetjs/data-bridge';
9
9
  import { LucideIcon } from 'lucide-react';
10
10
  import { ReactNode, JSX } from 'react';
11
11
  export { DatabaseRow, DatabaseRowData, ReverseRelation, UseCellOptions, UseCellResult, UseDatabaseDocResult, UseDatabaseOptions, UseDatabaseResult, UseDatabaseRowResult, UseDatabaseSchemaResult, UseRelatedRowsResult, UseReverseRelationsResult, useCell, useDatabase, useDatabaseDoc, useDatabaseRow, useDatabaseSchema, useRelatedRows, useReverseRelations } from './database.js';
12
12
  export { u as useNodeStore } from './useNodeStore-DTCSBF51.js';
13
+ import { ScopeTimelineEntry, PropertyDiff, HistoryHorizon, Frontier, RestoreResult, MergeDraftResult, RefreshDraftResult } from '@xnetjs/history';
14
+ export { DraftMergeConflict, Frontier, FrontierEntry, HistoryHorizon, MergeDraftResult, PropertyDiff, RefreshDraftResult, RestoreResult, ScopeTimelineEntry } from '@xnetjs/history';
13
15
  export { BlobStoreForSync, ConnectionManager, ConnectionManagerConfig, ConnectionStatus, InitialSyncManager, InitialSyncMessage, METABRIDGE_ORIGIN, METABRIDGE_SEED_ORIGIN, MetaBridge, MultiHubConnectionManagerConfig, NodePool, NodePoolConfig, NodeStoreSyncProvider, NodeSyncResponse, OfflineQueue, OfflineQueueConfig, PoolEntryState, ProgressListener, QueueEntry, Registry, RegistryConfig, RegistryStorage, SerializedNodeChange, SyncManager, SyncManagerConfig, SyncStatus as SyncManagerStatus, SyncPhase, SyncProgress, SyncReconciliationOptions, SyncReconciliationReport, TrackedNode, WebSocketSyncProvider, WebSocketSyncProviderOptions, channelShareRoom, createConnectionManager, createInitialSyncManager, createMetaBridge, createMultiHubConnectionManager, createNodePool, createOfflineQueue, createRegistry, createSyncManager, workspaceShareRoom } from '@xnetjs/runtime';
14
16
  import { Subscription, Customer, Invoice, Payment } from '@xnetjs/billing';
15
17
  export { n as TRACE_STAGES, s as TracingAttributes, T as TracingContext, p as TracingHandle, o as TracingReporter, r as TracingRootKind, q as TracingSpanInput, f as XNetConfig, X as XNetContextValue, e as XNetProvider, g as XNetProviderProps, h as XNetRuntimeConfig, i as XNetRuntimeFallback, j as XNetRuntimeMode, k as XNetRuntimePhase, d as XNetRuntimeStatus, l as XNetRuntimeWorkerConfig, u as useDataBridge, m as useTracingReporter, a as useXNet } from './context-aeFzX2eW.js';
@@ -19,7 +21,6 @@ import '@xnetjs/core';
19
21
  import 'y-protocols/awareness';
20
22
  import 'yjs';
21
23
  import '@xnetjs/identity';
22
- import '@xnetjs/history';
23
24
  import 'react/jsx-runtime';
24
25
  import '@xnetjs/crypto';
25
26
  import '@xnetjs/plugins';
@@ -457,6 +458,45 @@ declare function createSavedViewVisualCanvasProjectionRequest(input: {
457
458
  }): SavedViewVisualCanvasProjectionRequest;
458
459
  declare function SavedViewResultTable({ query, columns, expandedRowId, onToggleRow, loadingLabel, emptyLabel, formatValue }: SavedViewResultTableProps): JSX.Element;
459
460
 
461
+ /**
462
+ * Minimal Awareness surface (compatible with y-protocols/awareness).
463
+ * Duck-typed so tests and non-Yjs transports can provide their own.
464
+ */
465
+ interface PresenceAwareness {
466
+ clientID: number;
467
+ getLocalState(): Record<string, unknown> | null;
468
+ setLocalState(state: Record<string, unknown> | null): void;
469
+ getStates(): Map<number, Record<string, unknown>>;
470
+ on(event: 'change', handler: () => void): void;
471
+ off(event: 'change', handler: () => void): void;
472
+ }
473
+ interface PresencePeer<T> {
474
+ /** Awareness client id (one per connected tab/device). */
475
+ clientId: number;
476
+ /** That peer's presence state. */
477
+ state: T;
478
+ }
479
+ interface UsePresenceOptions {
480
+ /**
481
+ * Minimum ms between broadcasts (default 33 ≈ 30fps). The hub rate-limits
482
+ * at 100 messages/sec/connection and closes the socket on repeated
483
+ * breaches — do not go below ~16ms.
484
+ */
485
+ throttleMs?: number;
486
+ }
487
+ interface UsePresenceResult<T> {
488
+ /** Remote peers only (local client excluded). Evicted on disconnect. */
489
+ peers: Array<PresencePeer<T>>;
490
+ /**
491
+ * Merge a partial patch into local presence. Patches within one throttle
492
+ * window coalesce into a single broadcast (leading + trailing edge).
493
+ */
494
+ setState: (patch: Partial<T>) => void;
495
+ /** Local awareness client id, or null before awareness attaches. */
496
+ clientId: number | null;
497
+ }
498
+ declare function usePresence<T extends Record<string, unknown>>(awareness: PresenceAwareness | null | undefined, initialState: T, options?: UsePresenceOptions): UsePresenceResult<T>;
499
+
460
500
  /**
461
501
  * useCanvasTaskSync - Reconcile canvas checklist items with Task nodes.
462
502
  *
@@ -599,6 +639,166 @@ interface UseGridDatabaseResult {
599
639
  }
600
640
  declare function useGridDatabase(databaseId: string, options?: UseGridDatabaseOptions): UseGridDatabaseResult;
601
641
 
642
+ /**
643
+ * useTimeMachine — React binding for the Time Machine (exploration 0329 P1).
644
+ *
645
+ * Wraps the history engine's scrub stack (`ScopeTimeline` merged Lamport line,
646
+ * hash-anchored `Frontier` positions, named `Checkpoint` nodes, the prune
647
+ * horizon) into one hook a scrubber UI can bind to:
648
+ *
649
+ * - `timeline` is the merged, Lamport-ordered change line for the scope (the
650
+ * node itself by default; pass `memberIds` to widen to a database's rows…).
651
+ * - `position` glides along that line (`setPosition`/`stepBack`/`stepForward`);
652
+ * `preview` + `diffs` materialize the primary node there and compare it to
653
+ * current state (before = at position, after = now).
654
+ * - `checkpoints` are named versions scoped to the node; `createNamedVersion`
655
+ * captures-and-pins the current frontier (Google Docs' named versions).
656
+ * - `restore` applies one compensating transaction back to the scrubbed
657
+ * frontier (new changes, no log rewriting — the restore is itself undoable).
658
+ * - `horizon` is non-null when older history was compacted on this device.
659
+ *
660
+ * @example
661
+ * ```tsx
662
+ * const tm = useTimeMachine(nodeId)
663
+ * <input type="range" max={tm.changeCount - 1} value={tm.position}
664
+ * onChange={(e) => tm.setPosition(Number(e.target.value))} />
665
+ * ```
666
+ */
667
+
668
+ interface UseTimeMachineOptions {
669
+ /**
670
+ * Scope membership beyond the node itself (e.g. a database's row ids).
671
+ * The primary node is always included.
672
+ */
673
+ memberIds?: readonly NodeId[];
674
+ }
675
+ interface UseTimeMachineResult {
676
+ /** Merged, Lamport-ordered change line for the scope. */
677
+ timeline: ScopeTimelineEntry[];
678
+ /** Total changes on the line. */
679
+ changeCount: number;
680
+ /** Current scrub index on the line (latest = changeCount - 1). */
681
+ position: number;
682
+ /** True when scrubbed to (following) the latest change. */
683
+ atLatest: boolean;
684
+ setPosition: (index: number) => void;
685
+ /** Step one change back / forward along the line. */
686
+ stepBack: () => void;
687
+ stepForward: () => void;
688
+ /** Jump back to (and follow) the latest change. */
689
+ goToLatest: () => void;
690
+ /** The primary node materialized at the scrub position. */
691
+ preview: NodeState | null;
692
+ /** Property diff position → current (what restore would change back). */
693
+ diffs: PropertyDiff[];
694
+ /** Non-null when older history was compacted on this device. */
695
+ horizon: HistoryHorizon | null;
696
+ /** Yjs document snapshots stored for the node; null when storage can't say. */
697
+ docSnapshotCount: number | null;
698
+ /** Named versions (Checkpoint nodes) scoped to this node, newest first. */
699
+ checkpoints: NodeState[];
700
+ /** Capture-and-pin the current frontier under a name. */
701
+ createNamedVersion: (name: string, note?: string) => Promise<NodeState | null>;
702
+ /** Timeline index a checkpoint pins the scope at, or null (below horizon). */
703
+ positionOfCheckpoint: (checkpoint: NodeState) => number | null;
704
+ /** The hash-anchored frontier at a timeline index. */
705
+ frontierAt: (index: number) => Frontier;
706
+ /** Restore the scope to the scrubbed frontier (one compensating batch). */
707
+ restore: () => Promise<RestoreResult | null>;
708
+ loading: boolean;
709
+ error: Error | null;
710
+ reload: () => Promise<void>;
711
+ }
712
+ declare function useTimeMachine(nodeId: NodeId | null, options?: UseTimeMachineOptions): UseTimeMachineResult;
713
+
714
+ /**
715
+ * useDraft — React binding for drafts (exploration 0329 P2/P3).
716
+ *
717
+ * Given a host node id, wraps the draft engine (`@xnetjs/history` draft/merge
718
+ * modules) and the NodeStore checkout overlay into one hook the switcher and
719
+ * review surfaces bind to:
720
+ *
721
+ * - `drafts` lists open Draft nodes targeting the host, newest first.
722
+ * - `createDraft` opens an empty draft (Upwelling: a name that signals
723
+ * intent); forking stays lazy — the first write through the overlay clones
724
+ * the touched member (`onMissingMember` → `forkNodeIntoDraft`).
725
+ * - `checkout` installs the store overlay (content-swap reads, write
726
+ * redirect); `returnToMain` clears it. The clones map is re-derived from
727
+ * the draft's entries at checkout and kept fresh via
728
+ * `subscribeToDraftOverlay` (the store self-updates it on lazy forks).
729
+ * - `merge` is the merger-signed three-way squash — it returns conflict
730
+ * cards (applying nothing) when main and draft both changed a property.
731
+ * - `refresh` folds main's post-fork changes into the draft (floating
732
+ * drafts); it pauses on the same conflict cards.
733
+ * - `computeReview` builds per-property review cards (base at fork vs main
734
+ * now vs draft now) WITHOUT applying anything — the DraftReviewPanel's
735
+ * data source.
736
+ *
737
+ * @example
738
+ * ```tsx
739
+ * const d = useDraft(nodeId)
740
+ * {d.checkedOut ? `Draft: ${d.checkedOut.properties.name}` : 'Main'}
741
+ * ```
742
+ */
743
+
744
+ /** One reviewable property difference between main and the draft. */
745
+ interface DraftReviewCard {
746
+ /** The original (main-side) node the property lives on. */
747
+ originalId: NodeId;
748
+ property: string;
749
+ /** Value at the fork point (the three-way merge base). */
750
+ base: unknown;
751
+ /** Main's value now. */
752
+ main: unknown;
753
+ /** The draft's value now. */
754
+ draft: unknown;
755
+ /** True when main and draft both changed the property differently. */
756
+ conflict: boolean;
757
+ }
758
+ /** One forked member's review summary. */
759
+ interface DraftReviewMember {
760
+ originalId: NodeId;
761
+ cloneId: NodeId;
762
+ /** The member carries a Yjs document forked into the draft. */
763
+ hasDocument: boolean;
764
+ /**
765
+ * The member's document bytes differ between draft and main (no text diff
766
+ * yet — deferred; this powers the "document edited in draft" line).
767
+ */
768
+ documentDiffers: boolean;
769
+ }
770
+ /** Pending changes + conflicts for a draft, computed without applying. */
771
+ interface DraftReview {
772
+ cards: DraftReviewCard[];
773
+ members: DraftReviewMember[];
774
+ }
775
+ interface UseDraftResult {
776
+ /** Open drafts targeting the host node, newest first. */
777
+ drafts: NodeState[];
778
+ /** The Draft node checked out for THIS host, or null (on main). */
779
+ checkedOut: NodeState | null;
780
+ /** Create (and check out) an open draft named for its intent. */
781
+ createDraft: (name: string) => Promise<NodeState | null>;
782
+ /** Install the checkout overlay for one of the host's drafts. */
783
+ checkout: (draftId: NodeId) => Promise<boolean>;
784
+ /** Clear the overlay — reads and writes hit main again. */
785
+ returnToMain: () => void;
786
+ /** Tombstone clones + release pins; checks out main first if needed. */
787
+ discard: (draftId: NodeId) => Promise<boolean>;
788
+ /** Merger-signed squash; `{status:'conflicts'}` applies nothing. */
789
+ merge: (draftId: NodeId) => Promise<MergeDraftResult | null>;
790
+ /** Fold main's post-fork changes into the draft (floating drafts). */
791
+ refresh: (draftId: NodeId) => Promise<RefreshDraftResult | null>;
792
+ /** P4: flag the draft for review in the Inbox/Requests surface. */
793
+ setReviewRequested: (draftId: NodeId, requested: boolean) => Promise<void>;
794
+ /** Per-property review cards + member doc indicators; applies nothing. */
795
+ computeReview: (draftId: NodeId) => Promise<DraftReview | null>;
796
+ loading: boolean;
797
+ error: Error | null;
798
+ reload: () => Promise<void>;
799
+ }
800
+ declare function useDraft(hostId: NodeId | null): UseDraftResult;
801
+
602
802
  /**
603
803
  * useGlobalUndo - app-wide Cmd+Z (exploration 0179)
604
804
  *
@@ -630,6 +830,31 @@ interface UseGlobalUndoResult {
630
830
  }
631
831
  declare function useGlobalUndo(): UseGlobalUndoResult;
632
832
 
833
+ /**
834
+ * useCanCreate - Check whether the current user may create a node of a schema
835
+ * (exploration 0304).
836
+ *
837
+ * The check runs against a *draft* node built from `schemaId` + `properties`,
838
+ * so container relations in the draft (e.g. `space`, `channel`) resolve
839
+ * membership roles — pass the relation the composer is about to write into:
840
+ *
841
+ * ```tsx
842
+ * const { canCreate } = useCanCreate(CHAT_MESSAGE_SCHEMA_IRI, { channel: channelId })
843
+ * <SendButton disabled={!canCreate} />
844
+ * ```
845
+ *
846
+ * Schemas that declare no `create` expression fall back to their `write`
847
+ * policy, which includes the creator role in every preset — those schemas
848
+ * resolve to `canCreate: true`.
849
+ */
850
+
851
+ type UseCanCreateResult = {
852
+ canCreate: boolean;
853
+ loading: boolean;
854
+ error: Error | null;
855
+ };
856
+ declare function useCanCreate(schemaId: SchemaIRI, properties?: Record<string, unknown>): UseCanCreateResult;
857
+
633
858
  /**
634
859
  * useBilling — reactive billing state + checkout, the same shape as `useIdentity`.
635
860
  *
@@ -693,4 +918,4 @@ declare function flattenTaskTree(items: TaskTreeItem[], depth?: number): Rendera
693
918
  declare function formatTaskDueDate(timestamp: number | undefined): string | null;
694
919
  declare function isTaskOverdue(timestamp: number | undefined, completed: boolean): boolean;
695
920
 
696
- export { type AddRowOptions, type CanvasTaskInput, type CheckoutOptions, FlatNode, type GridFieldModel, type GridOptionModel, type GridRowModel, type GridViewModel, QueryFilter, type RenderableTaskRow, type SavedViewCanvasProjectionNode, type SavedViewDateBrushSelection, type SavedViewDateBucketFieldSummary, type SavedViewDateBucketInterval, type SavedViewDateBucketSummary, type SavedViewFacetSelection, type SavedViewFacetSummary, type SavedViewFacetValueSummary, type SavedViewFeedEnrichmentAdapter, type SavedViewFeedEnrichmentEntry, type SavedViewInspectorItem, type SavedViewInspectorItemKind, type SavedViewLensDraft, type SavedViewPresentationMode, type SavedViewPrivacyChip, type SavedViewPrivacyChipTone, type SavedViewPrivacySummary, type SavedViewQueryOverride, type SavedViewQueryResult, SavedViewResultTable, type SavedViewResultTableProps, type SavedViewRowInspectorModel, SavedViewRunner, type SavedViewRunnerProps, type SavedViewSchemaRegistry, type SavedViewSortDirection, type SavedViewVisualCanvasProjectionRequest, SavedViewVisualFeed, type SavedViewVisualLayoutId, type SavedViewVisualLayoutOption, type SavedViewVisualPreviewCreator, type SavedViewVisualPreviewKind, type SavedViewVisualPreviewModel, type SavedViewVisualPreviewPrivacy, type SavedViewVisualPreviewRelationship, type SavedViewVisualTimelineBucket, type SavedViewVisualWorkspaceLayout, TaskProjectionInput, TaskTreeItem, type UseBillingResult, type UseCanvasTaskSyncOptions, type UseCanvasTaskSyncResult, type UseEffectiveSchemaResult, type UseGlobalUndoResult, type UseGridDatabaseOptions, type UseGridDatabaseResult, type UseSavedViewOptions, type UseSavedViewResult, UseTaskProjectionSyncResult, createSavedViewCanvasProjectionNodes, createSavedViewLensDraft, createSavedViewVisualCanvasProjectionRequest, createSavedViewVisualPreviewFingerprint, deriveCachedSavedViewVisualPreviews, deriveSavedViewColumns, deriveSavedViewDateBucketSummaries, deriveSavedViewFacetSummaries, deriveSavedViewPrivacyChips, deriveSavedViewRowInspector, deriveSavedViewTimelineBuckets, deriveSavedViewVisualPreview, deriveSavedViewVisualPreviews, filterSavedViewRowsByDateBrush, filterSavedViewRowsByFacets, flattenTaskTree, formatSavedViewCellValue, formatTaskDueDate, getSavedViewSensitiveResultWarning, hasSavedViewVisualPreviewSensitiveData, isSavedViewVisualPreviewEmbeddable, isTaskOverdue, mergeSavedViewFeedEnrichment, savedViewVisualPreviewIsSelfActor, useBilling, useCanvasTaskSync, useEffectiveSchema, useGlobalUndo, useGridDatabase, useSavedView };
921
+ export { type AddRowOptions, type CanvasTaskInput, type CheckoutOptions, type DraftReview, type DraftReviewCard, type DraftReviewMember, FlatNode, type GridFieldModel, type GridOptionModel, type GridRowModel, type GridViewModel, type PresenceAwareness, type PresencePeer, QueryFilter, type RenderableTaskRow, type SavedViewCanvasProjectionNode, type SavedViewDateBrushSelection, type SavedViewDateBucketFieldSummary, type SavedViewDateBucketInterval, type SavedViewDateBucketSummary, type SavedViewFacetSelection, type SavedViewFacetSummary, type SavedViewFacetValueSummary, type SavedViewFeedEnrichmentAdapter, type SavedViewFeedEnrichmentEntry, type SavedViewInspectorItem, type SavedViewInspectorItemKind, type SavedViewLensDraft, type SavedViewPresentationMode, type SavedViewPrivacyChip, type SavedViewPrivacyChipTone, type SavedViewPrivacySummary, type SavedViewQueryOverride, type SavedViewQueryResult, SavedViewResultTable, type SavedViewResultTableProps, type SavedViewRowInspectorModel, SavedViewRunner, type SavedViewRunnerProps, type SavedViewSchemaRegistry, type SavedViewSortDirection, type SavedViewVisualCanvasProjectionRequest, SavedViewVisualFeed, type SavedViewVisualLayoutId, type SavedViewVisualLayoutOption, type SavedViewVisualPreviewCreator, type SavedViewVisualPreviewKind, type SavedViewVisualPreviewModel, type SavedViewVisualPreviewPrivacy, type SavedViewVisualPreviewRelationship, type SavedViewVisualTimelineBucket, type SavedViewVisualWorkspaceLayout, TaskProjectionInput, TaskTreeItem, type UseBillingResult, type UseCanCreateResult, type UseCanvasTaskSyncOptions, type UseCanvasTaskSyncResult, type UseDraftResult, type UseEffectiveSchemaResult, type UseGlobalUndoResult, type UseGridDatabaseOptions, type UseGridDatabaseResult, type UsePresenceOptions, type UsePresenceResult, type UseSavedViewOptions, type UseSavedViewResult, UseTaskProjectionSyncResult, type UseTimeMachineOptions, type UseTimeMachineResult, createSavedViewCanvasProjectionNodes, createSavedViewLensDraft, createSavedViewVisualCanvasProjectionRequest, createSavedViewVisualPreviewFingerprint, deriveCachedSavedViewVisualPreviews, deriveSavedViewColumns, deriveSavedViewDateBucketSummaries, deriveSavedViewFacetSummaries, deriveSavedViewPrivacyChips, deriveSavedViewRowInspector, deriveSavedViewTimelineBuckets, deriveSavedViewVisualPreview, deriveSavedViewVisualPreviews, filterSavedViewRowsByDateBrush, filterSavedViewRowsByFacets, flattenTaskTree, formatSavedViewCellValue, formatTaskDueDate, getSavedViewSensitiveResultWarning, hasSavedViewVisualPreviewSensitiveData, isSavedViewVisualPreviewEmbeddable, isTaskOverdue, mergeSavedViewFeedEnrichment, savedViewVisualPreviewIsSelfActor, useBilling, useCanCreate, useCanvasTaskSync, useDraft, useEffectiveSchema, useGlobalUndo, useGridDatabase, usePresence, useSavedView, useTimeMachine };