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
27 changes: 27 additions & 0 deletions .changeset/core-readme-registry-singleton-5258.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
---
'@object-ui/core': patch
---

Fix `packages/core/README.md`'s Component Registry example, which taught
`new ComponentRegistry()` against an exported singleton **instance**, not a
class — the built `packages/core/dist/registry/Registry.d.ts` declares
`export declare const ComponentRegistry: Registry<any>`, so the snippet did
not compile (`TS2351: This expression is not constructable`, measured by the
objectui#5138 doc-snippet type gate). A reader who copied it got a compile
error; if `new ComponentRegistry()` had compiled it would have produced a
second, empty registry nothing renders from, the more expensive half of the
mistake.

The snippet now calls `ComponentRegistry.register(...)` /
`ComponentRegistry.get(...)` directly on the singleton, with one line stating
it is the process-level shared instance `SchemaRenderer` resolves every
`type` against — the same wording `packages/components/README.md` was given
in objectui#5160, kept consistent across both READMEs. Readers who want their
own isolated registry still have `Registry` itself, separately exported as a
real class.

`scripts/check-doc-snippet-types.mjs`'s `UNGATED_DOCS` entry for
`packages/core/README.md` is updated to match: `TS2351x1` is dropped from its
reason text now that the diagnostic is gone. The entry is not deleted — the
document's remaining `TS2339x2` pair (a different, pre-existing defect) is
out of scope for this change; it's tracked as objectui#5257.
9 changes: 6 additions & 3 deletions packages/core/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,11 +46,14 @@ const mySchema: PageNodeSchema = {
```typescript
import { ComponentRegistry } from '@object-ui/core'

const registry = new ComponentRegistry()
registry.register('button', buttonMetadata)
const metadata = registry.get('button')
ComponentRegistry.register('button', buttonMetadata)
const metadata = ComponentRegistry.get('button')
```

`ComponentRegistry` is a process-level singleton exported by `@object-ui/core`;
`SchemaRenderer` resolves every `type` against it, so a component registered
here is renderable from schema anywhere in the app.

### Data Scope

`DataScopeManager` owns the named scopes a component tree reads from, and
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-doc-snippet-types.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -246,7 +246,7 @@ const UNGATED_DOCS = {
'packages/components/README.md':
'1 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines',
'packages/core/README.md':
'5 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2339x2 TS2351x1 — candidate real defects, un-triaged',
'5 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2339x2 — candidate real defects, un-triaged',
'packages/data-objectstack/README.md':
'10 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 41 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines',
'packages/fields/README.md':
Expand Down
Loading