@gradial/aci 0.1.3 → 0.1.4
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/bin/aci.js +1 -1
- package/dist/astro/index.d.ts +2 -0
- package/dist/astro/index.js +4 -0
- package/dist/next/server.d.ts +3 -0
- package/dist/next/server.js +35 -4
- package/dist/runtime/page.d.ts +8 -0
- package/dist/runtime/page.js +21 -0
- package/dist/sveltekit/index.d.ts +4 -0
- package/dist/sveltekit/index.js +4 -0
- package/dist/types/config.d.ts +1 -0
- package/package.json +7 -3
- package/src/types/config.ts +1 -0
- package/bin/aci +0 -0
package/bin/aci.js
CHANGED
|
@@ -46,7 +46,7 @@ function resolvePackagedBinary() {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function resolveWorkspaceBinary() {
|
|
49
|
-
const binaryPath = resolve(
|
|
49
|
+
const binaryPath = resolve(repoRoot, 'packages', `cli-${platformKey}`, 'bin', binName);
|
|
50
50
|
|
|
51
51
|
return existsSync(binaryPath) ? binaryPath : null;
|
|
52
52
|
}
|
package/dist/astro/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RenderInput } from '../content/types.js';
|
|
1
2
|
import { type GradialContentWatchOptions } from '../dev/index.js';
|
|
2
3
|
interface AstroConfigSetupParams {
|
|
3
4
|
injectScript(stage: 'head-inline' | 'page' | 'page-ssr', content: string): void;
|
|
@@ -31,6 +32,7 @@ export declare function getGradialStaticPaths(): Promise<Array<{
|
|
|
31
32
|
slug?: string;
|
|
32
33
|
};
|
|
33
34
|
}>>;
|
|
35
|
+
export declare function getPageRuntimeRenderInput(request: Request): RenderInput | null;
|
|
34
36
|
export interface GradialAstroOptions extends GradialContentWatchOptions {
|
|
35
37
|
/** Path to compiled content root. Defaults to ACI_CONTENT_ROOT env or '.aci/compiled' */
|
|
36
38
|
compiledRoot?: string;
|
package/dist/astro/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { getPendingRenderInputFromHeaders } from '../runtime/page.js';
|
|
3
4
|
import { gradialContentWatchPlugin, gradialDamAssetPlugin, devRefreshPort, devRefreshScript, } from '../dev/index.js';
|
|
4
5
|
// ---------------------------------------------------------------------------
|
|
5
6
|
// Static paths helper — for Astro SSG
|
|
@@ -27,6 +28,9 @@ export async function getGradialStaticPaths() {
|
|
|
27
28
|
};
|
|
28
29
|
});
|
|
29
30
|
}
|
|
31
|
+
export function getPageRuntimeRenderInput(request) {
|
|
32
|
+
return getPendingRenderInputFromHeaders(request.headers);
|
|
33
|
+
}
|
|
30
34
|
export function gradialAstro(options = {}) {
|
|
31
35
|
return {
|
|
32
36
|
name: 'gradial-astro',
|
package/dist/next/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FragmentNotFoundError, PageNotFoundError } from '../content/provider.js';
|
|
2
|
+
import type { RenderInput } from '../content/types.js';
|
|
2
3
|
export { FragmentNotFoundError, PageNotFoundError };
|
|
3
4
|
export interface GradialFetchConfig {
|
|
4
5
|
siteId?: string;
|
|
@@ -25,9 +26,11 @@ export interface GradialSiteConfig {
|
|
|
25
26
|
defaultLocale?: string;
|
|
26
27
|
}
|
|
27
28
|
export declare function getPage<T = unknown>(route?: string, config?: GradialFetchConfig): Promise<T>;
|
|
29
|
+
export declare function getSiteConfig<T extends GradialSiteConfig = GradialSiteConfig>(config?: GradialFetchConfig): Promise<T>;
|
|
28
30
|
export declare function getFragment<T = unknown>(name: string, config?: GradialFetchConfig): Promise<T>;
|
|
29
31
|
export declare function getRoutes(config?: GradialFetchConfig): Promise<string[]>;
|
|
30
32
|
export declare function getRenderInput<TPage, TSite extends GradialSiteConfig = GradialSiteConfig>(route?: string, config?: GradialFetchConfig): Promise<GradialRenderInput<TPage, TSite>>;
|
|
33
|
+
export declare function getPageRuntimeRenderInput(): Promise<RenderInput | null>;
|
|
31
34
|
export declare function routeFromNextParams(params?: Promise<{
|
|
32
35
|
slug?: string[];
|
|
33
36
|
}> | {
|
package/dist/next/server.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
import { headers } from 'next/headers';
|
|
2
2
|
import { FragmentNotFoundError, PageNotFoundError, } from '../content/provider.js';
|
|
3
3
|
import { S3ContentProvider } from '../providers/s3.js';
|
|
4
|
+
import { GRADIAL_RENDER_INPUT_HEADER, getPendingRenderInput } from '../runtime/page.js';
|
|
4
5
|
import { getUncachedEdgeConfigValue } from './edge-config.js';
|
|
5
6
|
const RELEASE_HEADER = 'x-gradial-release-id';
|
|
6
7
|
export { FragmentNotFoundError, PageNotFoundError };
|
|
7
8
|
export async function getPage(route = '', config = {}) {
|
|
8
|
-
const
|
|
9
|
+
const runtimeInput = await getPageRuntimeRenderInput();
|
|
10
|
+
if (runtimeInput)
|
|
11
|
+
return runtimeInput.page;
|
|
12
|
+
const provider = await resolveProviderWithFallback(config);
|
|
9
13
|
return await provider.getPage(route);
|
|
10
14
|
}
|
|
15
|
+
export async function getSiteConfig(config = {}) {
|
|
16
|
+
const runtimeInput = await getPageRuntimeRenderInput();
|
|
17
|
+
if (runtimeInput)
|
|
18
|
+
return runtimeInput.siteConfig;
|
|
19
|
+
const provider = await resolveProviderWithFallback(config);
|
|
20
|
+
return await provider.getSiteConfig();
|
|
21
|
+
}
|
|
11
22
|
export async function getFragment(name, config = {}) {
|
|
12
|
-
const provider = await
|
|
23
|
+
const provider = await resolveProviderWithFallback(config);
|
|
13
24
|
return await provider.getFragment(name);
|
|
14
25
|
}
|
|
15
26
|
export async function getRoutes(config = {}) {
|
|
16
|
-
const provider = await
|
|
27
|
+
const provider = await resolveProviderWithFallback(config);
|
|
17
28
|
const routes = await provider.listRoutes();
|
|
18
29
|
return routes.map((route) => route.path).sort();
|
|
19
30
|
}
|
|
20
31
|
export async function getRenderInput(route = '/', config = {}) {
|
|
21
|
-
const
|
|
32
|
+
const runtimeInput = await getPageRuntimeRenderInput();
|
|
33
|
+
if (runtimeInput) {
|
|
34
|
+
return runtimeInput;
|
|
35
|
+
}
|
|
36
|
+
const provider = await resolveProviderWithFallback(config);
|
|
22
37
|
const [page, siteConfig] = await Promise.all([
|
|
23
38
|
provider.getPage(route),
|
|
24
39
|
provider.getSiteConfig(),
|
|
@@ -31,6 +46,15 @@ export async function getRenderInput(route = '/', config = {}) {
|
|
|
31
46
|
page,
|
|
32
47
|
};
|
|
33
48
|
}
|
|
49
|
+
export async function getPageRuntimeRenderInput() {
|
|
50
|
+
try {
|
|
51
|
+
const current = await headers();
|
|
52
|
+
return getPendingRenderInput(current.get(GRADIAL_RENDER_INPUT_HEADER));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
34
58
|
export async function routeFromNextParams(params) {
|
|
35
59
|
if (!params)
|
|
36
60
|
return '/';
|
|
@@ -125,6 +149,13 @@ async function resolveProvider(config) {
|
|
|
125
149
|
endpoint: config.endpoint,
|
|
126
150
|
});
|
|
127
151
|
}
|
|
152
|
+
async function resolveProviderWithFallback(config) {
|
|
153
|
+
if (process.env.ACI_CONTENT_PROVIDER === 'file') {
|
|
154
|
+
const { FileContentProvider } = await import('../providers/file.js');
|
|
155
|
+
return new FileContentProvider();
|
|
156
|
+
}
|
|
157
|
+
return await resolveProvider(config);
|
|
158
|
+
}
|
|
128
159
|
async function releaseIdFromHeaders() {
|
|
129
160
|
try {
|
|
130
161
|
const current = await headers();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RenderInput } from '../content/types.js';
|
|
2
|
+
export declare const GRADIAL_RENDER_INPUT_HEADER = "x-gradial-render-input-id";
|
|
3
|
+
export declare const GRADIAL_PENDING_RENDER_INPUTS_KEY = "__GRADIAL_PENDING_RENDER_INPUTS__";
|
|
4
|
+
export declare function pendingRenderInputs(): Map<string, RenderInput>;
|
|
5
|
+
export declare function setPendingRenderInput(id: string, input: RenderInput): void;
|
|
6
|
+
export declare function deletePendingRenderInput(id: string): void;
|
|
7
|
+
export declare function getPendingRenderInput(id: string | null | undefined): RenderInput | null;
|
|
8
|
+
export declare function getPendingRenderInputFromHeaders(headers: Headers): RenderInput | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const GRADIAL_RENDER_INPUT_HEADER = 'x-gradial-render-input-id';
|
|
2
|
+
export const GRADIAL_PENDING_RENDER_INPUTS_KEY = '__GRADIAL_PENDING_RENDER_INPUTS__';
|
|
3
|
+
export function pendingRenderInputs() {
|
|
4
|
+
const global = globalThis;
|
|
5
|
+
global[GRADIAL_PENDING_RENDER_INPUTS_KEY] ??= new Map();
|
|
6
|
+
return global[GRADIAL_PENDING_RENDER_INPUTS_KEY];
|
|
7
|
+
}
|
|
8
|
+
export function setPendingRenderInput(id, input) {
|
|
9
|
+
pendingRenderInputs().set(id, input);
|
|
10
|
+
}
|
|
11
|
+
export function deletePendingRenderInput(id) {
|
|
12
|
+
pendingRenderInputs().delete(id);
|
|
13
|
+
}
|
|
14
|
+
export function getPendingRenderInput(id) {
|
|
15
|
+
if (!id)
|
|
16
|
+
return null;
|
|
17
|
+
return pendingRenderInputs().get(id) ?? null;
|
|
18
|
+
}
|
|
19
|
+
export function getPendingRenderInputFromHeaders(headers) {
|
|
20
|
+
return getPendingRenderInput(headers.get(GRADIAL_RENDER_INPUT_HEADER));
|
|
21
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GradialContentWatchOptions, type VitePluginLike } from '../dev/index.js';
|
|
2
|
+
import type { RenderInput } from '../content/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Generates prerender entries from the compiled content manifest for SvelteKit.
|
|
4
5
|
*
|
|
@@ -15,4 +16,7 @@ import { type GradialContentWatchOptions, type VitePluginLike } from '../dev/ind
|
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
18
|
export declare function gradialEntries(): Promise<string[]>;
|
|
19
|
+
export declare function getPageRuntimeRenderInput(event: {
|
|
20
|
+
request: Request;
|
|
21
|
+
}): RenderInput | null;
|
|
18
22
|
export declare function gradialSvelteKit(options?: GradialContentWatchOptions): VitePluginLike;
|
package/dist/sveltekit/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { gradialContentWatchPlugin, gradialDamAssetPlugin, devRefreshPort, devRefreshScriptTag, } from '../dev/index.js';
|
|
2
|
+
import { getPendingRenderInputFromHeaders } from '../runtime/page.js';
|
|
2
3
|
// ---------------------------------------------------------------------------
|
|
3
4
|
// Entries helper — for SvelteKit SSG prerendering
|
|
4
5
|
// ---------------------------------------------------------------------------
|
|
@@ -27,6 +28,9 @@ export async function gradialEntries() {
|
|
|
27
28
|
return normalized === '/' ? '/' : `/${normalized.replace(/^\/|\/$/g, '')}/`;
|
|
28
29
|
});
|
|
29
30
|
}
|
|
31
|
+
export function getPageRuntimeRenderInput(event) {
|
|
32
|
+
return getPendingRenderInputFromHeaders(event.request.headers);
|
|
33
|
+
}
|
|
30
34
|
// ---------------------------------------------------------------------------
|
|
31
35
|
// SvelteKit Vite plugin
|
|
32
36
|
// ---------------------------------------------------------------------------
|
package/dist/types/config.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradial/aci",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
"types": "./dist/assets/index.d.ts",
|
|
60
60
|
"import": "./dist/assets/index.js"
|
|
61
61
|
},
|
|
62
|
+
"./runtime": {
|
|
63
|
+
"types": "./dist/runtime/page.d.ts",
|
|
64
|
+
"import": "./dist/runtime/page.js"
|
|
65
|
+
},
|
|
62
66
|
"./react": {
|
|
63
67
|
"types": "./dist/react/index.d.ts",
|
|
64
68
|
"import": "./dist/react/index.js"
|
|
@@ -129,13 +133,13 @@
|
|
|
129
133
|
}
|
|
130
134
|
},
|
|
131
135
|
"devDependencies": {
|
|
132
|
-
"@vercel/edge-config": "^1.4.3",
|
|
133
136
|
"@types/node": "^24.10.1",
|
|
134
137
|
"@types/react": "^19.0.0",
|
|
138
|
+
"@vercel/edge-config": "^1.4.3",
|
|
135
139
|
"next": "^15.5.6",
|
|
136
140
|
"react": "^19.0.0",
|
|
137
141
|
"tsx": "^4.20.0",
|
|
138
|
-
"typescript": "^5.9.
|
|
142
|
+
"typescript": "^5.9.3",
|
|
139
143
|
"zod": "^4.0.0"
|
|
140
144
|
}
|
|
141
145
|
}
|
package/src/types/config.ts
CHANGED
package/bin/aci
DELETED
|
Binary file
|