@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.
- package/README.md +22 -0
- package/bin/aci +0 -0
- package/dist/astro/index.d.ts +2 -2
- package/dist/astro/index.js +5 -1
- package/dist/astro/preview.d.ts +5 -0
- package/dist/astro/preview.js +33 -0
- package/dist/content/cache.test.d.ts +1 -0
- package/dist/content/cache.test.js +86 -0
- package/dist/define-data-model.d.ts +2 -0
- package/dist/define-data-model.js +3 -0
- package/dist/dev/index.d.ts +12 -0
- package/dist/dev/index.js +84 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +13 -1
- package/dist/next/content-watch.d.ts +11 -0
- package/dist/next/content-watch.js +106 -0
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +2 -2
- package/dist/next/middleware.js +34 -50
- package/dist/next/page.d.ts +40 -0
- package/dist/next/page.js +59 -0
- package/dist/next/preview-mode.js +4 -8
- package/dist/next/server.js +0 -6
- package/dist/preview/core.d.ts +41 -0
- package/dist/preview/core.js +116 -0
- package/dist/sveltekit/index.d.ts +2 -1
- package/dist/sveltekit/index.js +5 -1
- package/dist/sveltekit/preview.d.ts +5 -0
- package/dist/sveltekit/preview.js +33 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/data.d.ts +19 -0
- package/dist/types/data.js +11 -0
- package/dist/types/image.d.ts +1 -1
- package/dist/types/image.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +24 -1
- package/src/cli/compile-registry.mjs +40 -1
- package/src/types/config.ts +1 -0
- package/src/types/data.ts +47 -0
- package/src/types/image.ts +2 -2
- package/src/types/index.ts +1 -0
- package/dist/render.d.ts +0 -14
- package/dist/render.js +0 -33
package/src/types/image.ts
CHANGED
|
@@ -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
|
|
68
|
+
if (!image.sources?.length) {
|
|
69
69
|
return img;
|
|
70
70
|
}
|
|
71
71
|
const sources = image.sources.map((source) => `<source${renderAttrs({
|
package/src/types/index.ts
CHANGED
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
|
-
}
|