@gradial/aci 0.1.20-preview.3 → 0.1.20

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 (224) hide show
  1. package/README.md +48 -108
  2. package/bin/{aci → aci-darwin-arm64} +0 -0
  3. package/bin/aci.js +99 -6
  4. package/dist/assets/index.d.ts +3 -3
  5. package/dist/assets/index.js +3 -3
  6. package/dist/astro/index.d.ts +12 -3
  7. package/dist/astro/index.js +20 -5
  8. package/dist/content/assets.d.ts +17 -0
  9. package/dist/content/assets.js +65 -0
  10. package/dist/content/index.d.ts +1 -0
  11. package/dist/content/index.js +1 -0
  12. package/dist/define-component.d.ts +1 -2
  13. package/dist/define-component.js +73 -5
  14. package/dist/dev/content-watch.d.ts +37 -0
  15. package/dist/dev/content-watch.js +154 -0
  16. package/dist/dev/index.d.ts +24 -43
  17. package/dist/dev/index.js +4 -169
  18. package/dist/index.d.ts +14 -6
  19. package/dist/index.js +8 -9
  20. package/dist/next/asset-route.js +2 -2
  21. package/dist/next/config.d.ts +2 -2
  22. package/dist/next/config.js +5 -5
  23. package/dist/next/content-watch.js +6 -1
  24. package/dist/next/index.d.ts +2 -2
  25. package/dist/next/index.js +2 -2
  26. package/dist/next/middleware.d.ts +2 -2
  27. package/dist/next/middleware.js +6 -6
  28. package/dist/next/page.d.ts +1 -1
  29. package/dist/next/page.js +14 -12
  30. package/dist/next/render.d.ts +3 -3
  31. package/dist/next/render.js +11 -9
  32. package/dist/next/server.d.ts +12 -12
  33. package/dist/next/server.js +1 -1
  34. package/dist/react/Media.d.ts +24 -0
  35. package/dist/react/Media.js +30 -0
  36. package/dist/react/Picture.d.ts +12 -0
  37. package/dist/react/Picture.js +11 -0
  38. package/dist/react/VideoPlayer.d.ts +13 -0
  39. package/dist/react/{GradialVideoPlayer.js → VideoPlayer.js} +6 -5
  40. package/dist/react/index.d.ts +333 -3
  41. package/dist/react/index.js +89 -3
  42. package/dist/registry.d.ts +2 -2
  43. package/dist/registry.js +3 -3
  44. package/dist/types/block-ref.d.ts +26 -0
  45. package/dist/types/block-ref.js +28 -0
  46. package/dist/types/component.d.ts +36 -32
  47. package/dist/types/config.d.ts +1 -1
  48. package/dist/types/image.d.ts +33 -20
  49. package/dist/types/image.js +42 -50
  50. package/dist/types/index.d.ts +1 -0
  51. package/dist/types/index.js +1 -0
  52. package/dist/types/link.d.ts +38 -0
  53. package/dist/types/link.js +58 -0
  54. package/dist/types/media.d.ts +16 -35
  55. package/dist/types/media.js +15 -84
  56. package/dist/types/renderer.d.ts +1 -1
  57. package/dist/types/rich-text.d.ts +40 -0
  58. package/dist/types/rich-text.js +39 -0
  59. package/dist/types/video.d.ts +7 -13
  60. package/dist/types/video.js +3 -3
  61. package/package.json +28 -76
  62. package/src/cli/compile-registry.mjs +120 -63
  63. package/src/cli/validate-content.mjs +38 -75
  64. package/src/types/image.ts +79 -60
  65. package/templates/astro/template/.aci.yaml +27 -0
  66. package/templates/astro/template/.storybook/main.ts +79 -0
  67. package/templates/astro/template/.storybook/manager.ts +6 -0
  68. package/templates/astro/template/.storybook/preview.ts +33 -0
  69. package/templates/astro/template/astro.config.mjs +37 -0
  70. package/templates/astro/template/package.json.tmpl +41 -0
  71. package/templates/astro/template/src/cms/contracts/layouts/index.ts +18 -0
  72. package/templates/astro/template/src/cms/registry.ts +28 -0
  73. package/templates/astro/template/src/components/chrome/Footer.astro +107 -0
  74. package/templates/astro/template/src/components/chrome/Header.astro +94 -0
  75. package/templates/astro/template/src/components/elements/AtomicBlock.astro +15 -0
  76. package/templates/astro/template/src/components/elements/AtomicBlocks.astro +16 -0
  77. package/templates/astro/template/src/components/elements/Button.astro +51 -0
  78. package/templates/astro/template/src/components/elements/ButtonBlock.astro +25 -0
  79. package/templates/astro/template/src/components/elements/Container.astro +11 -0
  80. package/templates/astro/template/src/components/elements/Icon.astro +31 -0
  81. package/templates/astro/template/src/components/elements/Logo.astro +29 -0
  82. package/templates/astro/template/src/components/elements/RemoteImage.astro +41 -0
  83. package/templates/astro/template/src/components/sections/ContainerSection.astro +32 -0
  84. package/templates/astro/template/src/components/sections/FeatureCard.astro +23 -0
  85. package/templates/astro/template/src/components/sections/FeatureGrid.astro +35 -0
  86. package/templates/astro/template/src/components/sections/HomeHero.astro +51 -0
  87. package/templates/astro/template/src/components/sections/StatsBar.astro +33 -0
  88. package/templates/astro/template/src/design-system/styles.css +399 -0
  89. package/templates/astro/template/src/design-system/tokens/colors.css +60 -0
  90. package/templates/astro/template/src/design-system/tokens/components.css +69 -0
  91. package/templates/astro/template/src/design-system/tokens/index.css +6 -0
  92. package/templates/astro/template/src/design-system/tokens/radii.css +5 -0
  93. package/templates/astro/template/src/design-system/tokens/shadows.css +5 -0
  94. package/templates/astro/template/src/design-system/tokens/spacing.css +13 -0
  95. package/templates/astro/template/src/design-system/tokens/typography.css +24 -0
  96. package/templates/astro/template/src/env.d.ts +1 -0
  97. package/templates/astro/template/src/fixtures/atomicBlocks.ts +33 -0
  98. package/templates/astro/template/src/fixtures/composition.ts +31 -0
  99. package/templates/astro/template/src/fixtures/index.ts +17 -0
  100. package/templates/astro/template/src/fixtures/sections.ts +39 -0
  101. package/templates/astro/template/src/layouts/SiteLayout.astro +30 -0
  102. package/templates/astro/template/src/pages/[...slug].astro +61 -0
  103. package/templates/astro/template/src/render/RenderPage.astro +66 -0
  104. package/templates/astro/template/src/stories/CompositionStoryFrame.astro +15 -0
  105. package/templates/astro/template/src/stories/HomeHero.stories.ts +24 -0
  106. package/templates/astro/template/src/stories/SectionStoryFrame.astro +16 -0
  107. package/templates/astro/template/src/stories/StoryDocFrame.astro +31 -0
  108. package/templates/astro/template/tsconfig.json +11 -0
  109. package/templates/common/.agents/AGENTS.md +37 -0
  110. package/templates/common/.agents/skills/aci/SKILL.md +162 -0
  111. package/templates/common/.agents/skills/authoring/SKILL.md +590 -0
  112. package/templates/common/.agents/skills/authoring/references/block-registry.md +151 -0
  113. package/templates/common/.agents/skills/authoring/references/contracts.md +153 -0
  114. package/templates/common/.agents/skills/authoring/references/design-system.md +171 -0
  115. package/templates/common/.agents/skills/authoring/references/image-assets.md +73 -0
  116. package/templates/common/.agents/skills/authoring/references/repo-structure.md +157 -0
  117. package/templates/common/.agents/skills/migration/SKILL.md +160 -0
  118. package/templates/common/.agents/skills/migration/references/analyzing-source.md +215 -0
  119. package/templates/common/.agents/skills/migration/references/component-migration.md +200 -0
  120. package/templates/common/.agents/skills/migration/references/selector-map.md +31 -0
  121. package/templates/common/.content/.gradial-dam/blobs/sha256/7f/bf/7fbfc7fe230ff12688c496f660119e41d9725c4504d82e310c15665c73c09292 +0 -0
  122. package/templates/common/.content/.gradial-dam/blobs/sha256/a0/f5/a0f506689de9b15a7055f70103a3f02cd3ba105771ae2de6754df2ede1210d3a +0 -0
  123. package/templates/common/.content/.gradial-dam/blobs/sha256/dd/b7/ddb7e9642be08317bcd4b2bd26b58ba8d0d34dd7239e03e684a4f3634fa3845b +0 -0
  124. package/templates/common/.content/.gradial-dam/blobs/sha256/fb/32/fb3260e8286ea8231ea1c77b9c0be92d6edd9026565731eb14cfdcfd6b1b75b3 +0 -0
  125. package/templates/common/.content/config/site.json +192 -0
  126. package/templates/common/.content/dam/folders/seed/ast_site_about_hero/asset.json +9 -0
  127. package/templates/common/.content/dam/folders/seed/ast_site_about_hero/editorial.json +14 -0
  128. package/templates/common/.content/dam/folders/seed/ast_site_about_hero/governance.json +23 -0
  129. package/templates/common/.content/dam/folders/seed/ast_site_about_hero/versions/v0001.json +37 -0
  130. package/templates/common/.content/dam/folders/seed/ast_site_home_hero/asset.json +9 -0
  131. package/templates/common/.content/dam/folders/seed/ast_site_home_hero/editorial.json +14 -0
  132. package/templates/common/.content/dam/folders/seed/ast_site_home_hero/governance.json +23 -0
  133. package/templates/common/.content/dam/folders/seed/ast_site_home_hero/versions/v0001.json +37 -0
  134. package/templates/common/.content/fragments/navbar/_index.json +25 -0
  135. package/templates/common/.content/fragments/site-footer/_index.json +62 -0
  136. package/templates/common/.content/pages/about/_index.json +51 -0
  137. package/templates/common/.content/pages/home/_index.json +112 -0
  138. package/templates/common/.content/schemas/site.schema.json +123 -0
  139. package/templates/common/README.md.tmpl +45 -0
  140. package/templates/common/contracts/components/button.contract.ts +19 -0
  141. package/templates/common/contracts/components/container.contract.ts +19 -0
  142. package/templates/common/contracts/components/featureCard.contract.ts +15 -0
  143. package/templates/common/contracts/components/featureGrid.contract.ts +16 -0
  144. package/templates/common/contracts/components/homeHero.contract.ts +36 -0
  145. package/templates/common/contracts/components/index.ts +21 -0
  146. package/templates/common/contracts/components/siteFooter.contract.ts +45 -0
  147. package/templates/common/contracts/components/siteNavigation.contract.ts +30 -0
  148. package/templates/common/contracts/components/statsBar.contract.ts +19 -0
  149. package/templates/common/design-system/styles.css +346 -0
  150. package/templates/common/design-system/tokens/colors.css +110 -0
  151. package/templates/common/design-system/tokens/components.css +86 -0
  152. package/templates/common/design-system/tokens/index.css +6 -0
  153. package/templates/common/design-system/tokens/radii.css +5 -0
  154. package/templates/common/design-system/tokens/shadows.css +9 -0
  155. package/templates/common/design-system/tokens/spacing.css +26 -0
  156. package/templates/common/design-system/tokens/typography.css +32 -0
  157. package/templates/common/eslint-rules/no-raw-tailwind-values.js +127 -0
  158. package/templates/common/public/assets/Dwire-model.png +0 -0
  159. package/templates/common/public/assets/bare-metal-logo.png +0 -0
  160. package/templates/common/public/assets/meridian-logo.svg +8 -0
  161. package/templates/common/public/assets/seattle.avif +0 -0
  162. package/templates/nextjs/template/.aci.yaml +25 -0
  163. package/templates/nextjs/template/.storybook/main.ts +13 -0
  164. package/templates/nextjs/template/.storybook/preview.ts +34 -0
  165. package/templates/nextjs/template/eslint.config.mjs +36 -0
  166. package/templates/nextjs/template/next-env.d.ts +6 -0
  167. package/templates/nextjs/template/next.config.ts +8 -0
  168. package/templates/nextjs/template/package.json.tmpl +46 -0
  169. package/templates/nextjs/template/postcss.config.mjs +7 -0
  170. package/templates/nextjs/template/src/app/[[...slug]]/page.tsx +8 -0
  171. package/templates/nextjs/template/src/app/gradial/assets/[releaseId]/[...path]/route.ts +31 -0
  172. package/templates/nextjs/template/src/app/layout.tsx +29 -0
  173. package/templates/nextjs/template/src/cms/contracts/components/button.contract.ts +19 -0
  174. package/templates/nextjs/template/src/cms/contracts/components/container.contract.ts +20 -0
  175. package/templates/nextjs/template/src/cms/contracts/components/homeHero.contract.ts +36 -0
  176. package/templates/nextjs/template/src/cms/contracts/components/index.ts +15 -0
  177. package/templates/nextjs/template/src/cms/contracts/components/siteFooter.contract.ts +45 -0
  178. package/templates/nextjs/template/src/cms/contracts/components/siteNavigation.contract.ts +30 -0
  179. package/templates/nextjs/template/src/cms/contracts/layouts/index.ts +16 -0
  180. package/templates/nextjs/template/src/cms/registry.ts +28 -0
  181. package/templates/nextjs/template/src/components/chrome/Footer.tsx +86 -0
  182. package/templates/nextjs/template/src/components/chrome/Header.tsx +74 -0
  183. package/templates/nextjs/template/src/components/elements/AtomicBlock.tsx +13 -0
  184. package/templates/nextjs/template/src/components/elements/Button.tsx +40 -0
  185. package/templates/nextjs/template/src/components/elements/ButtonBlock.tsx +18 -0
  186. package/templates/nextjs/template/src/components/elements/Container.tsx +14 -0
  187. package/templates/nextjs/template/src/components/elements/Icon.tsx +29 -0
  188. package/templates/nextjs/template/src/components/elements/Logo.tsx +38 -0
  189. package/templates/nextjs/template/src/components/sections/ContainerSection.tsx +28 -0
  190. package/templates/nextjs/template/src/components/sections/FeatureCard.tsx +25 -0
  191. package/templates/nextjs/template/src/components/sections/FeatureGrid.tsx +36 -0
  192. package/templates/nextjs/template/src/components/sections/HomeHero.tsx +62 -0
  193. package/templates/nextjs/template/src/components/sections/StatsBar.tsx +30 -0
  194. package/templates/nextjs/template/src/middleware.ts +4 -0
  195. package/templates/nextjs/template/src/stories/Button.stories.tsx +38 -0
  196. package/templates/nextjs/template/src/stories/Header.stories.tsx +30 -0
  197. package/templates/nextjs/template/src/stories/HomeHero.stories.tsx +33 -0
  198. package/templates/nextjs/template/tsconfig.json +23 -0
  199. package/templates/nextjs/template/vercel.json +6 -0
  200. package/dist/content/contract.d.ts +0 -83
  201. package/dist/content/contract.js +0 -104
  202. package/dist/content/tailwind-validator.d.ts +0 -6
  203. package/dist/content/tailwind-validator.js +0 -31
  204. package/dist/content/validation.d.ts +0 -108
  205. package/dist/content/validation.js +0 -183
  206. package/dist/react/GradialMedia.d.ts +0 -24
  207. package/dist/react/GradialMedia.js +0 -31
  208. package/dist/react/GradialPicture.d.ts +0 -14
  209. package/dist/react/GradialPicture.js +0 -30
  210. package/dist/react/GradialVideoPlayer.d.ts +0 -13
  211. package/dist/sveltekit/index.d.ts +0 -25
  212. package/dist/sveltekit/index.js +0 -66
  213. package/dist/sveltekit/preview.d.ts +0 -5
  214. package/dist/sveltekit/preview.js +0 -33
  215. package/src/types/component.ts +0 -49
  216. package/src/types/config.ts +0 -37
  217. package/src/types/data.ts +0 -47
  218. package/src/types/index.ts +0 -10
  219. package/src/types/layout.ts +0 -29
  220. package/src/types/media.ts +0 -125
  221. package/src/types/page.ts +0 -47
  222. package/src/types/render-mode.ts +0 -10
  223. package/src/types/renderer.ts +0 -83
  224. package/src/types/video.ts +0 -66
