view-contracts 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +1 -1
  2. package/cli-contract.yaml +1 -1
  3. package/dist/types/renderers/compose/elementMap.d.ts +10 -0
  4. package/dist/types/renderers/compose/lowering/lowerToCompose.d.ts +22 -0
  5. package/dist/types/renderers/compose/lowering/modifiers.d.ts +36 -0
  6. package/dist/types/renderers/compose/renderComponents.d.ts +9 -0
  7. package/dist/types/renderers/compose/renderRuntime.d.ts +10 -0
  8. package/dist/types/renderers/compose/renderTheme.d.ts +5 -0
  9. package/dist/types/renderers/react/elementMap.d.ts +32 -0
  10. package/dist/types/renderers/react/lowering/foldStyle.d.ts +7 -0
  11. package/dist/types/renderers/react/lowering/lowerToJsx.d.ts +6 -0
  12. package/dist/types/renderers/react/paths.d.ts +1 -0
  13. package/dist/types/renderers/react/renderComponents.d.ts +26 -0
  14. package/dist/types/renderers/react/renderRuntime.d.ts +3 -0
  15. package/dist/types/renderers/react/runtime/style.d.ts +19 -0
  16. package/dist/types/renderers/react/style/foldLiterals.d.ts +3 -0
  17. package/dist/types/renderers/react/syncGeneratedRuntime.d.ts +7 -0
  18. package/dist/types/renderers/registry.d.ts +35 -0
  19. package/dist/types/renderers/swiftui/elementMap.d.ts +10 -0
  20. package/dist/types/renderers/swiftui/lowering/lowerToSwiftUI.d.ts +15 -0
  21. package/dist/types/renderers/swiftui/lowering/modifiers.d.ts +16 -0
  22. package/dist/types/renderers/swiftui/renderComponents.d.ts +9 -0
  23. package/dist/types/renderers/swiftui/renderRuntime.d.ts +10 -0
  24. package/dist/types/renderers/swiftui/renderTheme.d.ts +6 -0
  25. package/dist/types/src/cli.d.ts +2 -0
  26. package/dist/types/src/commands/index.d.ts +2 -0
  27. package/dist/types/src/compiler/compileView.d.ts +27 -0
  28. package/dist/types/src/compiler/jsxToIr.d.ts +33 -0
  29. package/dist/types/src/compiler/viewPartial.d.ts +13 -0
  30. package/dist/types/src/config.d.ts +77 -0
  31. package/dist/types/src/design/buildThemeCss.d.ts +3 -0
  32. package/dist/types/src/design/cssEmitUtils.d.ts +3 -0
  33. package/dist/types/src/design/cssPropertyMap.d.ts +2 -0
  34. package/dist/types/src/design/emitDefaultCss.d.ts +2 -0
  35. package/dist/types/src/design/emitTokenCss.d.ts +4 -0
  36. package/dist/types/src/design/emitVariantCss.d.ts +2 -0
  37. package/dist/types/src/design/index.d.ts +19 -0
  38. package/dist/types/src/design/load.d.ts +1 -0
  39. package/dist/types/src/design/parseTheme.d.ts +2 -0
  40. package/dist/types/src/design/parseTokens.d.ts +2 -0
  41. package/dist/types/src/design/themeElementProperties.d.ts +5 -0
  42. package/dist/types/src/design/types.d.ts +37 -0
  43. package/dist/types/src/design/validate.d.ts +3 -0
  44. package/dist/types/src/design/validateProjectDesign.d.ts +3 -0
  45. package/dist/types/src/design/validateVcNamespace.d.ts +4 -0
  46. package/dist/types/src/design/validateViewVariants.d.ts +3 -0
  47. package/dist/types/src/dsl/index.d.ts +2 -0
  48. package/dist/types/src/dsl/screen.d.ts +17 -0
  49. package/dist/types/src/dsl/types.d.ts +59 -0
  50. package/dist/types/src/extensions/loadExtensions.d.ts +17 -0
  51. package/dist/types/src/extensions/validateExtensionUsage.d.ts +18 -0
  52. package/dist/types/src/generated/cli/contract.d.ts +2 -0
  53. package/dist/types/src/generated/cli/program.d.ts +28 -0
  54. package/dist/types/src/ir/collectViewRefs.d.ts +3 -0
  55. package/dist/types/src/ir/types.d.ts +67 -0
  56. package/dist/types/src/lib/packageRoot.d.ts +2 -0
  57. package/dist/types/src/lib/projectPath.d.ts +2 -0
  58. package/dist/types/src/lib/rendererPaths.d.ts +13 -0
  59. package/dist/types/src/preview/compileScreen.d.ts +15 -0
  60. package/dist/types/src/preview/previewAssets.d.ts +9 -0
  61. package/dist/types/src/preview/previewMock.d.ts +16 -0
  62. package/dist/types/src/preview/previewMockPlugin.d.ts +6 -0
  63. package/dist/types/src/preview/previewServer.d.ts +7 -0
  64. package/dist/types/src/preview/publish.d.ts +5 -0
  65. package/dist/types/src/preview/vitePlugin.d.ts +13 -0
  66. package/dist/types/src/renderer/bridge.d.ts +32 -0
  67. package/dist/types/src/renderer/elementMapValidation.d.ts +6 -0
  68. package/dist/types/src/renderer/style/mergeVisualProps.d.ts +20 -0
  69. package/dist/types/src/renderer/template.d.ts +2 -0
  70. package/dist/types/src/scaffold/standalone.d.ts +2 -0
  71. package/dist/types/src/schema/dsl-catalog.d.ts +56 -0
  72. package/dist/types/src/validate/validateViewProps.d.ts +5 -0
  73. package/dist/view-contracts.bundle.mjs +3 -3
  74. package/dist/view-contracts.bundle.mjs.map +1 -1
  75. package/docs/cli-reference.md +1 -1
  76. package/package.json +17 -6
