Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/6349-batch10-collaboration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@object-ui/collaboration': patch
---

`ConnectionState` is re-exported from `@object-ui/types` instead of being declared a second time here (objectui#6349, batch 10). `@object-ui/data-objectstack` declared the same five states for its adapter's connection, so both packages now publish the one declaration under the same name. The union is unchanged, and so are `RealtimeResult['connectionState']` and every import of `ConnectionState` from this package.

No runtime behaviour changes.
7 changes: 7 additions & 0 deletions .changeset/6349-batch10-data-objectstack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@object-ui/data-objectstack': patch
---

`ConnectionState` is re-exported from `@object-ui/types` instead of being declared a second time here (objectui#6349, batch 10). `@object-ui/collaboration` declared the same five states for `useRealtimeSubscription`, so both packages now publish the one declaration under the same name. The union is unchanged, and so are `getConnectionState()`, `ConnectionStateEvent` and every import of `ConnectionState` from this package.

No runtime behaviour changes.
9 changes: 9 additions & 0 deletions .changeset/6349-batch10-plugin-designer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@object-ui/plugin-designer': minor
---

The row type of the `VersionHistory` timeline is declared as `VersionHistoryEntry` instead of `VersionEntry` (objectui#6349, batch 10). `@object-ui/collaboration` publishes an unrelated `VersionEntry`: a version its `useConflictResolution` hook records, with an `id` and a per-field `changes` diff. This timeline's rows carry a prose `description` and an `isCurrent` flag instead, and one exported name has one declaration.

**Breaking-change note.** Nothing breaks for a consumer of this package: the package entry never exported `VersionEntry`, so no import named it, and the rows keep the same members (`version`, `timestamp`, `userId`, `userName`, `description`, `isCurrent`). Only the type name shown in the published declaration of `VersionHistory`'s `versions` prop changes.

No runtime behaviour changes.
9 changes: 9 additions & 0 deletions .changeset/6349-batch10-providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@object-ui/providers': minor
---

The props of this package's `ThemeProvider` are declared and exported as `ThemePreferenceProviderProps` instead of `ThemeProviderProps` (objectui#6349, batch 10). `@object-ui/react` publishes a different `ThemeProviderProps`: the props of its theme-system `ThemeProvider`, which registers whole `Theme` documents, takes a theme name as `defaultTheme` and the mode as `defaultMode`, and writes the active theme as CSS variables. This package's provider stores one `ThemePreference` (`auto | light | dark | system`) and takes that mode as `defaultTheme`. One exported name stood for two props types across the two packages, and react keeps it.

**Type change, breaking for some consumers.** `ThemeProviderProps` is no longer exported from `@object-ui/providers`. Replace `import type { ThemeProviderProps } from '@object-ui/providers'` with `ThemePreferenceProviderProps`; the members (`defaultTheme`, `storageKey`, `children`) are unchanged. The old import fails to compile with TS2724 ("has no exported member named 'ThemeProviderProps'"). That error's "Did you mean" names the `ThemeProvider` component, not the replacement; using the component's name as a type fails too (TS2749), so write `ThemePreferenceProviderProps`. The `ThemeProvider` component and `useTheme` keep their names.

No runtime behaviour changes.
7 changes: 7 additions & 0 deletions .changeset/6349-batch10-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@object-ui/types': minor
---

`ConnectionState` is a new export: the lifecycle state of one client connection, `'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error'` (objectui#6349, batch 10). `@object-ui/data-objectstack` (its adapter's connection) and `@object-ui/collaboration` (`useRealtimeSubscription`'s socket) each used to declare these same five states. Neither of those packages depends on the other, and both depend on this one, so the one declaration now lives here and both re-export it under the same name.

Nothing is removed or narrowed. No runtime behaviour changes.
9 changes: 8 additions & 1 deletion packages/collaboration/src/useRealtimeSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { useState, useEffect, useCallback, useRef } from 'react';
import type { ConnectionState } from '@object-ui/types';

/**
* WebSocket connection configuration for {@link useRealtimeSubscription}.
Expand Down Expand Up @@ -38,7 +39,13 @@ export interface RealtimeSubscriptionConfig {
authToken?: string;
}

export type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error';
/**
* The socket's connection state. Declared once in `@object-ui/types`, which
* `@object-ui/data-objectstack` re-exports too, for its adapter's connection
* (objectui#6349, batch 10); this package's entry keeps publishing it under
* the same name.
*/
export type { ConnectionState } from '@object-ui/types';

export interface RealtimeMessage<T = unknown> {
type: string;
Expand Down
7 changes: 5 additions & 2 deletions packages/data-objectstack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
import type { AnalyticsResult, DatasetSelection } from '@objectstack/spec/contracts';
import type {
DataSource,
ConnectionState,
// #4564 — the canonical `deleteView` receipt shapes, declared beside the
// `DataSource` interface they belong to. Imported for the local uses below
// and re-exported under the same names further down, so this package's
Expand Down Expand Up @@ -2031,9 +2032,11 @@ export function createQuietHttpLogger(): any {
}

/**
* Connection state for monitoring
* Connection state for monitoring. Declared once in `@object-ui/types`, which
* `@object-ui/collaboration` re-exports too (objectui#6349, batch 10); this
* package's entry keeps publishing it under the same name.
*/
export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error';
export type { ConnectionState } from '@object-ui/types';

/**
* Connection state change event
Expand Down
15 changes: 13 additions & 2 deletions packages/plugin-designer/src/components/VersionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ function cn(...inputs: (string | undefined | false)[]) {
return twMerge(clsx(inputs));
}

export interface VersionEntry {
/**
* One row of the {@link VersionHistory} timeline.
*
* Named `VersionHistoryEntry`, not `VersionEntry` (objectui#6349, batch 10).
* `@object-ui/collaboration` publishes a `VersionEntry` with a different
* meaning: a version its `useConflictResolution` hook RECORDS, with an `id`
* and a per-field `changes` diff that `revertToVersion` and `compareVersions`
* read. This is a display row instead: a prose `description` and an
* `isCurrent` flag, with no diff. This package's entry never exported the
* old name, so the rename moves no import.
*/
export interface VersionHistoryEntry {
/** Version number */
version: number;
/** Timestamp */
Expand All @@ -33,7 +44,7 @@ export interface VersionEntry {

export interface VersionHistoryProps {
/** Version entries */
versions: VersionEntry[];
versions: VersionHistoryEntry[];
/** Called when user wants to restore a version */
onRestore?: (version: number) => void;
/** CSS class */
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-designer/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export { PropertyEditor } from './PropertyEditor';
export type { PropertyEditorProps, PropertyField } from './PropertyEditor';

export { VersionHistory } from './VersionHistory';
export type { VersionHistoryProps, VersionEntry } from './VersionHistory';
export type { VersionHistoryProps, VersionHistoryEntry } from './VersionHistory';

export { HistoryPanel } from './HistoryPanel';
export type { HistoryPanelProps } from './HistoryPanel';
4 changes: 2 additions & 2 deletions packages/providers/src/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, useContext, useEffect, useState } from 'react';
import type { ThemePreference, ThemeProviderProps } from './types.js';
import type { ThemePreference, ThemePreferenceProviderProps } from './types.js';

interface ThemeContextValue {
theme: ThemePreference;
Expand All @@ -18,7 +18,7 @@ export function ThemeProvider({
defaultTheme = 'system',
storageKey = 'ui-theme',
children,
}: ThemeProviderProps) {
}: ThemePreferenceProviderProps) {
const [theme, setTheme] = useState<ThemePreference>(() => {
if (typeof window !== 'undefined') {
return (localStorage.getItem(storageKey) as ThemePreference) || defaultTheme;
Expand Down
2 changes: 1 addition & 1 deletion packages/providers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export {
export type {
DataSourceProviderProps,
MetadataProviderProps,
ThemeProviderProps,
ThemePreferenceProviderProps,
ThemePreference,
} from './types.js';

Expand Down
15 changes: 14 additions & 1 deletion packages/providers/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,20 @@ export interface MetadataProviderProps {
*/
export type ThemePreference = ThemeMode | 'system';

export interface ThemeProviderProps {
/**
* Props of this package's `ThemeProvider`, which stores one
* {@link ThemePreference} and applies it as the `light` / `dark` class.
*
* Named `ThemePreferenceProviderProps`, not `ThemeProviderProps`
* (objectui#6349, batch 10). `@object-ui/react` publishes a
* `ThemeProviderProps` with a different meaning: the props of its theme-system
* `ThemeProvider`, which registers whole `Theme` documents and turns the
* active one into CSS variables. There `defaultTheme` is a theme NAME and the
* mode is `defaultMode`; here `defaultTheme` is the mode itself. One exported
* name stood for both, so this, the narrower of the two, takes the specific
* name and react keeps the general one.
*/
export interface ThemePreferenceProviderProps {
defaultTheme?: ThemePreference;
storageKey?: string;
children: ReactNode;
Expand Down
14 changes: 14 additions & 0 deletions packages/types/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,20 @@ export interface DataSource<T = any> {
undoImportJob?(jobId: string): Promise<ImportJobUndoResult>;
}

/**
* The lifecycle state of one client connection: a data adapter's link to its
* server, or a realtime socket. `@object-ui/data-objectstack`'s adapter reports
* it through `getConnectionState()` / `onConnectionStateChange`, and
* `@object-ui/collaboration`'s `useRealtimeSubscription` returns it as
* `connectionState`. Both packages re-export this one declaration under the
* same name.
*
* Declared here once (objectui#6349, batch 10). Those two packages each used to
* declare the same five states, and neither depends on the other, so the one
* authority sits in this package, which both already depend on.
*/
export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error';

/**
* How each incoming import row is committed against existing data. Imported from
* `@objectstack/spec/api` at the top of this module.
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ export type {
QueryParams,
QueryResult,
DataSource,
ConnectionState,
DeleteViewResult,
ViewHomeDeleteOutcome,
GlobalSearchHit,
Expand Down
34 changes: 31 additions & 3 deletions scripts/__tests__/one-authority-per-exported-name-6273.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,15 @@ const KNOWN_COLLISIONS: ReadonlyMap<string, readonly string[]> = new Map([
// functions). Neither package's built entry exports the name. RENAME branch:
// the designer's declaration now spells `DesignerConfirmDialogState`
// (objectui#6349, batch 6).
['ConnectionState', ['packages/collaboration/src/useRealtimeSubscription.ts', 'packages/data-objectstack/src/index.ts']],
// `ConnectionState` sat here, colliding between
// `packages/collaboration/src/useRealtimeSubscription.ts` and
// `packages/data-objectstack/src/index.ts`. One vocabulary declared twice:
// the same five states, type-equal on both built entries — the realtime
// socket's state and the data adapter's. Neither package depends on the
// other, so neither could re-point at the other without a new dependency.
// Both depend on `@object-ui/types`, so the ONE declaration moved down there
// (`data.ts`, beside `DataSource`) and both sites now RE-EXPORT it; both
// package roots still publish the name (objectui#6349, batch 10).
['DataSource', ['packages/app-shell/src/types.ts', 'packages/types/src/data.ts']],
// `Diagnostic` sat here with THREE sites and three meanings:
// `packages/sdui-parser/src/types.ts` (a parser finding: `severity`, `code`,
Expand Down Expand Up @@ -566,7 +574,18 @@ const KNOWN_COLLISIONS: ReadonlyMap<string, readonly string[]> = new Map([
// depends on the other. RENAME branch: the dashboard's declaration now spells
// `DashboardRecordDetailDrawerProps` (objectui#6349, batch 8).
['SchemaNode', ['packages/sdui-parser/src/types.ts', 'packages/types/src/base.ts']],
['ThemeProviderProps', ['packages/providers/src/types.ts', 'packages/react/src/context/ThemeContext.tsx']],
// `ThemeProviderProps` sat here, colliding between
// `packages/providers/src/types.ts` and
// `packages/react/src/context/ThemeContext.tsx`. Two providers, not one
// drifted shape: react's is its theme-system `ThemeProvider` (`themes`
// documents, a theme-NAME `defaultTheme`, `defaultMode`, `persist`,
// `target`), and providers' a mode-only provider whose `defaultTheme` is the
// mode itself (a `ThemePreference`). Neither package depends on the other.
// RENAME branch: providers' declaration now spells
// `ThemePreferenceProviderProps`, and the providers root publishes that name
// instead; react keeps the general one. The two `ThemeProvider` components
// keep their names — value names are outside this gate's bound
// (objectui#6349, batch 10).
// `TranslateFn` sat here — i18next's `t` narrowed to `(key, options?) => string`,
// declared BYTE-IDENTICALLY in three files (one sha256 across the three).
// objectui#8165 re-pointed `packages/app-shell/src/providers/saveAdvisoryToast.ts`
Expand Down Expand Up @@ -607,7 +626,16 @@ const KNOWN_COLLISIONS: ReadonlyMap<string, readonly string[]> = new Map([
// existed. RENAME branch again: field-types' declaration now spells
// `FieldValidationFunction`, the name `src/index.ts` always published it under
// (objectui#6349).
['VersionEntry', ['packages/collaboration/src/useConflictResolution.ts', 'packages/plugin-designer/src/components/VersionHistory.tsx']],
// `VersionEntry` sat here, colliding between
// `packages/collaboration/src/useConflictResolution.ts` and
// `packages/plugin-designer/src/components/VersionHistory.tsx`. Two meanings
// that share `version`, `timestamp`, `userId` and `userName`: collaboration's
// is a version its conflict-resolution hook RECORDS (an `id` and a per-field
// `changes` diff that revert and compare replay), the designer's a row its
// `VersionHistory` timeline DISPLAYS (a prose `description`, `isCurrent`).
// Neither package depends on the other, and only collaboration's entry
// exports the name. RENAME branch: the designer's declaration now spells
// `VersionHistoryEntry` (objectui#6349, batch 10).
// `ViewSwitcherProps` sat here, colliding between
// `packages/plugin-list/src/ViewSwitcher.tsx` and
// `packages/plugin-view/src/ViewSwitcher.tsx`. Two switchers, not one:
Expand Down
Loading