@contractspec/bundle.marketing 1.12.0
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/.turbo/turbo-build$colon$types.log +1 -0
- package/.turbo/turbo-build.log +175 -0
- package/.turbo/turbo-lint.log +3 -0
- package/AGENTS.md +36 -0
- package/CHANGELOG.md +416 -0
- package/README.md +57 -0
- package/dist/components/marketing/ChangelogPage.d.ts +21 -0
- package/dist/components/marketing/ChangelogPage.d.ts.map +1 -0
- package/dist/components/marketing/ChangelogPage.js +65 -0
- package/dist/components/marketing/ChangelogPage.js.map +1 -0
- package/dist/components/marketing/CofounderPage.d.ts +7 -0
- package/dist/components/marketing/CofounderPage.d.ts.map +1 -0
- package/dist/components/marketing/CofounderPage.js +468 -0
- package/dist/components/marketing/CofounderPage.js.map +1 -0
- package/dist/components/marketing/ContactClient.d.ts +7 -0
- package/dist/components/marketing/ContactClient.d.ts.map +1 -0
- package/dist/components/marketing/ContactClient.js +158 -0
- package/dist/components/marketing/ContactClient.js.map +1 -0
- package/dist/components/marketing/ContributePage.d.ts +9 -0
- package/dist/components/marketing/ContributePage.d.ts.map +1 -0
- package/dist/components/marketing/ContributePage.js +362 -0
- package/dist/components/marketing/ContributePage.js.map +1 -0
- package/dist/components/marketing/DesignPartnerPage.d.ts +9 -0
- package/dist/components/marketing/DesignPartnerPage.d.ts.map +1 -0
- package/dist/components/marketing/DesignPartnerPage.js +215 -0
- package/dist/components/marketing/DesignPartnerPage.js.map +1 -0
- package/dist/components/marketing/LandingPage.d.ts +7 -0
- package/dist/components/marketing/LandingPage.d.ts.map +1 -0
- package/dist/components/marketing/LandingPage.js +38 -0
- package/dist/components/marketing/LandingPage.js.map +1 -0
- package/dist/components/marketing/PricingClient.d.ts +7 -0
- package/dist/components/marketing/PricingClient.d.ts.map +1 -0
- package/dist/components/marketing/PricingClient.js +521 -0
- package/dist/components/marketing/PricingClient.js.map +1 -0
- package/dist/components/marketing/ProductClientPage.d.ts +7 -0
- package/dist/components/marketing/ProductClientPage.d.ts.map +1 -0
- package/dist/components/marketing/ProductClientPage.js +460 -0
- package/dist/components/marketing/ProductClientPage.js.map +1 -0
- package/dist/components/marketing/index.d.ts +11 -0
- package/dist/components/marketing/index.js +12 -0
- package/dist/components/marketing/pricing-thinking-modal.d.ts +16 -0
- package/dist/components/marketing/pricing-thinking-modal.d.ts.map +1 -0
- package/dist/components/marketing/pricing-thinking-modal.js +202 -0
- package/dist/components/marketing/pricing-thinking-modal.js.map +1 -0
- package/dist/components/marketing/sections/AudienceSection.d.ts +7 -0
- package/dist/components/marketing/sections/AudienceSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/AudienceSection.js +68 -0
- package/dist/components/marketing/sections/AudienceSection.js.map +1 -0
- package/dist/components/marketing/sections/CorePositioningSection.d.ts +7 -0
- package/dist/components/marketing/sections/CorePositioningSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/CorePositioningSection.js +59 -0
- package/dist/components/marketing/sections/CorePositioningSection.js.map +1 -0
- package/dist/components/marketing/sections/CtaSection.d.ts +7 -0
- package/dist/components/marketing/sections/CtaSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/CtaSection.js +54 -0
- package/dist/components/marketing/sections/CtaSection.js.map +1 -0
- package/dist/components/marketing/sections/DevelopersSection.d.ts +7 -0
- package/dist/components/marketing/sections/DevelopersSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/DevelopersSection.js +45 -0
- package/dist/components/marketing/sections/DevelopersSection.js.map +1 -0
- package/dist/components/marketing/sections/FearsSection.d.ts +7 -0
- package/dist/components/marketing/sections/FearsSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/FearsSection.js +48 -0
- package/dist/components/marketing/sections/FearsSection.js.map +1 -0
- package/dist/components/marketing/sections/HeroMarketingSection.d.ts +7 -0
- package/dist/components/marketing/sections/HeroMarketingSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/HeroMarketingSection.js +77 -0
- package/dist/components/marketing/sections/HeroMarketingSection.js.map +1 -0
- package/dist/components/marketing/sections/IconGridSection.d.ts +45 -0
- package/dist/components/marketing/sections/IconGridSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/IconGridSection.js +44 -0
- package/dist/components/marketing/sections/IconGridSection.js.map +1 -0
- package/dist/components/marketing/sections/OutputsSection.d.ts +7 -0
- package/dist/components/marketing/sections/OutputsSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/OutputsSection.js +59 -0
- package/dist/components/marketing/sections/OutputsSection.js.map +1 -0
- package/dist/components/marketing/sections/ProblemSection.d.ts +7 -0
- package/dist/components/marketing/sections/ProblemSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/ProblemSection.js +46 -0
- package/dist/components/marketing/sections/ProblemSection.js.map +1 -0
- package/dist/components/marketing/sections/SolutionSection.d.ts +7 -0
- package/dist/components/marketing/sections/SolutionSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/SolutionSection.js +46 -0
- package/dist/components/marketing/sections/SolutionSection.js.map +1 -0
- package/dist/components/marketing/sections/StepsSection.d.ts +7 -0
- package/dist/components/marketing/sections/StepsSection.d.ts.map +1 -0
- package/dist/components/marketing/sections/StepsSection.js +52 -0
- package/dist/components/marketing/sections/StepsSection.js.map +1 -0
- package/dist/components/marketing/waitlist-section.d.ts +15 -0
- package/dist/components/marketing/waitlist-section.d.ts.map +1 -0
- package/dist/components/marketing/waitlist-section.js +578 -0
- package/dist/components/marketing/waitlist-section.js.map +1 -0
- package/dist/components/templates/TemplatesClientPage.d.ts +7 -0
- package/dist/components/templates/TemplatesClientPage.d.ts.map +1 -0
- package/dist/components/templates/TemplatesClientPage.js +625 -0
- package/dist/components/templates/TemplatesClientPage.js.map +1 -0
- package/dist/components/templates/TemplatesPage.d.ts +7 -0
- package/dist/components/templates/TemplatesPage.d.ts.map +1 -0
- package/dist/components/templates/TemplatesPage.js +125 -0
- package/dist/components/templates/TemplatesPage.js.map +1 -0
- package/dist/components/templates/TemplatesPreviewModal.d.ts +15 -0
- package/dist/components/templates/TemplatesPreviewModal.d.ts.map +1 -0
- package/dist/components/templates/TemplatesPreviewModal.js +137 -0
- package/dist/components/templates/TemplatesPreviewModal.js.map +1 -0
- package/dist/components/templates/index.d.ts +4 -0
- package/dist/components/templates/index.js +5 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +28 -0
- package/dist/libs/email/client.d.ts +15 -0
- package/dist/libs/email/client.d.ts.map +1 -0
- package/dist/libs/email/client.js +113 -0
- package/dist/libs/email/client.js.map +1 -0
- package/dist/libs/email/contact.d.ts +7 -0
- package/dist/libs/email/contact.d.ts.map +1 -0
- package/dist/libs/email/contact.js +71 -0
- package/dist/libs/email/contact.js.map +1 -0
- package/dist/libs/email/newsletter.d.ts +7 -0
- package/dist/libs/email/newsletter.d.ts.map +1 -0
- package/dist/libs/email/newsletter.js +95 -0
- package/dist/libs/email/newsletter.js.map +1 -0
- package/dist/libs/email/types.d.ts +53 -0
- package/dist/libs/email/types.d.ts.map +1 -0
- package/dist/libs/email/types.js +1 -0
- package/dist/libs/email/utils.d.ts +6 -0
- package/dist/libs/email/utils.d.ts.map +1 -0
- package/dist/libs/email/utils.js +7 -0
- package/dist/libs/email/utils.js.map +1 -0
- package/dist/libs/email/waitlist-application.d.ts +7 -0
- package/dist/libs/email/waitlist-application.d.ts.map +1 -0
- package/dist/libs/email/waitlist-application.js +170 -0
- package/dist/libs/email/waitlist-application.js.map +1 -0
- package/dist/libs/email/waitlist.d.ts +7 -0
- package/dist/libs/email/waitlist.d.ts.map +1 -0
- package/dist/libs/email/waitlist.js +105 -0
- package/dist/libs/email/waitlist.js.map +1 -0
- package/dist/libs/pricing-examples.d.ts +22 -0
- package/dist/libs/pricing-examples.d.ts.map +1 -0
- package/dist/libs/pricing-examples.js +21 -0
- package/dist/libs/pricing-examples.js.map +1 -0
- package/dist/registry/engine.d.ts +17 -0
- package/dist/registry/engine.d.ts.map +1 -0
- package/dist/registry/engine.js +24 -0
- package/dist/registry/engine.js.map +1 -0
- package/dist/registry/factory.d.ts +64 -0
- package/dist/registry/factory.d.ts.map +1 -0
- package/dist/registry/factory.js +61 -0
- package/dist/registry/factory.js.map +1 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/registry-docs.d.ts +15 -0
- package/dist/registry/registry-docs.d.ts.map +1 -0
- package/dist/registry/registry-docs.js +305 -0
- package/dist/registry/registry-docs.js.map +1 -0
- package/dist/registry/registry-landing.d.ts +19 -0
- package/dist/registry/registry-landing.d.ts.map +1 -0
- package/dist/registry/registry-landing.js +95 -0
- package/dist/registry/registry-landing.js.map +1 -0
- package/dist/registry/registry.d.ts +30 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +61 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/registry/types.d.ts +19 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +0 -0
- package/dist/registry/utils.d.ts +31 -0
- package/dist/registry/utils.d.ts.map +1 -0
- package/dist/registry/utils.js +54 -0
- package/dist/registry/utils.js.map +1 -0
- package/package.json +151 -0
- package/src/components/marketing/ChangelogPage.tsx +110 -0
- package/src/components/marketing/CofounderPage.tsx +409 -0
- package/src/components/marketing/ContactClient.tsx +174 -0
- package/src/components/marketing/ContributePage.tsx +319 -0
- package/src/components/marketing/DesignPartnerPage.tsx +181 -0
- package/src/components/marketing/LandingPage.tsx +30 -0
- package/src/components/marketing/PricingClient.tsx +446 -0
- package/src/components/marketing/ProductClientPage.tsx +391 -0
- package/src/components/marketing/index.ts +10 -0
- package/src/components/marketing/pricing-thinking-modal.tsx +224 -0
- package/src/components/marketing/sections/AudienceSection.tsx +66 -0
- package/src/components/marketing/sections/CorePositioningSection.tsx +44 -0
- package/src/components/marketing/sections/CtaSection.tsx +57 -0
- package/src/components/marketing/sections/DevelopersSection.tsx +38 -0
- package/src/components/marketing/sections/FearsSection.tsx +45 -0
- package/src/components/marketing/sections/HeroMarketingSection.tsx +73 -0
- package/src/components/marketing/sections/IconGridSection.tsx +91 -0
- package/src/components/marketing/sections/OutputsSection.tsx +59 -0
- package/src/components/marketing/sections/ProblemSection.tsx +47 -0
- package/src/components/marketing/sections/SolutionSection.tsx +47 -0
- package/src/components/marketing/sections/StepsSection.tsx +55 -0
- package/src/components/marketing/waitlist-section.tsx +606 -0
- package/src/components/templates/TemplatesClientPage.tsx +711 -0
- package/src/components/templates/TemplatesPage.tsx +129 -0
- package/src/components/templates/TemplatesPreviewModal.tsx +260 -0
- package/src/components/templates/index.ts +3 -0
- package/src/index.ts +15 -0
- package/src/libs/email/client.test.ts +107 -0
- package/src/libs/email/client.ts +146 -0
- package/src/libs/email/contact.ts +80 -0
- package/src/libs/email/newsletter.ts +108 -0
- package/src/libs/email/types.ts +59 -0
- package/src/libs/email/utils.ts +8 -0
- package/src/libs/email/waitlist-application.ts +192 -0
- package/src/libs/email/waitlist.ts +118 -0
- package/src/libs/pricing-examples.ts +19 -0
- package/src/registry/engine.ts +38 -0
- package/src/registry/factory.ts +110 -0
- package/src/registry/index.ts +7 -0
- package/src/registry/registry-docs.ts +843 -0
- package/src/registry/registry-landing.ts +118 -0
- package/src/registry/registry.ts +85 -0
- package/src/registry/types.ts +17 -0
- package/src/registry/utils.ts +99 -0
- package/tsconfig.json +13 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +10 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { TagsEnum } from '@contractspec/lib.contracts/ownership';
|
|
2
|
+
import type { PresentationSpec } from '@contractspec/lib.contracts/presentations';
|
|
3
|
+
import {
|
|
4
|
+
createComponentPresentation,
|
|
5
|
+
MARKETING_CONTEXT,
|
|
6
|
+
MARKETING_GOAL,
|
|
7
|
+
} from './factory';
|
|
8
|
+
import type { ComponentMap } from './types';
|
|
9
|
+
|
|
10
|
+
// Import page components - Root/Marketing pages
|
|
11
|
+
import {
|
|
12
|
+
ChangelogPage,
|
|
13
|
+
ContactClient,
|
|
14
|
+
LandingPage,
|
|
15
|
+
PricingClient,
|
|
16
|
+
ProductClientPage,
|
|
17
|
+
} from '../components/marketing';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Component map for landing/marketing page React rendering.
|
|
21
|
+
*/
|
|
22
|
+
export const landingComponentMap: ComponentMap = {
|
|
23
|
+
LandingPage,
|
|
24
|
+
PricingPage: PricingClient,
|
|
25
|
+
ProductPage: ProductClientPage,
|
|
26
|
+
ContactPage: ContactClient,
|
|
27
|
+
ChangelogPage,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Presentation specs for landing/marketing pages.
|
|
32
|
+
*/
|
|
33
|
+
export const landingPresentations: [string, PresentationSpec][] = [
|
|
34
|
+
[
|
|
35
|
+
'/',
|
|
36
|
+
createComponentPresentation({
|
|
37
|
+
key: 'web-landing.home',
|
|
38
|
+
componentKey: 'LandingPage',
|
|
39
|
+
description:
|
|
40
|
+
'ContractSpec landing page - Stabilize your AI-generated code',
|
|
41
|
+
goal: MARKETING_GOAL,
|
|
42
|
+
context: MARKETING_CONTEXT,
|
|
43
|
+
tags: ['landing', 'home'],
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
'/pricing',
|
|
48
|
+
createComponentPresentation({
|
|
49
|
+
key: 'web-landing.pricing',
|
|
50
|
+
componentKey: 'PricingPage',
|
|
51
|
+
description: 'ContractSpec pricing information',
|
|
52
|
+
goal: 'Help visitors understand pricing and choose a plan',
|
|
53
|
+
context: MARKETING_CONTEXT,
|
|
54
|
+
tags: ['pricing', 'plans'],
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'/product',
|
|
59
|
+
createComponentPresentation({
|
|
60
|
+
key: 'web-landing.product',
|
|
61
|
+
componentKey: 'ProductPage',
|
|
62
|
+
description: 'ContractSpec product overview',
|
|
63
|
+
goal: 'Explain product features and benefits',
|
|
64
|
+
context: MARKETING_CONTEXT,
|
|
65
|
+
tags: ['product', 'features'],
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
'/contact',
|
|
70
|
+
createComponentPresentation({
|
|
71
|
+
key: 'web-landing.contact',
|
|
72
|
+
componentKey: 'ContactPage',
|
|
73
|
+
description: 'Contact ContractSpec team',
|
|
74
|
+
goal: 'Enable visitors to reach the ContractSpec team',
|
|
75
|
+
context: MARKETING_CONTEXT,
|
|
76
|
+
tags: ['contact', 'support'],
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
'/changelog',
|
|
81
|
+
createComponentPresentation({
|
|
82
|
+
key: 'web-landing.changelog',
|
|
83
|
+
componentKey: 'ChangelogPage',
|
|
84
|
+
description: 'ContractSpec changelog and release notes',
|
|
85
|
+
goal: 'Keep users informed about changes and updates',
|
|
86
|
+
context: MARKETING_CONTEXT,
|
|
87
|
+
tags: ['changelog', 'releases'],
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Presentation specs for learning journey pages.
|
|
94
|
+
*/
|
|
95
|
+
export const learningPresentations: [string, PresentationSpec][] = [
|
|
96
|
+
[
|
|
97
|
+
'/learning',
|
|
98
|
+
createComponentPresentation({
|
|
99
|
+
key: 'web-landing.learning.tracks',
|
|
100
|
+
componentKey: 'LearningTrackList',
|
|
101
|
+
description: 'Learning tracks list',
|
|
102
|
+
goal: 'Guide users through ContractSpec learning paths',
|
|
103
|
+
context: 'Part of the onboarding and education experience',
|
|
104
|
+
tags: [TagsEnum.Guide, 'learning', 'onboarding'],
|
|
105
|
+
}),
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
'/learning/:trackId',
|
|
109
|
+
createComponentPresentation({
|
|
110
|
+
key: 'web-landing.learning.track-detail',
|
|
111
|
+
componentKey: 'LearningTrackDetail',
|
|
112
|
+
description: 'Learning track detail view',
|
|
113
|
+
goal: 'Show progress and content for a specific learning track',
|
|
114
|
+
context: 'Part of the onboarding and education experience',
|
|
115
|
+
tags: [TagsEnum.Guide, 'learning', 'onboarding'],
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
docBlocksToPresentationRoutes,
|
|
3
|
+
type DocPresentationRoute,
|
|
4
|
+
listRegisteredDocBlocks,
|
|
5
|
+
metaDocs,
|
|
6
|
+
techContractsDocs,
|
|
7
|
+
} from '@contractspec/lib.contracts/docs';
|
|
8
|
+
import type { PresentationSpec } from '@contractspec/lib.contracts/presentations';
|
|
9
|
+
import { opsDocBlocks } from '@contractspec/bundle.library/components/docs/ops/ops.docs';
|
|
10
|
+
import { productDocs } from '@contractspec/bundle.library/components/docs/product/product.docblocks';
|
|
11
|
+
import { techContractsDocBlocks } from '@contractspec/bundle.library/components/docs/tech/contracts/tech-docs.docblocks';
|
|
12
|
+
import type { ComponentMap } from './types';
|
|
13
|
+
|
|
14
|
+
// Import sub-registries
|
|
15
|
+
import { docsComponentMap, docsPresentations } from './registry-docs';
|
|
16
|
+
import {
|
|
17
|
+
landingComponentMap,
|
|
18
|
+
landingPresentations,
|
|
19
|
+
learningPresentations,
|
|
20
|
+
} from './registry-landing';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Merged component map for React rendering.
|
|
24
|
+
* Maps componentKey to actual React components.
|
|
25
|
+
*/
|
|
26
|
+
export const componentMap: ComponentMap = {
|
|
27
|
+
...landingComponentMap,
|
|
28
|
+
...docsComponentMap,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Presentation registry for all static pages.
|
|
33
|
+
* Maps route paths to PresentationSpec definitions.
|
|
34
|
+
*/
|
|
35
|
+
export const presentationRegistry = new Map<string, PresentationSpec>([
|
|
36
|
+
...landingPresentations,
|
|
37
|
+
...learningPresentations,
|
|
38
|
+
...docsPresentations,
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
// Add docBlocks-based presentations
|
|
42
|
+
const docRoutes: DocPresentationRoute[] = docBlocksToPresentationRoutes(
|
|
43
|
+
[
|
|
44
|
+
...opsDocBlocks,
|
|
45
|
+
...productDocs,
|
|
46
|
+
...techContractsDocBlocks,
|
|
47
|
+
...techContractsDocs,
|
|
48
|
+
...metaDocs,
|
|
49
|
+
...listRegisteredDocBlocks(),
|
|
50
|
+
],
|
|
51
|
+
{
|
|
52
|
+
namespace: 'web-landing.docs',
|
|
53
|
+
routePrefix: '/docs',
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
for (const { route, descriptor } of docRoutes) {
|
|
58
|
+
presentationRegistry.set(route, descriptor);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get presentation descriptor for a given route.
|
|
63
|
+
* Returns undefined if no presentation exists for the route.
|
|
64
|
+
*/
|
|
65
|
+
export function getPresentationForRoute(
|
|
66
|
+
route: string
|
|
67
|
+
): PresentationSpec | undefined {
|
|
68
|
+
// Normalize route (remove trailing slash, handle root)
|
|
69
|
+
const normalizedRoute = route === '/' ? '/' : route.replace(/\/$/, '');
|
|
70
|
+
return presentationRegistry.get(normalizedRoute);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Check if a route has a presentation descriptor.
|
|
75
|
+
*/
|
|
76
|
+
export function hasPresentation(route: string): boolean {
|
|
77
|
+
return getPresentationForRoute(route) !== undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get all registered routes with presentations.
|
|
82
|
+
*/
|
|
83
|
+
export function getAllPresentationRoutes(): string[] {
|
|
84
|
+
return Array.from(presentationRegistry.keys());
|
|
85
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PresentationSpec } from '@contractspec/lib.contracts/presentations';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component map for React rendering.
|
|
6
|
+
* Maps componentKey to actual React components.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Generic component map
|
|
9
|
+
export type ComponentMap = Record<string, React.ComponentType<any>>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Route-to-presentation mapping.
|
|
13
|
+
*/
|
|
14
|
+
export interface RoutePresentation {
|
|
15
|
+
route: string;
|
|
16
|
+
descriptor: PresentationSpec;
|
|
17
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { renderFeaturePresentation } from '@contractspec/lib.contracts/client/react/feature-render';
|
|
2
|
+
import type { PresentationSpec } from '@contractspec/lib.contracts/presentations';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
import { presentationEngine } from './engine';
|
|
5
|
+
import { componentMap } from './registry';
|
|
6
|
+
import type { ComponentMap } from './types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Render a presentation descriptor to markdown.
|
|
10
|
+
* Returns the markdown content as a string.
|
|
11
|
+
*/
|
|
12
|
+
export async function renderPresentationToMarkdown(
|
|
13
|
+
descriptor: PresentationSpec
|
|
14
|
+
): Promise<string> {
|
|
15
|
+
const result = await presentationEngine.render<{
|
|
16
|
+
mimeType: string;
|
|
17
|
+
body: string;
|
|
18
|
+
}>('markdown', descriptor);
|
|
19
|
+
|
|
20
|
+
return result.body;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Render a presentation descriptor to React element.
|
|
25
|
+
* Returns the React element or null if component not found.
|
|
26
|
+
*/
|
|
27
|
+
export async function renderPresentationToReact(
|
|
28
|
+
descriptor: PresentationSpec,
|
|
29
|
+
customComponentMap?: ComponentMap
|
|
30
|
+
): Promise<React.ReactElement | null> {
|
|
31
|
+
const map = customComponentMap ?? componentMap;
|
|
32
|
+
const element = await renderFeaturePresentation(
|
|
33
|
+
presentationEngine,
|
|
34
|
+
'react',
|
|
35
|
+
descriptor,
|
|
36
|
+
{
|
|
37
|
+
componentMap: map,
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (element && typeof element === 'object' && 'type' in element) {
|
|
42
|
+
return element as React.ReactElement;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get markdown URL for a given route.
|
|
50
|
+
* Uses llms. subdomain and .md extension.
|
|
51
|
+
*/
|
|
52
|
+
export function getMarkdownUrl(route: string, baseUrl?: string): string {
|
|
53
|
+
const base = baseUrl ?? 'https://contractspec.io/mdx';
|
|
54
|
+
const llmsBase = base.replace('contractspec.io', 'llms.contractspec.io');
|
|
55
|
+
|
|
56
|
+
// Normalize route
|
|
57
|
+
const normalizedRoute = route === '/' ? '/' : route.replace(/\/$/, '');
|
|
58
|
+
return `${llmsBase}${normalizedRoute}`;
|
|
59
|
+
|
|
60
|
+
// Add .md extension if not root
|
|
61
|
+
// const path = normalizedRoute === '/' ? '/index.md' : `${normalizedRoute}.md`;
|
|
62
|
+
// return `${llmsBase}${path}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get AI chat URLs for various providers.
|
|
67
|
+
*/
|
|
68
|
+
export interface AIChatProvider {
|
|
69
|
+
name: string;
|
|
70
|
+
getUrl: (url: string) => string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const aiChatProviders: AIChatProvider[] = [
|
|
74
|
+
{
|
|
75
|
+
name: 'ChatGPT',
|
|
76
|
+
getUrl: (url: string) =>
|
|
77
|
+
`https://chatgpt.com/?q=${encodeURIComponent(url)}`,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'Claude',
|
|
81
|
+
getUrl: (url: string) =>
|
|
82
|
+
`https://claude.ai/new?url=${encodeURIComponent(url)}`,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Grok',
|
|
86
|
+
getUrl: (url: string) =>
|
|
87
|
+
`https://x.com/i/grok?url=${encodeURIComponent(url)}`,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'Mistral',
|
|
91
|
+
getUrl: (url: string) =>
|
|
92
|
+
`https://mistral.ai/chat?url=${encodeURIComponent(url)}`,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'Perplexity',
|
|
96
|
+
getUrl: (url: string) =>
|
|
97
|
+
`https://www.perplexity.ai/?q=${encodeURIComponent(url)}`,
|
|
98
|
+
},
|
|
99
|
+
];
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@contractspec/tool.typescript/react-library.json",
|
|
3
|
+
"include": ["src/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@/*": ["./src/*"]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|