Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Nov 3, 2025

Changed ID, ID_FIELD, TYPE, NAME, and UI from concrete exports to ambient declarations in @commontools/api, getting it closer to being a pure TypeScript interface package. The actual runtime values are now defined in @commontools/runner/src/builder/types.ts, where the runtime environment is created. Type compatibility is maintained by having the runner reference the API's declared types using typeof, ensuring both locations share the same TypeScript symbol types.

Non-pattern code like tests or Lit components should import the types from @commontools/runner instead of @commontools/api


Summary by cubic

Moved runtime constants and helpers from @commontools/api to runtime packages: constants and schema/toSchema now live in @commontools/runner, and the JSX h function moved to @commontools/html. @commontools/api is now type-only with ambient declarations.

  • Refactors

    • Defined runtime constants and schema in packages/runner/src/builder/types.ts; TYPE/NAME/UI are declared as literal types in the API.
    • Added SchemaFunction/ToSchemaFunction types and ambient schema/toSchema in @commontools/api; runner provides a runtime toSchema stub for compile-time transformation.
    • Moved JSX h to @commontools/html and updated jsx-runtime/dev and tests to use it; runner no longer re-exports h.
    • Updated imports in tests and ct-render to source UI/VNode from @commontools/runner.
  • Migration

    • Import ID, ID_FIELD, TYPE, NAME, UI, VNode, and schema from @commontools/runner.
    • Import h from @commontools/html.
    • Use @commontools/api only for type declarations; do not import runtime values, h, or schema/toSchema from it.

Written for commit 10e9c1e. Summary will update automatically on new commits.

…o @commontools/runner

Changed ID, ID_FIELD, TYPE, NAME, and UI from concrete exports to ambient declarations in @commontools/api, getting it closer to being a pure TypeScript interface package. The actual runtime values are now defined in @commontools/runner/src/builder/types.ts, where the runtime environment is created. Type compatibility is maintained by having the runner reference the API's declared types using typeof, ensuring both locations share the same TypeScript symbol types.

Non-pattern code like tests or Lit components should import the types from @commontools/runner instead of @commontools/api
@seefeldb seefeldb requested a review from jsantell November 3, 2025 18:30
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/api/index.ts">

<violation number="1" location="packages/api/index.ts:17">
Turning `UI` into an ambient declaration removes the runtime export. Callers such as packages/html/test/jsx.test.tsx still import `UI` as a value and will now throw at module load because `@commontools/api` no longer provides that export. Please keep exporting the concrete value (or ensure all runtime imports move to the new location first).</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes from recent commits (found 1 issue).

1 issue found across 4 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/api/index.ts">

<violation number="1" location="packages/api/index.ts:976">
`toSchema` is still imported as a runtime helper elsewhere, but this change makes @commontools/api stop exporting any concrete value. That import will now fail at module load time because the symbol no longer exists.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 11 files

@seefeldb seefeldb merged commit e7dfeb0 into main Nov 3, 2025
9 checks passed
@seefeldb seefeldb deleted the berni/make-api-all-declarations branch November 3, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants