view-contracts 0.4.2 → 0.4.4

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Contract-first UI design toolchain. Compiles restricted view-contract TSX to language-neutral View IR and renders platform targets (React, SwiftUI, Compose).
4
4
 
5
- **Version:** 0.3.5
5
+ **Version:** 0.4.4
6
6
 
7
7
  ## Table of Contents
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "view-contracts",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Contract-first UI design toolchain — restricted TSX to View IR to platform renderers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -54,7 +54,10 @@ function partialFunctionParams(doc: ViewIrDocument): string {
54
54
  const match = doc.propsType.match(/^\{\s*([^}]+)\s*\}$/);
55
55
  if (!match) return `props: ${doc.propsType}`;
56
56
  const inner = match[1].trim();
57
- const propNames = inner.split(',').map((part) => part.split(':')[0]!.trim());
57
+ const propNames = inner
58
+ .split(/[,;]/)
59
+ .map((part) => part.split(':')[0]!.trim())
60
+ .filter(Boolean);
58
61
  return `{ ${propNames.join(', ')} }: ${doc.propsType}`;
59
62
  }
60
63
 
@@ -0,0 +1,62 @@
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
+
9
+ export type { RenderReactOptions } from './react/renderComponents.js';
10
+
11
+ export async function renderReactFromIr(
12
+ doc: ViewIrDocument,
13
+ outputPath: string,
14
+ options: import('./react/renderComponents.js').RenderReactOptions,
15
+ ): Promise<void> {
16
+ const mod = await import('./react/renderComponents.js');
17
+ return mod.renderReactFromIr(doc, outputPath, options);
18
+ }
19
+
20
+ export async function renderReactPreviewBundle(
21
+ screen: ViewIrDocument,
22
+ partials: ViewIrDocument[],
23
+ options: import('./react/renderComponents.js').RenderReactOptions,
24
+ ): Promise<string> {
25
+ const mod = await import('./react/renderComponents.js');
26
+ return mod.renderReactPreviewBundle(screen, partials, options);
27
+ }
28
+
29
+ export async function renderReactRuntime(
30
+ configPath: string,
31
+ config: ViewContractsConfig,
32
+ ): Promise<void> {
33
+ const mod = await import('./react/renderRuntime.js');
34
+ return mod.renderReactRuntime(configPath, config);
35
+ }
36
+
37
+ export async function renderSwiftUIRuntime(
38
+ configPath: string,
39
+ config: ViewContractsConfig,
40
+ bindings: ViewBindingsFile,
41
+ design?: { theme: ThemeIR; tokens: TokenIR },
42
+ compiledDocs?: { screens: Map<string, ViewIrDocument>; partials: ViewIrDocument[] },
43
+ ): Promise<void> {
44
+ const mod = await import('./swiftui/renderRuntime.js');
45
+ return mod.renderSwiftUIRuntime(configPath, config, bindings, design, compiledDocs);
46
+ }
47
+
48
+ export async function renderSwiftComponent(
49
+ doc: ViewIrDocument,
50
+ options: { theme: ThemeIR; tokens: TokenIR; allowlistExtra?: string[] },
51
+ ): Promise<string> {
52
+ const mod = await import('./swiftui/renderComponents.js');
53
+ return mod.renderSwiftComponent(doc, options);
54
+ }
55
+
56
+ export async function renderComposeRuntime(
57
+ config: ViewContractsConfig,
58
+ bindings: ViewBindingsFile,
59
+ ): Promise<void> {
60
+ const mod = await import('./compose/renderRuntime.js');
61
+ return mod.renderComposeRuntime(config, bindings);
62
+ }