view-contracts 0.4.3 → 0.4.5
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.
- package/cli-contract.yaml +1 -1
- package/dist/preview.mjs +262 -115
- package/dist/preview.mjs.map +4 -4
- package/dist/view-contracts.bundle.mjs +159 -159
- package/dist/view-contracts.bundle.mjs.map +4 -4
- package/docs/cli-reference.md +1 -1
- package/package.json +1 -1
- package/renderers/react/renderComponents.ts +4 -1
- package/renderers/react/routes.yaml +9 -6
- package/renderers/registry.ts +62 -0
package/docs/cli-reference.md
CHANGED
package/package.json
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -8,21 +8,24 @@ react:
|
|
|
8
8
|
templates: renderers/react/templates
|
|
9
9
|
outputs:
|
|
10
10
|
screen:
|
|
11
|
-
pattern: '{{projectRoot}}/generated/react/{{screenName}}.generated.tsx'
|
|
11
|
+
pattern: '{{projectRoot}}/generated/react/components/{{screenName}}.generated.tsx'
|
|
12
|
+
partial:
|
|
13
|
+
pattern: '{{projectRoot}}/generated/react/components/{{exportName}}.generated.tsx'
|
|
12
14
|
preview:
|
|
13
15
|
entry: .vite/preview-main.tsx
|
|
14
16
|
generatedEntry: src/main.tsx
|
|
15
17
|
|
|
16
18
|
swiftui:
|
|
17
|
-
description: SwiftUI renderer (
|
|
19
|
+
description: SwiftUI renderer (vocabulary lowering via renderers/swiftui/elements.yaml)
|
|
18
20
|
outputs:
|
|
19
21
|
screen:
|
|
20
|
-
pattern: '{{projectRoot}}/generated/swiftui/{{screenName}}.swift'
|
|
21
|
-
|
|
22
|
+
pattern: '{{projectRoot}}/generated/swiftui/{{screenName}}.generated.swift'
|
|
23
|
+
partial:
|
|
24
|
+
pattern: '{{projectRoot}}/generated/swiftui/{{exportName}}.generated.swift'
|
|
22
25
|
|
|
23
26
|
compose:
|
|
24
|
-
description: Jetpack Compose renderer (scaffold)
|
|
27
|
+
description: Jetpack Compose renderer (scaffold — screen stubs only; partial emission tracked separately)
|
|
25
28
|
outputs:
|
|
26
29
|
screen:
|
|
27
30
|
pattern: '{{projectRoot}}/generated/compose/{{screenName}}Screen.kt'
|
|
28
|
-
|
|
31
|
+
# partial: not emitted yet — see issue #47
|
|
@@ -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
|
+
}
|