@gradial/aci 0.1.0 → 0.1.1

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 (50) hide show
  1. package/README.md +1 -1
  2. package/bin/aci.js +45 -0
  3. package/dist/assets/index.d.ts +1 -0
  4. package/dist/assets/index.js +1 -0
  5. package/dist/astro/index.d.ts +24 -2
  6. package/dist/astro/index.js +42 -4
  7. package/dist/content/index.d.ts +0 -3
  8. package/dist/content/index.js +0 -3
  9. package/dist/content/provider.d.ts +32 -8
  10. package/dist/content/provider.js +26 -16
  11. package/dist/content/routes.d.ts +6 -12
  12. package/dist/content/routes.js +9 -55
  13. package/dist/content/validation.js +1 -1
  14. package/dist/define-layout.js +5 -1
  15. package/dist/dev/browser.d.ts +1 -1
  16. package/dist/dev/browser.js +1 -1
  17. package/dist/dev/index.d.ts +3 -3
  18. package/dist/dev/index.js +8 -8
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +1 -0
  21. package/dist/next/config.d.ts +14 -0
  22. package/dist/next/config.js +22 -0
  23. package/dist/next/dev-refresh.js +4 -4
  24. package/dist/next/edge-config.d.ts +1 -0
  25. package/dist/next/edge-config.js +92 -0
  26. package/dist/next/index.d.ts +2 -0
  27. package/dist/next/index.js +2 -0
  28. package/dist/next/middleware.js +4 -6
  29. package/dist/next/server.d.ts +5 -24
  30. package/dist/next/server.js +47 -152
  31. package/dist/providers/file.d.ts +11 -17
  32. package/dist/providers/file.js +44 -78
  33. package/dist/providers/s3.d.ts +24 -0
  34. package/dist/providers/s3.js +162 -0
  35. package/dist/sveltekit/index.d.ts +18 -2
  36. package/dist/sveltekit/index.js +35 -4
  37. package/dist/testing/index.d.ts +14 -12
  38. package/dist/testing/index.js +41 -28
  39. package/dist/types/component.d.ts +19 -2
  40. package/dist/types/config.d.ts +4 -0
  41. package/dist/types/image.d.ts +51 -0
  42. package/dist/types/image.js +58 -0
  43. package/dist/types/index.d.ts +1 -0
  44. package/dist/types/index.js +1 -0
  45. package/dist/types/layout.d.ts +12 -0
  46. package/package.json +26 -2
  47. package/src/cli/compile-registry.mjs +162 -0
  48. package/src/cli/css-stub-loader.mjs +27 -0
  49. package/src/cli/generate-registry.mjs +72 -0
  50. package/src/cli/validate-content.mjs +391 -0
package/README.md CHANGED
@@ -56,7 +56,7 @@ Use this in unit tests when you want the same provider API as
56
56
  Publish from this package directory:
57
57
 
58
58
  ```bash
59
- npm publish --access restricted
59
+ npm publish --access public
60
60
  ```
61
61
 
62
62
  The package includes a `prepack` script that builds `dist` before packing or
