@gradial/aci 0.1.20-preview.2 → 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.
- package/README.md +48 -110
- package/bin/{aci → aci-darwin-arm64} +0 -0
- package/bin/aci.js +99 -6
- package/dist/assets/index.d.ts +3 -3
- package/dist/assets/index.js +3 -3
- package/dist/astro/index.d.ts +14 -3
- package/dist/astro/index.js +24 -5
- package/dist/content/assets.d.ts +17 -0
- package/dist/content/assets.js +65 -0
- package/dist/content/index.d.ts +2 -0
- package/dist/content/index.js +2 -0
- package/dist/content/provider.d.ts +19 -0
- package/dist/content/provider.js +7 -0
- package/dist/content/resolve-slots.d.ts +9 -0
- package/dist/content/resolve-slots.js +24 -0
- package/dist/content/types.d.ts +1 -1
- package/dist/define-component.d.ts +1 -2
- package/dist/define-component.js +73 -11
- package/dist/define-layout.d.ts +2 -0
- package/dist/define-layout.js +3 -0
- package/dist/dev/content-watch.d.ts +37 -0
- package/dist/dev/content-watch.js +154 -0
- package/dist/dev/index.d.ts +24 -43
- package/dist/dev/index.js +4 -169
- package/dist/index.d.ts +14 -5
- package/dist/index.js +8 -8
- package/dist/next/asset-route.d.ts +2 -0
- package/dist/next/asset-route.js +12 -4
- package/dist/next/config.d.ts +2 -2
- package/dist/next/config.js +6 -6
- package/dist/next/content-watch.js +6 -1
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +2 -2
- package/dist/next/middleware.d.ts +7 -3
- package/dist/next/middleware.js +12 -7
- package/dist/next/page.d.ts +16 -15
- package/dist/next/page.js +30 -10
- package/dist/next/render.d.ts +5 -0
- package/dist/next/render.js +17 -0
- package/dist/next/root-layout.d.ts +4 -0
- package/dist/next/root-layout.js +5 -0
- package/dist/next/server.d.ts +14 -13
- package/dist/next/server.js +13 -3
- package/dist/providers/file.d.ts +2 -0
- package/dist/providers/file.js +61 -1
- package/dist/providers/s3.d.ts +1 -0
- package/dist/providers/s3.js +14 -1
- package/dist/react/Media.d.ts +24 -0
- package/dist/react/Media.js +30 -0
- package/dist/react/Picture.d.ts +12 -0
- package/dist/react/Picture.js +11 -0
- package/dist/react/VideoPlayer.d.ts +13 -0
- package/dist/react/{GradialVideoPlayer.js → VideoPlayer.js} +6 -5
- package/dist/react/index.d.ts +333 -3
- package/dist/react/index.js +89 -3
- package/dist/registry.d.ts +15 -0
- package/dist/registry.js +10 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.js +15 -2
- package/dist/types/block-ref.d.ts +26 -0
- package/dist/types/block-ref.js +28 -0
- package/dist/types/component.d.ts +36 -41
- package/dist/types/config.d.ts +1 -2
- package/dist/types/image.d.ts +33 -20
- package/dist/types/image.js +42 -50
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/link.d.ts +38 -0
- package/dist/types/link.js +58 -0
- package/dist/types/media.d.ts +16 -35
- package/dist/types/media.js +15 -84
- package/dist/types/page.d.ts +1 -2
- package/dist/types/render-mode.d.ts +0 -1
- package/dist/types/renderer.d.ts +1 -1
- package/dist/types/rich-text.d.ts +40 -0
- package/dist/types/rich-text.js +39 -0
- package/dist/types/video.d.ts +7 -13
- package/dist/types/video.js +3 -3
- package/package.json +32 -74
- package/src/cli/compile-registry.mjs +236 -59
- package/src/cli/validate-content.mjs +38 -75
- package/src/types/image.ts +79 -60
- package/templates/astro/template/.aci.yaml +27 -0
- package/templates/astro/template/.storybook/main.ts +79 -0
- package/templates/astro/template/.storybook/manager.ts +6 -0
- package/templates/astro/template/.storybook/preview.ts +33 -0
- package/templates/astro/template/astro.config.mjs +37 -0
- package/templates/astro/template/package.json.tmpl +41 -0
- package/templates/astro/template/src/cms/contracts/layouts/index.ts +18 -0
- package/templates/astro/template/src/cms/registry.ts +28 -0
- package/templates/astro/template/src/components/chrome/Footer.astro +107 -0
- package/templates/astro/template/src/components/chrome/Header.astro +94 -0
- package/templates/astro/template/src/components/elements/AtomicBlock.astro +15 -0
- package/templates/astro/template/src/components/elements/AtomicBlocks.astro +16 -0
- package/templates/astro/template/src/components/elements/Button.astro +51 -0
- package/templates/astro/template/src/components/elements/ButtonBlock.astro +25 -0
- package/templates/astro/template/src/components/elements/Container.astro +11 -0
- package/templates/astro/template/src/components/elements/Icon.astro +31 -0
- package/templates/astro/template/src/components/elements/Logo.astro +29 -0
- package/templates/astro/template/src/components/elements/RemoteImage.astro +41 -0
- package/templates/astro/template/src/components/sections/ContainerSection.astro +32 -0
- package/templates/astro/template/src/components/sections/FeatureCard.astro +23 -0
- package/templates/astro/template/src/components/sections/FeatureGrid.astro +35 -0
- package/templates/astro/template/src/components/sections/HomeHero.astro +51 -0
- package/templates/astro/template/src/components/sections/StatsBar.astro +33 -0
- package/templates/astro/template/src/design-system/styles.css +399 -0
- package/templates/astro/template/src/design-system/tokens/colors.css +60 -0
- package/templates/astro/template/src/design-system/tokens/components.css +69 -0
- package/templates/astro/template/src/design-system/tokens/index.css +6 -0
- package/templates/astro/template/src/design-system/tokens/radii.css +5 -0
- package/templates/astro/template/src/design-system/tokens/shadows.css +5 -0
- package/templates/astro/template/src/design-system/tokens/spacing.css +13 -0
- package/templates/astro/template/src/design-system/tokens/typography.css +24 -0
- package/templates/astro/template/src/env.d.ts +1 -0
- package/templates/astro/template/src/fixtures/atomicBlocks.ts +33 -0
- package/templates/astro/template/src/fixtures/composition.ts +31 -0
- package/templates/astro/template/src/fixtures/index.ts +17 -0
- package/templates/astro/template/src/fixtures/sections.ts +39 -0
- package/templates/astro/template/src/layouts/SiteLayout.astro +30 -0
- package/templates/astro/template/src/pages/[...slug].astro +61 -0
- package/templates/astro/template/src/render/RenderPage.astro +66 -0
- package/templates/astro/template/src/stories/CompositionStoryFrame.astro +15 -0
- package/templates/astro/template/src/stories/HomeHero.stories.ts +24 -0
- package/templates/astro/template/src/stories/SectionStoryFrame.astro +16 -0
- package/templates/astro/template/src/stories/StoryDocFrame.astro +31 -0
- package/templates/astro/template/tsconfig.json +11 -0
- package/templates/common/.agents/AGENTS.md +37 -0
- package/templates/common/.agents/skills/aci/SKILL.md +162 -0
- package/templates/common/.agents/skills/authoring/SKILL.md +590 -0
- package/templates/common/.agents/skills/authoring/references/block-registry.md +151 -0
- package/templates/common/.agents/skills/authoring/references/contracts.md +153 -0
- package/templates/common/.agents/skills/authoring/references/design-system.md +171 -0
- package/templates/common/.agents/skills/authoring/references/image-assets.md +73 -0
- package/templates/common/.agents/skills/authoring/references/repo-structure.md +157 -0
- package/templates/common/.agents/skills/migration/SKILL.md +160 -0
- package/templates/common/.agents/skills/migration/references/analyzing-source.md +215 -0
- package/templates/common/.agents/skills/migration/references/component-migration.md +200 -0
- package/templates/common/.agents/skills/migration/references/selector-map.md +31 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/7f/bf/7fbfc7fe230ff12688c496f660119e41d9725c4504d82e310c15665c73c09292 +0 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/a0/f5/a0f506689de9b15a7055f70103a3f02cd3ba105771ae2de6754df2ede1210d3a +0 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/dd/b7/ddb7e9642be08317bcd4b2bd26b58ba8d0d34dd7239e03e684a4f3634fa3845b +0 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/fb/32/fb3260e8286ea8231ea1c77b9c0be92d6edd9026565731eb14cfdcfd6b1b75b3 +0 -0
- package/templates/common/.content/config/site.json +192 -0
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/asset.json +9 -0
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/editorial.json +14 -0
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/governance.json +23 -0
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/versions/v0001.json +37 -0
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/asset.json +9 -0
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/editorial.json +14 -0
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/governance.json +23 -0
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/versions/v0001.json +37 -0
- package/templates/common/.content/fragments/navbar/_index.json +25 -0
- package/templates/common/.content/fragments/site-footer/_index.json +62 -0
- package/templates/common/.content/pages/about/_index.json +51 -0
- package/templates/common/.content/pages/home/_index.json +112 -0
- package/templates/common/.content/schemas/site.schema.json +123 -0
- package/templates/common/README.md.tmpl +45 -0
- package/templates/common/contracts/components/button.contract.ts +19 -0
- package/templates/common/contracts/components/container.contract.ts +19 -0
- package/templates/common/contracts/components/featureCard.contract.ts +15 -0
- package/templates/common/contracts/components/featureGrid.contract.ts +16 -0
- package/templates/common/contracts/components/homeHero.contract.ts +36 -0
- package/templates/common/contracts/components/index.ts +21 -0
- package/templates/common/contracts/components/siteFooter.contract.ts +45 -0
- package/templates/common/contracts/components/siteNavigation.contract.ts +30 -0
- package/templates/common/contracts/components/statsBar.contract.ts +19 -0
- package/templates/common/design-system/styles.css +346 -0
- package/templates/common/design-system/tokens/colors.css +110 -0
- package/templates/common/design-system/tokens/components.css +86 -0
- package/templates/common/design-system/tokens/index.css +6 -0
- package/templates/common/design-system/tokens/radii.css +5 -0
- package/templates/common/design-system/tokens/shadows.css +9 -0
- package/templates/common/design-system/tokens/spacing.css +26 -0
- package/templates/common/design-system/tokens/typography.css +32 -0
- package/templates/common/eslint-rules/no-raw-tailwind-values.js +127 -0
- package/templates/common/public/assets/Dwire-model.png +0 -0
- package/templates/common/public/assets/bare-metal-logo.png +0 -0
- package/templates/common/public/assets/meridian-logo.svg +8 -0
- package/templates/common/public/assets/seattle.avif +0 -0
- package/templates/nextjs/template/.aci.yaml +25 -0
- package/templates/nextjs/template/.storybook/main.ts +13 -0
- package/templates/nextjs/template/.storybook/preview.ts +34 -0
- package/templates/nextjs/template/eslint.config.mjs +36 -0
- package/templates/nextjs/template/next-env.d.ts +6 -0
- package/templates/nextjs/template/next.config.ts +8 -0
- package/templates/nextjs/template/package.json.tmpl +46 -0
- package/templates/nextjs/template/postcss.config.mjs +7 -0
- package/templates/nextjs/template/src/app/[[...slug]]/page.tsx +8 -0
- package/templates/nextjs/template/src/app/gradial/assets/[releaseId]/[...path]/route.ts +31 -0
- package/templates/nextjs/template/src/app/layout.tsx +29 -0
- package/templates/nextjs/template/src/cms/contracts/components/button.contract.ts +19 -0
- package/templates/nextjs/template/src/cms/contracts/components/container.contract.ts +20 -0
- package/templates/nextjs/template/src/cms/contracts/components/homeHero.contract.ts +36 -0
- package/templates/nextjs/template/src/cms/contracts/components/index.ts +15 -0
- package/templates/nextjs/template/src/cms/contracts/components/siteFooter.contract.ts +45 -0
- package/templates/nextjs/template/src/cms/contracts/components/siteNavigation.contract.ts +30 -0
- package/templates/nextjs/template/src/cms/contracts/layouts/index.ts +16 -0
- package/templates/nextjs/template/src/cms/registry.ts +28 -0
- package/templates/nextjs/template/src/components/chrome/Footer.tsx +86 -0
- package/templates/nextjs/template/src/components/chrome/Header.tsx +74 -0
- package/templates/nextjs/template/src/components/elements/AtomicBlock.tsx +13 -0
- package/templates/nextjs/template/src/components/elements/Button.tsx +40 -0
- package/templates/nextjs/template/src/components/elements/ButtonBlock.tsx +18 -0
- package/templates/nextjs/template/src/components/elements/Container.tsx +14 -0
- package/templates/nextjs/template/src/components/elements/Icon.tsx +29 -0
- package/templates/nextjs/template/src/components/elements/Logo.tsx +38 -0
- package/templates/nextjs/template/src/components/sections/ContainerSection.tsx +28 -0
- package/templates/nextjs/template/src/components/sections/FeatureCard.tsx +25 -0
- package/templates/nextjs/template/src/components/sections/FeatureGrid.tsx +36 -0
- package/templates/nextjs/template/src/components/sections/HomeHero.tsx +62 -0
- package/templates/nextjs/template/src/components/sections/StatsBar.tsx +30 -0
- package/templates/nextjs/template/src/middleware.ts +4 -0
- package/templates/nextjs/template/src/stories/Button.stories.tsx +38 -0
- package/templates/nextjs/template/src/stories/Header.stories.tsx +30 -0
- package/templates/nextjs/template/src/stories/HomeHero.stories.tsx +33 -0
- package/templates/nextjs/template/tsconfig.json +23 -0
- package/templates/nextjs/template/vercel.json +6 -0
- package/dist/content/cache.test.d.ts +0 -1
- package/dist/content/cache.test.js +0 -86
- package/dist/content/contract.d.ts +0 -83
- package/dist/content/contract.js +0 -104
- package/dist/content/tailwind-validator.d.ts +0 -6
- package/dist/content/tailwind-validator.js +0 -31
- package/dist/content/validation.d.ts +0 -108
- package/dist/content/validation.js +0 -184
- package/dist/next/preview-banner.d.ts +0 -4
- package/dist/next/preview-banner.js +0 -51
- package/dist/next/preview.d.ts +0 -7
- package/dist/next/preview.js +0 -37
- package/dist/react/GradialMedia.d.ts +0 -24
- package/dist/react/GradialMedia.js +0 -31
- package/dist/react/GradialPicture.d.ts +0 -14
- package/dist/react/GradialPicture.js +0 -30
- package/dist/react/GradialVideoPlayer.d.ts +0 -13
- package/dist/sveltekit/index.d.ts +0 -23
- package/dist/sveltekit/index.js +0 -62
- package/dist/sveltekit/preview.d.ts +0 -5
- package/dist/sveltekit/preview.js +0 -33
- package/src/cli/verify-renderer.mjs +0 -73
- package/src/types/component.ts +0 -59
- package/src/types/config.ts +0 -38
- package/src/types/data.ts +0 -47
- package/src/types/index.ts +0 -10
- package/src/types/layout.ts +0 -29
- package/src/types/media.ts +0 -125
- package/src/types/page.ts +0 -48
- package/src/types/render-mode.ts +0 -18
- package/src/types/renderer.ts +0 -83
- package/src/types/video.ts +0 -66
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { ComponentContract, ComponentDefinition } from './types/component.js';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare const defineComponentContract: typeof defineComponent;
|
|
2
|
+
export declare function defineComponentContract<const TId extends string, TSchema = unknown>(definition: ComponentDefinition<TId, TSchema>): ComponentContract<TId, TSchema>;
|
package/dist/define-component.js
CHANGED
|
@@ -1,14 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (!renderModes) {
|
|
4
|
-
throw new Error(`component ${definition.name} must define renderModes`);
|
|
5
|
-
}
|
|
1
|
+
import { getBlockRefMeta } from './types/block-ref.js';
|
|
2
|
+
export function defineComponentContract(definition) {
|
|
6
3
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
id: definition.id,
|
|
5
|
+
...(definition.displayName ? { displayName: definition.displayName } : {}),
|
|
6
|
+
props: definition.props,
|
|
7
|
+
...scanBlockSlots(definition.props),
|
|
8
|
+
...(definition.imageSlots ? { imageSlots: definition.imageSlots } : {}),
|
|
9
|
+
validate: definition.validate ?? [],
|
|
12
10
|
};
|
|
13
11
|
}
|
|
14
|
-
|
|
12
|
+
function scanBlockSlots(schema) {
|
|
13
|
+
const slots = {};
|
|
14
|
+
const shape = getSchemaShape(schema);
|
|
15
|
+
if (!shape)
|
|
16
|
+
return {};
|
|
17
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
18
|
+
const unwrapped = unwrapOptional(fieldSchema);
|
|
19
|
+
const meta = getBlockRefMeta(unwrapped) ?? getBlockRefMeta(unwrapArray(unwrapped));
|
|
20
|
+
if (meta) {
|
|
21
|
+
slots[key] = meta;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return Object.keys(slots).length ? { blockSlots: slots } : {};
|
|
25
|
+
}
|
|
26
|
+
function unwrapOptional(schema) {
|
|
27
|
+
let current = schema;
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
while (current && typeof current === 'object' && !seen.has(current)) {
|
|
30
|
+
seen.add(current);
|
|
31
|
+
const def = current._def;
|
|
32
|
+
if (!def || typeof def !== 'object')
|
|
33
|
+
break;
|
|
34
|
+
const type = def.type;
|
|
35
|
+
const typeName = def.typeName;
|
|
36
|
+
if (type === 'optional' || type === 'nullable' || type === 'default' ||
|
|
37
|
+
typeName === 'ZodOptional' || typeName === 'ZodNullable' || typeName === 'ZodDefault') {
|
|
38
|
+
const inner = def.innerType ?? def.schema;
|
|
39
|
+
if (inner) {
|
|
40
|
+
current = inner;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return current;
|
|
47
|
+
}
|
|
48
|
+
function getSchemaShape(schema) {
|
|
49
|
+
if (!schema || typeof schema !== 'object')
|
|
50
|
+
return null;
|
|
51
|
+
const def = schema._def;
|
|
52
|
+
if (!def || typeof def !== 'object')
|
|
53
|
+
return null;
|
|
54
|
+
const shape = def.shape;
|
|
55
|
+
if (typeof shape === 'function') {
|
|
56
|
+
return shape.call(def);
|
|
57
|
+
}
|
|
58
|
+
if (shape && typeof shape === 'object') {
|
|
59
|
+
return shape;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function unwrapArray(schema) {
|
|
64
|
+
if (!schema || typeof schema !== 'object')
|
|
65
|
+
return null;
|
|
66
|
+
const def = schema._def;
|
|
67
|
+
if (!def || typeof def !== 'object')
|
|
68
|
+
return null;
|
|
69
|
+
const type = def.type;
|
|
70
|
+
const typeName = def.typeName;
|
|
71
|
+
if (type === 'array' && def.element)
|
|
72
|
+
return def.element;
|
|
73
|
+
if (typeName === 'ZodArray' && def.type)
|
|
74
|
+
return def.type;
|
|
75
|
+
return null;
|
|
76
|
+
}
|
package/dist/define-layout.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { LayoutContract, LayoutDefinition, LayoutSlot } from './types/layout.js';
|
|
2
|
+
import type { FragmentRefNode } from './types/page.js';
|
|
2
3
|
export declare function defineLayout(definition: LayoutDefinition): LayoutContract;
|
|
3
4
|
export declare const defineLayoutContract: typeof defineLayout;
|
|
4
5
|
export declare function slot(name: string, required?: boolean): LayoutSlot;
|
|
6
|
+
export declare function fragmentDefault(fragmentId: string): FragmentRefNode;
|
package/dist/define-layout.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { type DevRefreshOptions } from './browser.js';
|
|
3
|
+
export interface ContentWatchOptions extends DevRefreshOptions {
|
|
4
|
+
contentRoot?: string;
|
|
5
|
+
compiledRoot?: string;
|
|
6
|
+
bin?: string;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface ViteModuleGraph {
|
|
10
|
+
idToModuleMap: Map<unknown, {
|
|
11
|
+
id: string | null;
|
|
12
|
+
}>;
|
|
13
|
+
invalidateModule(mod: unknown): void;
|
|
14
|
+
}
|
|
15
|
+
interface ViteDevServerLike {
|
|
16
|
+
middlewares?: {
|
|
17
|
+
use(path: string, handler: (req: IncomingMessage, res: ServerResponse, next: () => void) => void): void;
|
|
18
|
+
};
|
|
19
|
+
watcher: {
|
|
20
|
+
add(path: string): void;
|
|
21
|
+
on(event: string, callback: (eventName: string, filePath: string) => void): void;
|
|
22
|
+
};
|
|
23
|
+
ws: {
|
|
24
|
+
send(payload: unknown): void;
|
|
25
|
+
};
|
|
26
|
+
moduleGraph?: ViteModuleGraph;
|
|
27
|
+
}
|
|
28
|
+
export interface VitePluginLike {
|
|
29
|
+
name: string;
|
|
30
|
+
apply?: 'serve' | 'build';
|
|
31
|
+
configureServer?(server: ViteDevServerLike): void;
|
|
32
|
+
transformIndexHtml?(html: string): string;
|
|
33
|
+
}
|
|
34
|
+
export declare function devRefreshPort(options?: DevRefreshOptions): number;
|
|
35
|
+
export declare function contentWatchPlugin(options?: ContentWatchOptions): VitePluginLike;
|
|
36
|
+
export declare function damAssetPlugin(options?: ContentWatchOptions): VitePluginLike;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { compiledContentRoot } from '../content/routes.js';
|
|
5
|
+
import { DEFAULT_DEV_REFRESH_PORT } from './browser.js';
|
|
6
|
+
export function devRefreshPort(options = {}) {
|
|
7
|
+
const value = options.wsPort ?? process.env.ACI_DEV_WS_PORT;
|
|
8
|
+
if (value === 0 || value === '0') {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
const parsed = Number(value);
|
|
12
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_DEV_REFRESH_PORT;
|
|
13
|
+
}
|
|
14
|
+
function sourceContentRoot(options) {
|
|
15
|
+
return path.resolve(options.contentRoot || process.env.ACI_CONTENT_SOURCE || './.content');
|
|
16
|
+
}
|
|
17
|
+
function resolveBin(options) {
|
|
18
|
+
return options.bin || process.env.ACI_BIN || 'aci';
|
|
19
|
+
}
|
|
20
|
+
function recompileContent(options, reason) {
|
|
21
|
+
const siteDir = process.cwd();
|
|
22
|
+
const src = sourceContentRoot(options);
|
|
23
|
+
const out = path.resolve(options.compiledRoot || process.env.ACI_CONTENT_ROOT || '.aci/compiled');
|
|
24
|
+
const bin = resolveBin(options);
|
|
25
|
+
console.log(`[aci] compiling content (${reason})`);
|
|
26
|
+
const result = spawnSync(bin, ['-s', siteDir, 'build', '--content', src, '--out', out, '--skip-code'], {
|
|
27
|
+
cwd: siteDir,
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
env: process.env,
|
|
30
|
+
});
|
|
31
|
+
if (result.status !== 0) {
|
|
32
|
+
console.error(`[aci] content compile failed with exit code ${result.status ?? 'unknown'}`);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
export function contentWatchPlugin(options = {}) {
|
|
38
|
+
const enabled = options.enabled ?? process.env.ACI_DISABLE_CONTENT_WATCH !== '1';
|
|
39
|
+
if (!enabled) {
|
|
40
|
+
return { name: 'content-watch-disabled', apply: 'serve' };
|
|
41
|
+
}
|
|
42
|
+
let timer;
|
|
43
|
+
let running = false;
|
|
44
|
+
let queued = false;
|
|
45
|
+
function rebuild(server, reason) {
|
|
46
|
+
if (running) {
|
|
47
|
+
queued = true;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
running = true;
|
|
51
|
+
const success = recompileContent(options, reason);
|
|
52
|
+
running = false;
|
|
53
|
+
if (success) {
|
|
54
|
+
if (server.moduleGraph) {
|
|
55
|
+
for (const mod of server.moduleGraph.idToModuleMap.values()) {
|
|
56
|
+
server.moduleGraph.invalidateModule(mod);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
server.ws.send({ type: 'full-reload' });
|
|
60
|
+
}
|
|
61
|
+
if (queued) {
|
|
62
|
+
queued = false;
|
|
63
|
+
rebuild(server, 'queued change');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
name: 'content-watch',
|
|
68
|
+
apply: 'serve',
|
|
69
|
+
configureServer(server) {
|
|
70
|
+
const src = sourceContentRoot(options);
|
|
71
|
+
const compiled = path.resolve(options.compiledRoot || process.env.ACI_CONTENT_ROOT || compiledContentRoot());
|
|
72
|
+
server.watcher.add(src);
|
|
73
|
+
server.watcher.add(compiled);
|
|
74
|
+
rebuild(server, 'startup');
|
|
75
|
+
server.watcher.on('all', (_event, filePath) => {
|
|
76
|
+
const changed = path.resolve(filePath);
|
|
77
|
+
const isSource = changed.startsWith(src + path.sep);
|
|
78
|
+
const isCompiled = changed.startsWith(compiled + path.sep);
|
|
79
|
+
if (!isSource && !isCompiled)
|
|
80
|
+
return;
|
|
81
|
+
if (isCompiled) {
|
|
82
|
+
server.ws.send({ type: 'full-reload' });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
timer = setTimeout(() => rebuild(server, path.relative(src, changed)), 100);
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function damAssetPlugin(options = {}) {
|
|
92
|
+
return {
|
|
93
|
+
name: 'dam-assets',
|
|
94
|
+
apply: 'serve',
|
|
95
|
+
configureServer(server) {
|
|
96
|
+
if (!server.middlewares)
|
|
97
|
+
return;
|
|
98
|
+
server.middlewares.use('/.gradial-dam', async (req, res, next) => {
|
|
99
|
+
const root = path.resolve(options.compiledRoot || compiledContentRoot());
|
|
100
|
+
const requestPath = safeRequestPath(req.url || '');
|
|
101
|
+
if (!requestPath) {
|
|
102
|
+
res.statusCode = 404;
|
|
103
|
+
res.end('asset not found');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const filePath = path.resolve(root, '.gradial-dam', requestPath.replace(/^\/+/, ''));
|
|
107
|
+
if (!isInside(root, filePath)) {
|
|
108
|
+
res.statusCode = 404;
|
|
109
|
+
res.end('asset not found');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const body = await fs.readFile(filePath);
|
|
114
|
+
res.statusCode = 200;
|
|
115
|
+
res.setHeader('Content-Type', contentType(filePath));
|
|
116
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
|
|
117
|
+
res.end(body);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
next();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function safeRequestPath(url) {
|
|
127
|
+
const rawPath = url.split('?')[0] || '';
|
|
128
|
+
try {
|
|
129
|
+
const decoded = decodeURIComponent(rawPath);
|
|
130
|
+
return decoded.startsWith('/.gradial-dam/') ? decoded.slice('/.gradial-dam/'.length) : decoded;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function isInside(root, filePath) {
|
|
137
|
+
const rel = path.relative(root, filePath);
|
|
138
|
+
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
139
|
+
}
|
|
140
|
+
function contentType(filePath) {
|
|
141
|
+
switch (path.extname(filePath).toLowerCase()) {
|
|
142
|
+
case '.webp':
|
|
143
|
+
return 'image/webp';
|
|
144
|
+
case '.svg':
|
|
145
|
+
return 'image/svg+xml';
|
|
146
|
+
case '.jpg':
|
|
147
|
+
case '.jpeg':
|
|
148
|
+
return 'image/jpeg';
|
|
149
|
+
case '.png':
|
|
150
|
+
return 'image/png';
|
|
151
|
+
default:
|
|
152
|
+
return 'application/octet-stream';
|
|
153
|
+
}
|
|
154
|
+
}
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -1,48 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type DevRefreshMessage = {
|
|
2
|
+
type: 'connected';
|
|
3
|
+
siteId?: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: 'compile-started';
|
|
6
|
+
reason?: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'compile-succeeded';
|
|
9
|
+
releaseId?: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'compile-failed';
|
|
12
|
+
errors?: string[];
|
|
13
|
+
} | {
|
|
14
|
+
type: 'content-updated';
|
|
15
|
+
releaseId?: string;
|
|
16
|
+
};
|
|
17
|
+
interface DevRefreshScriptOptions {
|
|
18
|
+
wsPort?: number | string;
|
|
19
|
+
path?: string;
|
|
20
|
+
reconnectMs?: number;
|
|
21
|
+
}
|
|
4
22
|
declare global {
|
|
5
23
|
interface Window {
|
|
6
24
|
__gradialDevRefresh?: boolean;
|
|
7
25
|
}
|
|
8
26
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** Compiled content output root. Defaults to ACI_CONTENT_ROOT env or '.aci/compiled' */
|
|
13
|
-
compiledRoot?: string;
|
|
14
|
-
/** Path to the ACI CLI binary. Defaults to ACI_BIN env or 'aci' */
|
|
15
|
-
aciBin?: string;
|
|
16
|
-
/** Disable content watching entirely. Defaults to ACI_DISABLE_CONTENT_WATCH env */
|
|
17
|
-
enabled?: boolean;
|
|
18
|
-
}
|
|
19
|
-
interface ViteModuleGraph {
|
|
20
|
-
idToModuleMap: Map<unknown, {
|
|
21
|
-
id: string | null;
|
|
22
|
-
}>;
|
|
23
|
-
invalidateModule(mod: unknown): void;
|
|
24
|
-
}
|
|
25
|
-
interface ViteDevServerLike {
|
|
26
|
-
middlewares?: {
|
|
27
|
-
use(path: string, handler: (req: IncomingMessage, res: ServerResponse, next: () => void) => void): void;
|
|
28
|
-
};
|
|
29
|
-
watcher: {
|
|
30
|
-
add(path: string): void;
|
|
31
|
-
on(event: string, callback: (eventName: string, filePath: string) => void): void;
|
|
32
|
-
};
|
|
33
|
-
ws: {
|
|
34
|
-
send(payload: unknown): void;
|
|
35
|
-
};
|
|
36
|
-
moduleGraph?: ViteModuleGraph;
|
|
37
|
-
}
|
|
38
|
-
export interface VitePluginLike {
|
|
39
|
-
name: string;
|
|
40
|
-
apply?: 'serve' | 'build';
|
|
41
|
-
configureServer?(server: ViteDevServerLike): void;
|
|
42
|
-
transformIndexHtml?(html: string): string;
|
|
43
|
-
}
|
|
44
|
-
export declare function devRefreshPort(options?: DevRefreshOptions): number;
|
|
45
|
-
export declare function devRefreshScript(options?: DevRefreshOptions): string;
|
|
46
|
-
export declare function devRefreshScriptTag(options?: DevRefreshOptions): string;
|
|
47
|
-
export declare function gradialContentWatchPlugin(options?: GradialContentWatchOptions): VitePluginLike;
|
|
48
|
-
export declare function gradialDamAssetPlugin(options?: GradialContentWatchOptions): VitePluginLike;
|
|
27
|
+
export declare function createDevRefreshBrowserScript(options?: DevRefreshScriptOptions): string;
|
|
28
|
+
export declare function createDevRefreshScriptTag(options?: DevRefreshScriptOptions): string;
|
|
29
|
+
export {};
|
package/dist/dev/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { compiledContentRoot } from '../content/routes.js';
|
|
5
1
|
import { DEFAULT_DEV_REFRESH_PATH, DEFAULT_DEV_REFRESH_PORT, } from './browser.js';
|
|
6
|
-
export { DEFAULT_DEV_REFRESH_PATH, DEFAULT_DEV_REFRESH_PORT } from './browser.js';
|
|
7
2
|
function numberOption(value, fallback) {
|
|
8
3
|
if (value === undefined || value === '') {
|
|
9
4
|
return fallback;
|
|
@@ -11,14 +6,14 @@ function numberOption(value, fallback) {
|
|
|
11
6
|
const parsed = Number(value);
|
|
12
7
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
13
8
|
}
|
|
14
|
-
|
|
9
|
+
function devRefreshPort(options = {}) {
|
|
15
10
|
const value = options.wsPort ?? process.env.ACI_DEV_WS_PORT;
|
|
16
11
|
if (value === 0 || value === '0') {
|
|
17
12
|
return 0;
|
|
18
13
|
}
|
|
19
14
|
return numberOption(value, DEFAULT_DEV_REFRESH_PORT);
|
|
20
15
|
}
|
|
21
|
-
export function
|
|
16
|
+
export function createDevRefreshBrowserScript(options = {}) {
|
|
22
17
|
const wsPort = devRefreshPort(options);
|
|
23
18
|
if (wsPort <= 0) {
|
|
24
19
|
return '';
|
|
@@ -46,166 +41,6 @@ export function devRefreshScript(options = {}) {
|
|
|
46
41
|
connect();
|
|
47
42
|
})();`;
|
|
48
43
|
}
|
|
49
|
-
export function
|
|
50
|
-
return `<script>${
|
|
51
|
-
}
|
|
52
|
-
function sourceContentRoot(options) {
|
|
53
|
-
return path.resolve(options.contentRoot ||
|
|
54
|
-
process.env.ACI_CONTENT_SOURCE ||
|
|
55
|
-
'./.content');
|
|
56
|
-
}
|
|
57
|
-
function resolveAciBin(options) {
|
|
58
|
-
return options.aciBin || process.env.ACI_BIN || 'aci';
|
|
59
|
-
}
|
|
60
|
-
function recompileContent(options, reason) {
|
|
61
|
-
const siteDir = process.cwd();
|
|
62
|
-
const src = sourceContentRoot(options);
|
|
63
|
-
const out = path.resolve(options.compiledRoot ||
|
|
64
|
-
process.env.ACI_CONTENT_ROOT ||
|
|
65
|
-
'.aci/compiled');
|
|
66
|
-
const bin = resolveAciBin(options);
|
|
67
|
-
console.log(`[aci] compiling content (${reason})`);
|
|
68
|
-
const result = spawnSync(bin, [
|
|
69
|
-
'-s', siteDir,
|
|
70
|
-
'build',
|
|
71
|
-
'--content', src,
|
|
72
|
-
'--out', out,
|
|
73
|
-
'--skip-code',
|
|
74
|
-
], {
|
|
75
|
-
cwd: siteDir,
|
|
76
|
-
stdio: 'inherit',
|
|
77
|
-
env: process.env,
|
|
78
|
-
});
|
|
79
|
-
if (result.status !== 0) {
|
|
80
|
-
console.error(`[aci] content compile failed with exit code ${result.status ?? 'unknown'}`);
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
export function gradialContentWatchPlugin(options = {}) {
|
|
86
|
-
const enabled = options.enabled ?? process.env.ACI_DISABLE_CONTENT_WATCH !== '1';
|
|
87
|
-
if (!enabled) {
|
|
88
|
-
return {
|
|
89
|
-
name: 'gradial-content-watch-disabled',
|
|
90
|
-
apply: 'serve',
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
let timer;
|
|
94
|
-
let running = false;
|
|
95
|
-
let queued = false;
|
|
96
|
-
function rebuild(server, reason) {
|
|
97
|
-
if (running) {
|
|
98
|
-
queued = true;
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
running = true;
|
|
102
|
-
const success = recompileContent(options, reason);
|
|
103
|
-
running = false;
|
|
104
|
-
if (success) {
|
|
105
|
-
if (server.moduleGraph) {
|
|
106
|
-
for (const mod of server.moduleGraph.idToModuleMap.values()) {
|
|
107
|
-
server.moduleGraph.invalidateModule(mod);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
server.ws.send({ type: 'full-reload' });
|
|
111
|
-
}
|
|
112
|
-
if (queued) {
|
|
113
|
-
queued = false;
|
|
114
|
-
rebuild(server, 'queued change');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
name: 'gradial-content-watch',
|
|
119
|
-
apply: 'serve',
|
|
120
|
-
configureServer(server) {
|
|
121
|
-
const src = sourceContentRoot(options);
|
|
122
|
-
const compiled = path.resolve(options.compiledRoot ||
|
|
123
|
-
process.env.ACI_CONTENT_ROOT ||
|
|
124
|
-
compiledContentRoot());
|
|
125
|
-
server.watcher.add(src);
|
|
126
|
-
server.watcher.add(compiled);
|
|
127
|
-
rebuild(server, 'startup');
|
|
128
|
-
server.watcher.on('all', (_event, filePath) => {
|
|
129
|
-
const changed = path.resolve(filePath);
|
|
130
|
-
const isSource = changed.startsWith(src + path.sep);
|
|
131
|
-
const isCompiled = changed.startsWith(compiled + path.sep);
|
|
132
|
-
if (!isSource && !isCompiled)
|
|
133
|
-
return;
|
|
134
|
-
if (isCompiled) {
|
|
135
|
-
server.ws.send({ type: 'full-reload' });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
clearTimeout(timer);
|
|
139
|
-
timer = setTimeout(() => {
|
|
140
|
-
const relative = path.relative(src, changed);
|
|
141
|
-
rebuild(server, relative);
|
|
142
|
-
}, 100);
|
|
143
|
-
});
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
export function gradialDamAssetPlugin(options = {}) {
|
|
148
|
-
return {
|
|
149
|
-
name: 'gradial-dam-assets',
|
|
150
|
-
apply: 'serve',
|
|
151
|
-
configureServer(server) {
|
|
152
|
-
if (!server.middlewares) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
server.middlewares.use('/.gradial-dam', async (req, res, next) => {
|
|
156
|
-
const root = path.resolve(options.compiledRoot || compiledContentRoot());
|
|
157
|
-
const requestPath = safeRequestPath(req.url || '');
|
|
158
|
-
if (!requestPath) {
|
|
159
|
-
res.statusCode = 404;
|
|
160
|
-
res.end('asset not found');
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const filePath = path.resolve(root, '.gradial-dam', requestPath.replace(/^\/+/, ''));
|
|
164
|
-
if (!isInside(root, filePath)) {
|
|
165
|
-
res.statusCode = 404;
|
|
166
|
-
res.end('asset not found');
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
const body = await fs.readFile(filePath);
|
|
171
|
-
res.statusCode = 200;
|
|
172
|
-
res.setHeader('Content-Type', contentType(filePath));
|
|
173
|
-
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
|
|
174
|
-
res.end(body);
|
|
175
|
-
}
|
|
176
|
-
catch {
|
|
177
|
-
next();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function safeRequestPath(url) {
|
|
184
|
-
const rawPath = url.split('?')[0] || '';
|
|
185
|
-
try {
|
|
186
|
-
const decoded = decodeURIComponent(rawPath);
|
|
187
|
-
return decoded.startsWith('/.gradial-dam/') ? decoded.slice('/.gradial-dam/'.length) : decoded;
|
|
188
|
-
}
|
|
189
|
-
catch {
|
|
190
|
-
return '';
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function isInside(root, filePath) {
|
|
194
|
-
const rel = path.relative(root, filePath);
|
|
195
|
-
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
196
|
-
}
|
|
197
|
-
function contentType(filePath) {
|
|
198
|
-
switch (path.extname(filePath).toLowerCase()) {
|
|
199
|
-
case '.webp':
|
|
200
|
-
return 'image/webp';
|
|
201
|
-
case '.svg':
|
|
202
|
-
return 'image/svg+xml';
|
|
203
|
-
case '.jpg':
|
|
204
|
-
case '.jpeg':
|
|
205
|
-
return 'image/jpeg';
|
|
206
|
-
case '.png':
|
|
207
|
-
return 'image/png';
|
|
208
|
-
default:
|
|
209
|
-
return 'application/octet-stream';
|
|
210
|
-
}
|
|
44
|
+
export function createDevRefreshScriptTag(options = {}) {
|
|
45
|
+
return `<script>${createDevRefreshBrowserScript(options)}</script>`;
|
|
211
46
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { defineComponentContract } from './define-component.js';
|
|
2
|
+
export { defineLayoutContract, slot, fragmentDefault } from './define-layout.js';
|
|
3
|
+
export { createRegistry, registryLookup } from './registry.js';
|
|
4
|
+
export type { Registry, RegistryEntry, AnyComponent } from './registry.js';
|
|
5
|
+
export { blockRef, blockRefArray } from './types/block-ref.js';
|
|
6
|
+
export type { BlockRef, BlockRefEntry, BlockRefMeta, BlockRefUnion } from './types/block-ref.js';
|
|
7
|
+
export type { ComponentContract, ComponentContractID, ComponentContractValidator, ComponentRegistry, ComponentValidationContext, ComponentValidationIssue, InferComponentProps, } from './types/component.js';
|
|
8
|
+
export { ImageSchema, imageAttrs, primaryImageSource, type Image, type ImageSource, type ImageAttrs, type ImageSlotContract, type SlotOutput, } from './types/image.js';
|
|
9
|
+
export { LinkSchema, type Link, type LinkTarget, type LinkResolverContext, resolveLink, resolveHref, assertSafeHref, normalizeLinkRel, } from './types/link.js';
|
|
10
|
+
export { HeadingSchema, InlineContentSchema, RichTextValueSchema, type Heading, type InlineContent, type RichTextValue, } from './types/rich-text.js';
|
|
11
|
+
export type { Config, RouteConfig, ExternalDependency, DAMConfig, } from './types/config.js';
|
|
12
|
+
export type { Renderer, RenderCapabilities, RenderPageRequest, RenderPageResult, RequestContext, ReleaseContext, RenderFragmentRequest, RenderIslandRequest, RenderResult, IslandDescriptor, CachePolicy, GeoContext, } from './types/renderer.js';
|
|
13
|
+
export type { Asset, } from './types/media.js';
|
|
14
|
+
export { AssetSchema, isImage, isAsset, } from './types/media.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export { defineComponentContract } from './define-component.js';
|
|
2
|
+
export { defineLayoutContract, slot, fragmentDefault } from './define-layout.js';
|
|
3
|
+
export { createRegistry, registryLookup } from './registry.js';
|
|
4
|
+
export { blockRef, blockRefArray } from './types/block-ref.js';
|
|
5
|
+
export { ImageSchema, imageAttrs, primaryImageSource, } from './types/image.js';
|
|
6
|
+
export { LinkSchema, resolveLink, resolveHref, assertSafeHref, normalizeLinkRel, } from './types/link.js';
|
|
7
|
+
export { HeadingSchema, InlineContentSchema, RichTextValueSchema, } from './types/rich-text.js';
|
|
8
|
+
export { AssetSchema, isImage, isAsset, } from './types/media.js';
|
|
@@ -5,5 +5,7 @@ type AssetRouteParams = {
|
|
|
5
5
|
releaseId?: string;
|
|
6
6
|
path?: string[];
|
|
7
7
|
};
|
|
8
|
+
export declare const runtime = "nodejs";
|
|
9
|
+
export declare const dynamic = "force-dynamic";
|
|
8
10
|
export declare function GET(_request: Request, { params }: AssetRouteContext): Promise<Response>;
|
|
9
11
|
export {};
|
package/dist/next/asset-route.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileContentProvider } from '../providers/file.js';
|
|
2
|
+
import { getReleaseAssetResponse } from '../content/assets.js';
|
|
3
|
+
const LOCAL_RELEASE_ID = 'local';
|
|
4
|
+
export const runtime = 'nodejs';
|
|
5
|
+
export const dynamic = 'force-dynamic';
|
|
2
6
|
export async function GET(_request, { params }) {
|
|
3
7
|
const resolvedParams = await params;
|
|
4
8
|
const releaseId = resolvedParams.releaseId || '';
|
|
5
|
-
const assetPath = (resolvedParams.path || []).join('/');
|
|
6
|
-
if (!releaseId ||
|
|
9
|
+
const assetPath = '/' + (resolvedParams.path || []).join('/');
|
|
10
|
+
if (!releaseId || assetPath === '/') {
|
|
7
11
|
return new Response('asset not found', { status: 404 });
|
|
8
12
|
}
|
|
13
|
+
if (releaseId === LOCAL_RELEASE_ID) {
|
|
14
|
+
const provider = new FileContentProvider();
|
|
15
|
+
return provider.fetchRaw(assetPath);
|
|
16
|
+
}
|
|
9
17
|
try {
|
|
10
|
-
return await getReleaseAssetResponse(releaseId, assetPath);
|
|
18
|
+
return await getReleaseAssetResponse({ releaseId, assetPath });
|
|
11
19
|
}
|
|
12
20
|
catch {
|
|
13
21
|
return new Response('asset not found', { status: 404 });
|
package/dist/next/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
-
export interface
|
|
2
|
+
export interface WithAciOptions {
|
|
3
3
|
/** Asset rewrite prefix. Defaults to '/.gradial-dam' */
|
|
4
4
|
assetPrefix?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function withAci(nextConfig?: NextConfig, options?: WithAciOptions): NextConfig;
|