refactor: extract ui-extensions-sdk - #62
Draft
maxy-shpfy wants to merge 1 commit into
Draft
Conversation
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TL;DR
Introduces
@tangent/ui-extensions-sdkas the canonical package for authoring Tangle UI extensions, replacing the internal@tangent/bundle-uispecifier. All component wire contracts, bridge types, the shared esbuild helper, and a newui-extensionsCLI are consolidated into this package.What changed?
A new
packages/ui-extensions-sdkworkspace package is introduced with the following structure:src/types.ts— theHostBridge,HostFetchInput,HostRequestInit,HostResponse,UICommand, andBundleUiKindtypes, previously inlined inapps/web/src/features/bundle-ui/types.ts, are now the single source of truth here.src/contracts/— all per-component zod schemas (TAG,attributes,events) and the sharedenums.ts/events.tsare moved fromapps/web/src/features/bundle-ui/components/*/into this package and consumed via@tangent/ui-extensions-sdk/contracts/<name>subpath imports.src/components.ts— typed stub components whose prop types are derived directly from the zod contracts, giving authors full autocomplete without coupling to the web runtime.src/host.ts— the typedhostbridge object.src/build.ts— a sharedbuildUiComponenthelper (andUiComponentBuildError) that both the server'sfileAgentBundleStoreand the new CLI use, ensuring local builds are identical to server-side upload compilation. The explicitexternallist prevents workspace-symlinked packages from being inlined.src/cli.ts— aui-extensionsbinary withbuild,typecheck, andinitsubcommands for local extension development.tsconfig.author.json— a self-contained tsconfig preset authors extend.The web app's
bundle-ui.worker.tsnow registers@tangent/ui-extensions-sdkin the worker module map alongside a legacy alias for@tangent/bundle-ui, so bundles compiled before the rename continue to resolve correctly. The Vite alias andtsconfig.jsonpath mapping inapps/webare updated from@tangent/bundle-uito@tangent/ui-extensions-sdk, using a regex alias so subpath imports (e.g.contracts/*) still resolve to the real package rather than the bridge stub.The server's
fileAgentBundleStorenow callsbuildUiComponentfrom the SDK instead of invoking esbuild directly, and surfacesUiComponentBuildErrordetails in the validation error message.How to test?
pnpm --filter @tangent/ui-extensions-sdk typecheckandpnpm --filter @tangent/ui-extensions-sdk lintto validate the new package.pnpm --filter @tangent/server testto exercise the upload → compile path end-to-end.pnpm --filter @tangent/ui-extensions-sdk cli build ../../examples/tangle-ossandpnpm --filter @tangent/ui-extensions-sdk cli typecheck ../../examples/tangle-oss.apps/web/public/bundle-ui-harness/and confirm the sample component (which now imports from@tangent/ui-extensions-sdk) renders correctly.@tangent/bundle-uispecifier and confirm it still resolves via the legacy alias.Why make this change?
Previously the component contracts, bridge types, and esbuild configuration were split across the web app's internal feature directory with no public surface for extension authors. This meant local builds could diverge from server-side compilation, there was no way to type-check an extension outside the monorepo, and the
@tangent/bundle-uiname gave no indication it was an authoring SDK. Consolidating everything into@tangent/ui-extensions-sdkgives authors a single, versioned package with full typing, a CLI that mirrors the server's build exactly, and a clear contract boundary between the SDK, the host runtime, and the worker — with no risk of the two sides drifting.