package/bin/aci.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import { execFileSync } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ import { createRequire } from 'node:module';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const require = createRequire(import.meta.url);
9
+
10
+ const PLATFORMS = {
11
+ 'darwin-arm64': '@gradial/cli-darwin-arm64',
12
+ 'darwin-x64': '@gradial/cli-darwin-x64',
13
+ 'linux-x64': '@gradial/cli-linux-x64',
14
+ 'linux-arm64': '@gradial/cli-linux-arm64',
15
+ 'win32-x64': '@gradial/cli-win32-x64',
16
+ };
17
+
18
+ const key = `${process.platform}-${process.arch}`;
19
+ const pkg = PLATFORMS[key];
20
+ if (!pkg) {
21
+ console.error(`ACI: unsupported platform ${key}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ const ext = process.platform === 'win32' ? '.exe' : '';
26
+ let bin;
27
+ const localBin = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..', 'bin', `aci${ext}`);
28
+ if (process.env.ACI_BIN) {
29
+ bin = process.env.ACI_BIN;
30
+ } else if (existsSync(localBin)) {
31
+ bin = localBin;
32
+ }
33
+
34
+ try {
35
+ bin ||= require.resolve(`${pkg}/bin/aci${ext}`);
36
+ } catch {
37
+ console.error('ACI: binary not installed. Run: npm install');
38
+ process.exit(1);
39
+ }
40
+
41
+ try {
42
+ execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });
43
+ } catch (error) {
44
+ process.exit(error.status ?? 1);
45
+ }
@@ -0,0 +1 @@
1
+ export { type GradialImage, type ImageSource, type PictureSource, type ImageSlotContract, type SlotOutput, type ImageHTMLAttributes, GradialImageSchema, renderImageHTML, } from '../types/image.js';
@@ -0,0 +1 @@
1
+ export { GradialImageSchema, renderImageHTML, } from '../types/image.js';
@@ -1,4 +1,4 @@
1
- import { type BareMetalContentWatchOptions } from '../dev/index.js';
1
+ import { type GradialContentWatchOptions } from '../dev/index.js';
2
2
  interface AstroConfigSetupParams {
3
3
  injectScript(stage: 'head-inline' | 'page' | 'page-ssr', content: string): void;
4
4
  updateConfig(config: {
@@ -7,11 +7,33 @@ interface AstroConfigSetupParams {
7
7
  };
8
8
  }): void;
9
9
  }
10
+ interface AstroBuildDoneParams {
11
+ dir: URL;
12
+ }
10
13
  export interface AstroIntegrationLike {
11
14
  name: string;
12
15
  hooks: {
13
16
  'astro:config:setup'(params: AstroConfigSetupParams): void;
17
+ 'astro:build:done'?(params: AstroBuildDoneParams): void;
18
+ };
19
+ }
20
+ /**
21
+ * Generates static paths from the compiled content manifest for Astro.
22
+ *
23
+ * Usage in a catch-all page (e.g. `pages/[...slug].astro`):
24
+ * ```ts
25
+ * import { getGradialStaticPaths } from '@gradial/aci/astro';
26
+ * export const getStaticPaths = getGradialStaticPaths;
27
+ * ```
28
+ */
29
+ export declare function getGradialStaticPaths(): Promise<Array<{
30
+ params: {
31
+ slug?: string;
14
32
  };
33
+ }>>;
34
+ export interface GradialAstroOptions extends GradialContentWatchOptions {
35
+ /** Path to compiled content root. Defaults to ACI_CONTENT_ROOT env or '.aci/compiled' */
36
+ compiledRoot?: string;
15
37
  }
16
- export declare function baremetalAstro(options?: BareMetalContentWatchOptions): AstroIntegrationLike;
38
+ export declare function gradialAstro(options?: GradialAstroOptions): AstroIntegrationLike;
17
39
  export {};
@@ -1,7 +1,35 @@
1
- import { baremetalContentWatchPlugin, devRefreshPort, devRefreshScript, } from '../dev/index.js';
2
- export function baremetalAstro(options = {}) {
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { gradialContentWatchPlugin, devRefreshPort, devRefreshScript, } from '../dev/index.js';
4
+ // ---------------------------------------------------------------------------
5
+ // Static paths helper — for Astro SSG
6
+ // ---------------------------------------------------------------------------
7
+ /**
8
+ * Generates static paths from the compiled content manifest for Astro.
9
+ *
10
+ * Usage in a catch-all page (e.g. `pages/[...slug].astro`):
11
+ * ```ts
12
+ * import { getGradialStaticPaths } from '@gradial/aci/astro';
13
+ * export const getStaticPaths = getGradialStaticPaths;
14
+ * ```
15
+ */
16
+ export async function getGradialStaticPaths() {
17
+ const { FileContentProvider } = await import('../providers/file.js');
18
+ const { normalizeRoute } = await import('../content/routes.js');
19
+ const provider = new FileContentProvider();
20
+ const routes = await provider.listRoutes();
21
+ return routes.map((entry) => {
22
+ const normalized = normalizeRoute(entry.path);
23
+ return {
24
+ params: {
25
+ slug: normalized === '/' ? undefined : normalized.replace(/^\/|\/$/g, '')
26
+ }
27
+ };
28
+ });
29
+ }
30
+ export function gradialAstro(options = {}) {
3
31
  return {
4
- name: 'baremetal-astro',
32
+ name: 'gradial-astro',
5
33
  hooks: {
6
34
  'astro:config:setup'({ injectScript, updateConfig }) {
7
35
  if (process.env.NODE_ENV === 'production') {
@@ -12,10 +40,20 @@ export function baremetalAstro(options = {}) {
12
40
  }
13
41
  updateConfig({
14
42
  vite: {
15
- plugins: [baremetalContentWatchPlugin(options)],
43
+ plugins: [gradialContentWatchPlugin(options)],
16
44
  },
17
45
  });
18
46
  },
47
+ 'astro:build:done'({ dir }) {
48
+ const siteDir = process.cwd();
49
+ const compiledRoot = path.resolve(siteDir, options.compiledRoot || process.env.ACI_CONTENT_ROOT || '.aci/compiled');
50
+ const source = path.join(compiledRoot, '.aci-dam');
51
+ if (!fs.existsSync(source))
52
+ return;
53
+ const target = path.join(dir.pathname, '.aci-dam');
54
+ fs.rmSync(target, { recursive: true, force: true });
55
+ fs.cpSync(source, target, { recursive: true });
56
+ },
19
57
  },
20
58
  };
21
59
  }
@@ -1,6 +1,3 @@
1
- export * from './contract.js';
2
1
  export * from './provider.js';
3
2
  export * from './routes.js';
4
- export * from './tailwind-validator.js';
5
3
  export * from './types.js';
6
- export * from './validation.js';
@@ -1,6 +1,3 @@
1
- export * from './contract.js';
2
1
  export * from './provider.js';
3
2
  export * from './routes.js';
4
- export * from './tailwind-validator.js';
5
3
  export * from './types.js';
6
- export * from './validation.js';
@@ -1,15 +1,39 @@
1
1
  import type { KernelPage, KernelRouteMetadata, KernelSiteConfig, RenderInput } from './types.js';
2
- export interface ContentProvider<TPage extends KernelPage = KernelPage, TSiteConfig extends KernelSiteConfig = KernelSiteConfig> {
3
- loadSiteConfig(): Promise<TSiteConfig>;
4
- loadPage(route?: string): Promise<TPage | null>;
5
- listRoutes(): Promise<string[]>;
6
- listPublishedRoutes?(): Promise<string[]>;
7
- resolveRouteMetadata?(route?: string): Promise<KernelRouteMetadata>;
2
+ export interface RouteEntry {
3
+ slug: string;
4
+ path: string;
5
+ payloadRef: string;
6
+ digest: string;
7
+ fragmentRefs?: string[];
8
+ }
9
+ export interface FragmentEntry {
10
+ id: string;
11
+ payloadRef: string;
12
+ digest: string;
13
+ fragmentRefs?: string[];
14
+ }
15
+ export interface CompiledManifest {
16
+ manifestVersion: string;
17
+ buildDigest: string;
18
+ siteConfigRef: string;
19
+ routes: Record<string, RouteEntry>;
20
+ fragments: Record<string, FragmentEntry>;
21
+ }
22
+ export interface ContentProvider {
23
+ getSiteConfig<T = unknown>(): Promise<T>;
24
+ getPage<T = unknown>(route: string): Promise<T>;
25
+ getFragment<T = unknown>(id: string): Promise<T>;
26
+ listRoutes(): Promise<RouteEntry[]>;
27
+ }
28
+ export declare class PageNotFoundError extends Error {
29
+ constructor(route: string, cause?: unknown);
30
+ }
31
+ export declare class FragmentNotFoundError extends Error {
32
+ constructor(id: string, cause?: unknown);
8
33
  }
9
34
  export interface RenderInputOptions {
10
35
  domain?: string;
11
36
  locale?: string;
12
37
  }
13
- export declare function loadRenderInput<TPage extends KernelPage = KernelPage, TSiteConfig extends KernelSiteConfig = KernelSiteConfig>(provider: ContentProvider<TPage, TSiteConfig>, route?: string, options?: RenderInputOptions): Promise<RenderInput<TPage, TSiteConfig>>;
38
+ export declare function loadRenderInput(provider: ContentProvider, route?: string, options?: RenderInputOptions): Promise<RenderInput>;
14
39
  export declare function routeMetadataForContent(siteConfig: KernelSiteConfig, page: KernelPage | null): KernelRouteMetadata;
15
- export declare function resolveRouteMetadata(provider: ContentProvider, route?: string): Promise<KernelRouteMetadata>;
@@ -1,14 +1,35 @@
1
1
  import { normalizeRoute } from './routes.js';
2
+ // ---------------------------------------------------------------------------
3
+ // Errors
4
+ // ---------------------------------------------------------------------------
5
+ export class PageNotFoundError extends Error {
6
+ constructor(route, cause) {
7
+ super(`Page not found for route ${route}`);
8
+ this.name = 'PageNotFoundError';
9
+ this.cause = cause;
10
+ }
11
+ }
12
+ export class FragmentNotFoundError extends Error {
13
+ constructor(id, cause) {
14
+ super(`Fragment not found: ${id}`);
15
+ this.name = 'FragmentNotFoundError';
16
+ this.cause = cause;
17
+ }
18
+ }
2
19
  export async function loadRenderInput(provider, route = '/', options = {}) {
3
- const normalizedRoute = normalizeRoute(route);
20
+ const normalized = normalizeRoute(route);
4
21
  const [siteConfig, page] = await Promise.all([
5
- provider.loadSiteConfig(),
6
- provider.loadPage(normalizedRoute)
22
+ provider.getSiteConfig(),
23
+ provider.getPage(normalized).catch((error) => {
24
+ if (error instanceof PageNotFoundError)
25
+ return null;
26
+ throw error;
27
+ })
7
28
  ]);
8
29
  return {
9
- route: normalizedRoute,
30
+ route: normalized,
10
31
  domain: options.domain || siteConfig.domain,
11
- locale: (options.locale || siteConfig.defaultLocale).toLowerCase(),
32
+ locale: (options.locale || siteConfig.defaultLocale || 'en-us').toLowerCase(),
12
33
  siteConfig,
13
34
  page
14
35
  };
@@ -23,14 +44,3 @@ export function routeMetadataForContent(siteConfig, page) {
23
44
  siteName: siteConfig.seo?.siteName || siteConfig.title
24
45
  };
25
46
  }
26
- export async function resolveRouteMetadata(provider, route = '/') {
27
- if (provider.resolveRouteMetadata) {
28
- return provider.resolveRouteMetadata(route);
29
- }
30
- const normalizedRoute = normalizeRoute(route);
31
- const [siteConfig, page] = await Promise.all([
32
- provider.loadSiteConfig(),
33
- provider.loadPage(normalizedRoute)
34
- ]);
35
- return routeMetadataForContent(siteConfig, page);
36
- }
@@ -1,16 +1,10 @@
1
- export declare const DEFAULT_DOMAIN = "www.baremetal.local";
1
+ export declare const DEFAULT_DOMAIN = "www.aci.local";
2
2
  export declare const DEFAULT_LOCALE = "en-us";
3
- export interface ContentPathOptions {
4
- cwd?: string;
5
- env?: NodeJS.ProcessEnv;
6
- maxWorkspaceDepth?: number;
7
- }
8
3
  export declare function activeDomain(env?: NodeJS.ProcessEnv): string;
9
4
  export declare function activeLocale(env?: NodeJS.ProcessEnv): string;
10
5
  export declare function normalizeRoute(route: string): string;
11
- export declare function workspaceRoot(options?: ContentPathOptions): string;
12
- export declare function contentRoot(options?: ContentPathOptions): string;
13
- export declare function siteRoot(options?: ContentPathOptions): string;
14
- export declare function localeRoot(options?: ContentPathOptions): string;
15
- export declare function routeToPagePath(route: string, options?: ContentPathOptions): string;
16
- export declare function routeFromRelativePagePath(relativePath: string): string;
6
+ /**
7
+ * Returns the root directory for compiled content output.
8
+ * Reads from ACI_CONTENT_ROOT or defaults to `.aci/compiled` relative to cwd.
9
+ */
10
+ export declare function compiledContentRoot(env?: NodeJS.ProcessEnv): string;
@@ -1,15 +1,11 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
3
- export const DEFAULT_DOMAIN = 'www.baremetal.local';
2
+ export const DEFAULT_DOMAIN = 'www.aci.local';
4
3
  export const DEFAULT_LOCALE = 'en-us';
5
- function resolveFrom(cwd, value) {
6
- return path.isAbsolute(value) ? value : path.resolve(cwd, value);
7
- }
8
4
  export function activeDomain(env = process.env) {
9
- return env.BARE_METAL_DOMAIN || DEFAULT_DOMAIN;
5
+ return env.ACI_DOMAIN || DEFAULT_DOMAIN;
10
6
  }
11
7
  export function activeLocale(env = process.env) {
12
- return (env.BARE_METAL_LOCALE || DEFAULT_LOCALE).toLowerCase();
8
+ return (env.ACI_LOCALE || DEFAULT_LOCALE).toLowerCase();
13
9
  }
14
10
  export function normalizeRoute(route) {
15
11
  const trimmed = String(route || '').trim();
@@ -18,52 +14,10 @@ export function normalizeRoute(route) {
18
14
  }
19
15
  return `/${trimmed.replace(/^\/+/, '').replace(/\/+$/, '')}`;
20
16
  }
21
- export function workspaceRoot(options = {}) {
22
- const cwd = options.cwd || process.cwd();
23
- const env = options.env || process.env;
24
- if (env.BARE_METAL_WORKSPACE_ROOT) {
25
- return resolveFrom(cwd, env.BARE_METAL_WORKSPACE_ROOT);
26
- }
27
- let current = cwd;
28
- const maxDepth = options.maxWorkspaceDepth ?? 6;
29
- for (let depth = 0; depth < maxDepth; depth += 1) {
30
- if (fs.existsSync(path.join(current, '.content', 'config', 'site.json'))) {
31
- return current;
32
- }
33
- const parent = path.dirname(current);
34
- if (parent === current) {
35
- break;
36
- }
37
- current = parent;
38
- }
39
- return cwd;
40
- }
41
- export function contentRoot(options = {}) {
42
- const cwd = options.cwd || process.cwd();
43
- const env = options.env || process.env;
44
- if (env.BARE_METAL_CONTENT_ROOT) {
45
- return resolveFrom(cwd, env.BARE_METAL_CONTENT_ROOT);
46
- }
47
- return path.join(workspaceRoot(options), '.content');
48
- }
49
- export function siteRoot(options = {}) {
50
- return path.join(contentRoot(options), 'config');
51
- }
52
- export function localeRoot(options = {}) {
53
- return path.join(contentRoot(options), 'pages');
54
- }
55
- export function routeToPagePath(route, options = {}) {
56
- const normalized = normalizeRoute(route);
57
- if (normalized === '/') {
58
- return path.join(localeRoot(options), 'home', '_index.json');
59
- }
60
- return path.join(localeRoot(options), normalized.slice(1), '_index.json');
61
- }
62
- export function routeFromRelativePagePath(relativePath) {
63
- const normalized = relativePath.split(/[\\/]+/).join('/');
64
- const slug = normalized.replace(/\/_index\.json$/, '');
65
- if (slug === 'home') {
66
- return '/';
67
- }
68
- return normalizeRoute(slug);
17
+ /**
18
+ * Returns the root directory for compiled content output.
19
+ * Reads from ACI_CONTENT_ROOT or defaults to `.aci/compiled` relative to cwd.
20
+ */
21
+ export function compiledContentRoot(env = process.env) {
22
+ return env.ACI_CONTENT_ROOT || path.resolve(process.cwd(), '.aci/compiled');
69
23
  }
@@ -165,7 +165,7 @@ export function formatZodError(source, error) {
165
165
  return `- ${path}: ${issue.message}`;
166
166
  })
167
167
  .join('\n');
168
- return `Invalid bare-metal content in ${source}:\n${issues}`;
168
+ return `Invalid Gradial content in ${source}:\n${issues}`;
169
169
  }
170
170
  export function parseWithSchema(schema, value, source) {
171
171
  const parsed = schema.safeParse(value);
@@ -1,5 +1,9 @@
1
1
  export function defineLayout(definition) {
2
- return definition;
2
+ return {
3
+ name: definition.name,
4
+ slots: definition.slots,
5
+ defaults: definition.defaults,
6
+ };
3
7
  }
4
8
  export function slot(name, required = false) {
5
9
  return { name, required };
@@ -1,5 +1,5 @@
1
1
  export declare const DEFAULT_DEV_REFRESH_PORT = 24680;
2
- export declare const DEFAULT_DEV_REFRESH_PATH = "/baremetal-dev";
2
+ export declare const DEFAULT_DEV_REFRESH_PATH = "/aci-dev";
3
3
  export interface DevRefreshOptions {
4
4
  wsPort?: number | string;
5
5
  path?: string;
@@ -1,2 +1,2 @@
1
1
  export const DEFAULT_DEV_REFRESH_PORT = 24680;
2
- export const DEFAULT_DEV_REFRESH_PATH = '/baremetal-dev';
2
+ export const DEFAULT_DEV_REFRESH_PATH = '/aci-dev';
@@ -2,10 +2,10 @@ import { type DevRefreshOptions } from './browser.js';
2
2
  export { DEFAULT_DEV_REFRESH_PATH, DEFAULT_DEV_REFRESH_PORT, type DevRefreshOptions } from './browser.js';
3
3
  declare global {
4
4
  interface Window {
5
- __bareMetalDevRefresh?: boolean;
5
+ __gradialDevRefresh?: boolean;
6
6
  }
7
7
  }
8
- export interface BareMetalContentWatchOptions extends DevRefreshOptions {
8
+ export interface GradialContentWatchOptions extends DevRefreshOptions {
9
9
  contentRoot?: string;
10
10
  enabled?: boolean;
11
11
  }
@@ -27,4 +27,4 @@ export interface VitePluginLike {
27
27
  export declare function devRefreshPort(options?: DevRefreshOptions): number;
28
28
  export declare function devRefreshScript(options?: DevRefreshOptions): string;
29
29
  export declare function devRefreshScriptTag(options?: DevRefreshOptions): string;
30
- export declare function baremetalContentWatchPlugin(options?: BareMetalContentWatchOptions): VitePluginLike;
30
+ export declare function gradialContentWatchPlugin(options?: GradialContentWatchOptions): VitePluginLike;
package/dist/dev/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { contentRoot } from '../content/routes.js';
2
+ import { compiledContentRoot } from '../content/routes.js';
3
3
  import { DEFAULT_DEV_REFRESH_PATH, DEFAULT_DEV_REFRESH_PORT, } from './browser.js';
4
4
  export { DEFAULT_DEV_REFRESH_PATH, DEFAULT_DEV_REFRESH_PORT } from './browser.js';
5
5
  function numberOption(value, fallback) {
@@ -10,7 +10,7 @@ function numberOption(value, fallback) {
10
10
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
11
11
  }
12
12
  export function devRefreshPort(options = {}) {
13
- const value = options.wsPort ?? process.env.BARE_METAL_DEV_WS_PORT;
13
+ const value = options.wsPort ?? process.env.ACI_DEV_WS_PORT;
14
14
  if (value === 0 || value === '0') {
15
15
  return 0;
16
16
  }
@@ -24,8 +24,8 @@ export function devRefreshScript(options = {}) {
24
24
  const wsPath = options.path || DEFAULT_DEV_REFRESH_PATH;
25
25
  const reconnectMs = numberOption(options.reconnectMs, 1000);
26
26
  return `(() => {
27
- if (typeof window === 'undefined' || window.__bareMetalDevRefresh) return;
28
- window.__bareMetalDevRefresh = true;
27
+ if (typeof window === 'undefined' || window.__gradialDevRefresh) return;
28
+ window.__gradialDevRefresh = true;
29
29
  const port = ${JSON.stringify(wsPort)};
30
30
  const path = ${JSON.stringify(wsPath)};
31
31
  const reconnectMs = ${JSON.stringify(reconnectMs)};
@@ -47,16 +47,16 @@ export function devRefreshScript(options = {}) {
47
47
  export function devRefreshScriptTag(options = {}) {
48
48
  return `<script>${devRefreshScript(options)}</script>`;
49
49
  }
50
- export function baremetalContentWatchPlugin(options = {}) {
51
- const enabled = options.enabled ?? process.env.BARE_METAL_DISABLE_CONTENT_WATCH !== '1';
50
+ export function gradialContentWatchPlugin(options = {}) {
51
+ const enabled = options.enabled ?? process.env.ACI_DISABLE_CONTENT_WATCH !== '1';
52
52
  return {
53
- name: 'baremetal-content-watch',
53
+ name: 'gradial-content-watch',
54
54
  apply: 'serve',
55
55
  configureServer(server) {
56
56
  if (!enabled) {
57
57
  return;
58
58
  }
59
- const root = path.resolve(options.contentRoot || contentRoot());
59
+ const root = path.resolve(options.contentRoot || compiledContentRoot());
60
60
  server.watcher.add(root);
61
61
  server.watcher.on('all', (_eventName, filePath) => {
62
62
  const changed = path.resolve(filePath);
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './define-component.js';
2
2
  export * from './define-layout.js';
3
+ export * from './content/index.js';
3
4
  export * from './types/index.js';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './define-component.js';
2
2
  export * from './define-layout.js';
3
+ export * from './content/index.js';
3
4
  export * from './types/index.js';
@@ -0,0 +1,14 @@
1
+ interface NextRewrite {
2
+ source: string;
3
+ destination: string;
4
+ }
5
+ interface NextConfig {
6
+ rewrites?: () => Promise<NextRewrite[]> | NextRewrite[];
7
+ [key: string]: unknown;
8
+ }
9
+ export interface WithGradialOptions {
10
+ /** Asset rewrite prefix. Defaults to '/.aci-dam' */
11
+ assetPrefix?: string;
12
+ }
13
+ export declare function withGradial(nextConfig?: NextConfig, options?: WithGradialOptions): NextConfig;
14
+ export {};
@@ -0,0 +1,22 @@
1
+ export function withGradial(nextConfig = {}, options = {}) {
2
+ const assetPrefix = options.assetPrefix || '/.aci-dam';
3
+ const userRewrites = nextConfig.rewrites;
4
+ return {
5
+ ...nextConfig,
6
+ rewrites: async () => {
7
+ const gradialRewrites = [
8
+ {
9
+ source: `${assetPrefix}/:path*`,
10
+ destination: `/api/aci-assets${assetPrefix}/:path*`,
11
+ },
12
+ ];
13
+ if (!userRewrites)
14
+ return gradialRewrites;
15
+ const userResult = await (typeof userRewrites === 'function' ? userRewrites() : userRewrites);
16
+ if (Array.isArray(userResult)) {
17
+ return [...gradialRewrites, ...userResult];
18
+ }
19
+ return gradialRewrites;
20
+ },
21
+ };
22
+ }
@@ -3,10 +3,10 @@ import { useEffect } from 'react';
3
3
  import { DEFAULT_DEV_REFRESH_PATH, DEFAULT_DEV_REFRESH_PORT, } from '../dev/browser.js';
4
4
  export function DevRefresh({ enabled = process.env.NODE_ENV !== 'production', wsPort = DEFAULT_DEV_REFRESH_PORT, path = DEFAULT_DEV_REFRESH_PATH, reconnectMs = 1000, }) {
5
5
  useEffect(() => {
6
- if (!enabled || Number(wsPort) <= 0 || typeof window === 'undefined' || window.__bareMetalDevRefresh) {
6
+ if (!enabled || Number(wsPort) <= 0 || typeof window === 'undefined' || window.__gradialDevRefresh) {
7
7
  return undefined;
8
8
  }
9
- window.__bareMetalDevRefresh = true;
9
+ window.__gradialDevRefresh = true;
10
10
  let reconnectTimer;
11
11
  let socket;
12
12
  let active = true;
@@ -21,7 +21,7 @@ export function DevRefresh({ enabled = process.env.NODE_ENV !== 'production', ws
21
21
  }
22
22
  }
23
23
  catch {
24
- // Ignore non-Bare Metal dev server frames.
24
+ // Ignore non-Gradial dev server frames.
25
25
  }
26
26
  });
27
27
  socket.addEventListener('close', () => {
@@ -33,7 +33,7 @@ export function DevRefresh({ enabled = process.env.NODE_ENV !== 'production', ws
33
33
  connect();
34
34
  return () => {
35
35
  active = false;
36
- window.__bareMetalDevRefresh = false;
36
+ window.__gradialDevRefresh = false;
37
37
  if (reconnectTimer) {
38
38
  clearTimeout(reconnectTimer);
39
39
  }
@@ -0,0 +1 @@
1
+ export declare function getUncachedEdgeConfigValue(edgeConfig: string, key: string): Promise<unknown>;