package/README.md CHANGED
@@ -335,7 +335,7 @@ npm install -D view-contracts
335
335
  npx view-contracts build -c view-contracts.config.yaml
336
336
  ```
337
337
 
338
- Releases are published to npm when a [GitHub Release](https://github.com/foo-log-inc/view-contracts/releases) is published (`v*` tag).
338
+ **Merging to `main` publishes to npm.** `release.yml` runs on every push to `main`, creates the `v<version>` [GitHub Release](https://github.com/foo-log-inc/view-contracts/releases) when that tag does not exist yet, and `publish.yml` publishes on that Release. There is no manual step between merge and publish, so a merge that carries a version bump ships that version.
339
339
 
340
340
  ### Bumping the version
341
341
 
package/cli-contract.yaml CHANGED
@@ -3,7 +3,7 @@ cli_contracts: 0.1.0
3
3
 
4
4
  info:
5
5
  title: view-contracts CLI
6
- version: 0.5.8
6
+ version: 0.5.9
7
7
  description: >-
8
8
  Contract-first UI design toolchain. Compiles restricted view-contract TSX
9
9
  to language-neutral View IR and renders platform targets (React, SwiftUI, Compose).
@@ -0,0 +1,10 @@
1
+ export interface ComposeElementConfig {
2
+ container?: 'group' | 'vstack' | 'hstack' | 'navstack' | 'scrollview' | 'field' | 'cellgroup' | 'tablestack';
3
+ leaf?: 'text' | 'button' | 'textfield' | 'texteditor' | 'picker' | 'spacer' | 'divider' | 'image' | 'progressview' | 'toggle';
4
+ spacingProp?: string;
5
+ }
6
+ export interface ComposeElementMap {
7
+ elements: Record<string, ComposeElementConfig>;
8
+ }
9
+ export declare function loadComposeElementMap(customPath?: string): Promise<ComposeElementMap>;
10
+ export declare function isComposeVocabulary(name: string, map: ComposeElementMap, allowlistExtra?: string[]): boolean;
@@ -0,0 +1,22 @@
1
+ import type { ThemeIR, TokenIR } from '../../../src/design/types.js';
2
+ import type { IrNode } from '../../../src/ir/types.js';
3
+ import type { ComposeElementMap } from '../elementMap.js';
4
+ export interface ComposeRenderContext {
5
+ map: ComposeElementMap;
6
+ theme: ThemeIR;
7
+ tokens: TokenIR;
8
+ allowlistExtra: string[];
9
+ propsRoot?: string;
10
+ /** How list `.map()` IR nodes should lower inside the current container. */
11
+ listScope?: 'none' | 'lazyColumn' | 'lazyGrid';
12
+ /** When true, Text leaves inherit table cell truncation behavior. */
13
+ cellTextBehavior?: boolean;
14
+ /** True when rendering inside a verticalScroll container. */
15
+ inVerticalScroll?: boolean;
16
+ /** True when rendering TableHeader column cells (compact vertical padding). */
17
+ inTableHeader?: boolean;
18
+ }
19
+ type NodeRenderer = (node: IrNode, level: number, itemScope?: string) => string;
20
+ export declare function createComposeNodeRenderer(ctx: ComposeRenderContext): NodeRenderer;
21
+ export declare function lowerIrToComposeBody(root: IrNode, ctx: ComposeRenderContext, level?: number): string;
22
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { VisualPropSet } from '../../../src/renderer/style/mergeVisualProps.js';
2
+ export declare function composeColorExpr(value: string): string | null;
3
+ /** Map DSL justify enum to Compose Row horizontalArrangement (accepts schema + legacy aliases). */
4
+ export declare function composeRowArrangement(justifyLit: unknown, spacing: string): string;
5
+ export declare function composeContentAlignment(value: string): string;
6
+ export interface VisualPropModifierOptions {
7
+ /** When true, text appearance props target the Text composable directly. */
8
+ isLeaf?: boolean;
9
+ }
10
+ /**
11
+ * Convert merged DSL visual props to Compose modifier / text-behavior tags.
12
+ *
13
+ * Order for Compose (outside-in, opposite of SwiftUI):
14
+ * foreground/font → fillMax frame → shadow → background → clip → border → fixed sizes → padding → margin → opacity → text behavior
15
+ */
16
+ export declare function visualPropSetToModifiers(merged: VisualPropSet, options?: VisualPropModifierOptions): string[];
17
+ export declare function stripLayoutFrameModifiers(mods: string[]): string[];
18
+ export declare function stripBackgroundModifiers(mods: string[]): string[];
19
+ export declare function stripPaddingModifiers(mods: string[]): string[];
20
+ export declare function stripClipModifiers(mods: string[]): string[];
21
+ export declare function extractPaddingModifiers(mods: string[]): string[];
22
+ export declare function extractClipRadiusDp(mods: string[]): number | null;
23
+ /** Convert extracted `.padding(...)` modifiers to a Compose PaddingValues expression. */
24
+ export declare function paddingModifiersToPaddingValues(mods: string[]): string | null;
25
+ export declare function hasStyledContainerModifiers(mods: string[]): boolean;
26
+ export declare function hasFillMaxHeight(modifiers: string[]): boolean;
27
+ export declare function dedupeModifiers(mods: string[]): string[];
28
+ export declare function applyModifiers(base: string, modifiers: string[]): string;
29
+ export declare function extractTextStyleModifiers(modifiers: string[]): string[];
30
+ export declare function extractTextMaxLines(modifiers: string[]): number | null;
31
+ export declare function extractTextOverflow(modifiers: string[]): string | null;
32
+ export declare function hasTextFillMaxWidth(modifiers: string[]): boolean;
33
+ export declare function extractContentColor(modifiers: string[]): string | null;
34
+ export declare function extractInheritedTextStyleParts(modifiers: string[]): string[];
35
+ export declare function hasWrapContentCenter(modifiers: string[]): boolean;
36
+ export declare function extractApplyVcStyleExpr(modifierExpr: string): string | null;
@@ -0,0 +1,9 @@
1
+ import type { ViewIrDocument } from '../../src/ir/types.js';
2
+ import type { ThemeIR, TokenIR } from '../../src/design/types.js';
3
+ export interface RenderComposeOptions {
4
+ theme: ThemeIR;
5
+ tokens: TokenIR;
6
+ allowlistExtra?: string[];
7
+ elementMapPath?: string;
8
+ }
9
+ export declare function renderComposeComponent(doc: ViewIrDocument, options: RenderComposeOptions): Promise<string>;
@@ -0,0 +1,10 @@
1
+ import type { ViewBindingsFile, ViewContractsConfig } from '../../src/config.js';
2
+ import type { ThemeIR, TokenIR } from '../../src/design/types.js';
3
+ import type { ViewIrDocument } from '../../src/ir/types.js';
4
+ export declare function renderComposeRuntime(configPath: string, config: ViewContractsConfig, bindings: ViewBindingsFile, design?: {
5
+ theme: ThemeIR;
6
+ tokens: TokenIR;
7
+ }, compiledDocs?: {
8
+ screens: Map<string, ViewIrDocument>;
9
+ partials: ViewIrDocument[];
10
+ }): Promise<void>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generate VcTheme.kt with variant style dictionary for runtime lookup.
3
+ */
4
+ import type { ThemeIR, TokenIR } from '../../src/design/types.js';
5
+ export declare function renderComposeTheme(theme: ThemeIR, tokens: TokenIR): string;
@@ -0,0 +1,32 @@
1
+ /** Shape of entries in renderers/react/elements.yaml (renderer-owned SSoT). */
2
+ export interface ReactRendererElementConfig {
3
+ tag: string;
4
+ className?: string;
5
+ ariaLabel?: boolean;
6
+ ariaHidden?: boolean;
7
+ flex?: 'row' | 'column';
8
+ wrapProp?: string;
9
+ flexGrowProp?: string;
10
+ void?: boolean;
11
+ actionEvent?: 'onClick' | 'onSubmit';
12
+ fieldWrap?: boolean;
13
+ inputType?: string;
14
+ sizeClass?: string;
15
+ optionsProp?: string;
16
+ checkbox?: boolean;
17
+ fieldContainer?: boolean;
18
+ scrollContainer?: boolean;
19
+ defaultRole?: string;
20
+ tableCell?: boolean;
21
+ }
22
+ export interface ReactElementMapFile {
23
+ elements: Record<string, ReactRendererElementConfig>;
24
+ }
25
+ export type ReactElementMap = ReactElementMapFile;
26
+ export type ElementMapEntry = ReactRendererElementConfig;
27
+ export declare function loadReactElementMap(customPath?: string): Promise<ReactElementMapFile>;
28
+ /** DSL vocabulary element with a React HTML lowering entry (excludes project extensions). */
29
+ export declare function isLowerableVocabularyElement(name: string, map: ReactElementMapFile, allowlistExtra?: string[]): boolean;
30
+ export declare function validateElementMapCoversVocabulary(customPath?: string): Promise<void>;
31
+ export declare const assertElementMapCoversImplementedVocabulary: typeof validateElementMapCoversVocabulary;
32
+ export declare function isVocabularyElement(name: string, map: ReactElementMapFile, allowlistExtra?: string[]): boolean;
@@ -0,0 +1,7 @@
1
+ import type { IrValue } from '../../../src/ir/types.js';
2
+ import type { ElementMapEntry } from '../elementMap.js';
3
+ import { type FoldedCss } from '../style/foldLiterals.js';
4
+ export declare function collectLiteralStyleProps(props: Record<string, IrValue>): Record<string, unknown>;
5
+ export declare function foldFlexContainer(entry: ElementMapEntry): FoldedCss;
6
+ export declare function styleAttrForElement(entry: ElementMapEntry, props: Record<string, IrValue>): string;
7
+ export { foldLiteralsToCss, foldedStyleToJsx } from '../style/foldLiterals.js';
@@ -0,0 +1,6 @@
1
+ import type { ReactElementMap } from '../elementMap.js';
2
+ import type { IrComponentNode, IrNode, IrValue } from '../../../src/ir/types.js';
3
+ export declare function renderValue(value: IrValue, level: number, castActions?: boolean): string;
4
+ export declare function collectViewRefComponents(node: IrNode, names: Set<string>): void;
5
+ export declare function collectExtensionComponents(node: IrNode, map: ReactElementMap, allowlistExtra: string[], names: Set<string>): void;
6
+ export declare function createNodeRenderer(map: ReactElementMap, allowlistExtra: string[]): (node: IrComponentNode, level: number, itemScope?: string) => string;
@@ -0,0 +1 @@
1
+ export { reactTemplatesDir, reactRuntimeDir, reactStructuralCssPath, } from '../../src/lib/rendererPaths.js';
@@ -0,0 +1,26 @@
1
+ import type { ViewIrDocument } from '../../src/ir/types.js';
2
+ export interface PreviewImportSpecifiers {
3
+ dispatch: string;
4
+ styleHelpers: string;
5
+ contracts: string;
6
+ extensions: string;
7
+ }
8
+ export interface RenderReactOptions {
9
+ runtimeImportFrom: string;
10
+ extensionsImportFrom: string;
11
+ contractsImportFrom: string;
12
+ allowlistExtra?: string[];
13
+ elementMapPath?: string;
14
+ previewImports?: PreviewImportSpecifiers;
15
+ /** When set, viewRef nodes import from these paths instead of sibling .generated.js files. */
16
+ viewRefImportFrom?: Map<string, string>;
17
+ /** When true, omit viewRef import lines (partials defined in the same module). */
18
+ inlineViewRefs?: boolean;
19
+ /** @deprecated Use runtimeImportFrom */
20
+ componentsImportFrom?: string;
21
+ }
22
+ export declare function renderReactComponent(doc: ViewIrDocument, options: RenderReactOptions): Promise<string>;
23
+ export declare function renderReactFromIr(doc: ViewIrDocument, outputPath: string, options: RenderReactOptions): Promise<void>;
24
+ /** Render screen + partial modules for preview (single file, no cross-imports). */
25
+ export declare function renderReactPreviewBundle(screen: ViewIrDocument, partials: ViewIrDocument[], options: RenderReactOptions): Promise<string>;
26
+ export declare function partialReactOutputPath(reactDir: string, partial: ViewIrDocument): string;
@@ -0,0 +1,3 @@
1
+ import type { ViewContractsConfig } from '../../src/config.js';
2
+ /** Emit standalone generated runtime (no preview vocabulary copy; no @view-contracts imports). */
3
+ export declare function renderReactRuntime(configPath: string, config: ViewContractsConfig): Promise<void>;
@@ -0,0 +1,19 @@
1
+ /** Map flex alignment shorthand to CSS align-items / align-self values. */
2
+ export declare function mapAlign(value?: string): string | undefined;
3
+ /** Map flex justification shorthand to CSS justify-content values. */
4
+ export declare function mapJustify(value?: string): string | undefined;
5
+ /** Preview vocabulary helper — production lowered JSX uses visibility guards instead. */
6
+ export declare function isHidden(props: {
7
+ visible?: boolean;
8
+ hidden?: boolean;
9
+ }): boolean;
10
+ /** Sample/extension helper for preview tone class names. */
11
+ export declare function toneClass(tone: string | undefined): string;
12
+ /** Resolve theme variant name from variant or legacy tone prop. */
13
+ export declare function resolveExtensionVariant(variant?: string, tone?: string): string;
14
+ /** Build vc-* base + --variant modifier for themed extension components. */
15
+ export declare function extensionClassName(component: string, options?: {
16
+ variant?: string;
17
+ tone?: string;
18
+ extra?: string | false;
19
+ }): string;
@@ -0,0 +1,3 @@
1
+ export type FoldedCss = Record<string, string | number>;
2
+ export declare function foldLiteralsToCss(literals: Record<string, unknown>): FoldedCss;
3
+ export declare function foldedStyleToJsx(style: FoldedCss): string;
@@ -0,0 +1,7 @@
1
+ import type { ViewContractsConfig } from '../../src/config.js';
2
+ /** Remove legacy generated layout under generated/react/. */
3
+ export declare function removeLegacyReactRuntimeLayout(reactDir: string): Promise<void>;
4
+ /** Emit generated/react/runtime.ts — fixed system runtime only (dispatch + style helpers). */
5
+ export declare function writeGeneratedRuntimeBundle(configPath: string, config: ViewContractsConfig, templatesDir?: string): Promise<{
6
+ runtimePath: string;
7
+ }>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Unified renderer registry — sole entry point for core → renderer dispatch.
3
+ * Each export lazily loads its submodule so unused renderers are not pulled in.
4
+ */
5
+ import type { ViewContractsConfig, ViewBindingsFile } from '../src/config.js';
6
+ import type { ViewIrDocument } from '../src/ir/types.js';
7
+ import type { ThemeIR, TokenIR } from '../src/design/types.js';
8
+ export type { RenderReactOptions } from './react/renderComponents.js';
9
+ export declare function renderReactFromIr(doc: ViewIrDocument, outputPath: string, options: import('./react/renderComponents.js').RenderReactOptions): Promise<void>;
10
+ export declare function renderReactPreviewBundle(screen: ViewIrDocument, partials: ViewIrDocument[], options: import('./react/renderComponents.js').RenderReactOptions): Promise<string>;
11
+ export declare function renderReactRuntime(configPath: string, config: ViewContractsConfig): Promise<void>;
12
+ export declare function renderSwiftUIRuntime(configPath: string, config: ViewContractsConfig, bindings: ViewBindingsFile, design?: {
13
+ theme: ThemeIR;
14
+ tokens: TokenIR;
15
+ }, compiledDocs?: {
16
+ screens: Map<string, ViewIrDocument>;
17
+ partials: ViewIrDocument[];
18
+ }): Promise<void>;
19
+ export declare function renderSwiftComponent(doc: ViewIrDocument, options: {
20
+ theme: ThemeIR;
21
+ tokens: TokenIR;
22
+ allowlistExtra?: string[];
23
+ }): Promise<string>;
24
+ export declare function renderComposeComponent(doc: ViewIrDocument, options: {
25
+ theme: ThemeIR;
26
+ tokens: TokenIR;
27
+ allowlistExtra?: string[];
28
+ }): Promise<string>;
29
+ export declare function renderComposeRuntime(configPath: string, config: ViewContractsConfig, bindings: ViewBindingsFile, design?: {
30
+ theme: ThemeIR;
31
+ tokens: TokenIR;
32
+ }, compiledDocs?: {
33
+ screens: Map<string, ViewIrDocument>;
34
+ partials: ViewIrDocument[];
35
+ }): Promise<void>;
@@ -0,0 +1,10 @@
1
+ export interface SwiftUIElementConfig {
2
+ container?: 'group' | 'vstack' | 'hstack' | 'navstack' | 'scrollview' | 'field' | 'cellgroup' | 'tablestack';
3
+ leaf?: 'text' | 'button' | 'textfield' | 'texteditor' | 'picker' | 'spacer' | 'divider' | 'image' | 'progressview' | 'toggle';
4
+ spacingProp?: string;
5
+ }
6
+ export interface SwiftUIElementMap {
7
+ elements: Record<string, SwiftUIElementConfig>;
8
+ }
9
+ export declare function loadSwiftUIElementMap(customPath?: string): Promise<SwiftUIElementMap>;
10
+ export declare function isSwiftUIVocabulary(name: string, map: SwiftUIElementMap, allowlistExtra?: string[]): boolean;
@@ -0,0 +1,15 @@
1
+ import type { ThemeIR, TokenIR } from '../../../src/design/types.js';
2
+ import type { IrNode } from '../../../src/ir/types.js';
3
+ import type { SwiftUIElementMap } from '../elementMap.js';
4
+ export interface SwiftUIRenderContext {
5
+ map: SwiftUIElementMap;
6
+ theme: ThemeIR;
7
+ tokens: TokenIR;
8
+ allowlistExtra: string[];
9
+ /** Root prop name for partial scope (e.g. "item" for KpiCard). */
10
+ propsRoot?: string;
11
+ }
12
+ type NodeRenderer = (node: IrNode, level: number, itemScope?: string) => string;
13
+ export declare function createSwiftUINodeRenderer(ctx: SwiftUIRenderContext): NodeRenderer;
14
+ export declare function lowerIrToSwiftBody(root: IrNode, ctx: SwiftUIRenderContext, level?: number): string;
15
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { VisualPropSet } from '../../../src/renderer/style/mergeVisualProps.js';
2
+ /**
3
+ * Convert merged DSL visual props to a single SwiftUI modifier chain.
4
+ *
5
+ * SwiftUI modifier order for fill elements:
6
+ * foreground / font → padding → frame(fill) → background → clipShape → shadow → overlay → frame(fixed) → opacity
7
+ *
8
+ * For non-fill elements:
9
+ * foreground / font → padding → background → clipShape → shadow → overlay → frame → opacity
10
+ *
11
+ * The key insight: .frame(maxWidth: .infinity) MUST come BEFORE .background()
12
+ * so the background fills the expanded area. Otherwise the background only
13
+ * covers the natural content width.
14
+ */
15
+ export declare function visualPropSetToModifiers(merged: VisualPropSet): string[];
16
+ export declare function applyModifiers(body: string, modifiers: string[], indent: number): string;
@@ -0,0 +1,9 @@
1
+ import type { ViewIrDocument } from '../../src/ir/types.js';
2
+ import type { ThemeIR, TokenIR } from '../../src/design/types.js';
3
+ export interface RenderSwiftOptions {
4
+ theme: ThemeIR;
5
+ tokens: TokenIR;
6
+ allowlistExtra?: string[];
7
+ elementMapPath?: string;
8
+ }
9
+ export declare function renderSwiftComponent(doc: ViewIrDocument, options: RenderSwiftOptions): Promise<string>;
@@ -0,0 +1,10 @@
1
+ import type { ViewBindingsFile, ViewContractsConfig } from '../../src/config.js';
2
+ import type { ThemeIR, TokenIR } from '../../src/design/types.js';
3
+ import type { ViewIrDocument } from '../../src/ir/types.js';
4
+ export declare function renderSwiftUIRuntime(configPath: string, config: ViewContractsConfig, bindings: ViewBindingsFile, design?: {
5
+ theme: ThemeIR;
6
+ tokens: TokenIR;
7
+ }, compiledDocs?: {
8
+ screens: Map<string, ViewIrDocument>;
9
+ partials: ViewIrDocument[];
10
+ }): Promise<void>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate VcTheme.swift with variant style dictionary for runtime lookup.
3
+ * Enables dynamic variant resolution (IrConcat / IrBinding) in SwiftUI lowering.
4
+ */
5
+ import type { ThemeIR, TokenIR } from '../../src/design/types.js';
6
+ export declare function renderSwiftTheme(theme: ThemeIR, tokens: TokenIR): string;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { CommandHandlers } from '../generated/cli/program.js';
2
+ export declare const handlers: CommandHandlers;
@@ -0,0 +1,27 @@
1
+ import type { ViewIrDocument } from '../ir/types.js';
2
+ import type { ExtensionRegistryDocument } from '../extensions/loadExtensions.js';
3
+ export interface CompileViewInput {
4
+ sourcePath: string;
5
+ exportName?: string;
6
+ screenName: string;
7
+ targets?: string[];
8
+ }
9
+ export interface CompileOptions {
10
+ /** Project root (the view-contracts.config.yaml directory) that IR source paths are relative to. */
11
+ projectRoot: string;
12
+ allowlistExtra?: string[];
13
+ extensionRegistry?: ExtensionRegistryDocument;
14
+ targets?: string[];
15
+ }
16
+ export interface CompileViewResult {
17
+ screen: ViewIrDocument;
18
+ partials: ViewIrDocument[];
19
+ }
20
+ export declare function compileViewFile(options: CompileViewInput, compileOptions: CompileOptions): Promise<ViewIrDocument>;
21
+ export declare function compileViewFileWithPartials(options: CompileViewInput, compileOptions: CompileOptions): Promise<CompileViewResult>;
22
+ export declare function compileAllViews(views: CompileViewInput[], options: CompileOptions): Promise<ViewIrDocument[]>;
23
+ export declare function compileAllViewsWithPartials(views: CompileViewInput[], options: CompileOptions): Promise<{
24
+ screens: ViewIrDocument[];
25
+ partials: ViewIrDocument[];
26
+ }>;
27
+ export declare function partialOutputName(doc: ViewIrDocument): string;
@@ -0,0 +1,33 @@
1
+ import type { IrBinding, IrNode } from '../ir/types.js';
2
+ export interface CompileContext {
3
+ vmName: string;
4
+ scopes: string[];
5
+ propBindings: Record<string, IrBinding>;
6
+ errors: string[];
7
+ warnings: string[];
8
+ viewImports: Map<string, string>;
9
+ allowedComponents: Set<string>;
10
+ /** Source binding from an ancestor Table element, used by TableRow each="..." */
11
+ tableSource?: IrBinding;
12
+ }
13
+ export interface ParsedViewPartialResult {
14
+ exportName: string;
15
+ propsType?: string;
16
+ propNames: string[];
17
+ root: IrNode;
18
+ errors: string[];
19
+ warnings: string[];
20
+ }
21
+ export interface ParsedView {
22
+ viewModel: string;
23
+ exportName: string;
24
+ root: IrNode;
25
+ errors: string[];
26
+ warnings: string[];
27
+ }
28
+ export declare function compileViewSource(source: string, fileName: string, exportName: string, options?: {
29
+ allowlistExtra?: string[];
30
+ }): ParsedView;
31
+ export declare function compileViewPartialSource(source: string, fileName: string, exportName: string, options?: {
32
+ allowlistExtra?: string[];
33
+ }): ParsedViewPartialResult;
@@ -0,0 +1,13 @@
1
+ import ts from 'typescript';
2
+ export interface ParsedViewPartial {
3
+ paramName: string;
4
+ jsxRoot: ts.JsxChild;
5
+ /** Destructured prop names from view callback (e.g. ["items"] from ({ items }) =>). */
6
+ propNames: string[];
7
+ /** Raw TypeScript type from view<T>() generic, if present. */
8
+ propsType?: string;
9
+ }
10
+ export declare function parseViewImports(sourceFile: ts.SourceFile, fileDir: string): Map<string, string>;
11
+ export declare function findViewPartialInSource(sourceFile: ts.SourceFile, exportName: string): ParsedViewPartial | null;
12
+ export declare function loadViewPartial(filePath: string, exportName: string): ParsedViewPartial | null;
13
+ export declare function resolveViewModulePath(importPath: string, fileDir: string): string;
@@ -0,0 +1,77 @@
1
+ export interface ViewBinding {
2
+ id: string;
3
+ screenConst: string;
4
+ screenId: string;
5
+ screenName: string;
6
+ route: string;
7
+ operationId: string;
8
+ viewModel: string;
9
+ source: string;
10
+ exportName: string;
11
+ targets: string[];
12
+ }
13
+ export interface ViewBindingsFile {
14
+ version: string;
15
+ openapi: string;
16
+ views: ViewBinding[];
17
+ clientActions?: Array<{
18
+ name: string;
19
+ description: string;
20
+ }>;
21
+ }
22
+ export interface DesignConfig {
23
+ /** DTCG tokens file (.yaml, .yml, or .json) relative to config file directory. */
24
+ tokens?: string;
25
+ /** Theme variants file (.yaml, .yml, or .json) relative to config file directory. */
26
+ theme?: string;
27
+ /** Optional project extensions CSS relative to config file directory. */
28
+ extensionsCss?: string;
29
+ }
30
+ export interface ViewContractsConfig {
31
+ version: string;
32
+ openapi: string;
33
+ bindings: string;
34
+ microContractsConfig: string;
35
+ generated: {
36
+ contractDir: string;
37
+ actions: string;
38
+ bridge: string;
39
+ reactDir: string;
40
+ };
41
+ viewsDir: string;
42
+ /** Generated React runtime bundle (e.g. generated/react/runtime.ts). */
43
+ runtimeModule?: string;
44
+ /** @deprecated Use runtimeModule */
45
+ componentsModule?: string;
46
+ /** Project React theme CSS path (e.g. generated/react/theme.css). */
47
+ themeModule?: string;
48
+ /** Design token / theme inputs (required for build). */
49
+ design?: DesignConfig;
50
+ /** Extra component names allowed at compile time (sample/project extensions). */
51
+ allowlistExtra?: string[];
52
+ /** Optional custom Handlebars templates directory (relative to project root). */
53
+ rendererTemplatesDir?: string;
54
+ /** Optional extension registry YAML (relative to project root). */
55
+ extensions?: string;
56
+ /** Preview-only options (not used by production builds). */
57
+ preview?: {
58
+ /** Directory of *.mock.yaml files relative to config (default: views/preview). */
59
+ mocksDir?: string;
60
+ };
61
+ }
62
+ export declare function discoverConfigPath(startDir?: string): Promise<string | null>;
63
+ export declare function resolveConfigPath(config?: string): Promise<string>;
64
+ export declare function loadConfig(configPath: string): Promise<ViewContractsConfig>;
65
+ /** Resolve config paths relative to the config file directory (project root). */
66
+ export declare function normalizeConfig(configPath: string, config: ViewContractsConfig): ViewContractsConfig;
67
+ export declare function loadBindings(bindingsPath: string): Promise<ViewBindingsFile>;
68
+ export declare function reactOutputPath(config: ViewContractsConfig, view: ViewBinding): string;
69
+ export declare function projectRoot(configPath: string): string;
70
+ export declare function themeCssPath(_configPath: string, config: ViewContractsConfig): string;
71
+ export declare function requireDesignPaths(config: ViewContractsConfig): {
72
+ tokensPath: string;
73
+ themePath: string;
74
+ };
75
+ export declare function runtimeImportSpecifier(_configPath: string, _config: ViewContractsConfig, outputPath: string): string;
76
+ /** @deprecated Use runtimeImportSpecifier */
77
+ export declare function componentsImportSpecifier(configPath: string, config: ViewContractsConfig, outputPath: string): string;
@@ -0,0 +1,3 @@
1
+ import type { ViewContractsConfig } from '../config.js';
2
+ /** Merge project design inputs + package structural CSS into theme stylesheet content. */
3
+ export declare function buildThemeCss(config: ViewContractsConfig, configPath: string): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { TokenIR } from './types.js';
2
+ export declare function componentToKebab(name: string): string;
3
+ export declare function tokenCssVar(tokens: TokenIR, ref: string): string;
@@ -0,0 +1,2 @@
1
+ import type { VariantProperty } from './types.js';
2
+ export declare const CSS_PROPERTY_BY_VARIANT_PROPERTY: Record<VariantProperty, string>;
@@ -0,0 +1,2 @@
1
+ import type { ThemeIR, TokenIR } from './types.js';
2
+ export declare function emitDefaultCss(tokens: TokenIR, theme: ThemeIR): string;
@@ -0,0 +1,4 @@
1
+ import type { TokenIR } from './types.js';
2
+ export declare function emitTokenCss(ir: TokenIR): string;
3
+ /** Structural CSS only — visual values live in tokens.yaml + theme.yaml (+ extensions.css). */
4
+ export declare function extractStructuralThemeCss(css: string): string;
@@ -0,0 +1,2 @@
1
+ import type { ThemeIR, TokenIR } from './types.js';
2
+ export declare function emitVariantCss(tokens: TokenIR, theme: ThemeIR): string;
@@ -0,0 +1,19 @@
1
+ export { emitTokenCss, extractStructuralThemeCss } from './emitTokenCss.js';
2
+ export { emitDefaultCss } from './emitDefaultCss.js';
3
+ export { emitVariantCss } from './emitVariantCss.js';
4
+ export { loadDesignFile } from './load.js';
5
+ export { parseTheme } from './parseTheme.js';
6
+ export { parseTokens } from './parseTokens.js';
7
+ export { validateDesign, validateTheme } from './validate.js';
8
+ export { validateViewVariants } from './validateViewVariants.js';
9
+ export { validateVcNamespaceCss, validateVcNamespaceSource } from './validateVcNamespace.js';
10
+ export { validateProjectDesign } from './validateProjectDesign.js';
11
+ export { buildThemeCss } from './buildThemeCss.js';
12
+ export { DesignThemeError, DesignTokenError, DesignConstraintError, TOKEN_TYPES, VARIANT_PROPERTIES } from './types.js';
13
+ export type { ThemeIR, TokenEntry, TokenIR, TokenType, VariantProperty, VariantPropertyRef, } from './types.js';
14
+ export declare function loadAndParseTokens(filePath: string): Promise<import("./types.js").TokenIR>;
15
+ export declare function loadAndParseTheme(filePath: string): Promise<import("./types.js").ThemeIR>;
16
+ export declare function loadValidateDesign(tokensPath: string, themePath: string): Promise<{
17
+ tokenIR: import("./types.js").TokenIR;
18
+ themeIR: import("./types.js").ThemeIR;
19
+ }>;
@@ -0,0 +1 @@
1
+ export declare function loadDesignFile(filePath: string): Promise<unknown>;
@@ -0,0 +1,2 @@
1
+ import { type ThemeIR } from './types.js';
2
+ export declare function parseTheme(source: unknown): ThemeIR;
@@ -0,0 +1,2 @@
1
+ import { type TokenIR } from './types.js';
2
+ export declare function parseTokens(source: unknown): TokenIR;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Properties allowed in theme defaults/variants for a vocabulary element.
3
+ * Returns the intersection of the element's catalog properties and VARIANT_PROPERTIES.
4
+ */
5
+ export declare function themePropertiesForElement(elementName: string): Set<string>;
@@ -0,0 +1,37 @@
1
+ export declare const TOKEN_TYPES: readonly ["color", "dimension", "shadow", "typography", "layout"];
2
+ export type TokenType = (typeof TOKEN_TYPES)[number];
3
+ export interface TokenEntry {
4
+ /** Dot-separated path, e.g. `ui.primary` or `semantic.color.text`. */
5
+ path: string;
6
+ type: TokenType;
7
+ /** Resolved CSS-ready value. */
8
+ value: string;
9
+ cssVar: string;
10
+ /** Set when the token was defined via `{group.token}` reference. */
11
+ ref?: string;
12
+ }
13
+ export interface TokenIR {
14
+ entries: TokenEntry[];
15
+ }
16
+ export declare class DesignTokenError extends Error {
17
+ constructor(message: string);
18
+ }
19
+ export declare const VARIANT_PROPERTIES: readonly ["background", "foreground", "radius", "padding", "shadow", "typography", "display", "gridTemplateColumns", "minHeight", "maxWidth", "width", "height", "margin", "border", "borderColor", "flexDirection", "fontWeight", "fontSize", "alignItems", "justifyContent"];
20
+ export type VariantProperty = (typeof VARIANT_PROPERTIES)[number];
21
+ export declare const VARIANT_PROPERTY_ACCEPTS: Record<VariantProperty, readonly TokenType[]>;
22
+ export interface VariantPropertyRef {
23
+ ref: string;
24
+ accepts: TokenType[];
25
+ }
26
+ export interface ThemeIR {
27
+ /** Element-level defaults applied when no variant is specified. */
28
+ defaults: Record<string, Record<string, VariantPropertyRef>>;
29
+ variants: Record<string, Record<string, Record<string, VariantPropertyRef>>>;
30
+ }
31
+ export declare class DesignThemeError extends Error {
32
+ constructor(message: string);
33
+ }
34
+ /** Project design violated a namespace constraint (e.g. hand-written .vc-* outside DSL output). */
35
+ export declare class DesignConstraintError extends Error {
36
+ constructor(message: string);
37
+ }