@contractspec/lib.presentation-runtime-core
v5.2.3
Published
Core presentation runtime for contract-driven UIs
Maintainers
Readme
@contractspec/lib.presentation-runtime-core
Website: https://contractspec.io
Core presentation runtime for contract-driven UIs.
What It Provides
- Layer: lib.
- Consumers: presentation-runtime-react, presentation-runtime-react-native.
- Related ContractSpec packages include
@contractspec/lib.contracts-spec,@contractspec/tool.bun,@contractspec/tool.typescript. - Related ContractSpec packages include
@contractspec/lib.contracts-spec,@contractspec/tool.bun,@contractspec/tool.typescript.
Installation
npm install @contractspec/lib.presentation-runtime-core
or
bun add @contractspec/lib.presentation-runtime-core
Usage
Import the root entrypoint from @contractspec/lib.presentation-runtime-core, or choose a documented subpath when you only need one part of the package surface.
Bundler Helpers
Import the bundler helpers from the root package:
import {
withPresentationTurbopackAliases,
withPresentationWebpackAliases,
withPresentationMetroAliases,
} from '@contractspec/lib.presentation-runtime-core';Next.js Turbopack helper (default)
Use Turbopack as the default Next.js path:
import { withPresentationTurbopackAliases } from '@contractspec/lib.presentation-runtime-core';
const nextConfig = withPresentationTurbopackAliases({
turbopack: {
resolveAlias: {
fs: { browser: 'browserify-fs' },
},
},
});
export default nextConfig;Next.js Webpack helper (fallback)
Use Webpack only when you opt in with next dev --webpack or next build --webpack:
import { withPresentationWebpackAliases } from '@contractspec/lib.presentation-runtime-core';
const nextConfig = {
webpack: (config) => withPresentationWebpackAliases(config),
};
export default nextConfig;Expo / Metro helper
const { getDefaultConfig } = require('expo/metro-config');
const {
withPresentationMetroAliases,
} = require('@contractspec/lib.presentation-runtime-core');
const projectRoot = __dirname;
const config = getDefaultConfig(projectRoot);
module.exports = withPresentationMetroAliases(config);The helpers also keep shared UI imports platform-correct:
- Metro rewrites
@contractspec/lib.ui-kit-web/ui/*to@contractspec/lib.ui-kit/ui/*,@contractspec/lib.presentation-runtime-reactto@contractspec/lib.presentation-runtime-react-native, andlucide-reacttolucide-react-nativefor native platforms. - Metro also enables package exports and merges platform export conditions so
ios,android,react-native, andbrowserpackage conditions can resolve platform-specific build-tool outputs. - Next.js Turbopack/Webpack rewrites the native package names back to the web packages, including
lucide-react-nativetolucide-react.
Architecture
src/index.tsis the root public barrel that builds the package entrypoint.src/metro.tsis part of the package's public or composition surface.src/next.tsis part of the package's public or composition surface.src/table.tsis part of the package's public or composition surface.src/visualization.echarts.tsis part of the package's public or composition surface.src/visualization.model.builders.tsis part of the package's public or composition surface.src/visualization.model.helpers.tsis part of the package's public or composition surface.
Public Entry Points
- Export
.publishes through./dist/index.js; CommonJSrequireresolves to the generated Metro helper at./dist/metro.cjs. - Bundler helpers are part of the root entrypoint; no dedicated
./webpackor./turbopacksubpaths are published. - Export
./metrobuilds from./src/metro.tsand publishes a generated CommonJSdist/metro.cjsrequire target for Metro config files. - Export
./nextbuilds from./src/next.ts. - Export
./tablebuilds from./src/table.ts. - Export
./visualizationbuilds from./src/visualization.ts. - Export
./visualization.echartsbuilds from./src/visualization.echarts.ts. - Export
./visualization.modelbuilds from./src/visualization.model.ts. - Export
./visualization.model.buildersbuilds from./src/visualization.model.builders.ts. - Export
./visualization.model.helpersbuilds from./src/visualization.model.helpers.ts. - Export
./visualization.typesbuilds from./src/visualization.types.ts. - Export
./visualization.utilsbuilds from./src/visualization.utils.ts.
Local Commands
bun run dev— contractspec-bun-build devbun run build— bun run prebuild && bun run build:bundle && bun run build:typesbun run lint— bun run lint:fixbun run lint:check— biome check .bun run lint:fix— biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .bun run typecheck— tsc --noEmit -p tsconfig.jsonbun run publish:pkg— bun publish --tolerate-republish --ignore-scripts --verbosebun run publish:pkg:canary— bun publish:pkg --tag canarybun run clean— rimraf dist .turbobun run build:bundle— contractspec-bun-build transpilebun run build:types— contractspec-bun-build typesbun run prebuild— contractspec-bun-build prebuild
Recent Updates
- Replace eslint+prettier by biomejs to optimize speed.
- Add data visualization capabilities.
- Add table capabilities.
- Add table overflow metadata to controller render models so web and native renderers can apply consistent cell overflow behavior.
Notes
- Core runtime interface is consumed by all presentation runtimes — changes here affect both web and mobile.
- Must remain platform-agnostic; no React or React Native imports allowed.
- API surface changes require coordinated updates in both downstream runtimes.
