diff --git a/packages/core/README.md b/packages/core/README.md index 807bec8aee..c16b161b07 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -45,14 +45,20 @@ const mySchema: PageNodeSchema = { ```typescript import { ComponentRegistry } from '@object-ui/core' +import type { ComponentRenderer } from '@object-ui/core' -ComponentRegistry.register('button', buttonMetadata) -const metadata = ComponentRegistry.get('button') +// Your component, in whatever renderer shape the host framework uses. +declare const buttonRenderer: ComponentRenderer + +ComponentRegistry.register('button', buttonRenderer) +const renderer = 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. +here is renderable from schema anywhere in the app. `register()`'s second +argument is the component itself; registration metadata is its optional third +argument, and `getMeta()` — not `get()` — reads that metadata back. ### Data Scope @@ -82,6 +88,14 @@ object scope, which are injected: ```typescript import { createServerActionHandler } from '@object-ui/core' +import type { ActionRunner, ServerActionFetch } from '@object-ui/core' + +// Injected by the host. Each stand-in is typed from the shipped surface, so +// this example is checked against the factory's own config rather than a copy. +declare const myAuthenticatedFetch: ServerActionFetch +declare const currentObject: string | undefined +declare const refetchData: () => void +declare const runner: ActionRunner const script = createServerActionHandler({ fetch: myAuthenticatedFetch, // your auth wrapper (Bearer/cookies/...) @@ -116,6 +130,7 @@ export const userListView = defineSystemView({ columns: [{ name: 'email' }], }) +// @ts-expect-error readonly by defineSystemView — refused at compile time, not just at run time userListView.columns.push({ name: 'name' }) // ❌ TypeError (strict mode) isSystemView(userListView) // ✅ true diff --git a/scripts/check-doc-snippet-types.mjs b/scripts/check-doc-snippet-types.mjs index aa352458ae..aef42073f6 100644 --- a/scripts/check-doc-snippet-types.mjs +++ b/scripts/check-doc-snippet-types.mjs @@ -705,16 +705,6 @@ const UNGATED_DOCS = { 'what is left is fragment shape, and no gate reads this page\'s import names.', 'packages/auth/README.md': '1 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 15 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2741x1 — candidate real defects, un-triaged', - 'packages/core/README.md': - '5 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the ' + - 'page never defines; plus TS2339x1 — TRIAGED, and NOT a defect: the remaining one is ' + - '`userListView.columns.push(...) // ❌ TypeError (strict mode)`, the System-View immutability ' + - 'demonstration, so a readonly rejection there is the documentation working as written. ' + - 'This entry read TS2339x2 until objectui#5257: the second one, on the `cloneAsOverride` draft ' + - 'one block below, was a real signature defect — `cloneAsOverride` returned its input type, so ' + - 'the documented override flow did not compile. It now returns `DeepMutable` and that ' + - 'diagnostic is gone. Covering this page still needs the 5 undefined-name blocks made ' + - 'self-contained or declared, plus a way to declare a block whose rejection IS the point.', 'packages/fields/README.md': '2 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; 1 unresolved-module diagnostic(s)', 'packages/plugin-ai/README.md':