@gradial/aci 0.1.19 → 0.1.20-preview.2

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 (46) hide show
  1. package/README.md +22 -0
  2. package/bin/aci +0 -0
  3. package/dist/astro/index.d.ts +2 -2
  4. package/dist/astro/index.js +5 -1
  5. package/dist/astro/preview.d.ts +5 -0
  6. package/dist/astro/preview.js +33 -0
  7. package/dist/content/cache.test.d.ts +1 -0
  8. package/dist/content/cache.test.js +86 -0
  9. package/dist/define-data-model.d.ts +2 -0
  10. package/dist/define-data-model.js +3 -0
  11. package/dist/dev/index.d.ts +12 -0
  12. package/dist/dev/index.js +84 -9
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +1 -0
  15. package/dist/next/config.d.ts +1 -1
  16. package/dist/next/config.js +13 -1
  17. package/dist/next/content-watch.d.ts +11 -0
  18. package/dist/next/content-watch.js +106 -0
  19. package/dist/next/index.d.ts +2 -2
  20. package/dist/next/index.js +2 -2
  21. package/dist/next/middleware.js +34 -50
  22. package/dist/next/page.d.ts +40 -0
  23. package/dist/next/page.js +59 -0
  24. package/dist/next/preview-mode.js +4 -8
  25. package/dist/next/server.js +0 -6
  26. package/dist/preview/core.d.ts +41 -0
  27. package/dist/preview/core.js +116 -0
  28. package/dist/sveltekit/index.d.ts +2 -1
  29. package/dist/sveltekit/index.js +5 -1
  30. package/dist/sveltekit/preview.d.ts +5 -0
  31. package/dist/sveltekit/preview.js +33 -0
  32. package/dist/types/config.d.ts +1 -0
  33. package/dist/types/data.d.ts +19 -0
  34. package/dist/types/data.js +11 -0
  35. package/dist/types/image.d.ts +1 -1
  36. package/dist/types/image.js +1 -1
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/index.js +1 -0
  39. package/package.json +24 -1
  40. package/src/cli/compile-registry.mjs +40 -1
  41. package/src/types/config.ts +1 -0
  42. package/src/types/data.ts +47 -0
  43. package/src/types/image.ts +2 -2
  44. package/src/types/index.ts +1 -0
  45. package/dist/render.d.ts +0 -14
  46. package/dist/render.js +0 -33
@@ -20,7 +20,7 @@ export interface GradialImage {
20
20
  versionId: string;
21
21
  alt: string;
22
22
  fallback: ImageSource;
23
- sources: PictureSource[];
23
+ sources: PictureSource[] | null;
24
24
  }
25
25
 
26
26
  export interface ImageSlotContract {
@@ -65,7 +65,7 @@ export function renderImageHTML(image: GradialImage, attrs: ImageHTMLAttributes
65
65
  height: image.fallback.height > 0 ? image.fallback.height : undefined,
66
66
  });
67
67
  const img = `<img${imgAttrs}>`;
68
- if (!image.sources.length) {
68
+ if (!image.sources?.length) {
69
69
  return img;
70
70
  }
71
71
  const sources = image.sources.map((source) => `<source${renderAttrs({
@@ -1,5 +1,6 @@
1
1
  export * from './config.js';
2
2
  export * from './component.js';
3
+ export * from './data.js';
3
4
  export * from './layout.js';
4
5
  export * from './page.js';
5
6
  export * from './renderer.js';
package/dist/render.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { ComponentType, ReactNode } from 'react';
2
- export interface BlockData {
3
- id: string;
4
- component: string;
5
- props: Record<string, unknown>;
6
- }
7
- export type ComponentRegistry = Record<string, ComponentType<any>>;
8
- export interface RenderBlocksOptions {
9
- registry: ComponentRegistry;
10
- compositionParams?: Record<string, unknown>;
11
- slot?: string;
12
- }
13
- export declare function renderBlock(block: BlockData, registry: ComponentRegistry, compositionParams?: Record<string, unknown>): ReactNode;
14
- export declare function renderBlocks(blocks: readonly BlockData[], opts: RenderBlocksOptions): ReactNode[];
package/dist/render.js DELETED
@@ -1,33 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { PreviewBanner } from './next/preview-banner.js';
3
- function BlockError({ component, id }) {
4
- return (_jsxs("div", { style: {
5
- padding: '1rem 1.25rem',
6
- margin: '1rem 0',
7
- background: '#fef2f2',
8
- border: '2px solid #dc2626',
9
- borderRadius: '6px',
10
- fontFamily: 'ui-monospace, monospace',
11
- fontSize: '13px',
12
- lineHeight: 1.5,
13
- color: '#991b1b',
14
- }, children: [_jsx("strong", { children: "Unknown block:" }), " ", _jsx("code", { children: component }), _jsx("br", {}), _jsxs("span", { style: { color: '#b91c1c', opacity: 0.7 }, children: ["id: ", id] })] }));
15
- }
16
- export function renderBlock(block, registry, compositionParams) {
17
- const Component = registry[block.component];
18
- if (!Component) {
19
- if (process.env.NODE_ENV !== 'production') {
20
- return _jsx(BlockError, { component: block.component, id: block.id }, block.id);
21
- }
22
- return null;
23
- }
24
- return _jsx(Component, { ...block.props, ...compositionParams }, block.id);
25
- }
26
- export function renderBlocks(blocks, opts) {
27
- const { registry, compositionParams, slot } = opts;
28
- const rendered = blocks.map((block) => renderBlock(block, registry, compositionParams));
29
- if (slot === 'main') {
30
- return [_jsx(PreviewBanner, {}, "__gradial_preview"), ...rendered];
31
- }
32
- return rendered;
33
- }