@@ -1,66 +0,0 @@
1
- import { gradialContentWatchPlugin, gradialDamAssetPlugin, devRefreshPort, devRefreshScriptTag, } from '../dev/index.js';
2
- import { getPendingRenderInputFromHeaders } from '../runtime/page.js';
3
- // ---------------------------------------------------------------------------
4
- // Entries helper — for SvelteKit SSG prerendering
5
- // ---------------------------------------------------------------------------
6
- /**
7
- * Generates prerender entries from the compiled content manifest for SvelteKit.
8
- *
9
- * Usage in svelte.config.js:
10
- * ```js
11
- * import { gradialEntries } from '@gradial/aci/sveltekit';
12
- * export default { kit: { prerender: { entries: await gradialEntries() } } };
13
- * ```
14
- *
15
- * Or in a catch-all `+page.server.ts`:
16
- * ```ts
17
- * import { gradialEntries } from '@gradial/aci/sveltekit';
18
- * export const entries = gradialEntries;
19
- * ```
20
- */
21
- export async function gradialEntries() {
22
- const { FileContentProvider } = await import('../providers/file.js');
23
- const { normalizeRoute } = await import('../content/routes.js');
24
- const provider = new FileContentProvider();
25
- const routes = await provider.listRoutes();
26
- return routes.map((entry) => {
27
- const normalized = normalizeRoute(entry.path);
28
- return normalized === '/' ? '/' : `/${normalized.replace(/^\/|\/$/g, '')}/`;
29
- });
30
- }
31
- export function getPageRuntimeRenderInput(event) {
32
- return getPendingRenderInputFromHeaders(event.request.headers);
33
- }
34
- // ---------------------------------------------------------------------------
35
- // Registry helpers
36
- // ---------------------------------------------------------------------------
37
- export { createRegistry, registryLookup } from '../registry.js';
38
- // ---------------------------------------------------------------------------
39
- // Preview support
40
- // ---------------------------------------------------------------------------
41
- export { getPreviewMode, createPreviewBannerHTML, createPreviewCookies, } from './preview.js';
42
- // ---------------------------------------------------------------------------
43
- // SvelteKit Vite plugin
44
- // ---------------------------------------------------------------------------
45
- export function withGradialAci(options = {}) {
46
- const watchPlugin = gradialContentWatchPlugin(options);
47
- const damAssetPlugin = gradialDamAssetPlugin(options);
48
- return {
49
- ...watchPlugin,
50
- name: 'gradial-sveltekit',
51
- configureServer(server) {
52
- damAssetPlugin.configureServer?.(server);
53
- watchPlugin.configureServer?.(server);
54
- },
55
- transformIndexHtml(html) {
56
- if (process.env.NODE_ENV === 'production') {
57
- return html;
58
- }
59
- if (devRefreshPort(options) <= 0) {
60
- return html;
61
- }
62
- const script = devRefreshScriptTag(options);
63
- return html.includes('</body>') ? html.replace('</body>', `${script}</body>`) : `${html}${script}`;
64
- },
65
- };
66
- }
@@ -1,5 +0,0 @@
1
- import { type PreviewContext, type PreviewCookie } from '../preview/core.js';
2
- export declare function getPreviewMode(request: Request, siteId: string): Promise<PreviewContext>;
3
- export declare function createPreviewBannerHTML(releaseId: string): string;
4
- export declare function createPreviewCookies(token: string, releaseId: string): PreviewCookie[];
5
- export type { PreviewContext, PreviewCookie };
@@ -1,33 +0,0 @@
1
- import { extractPreviewToken, resolvePreviewContext, createPreviewBannerHTML as coreCreatePreviewBannerHTML, createPreviewCookies as coreCreatePreviewCookies, previewSignKey, } from '../preview/core.js';
2
- export async function getPreviewMode(request, siteId) {
3
- const url = new URL(request.url);
4
- const token = extractPreviewToken({
5
- query: url.searchParams,
6
- cookies: parseCookieHeader(request.headers.get('cookie') || ''),
7
- authorization: request.headers.get('authorization') || undefined,
8
- });
9
- if (!token)
10
- return { isPreview: false };
11
- return resolvePreviewContext({ token, siteId, signKey: previewSignKey() });
12
- }
13
- export function createPreviewBannerHTML(releaseId) {
14
- return coreCreatePreviewBannerHTML(releaseId);
15
- }
16
- export function createPreviewCookies(token, releaseId) {
17
- return coreCreatePreviewCookies(token, releaseId);
18
- }
19
- function parseCookieHeader(header) {
20
- const cookies = new Map();
21
- for (const part of header.split(';')) {
22
- const trimmed = part.trim();
23
- if (!trimmed)
24
- continue;
25
- const idx = trimmed.indexOf('=');
26
- if (idx < 0)
27
- continue;
28
- const name = trimmed.slice(0, idx).trim();
29
- const value = trimmed.slice(idx + 1).trim();
30
- cookies.set(name, decodeURIComponent(value));
31
- }
32
- return cookies;
33
- }
@@ -1,49 +0,0 @@
1
- import type { IslandMode, VaryDimension } from './render-mode.js';
2
- import type { ImageSlotContract } from './image.js';
3
- import type { z } from 'zod';
4
-
5
- /**
6
- * A CMS-registered component — sync or async (server components).
7
- * Accepts content props derived from the Zod schema.
8
- */
9
- type CmsComponentFn<TProps = any> =
10
- | ((props: TProps) => import('react').ReactElement | null)
11
- | ((props: TProps) => Promise<import('react').ReactElement | null>);
12
-
13
- /**
14
- * Infers the props type from a schema.
15
- * If TSchema is a Zod type, returns z.infer<TSchema>.
16
- * Otherwise returns Record<string, unknown>.
17
- */
18
- type InferContentProps<TSchema> = TSchema extends z.ZodType<infer T> ? T : Record<string, unknown>;
19
-
20
- export interface ComponentDefinition<TSchema = unknown> {
21
- name: string;
22
- /**
23
- * The React component that renders this CMS block.
24
- * Accepts at least the schema-derived props, but may accept additional
25
- * composition params (className, etc.) passed by parent sections.
26
- */
27
- component?: CmsComponentFn<any>;
28
- schema: TSchema;
29
- defaultIslandMode?: IslandMode;
30
- varyDimensions?: VaryDimension[];
31
- vary?: VaryDimension[];
32
- imageSlots?: Record<string, ImageSlotContract>;
33
- }
34
-
35
- export interface ComponentContract<TSchema = unknown> {
36
- name: string;
37
- component?: CmsComponentFn<any>;
38
- schema: TSchema;
39
- defaultIslandMode?: IslandMode;
40
- varyDimensions?: VaryDimension[];
41
- vary?: VaryDimension[];
42
- imageSlots?: Record<string, ImageSlotContract>;
43
- }
44
-
45
- export type InferComponentProps<TContract> = TContract extends ComponentContract<infer TSchema>
46
- ? InferContentProps<TSchema>
47
- : Record<string, unknown>;
48
-
49
- export type { CmsComponentFn, InferContentProps };
@@ -1,37 +0,0 @@
1
- import type { RenderCapabilities } from './renderer.js';
2
-
3
- export interface BareMetalConfig {
4
- version: '1';
5
- siteId: string;
6
- framework: 'astro' | 'next' | 'sveltekit' | 'custom';
7
- source: {
8
- root: string;
9
- outDir?: string;
10
- publicDir?: string;
11
- };
12
- componentRegistry: string;
13
- dataRegistry?: string;
14
- layoutRegistry: string;
15
- capabilities: RenderCapabilities;
16
- routes: RouteConfig;
17
- dam?: DAMConfig;
18
- externalDependencies?: ExternalDependency[];
19
- rendererProtocol: 'http' | 'stdio-json';
20
- }
21
-
22
- export interface RouteConfig {
23
- cmsManaged: string;
24
- frameworkOwned?: string[];
25
- }
26
-
27
- export interface ExternalDependency {
28
- name: string;
29
- host: string;
30
- kind?: 'api' | 'client-script';
31
- description?: string;
32
- cacheTTL?: number;
33
- }
34
-
35
- export interface DAMConfig {
36
- autoApproveUploads?: boolean;
37
- }
package/src/types/data.ts DELETED
@@ -1,47 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- type InferDataProps<TSchema> = TSchema extends z.ZodType<infer T>
4
- ? T
5
- : Record<string, unknown>;
6
-
7
- const dataRefPattern = /^\$ref:data\/[A-Za-z0-9][A-Za-z0-9_./-]*$/;
8
-
9
- export interface DataModelDefinition<TSchema = unknown, TType extends string = string> {
10
- type: TType;
11
- schema: TSchema;
12
- }
13
-
14
- export interface DataModelContract<TSchema = unknown, TType extends string = string> {
15
- type: TType;
16
- schema: TSchema;
17
- }
18
-
19
- export interface DataEntry<TProps = Record<string, unknown>, TType extends string = string> {
20
- $type: TType;
21
- props: TProps;
22
- }
23
-
24
- export type InferDataModelProps<TContract> = TContract extends DataModelContract<infer TSchema, string>
25
- ? InferDataProps<TSchema>
26
- : Record<string, unknown>;
27
-
28
- export type InferDataModelType<TContract> = TContract extends DataModelContract<unknown, infer TType>
29
- ? TType
30
- : string;
31
-
32
- export type DataModelRef<TContract extends DataModelContract> = DataEntry<
33
- InferDataModelProps<TContract>,
34
- InferDataModelType<TContract>
35
- >;
36
-
37
- export function dataModelRef<TContract extends DataModelContract<z.ZodTypeAny>>(
38
- contract: TContract,
39
- ): z.ZodType<DataModelRef<TContract>> {
40
- return z.union([
41
- z.string().regex(dataRefPattern, `expected a $ref:data/... pointer for ${contract.type}`),
42
- z.object({
43
- $type: z.literal(contract.type),
44
- props: contract.schema,
45
- }),
46
- ]).describe(`data model reference: ${contract.type}`) as unknown as z.ZodType<DataModelRef<TContract>>;
47
- }
@@ -1,10 +0,0 @@
1
- export * from './config.js';
2
- export * from './component.js';
3
- export * from './data.js';
4
- export * from './layout.js';
5
- export * from './page.js';
6
- export * from './renderer.js';
7
- export * from './render-mode.js';
8
- export * from './image.js';
9
- export * from './video.js';
10
- export * from './media.js';
@@ -1,29 +0,0 @@
1
- import type { FragmentRefNode } from './page.js';
2
-
3
- export interface LayoutSlot {
4
- name: string;
5
- required: boolean;
6
- }
7
-
8
- /** Default content for non-required layout slots, keyed by slot name. */
9
- export type LayoutDefaults = Record<string, FragmentRefNode[]>;
10
-
11
- export interface LayoutDefinition {
12
- name: string;
13
- slots: LayoutSlot[];
14
- /** Default fragment references for slots not provided by the page. */
15
- defaults?: LayoutDefaults;
16
- }
17
-
18
- export interface LayoutContract {
19
- name: string;
20
- slots: LayoutSlot[];
21
- defaults?: LayoutDefaults;
22
- }
23
-
24
- /** A compiled layout file as stored on disk. */
25
- export interface CompiledLayout {
26
- name: string;
27
- slots: LayoutSlot[];
28
- defaults: LayoutDefaults;
29
- }
@@ -1,125 +0,0 @@
1
- import { z } from 'zod';
2
- import { GradialImageSchema, renderImageHTML, type GradialImage } from './image.js';
3
- import { GradialVideoSchema, type GradialVideo } from './video.js';
4
-
5
- // ---------------------------------------------------------------------------
6
- // GradialAsset — union of all DAM-backed asset types
7
- //
8
- // Content authors write: { "$type": "dam.assetRef", "assetId": "..." }
9
- // The compiler resolves this to a GradialImage or GradialVideo based on
10
- // the asset's media type in the DAM.
11
- // ---------------------------------------------------------------------------
12
-
13
- /** Discriminated union of all compiler-resolved asset types. */
14
- export type GradialAsset = GradialImage | GradialVideo;
15
-
16
- // ---------------------------------------------------------------------------
17
- // Zod schema — discriminated on $type
18
- // ---------------------------------------------------------------------------
19
-
20
- export const GradialAssetSchema = z.discriminatedUnion('$type', [
21
- GradialImageSchema,
22
- GradialVideoSchema,
23
- ]);
24
-
25
- // ---------------------------------------------------------------------------
26
- // Type guards
27
- // ---------------------------------------------------------------------------
28
-
29
- export function isGradialImage(value: unknown): value is GradialImage {
30
- return (
31
- typeof value === 'object' &&
32
- value !== null &&
33
- (value as Record<string, unknown>).$type === 'gradial.image'
34
- );
35
- }
36
-
37
- export function isGradialVideo(value: unknown): value is GradialVideo {
38
- return (
39
- typeof value === 'object' &&
40
- value !== null &&
41
- (value as Record<string, unknown>).$type === 'gradial.video'
42
- );
43
- }
44
-
45
- export function isGradialAsset(value: unknown): value is GradialAsset {
46
- return isGradialImage(value) || isGradialVideo(value);
47
- }
48
-
49
- // ---------------------------------------------------------------------------
50
- // HTML string renderers (framework-agnostic)
51
- // ---------------------------------------------------------------------------
52
-
53
- /**
54
- * Renders a GradialVideo to an HTML string.
55
- * Uses poster.fallback.src for the poster attribute.
56
- * Includes <source> elements for format variants.
57
- */
58
- export function renderVideoHTML(
59
- video: GradialVideo,
60
- attrs: Record<string, string | number | boolean | undefined | null> = {},
61
- ): string {
62
- const posterSrc = video.poster?.fallback.src;
63
- const attrPairs: Array<[string, string | number | boolean | undefined | null]> = [
64
- ...Object.entries(attrs),
65
- ['src', video.sources?.length ? undefined : video.src],
66
- ['poster', posterSrc],
67
- ['width', video.width > 0 ? video.width : undefined],
68
- ['height', video.height > 0 ? video.height : undefined],
69
- ];
70
- const attrString = renderAttrs(attrPairs);
71
-
72
- const sources = (video.sources ?? [])
73
- .map((s) => `<source${renderAttrs([['src', s.src], ['type', s.type]])}>`)
74
- .join('');
75
-
76
- // If no format variants, src is on the <video> element itself
77
- if (!sources) {
78
- return `<video${attrString}></video>`;
79
- }
80
- return `<video${attrString}>${sources}</video>`;
81
- }
82
-
83
- /**
84
- * Renders any GradialAsset to an HTML string.
85
- * Delegates to renderImageHTML or renderVideoHTML based on $type.
86
- */
87
- export function renderAssetHTML(
88
- asset: GradialAsset,
89
- attrs: Record<string, string | number | boolean | undefined | null> = {},
90
- ): string {
91
- if (asset.$type === 'gradial.image') {
92
- return renderImageHTML(asset, attrs);
93
- }
94
- return renderVideoHTML(asset, attrs);
95
- }
96
-
97
- // ---------------------------------------------------------------------------
98
- // Internal helpers
99
- // ---------------------------------------------------------------------------
100
-
101
- function renderAttrs(
102
- pairs: Array<[string, string | number | boolean | undefined | null]>,
103
- ): string {
104
- const rendered = pairs
105
- .filter(([, value]) => value !== undefined && value !== null && value !== false)
106
- .map(([name, value]) =>
107
- value === true
108
- ? escapeName(name)
109
- : `${escapeName(name)}="${escapeAttr(String(value))}"`,
110
- );
111
- if (!rendered.length) return '';
112
- return ' ' + rendered.join(' ');
113
- }
114
-
115
- function escapeName(name: string): string {
116
- return name.replace(/[^A-Za-z0-9_:-]/g, '');
117
- }
118
-
119
- function escapeAttr(value: string): string {
120
- return value
121
- .replace(/&/g, '&amp;')
122
- .replace(/"/g, '&quot;')
123
- .replace(/</g, '&lt;')
124
- .replace(/>/g, '&gt;');
125
- }
package/src/types/page.ts DELETED
@@ -1,47 +0,0 @@
1
- import type { VaryDimension } from './render-mode.js';
2
-
3
- export interface PageDocument {
4
- path: string;
5
- layout: string;
6
- locale: string;
7
- metadata: PageMetadata;
8
- regions: Record<string, RegionNode>;
9
- }
10
-
11
- export interface PageMetadata {
12
- title: string;
13
- description?: string;
14
- openGraph?: Record<string, string>;
15
- canonicalUrl?: string;
16
- alternateLocales?: { locale: string; path: string }[];
17
- customHead?: string[];
18
- }
19
-
20
- export interface RegionNode {
21
- kind: 'region';
22
- name: string;
23
- children: Array<BlockNode | FragmentRefNode>;
24
- }
25
-
26
- export interface BlockNode {
27
- kind: 'block';
28
- id: string;
29
- component: string;
30
- props: Record<string, unknown>;
31
- renderHints: BlockRenderHints;
32
- contentRef?: string;
33
- }
34
-
35
- export interface BlockRenderHints {
36
- canStatic: boolean;
37
- needsSSR: boolean;
38
- isIsland: boolean;
39
- islandMode?: 'ssr' | 'client';
40
- varyDimensions?: VaryDimension[];
41
- }
42
-
43
- export interface FragmentRefNode {
44
- kind: 'fragment-ref';
45
- fragmentId: string;
46
- inline: boolean;
47
- }
@@ -1,10 +0,0 @@
1
- export type IslandMode = 'ssr' | 'client';
2
-
3
- export type VaryDimension =
4
- | 'geo:country'
5
- | 'geo:region'
6
- | 'geo:city'
7
- | `cookie:${string}`
8
- | `header:${string}`
9
- | 'locale'
10
- | `query:${string}`;
@@ -1,83 +0,0 @@
1
- import type { PageDocument } from './page.js';
2
- import type { VaryDimension } from './render-mode.js';
3
-
4
- export interface RenderCapabilities {
5
- staticRender: boolean;
6
- ssr: boolean;
7
- ssrIslands: boolean;
8
- clientIslands: boolean;
9
- fragmentRender: boolean;
10
- }
11
-
12
- export interface GradialRenderer {
13
- renderPage(request: RenderPageRequest): Promise<RenderPageResult>;
14
- renderFragment?(request: RenderFragmentRequest): Promise<RenderResult>;
15
- renderIsland?(request: RenderIslandRequest): Promise<RenderResult>;
16
- }
17
-
18
- export interface RenderPageRequest {
19
- page: PageDocument;
20
- requestContext?: RequestContext;
21
- release: ReleaseContext;
22
- }
23
-
24
- export interface RequestContext {
25
- url: string;
26
- method: string;
27
- headers: Record<string, string>;
28
- cookies: Record<string, string>;
29
- geo?: GeoContext;
30
- }
31
-
32
- export interface GeoContext {
33
- country?: string;
34
- region?: string;
35
- city?: string;
36
- }
37
-
38
- export interface ReleaseContext {
39
- releaseId: string;
40
- codeDigest: string;
41
- contentSnapshotId: string;
42
- assetUrl(logicalPath: string): string;
43
- }
44
-
45
- export interface RenderFragmentRequest {
46
- fragmentId: string;
47
- content: unknown;
48
- release: ReleaseContext;
49
- }
50
-
51
- export interface RenderIslandRequest {
52
- islandId: string;
53
- component: string;
54
- props: Record<string, unknown>;
55
- requestContext: RequestContext;
56
- release: ReleaseContext;
57
- }
58
-
59
- export interface RenderResult {
60
- html: string;
61
- status?: number;
62
- headers?: Record<string, string>;
63
- cachePolicy?: CachePolicy;
64
- }
65
-
66
- export interface RenderPageResult extends RenderResult {
67
- islands?: IslandDescriptor[];
68
- }
69
-
70
- export interface IslandDescriptor {
71
- islandId: string;
72
- component: string;
73
- props: Record<string, unknown>;
74
- mode: 'ssr' | 'client';
75
- varyDimensions?: VaryDimension[];
76
- }
77
-
78
- export interface CachePolicy {
79
- scope: 'public' | 'private' | 'no-store';
80
- ttl?: number;
81
- staleWhileRevalidate?: number;
82
- tags?: string[];
83
- }
@@ -1,66 +0,0 @@
1
- import { z } from 'zod';
2
- import { GradialImageSchema, type GradialImage } from './image.js';
3
-
4
- // ---------------------------------------------------------------------------
5
- // Video source variant (format alternatives)
6
- // ---------------------------------------------------------------------------
7
-
8
- export interface VideoSource {
9
- src: string;
10
- type: string; // MIME type: video/mp4, video/webm
11
- }
12
-
13
- // ---------------------------------------------------------------------------
14
- // GradialVideo — DAM-backed video asset with compiler-resolved derivatives
15
- // ---------------------------------------------------------------------------
16
-
17
- export interface GradialVideo {
18
- /** Discriminator — always 'gradial.video'. */
19
- $type: 'gradial.video';
20
- /** DAM asset identifier. */
21
- assetId: string;
22
- /** DAM version identifier. */
23
- versionId: string;
24
- /** Accessible description of the video content. */
25
- alt: string;
26
- /** Primary video URL (compiler-resolved). */
27
- src: string;
28
- /** Primary video MIME type (e.g. 'video/mp4'). */
29
- type: string;
30
- /** Intrinsic width in pixels. */
31
- width: number;
32
- /** Intrinsic height in pixels. */
33
- height: number;
34
- /**
35
- * Poster frame — a full GradialImage with responsive srcset.
36
- * The compiler extracts or generates this from the video asset.
37
- */
38
- poster?: GradialImage;
39
- /** Format variants (e.g. mp4 + webm). Maps to <video><source> elements. */
40
- sources?: VideoSource[];
41
- /** Duration in seconds (if known). */
42
- duration?: number;
43
- }
44
-
45
- // ---------------------------------------------------------------------------
46
- // Zod schema
47
- // ---------------------------------------------------------------------------
48
-
49
- export const VideoSourceSchema = z.object({
50
- src: z.string().min(1),
51
- type: z.string().min(1),
52
- });
53
-
54
- export const GradialVideoSchema = z.object({
55
- $type: z.literal('gradial.video'),
56
- assetId: z.string().min(1),
57
- versionId: z.string().min(1),
58
- alt: z.string(),
59
- src: z.string().min(1),
60
- type: z.string().min(1),
61
- width: z.number().int().nonnegative(),
62
- height: z.number().int().nonnegative(),
63
- poster: GradialImageSchema.optional(),
64
- sources: z.array(VideoSourceSchema).optional(),
65
- duration: z.number().nonnegative().optional(),
66
- });