fimo-next 2.2.0-staging.8 → 2.2.0

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/dist/config.d.ts CHANGED
@@ -10,9 +10,10 @@ export type FimoNextConfig<TConfig extends object = object> = TConfig | FimoNext
10
10
  * which preview provider Fimo currently uses. When an application does not
11
11
  * configure Next's development indicator, hosted Preview hides it while local
12
12
  * development keeps Next's default. Explicit application config is preserved.
13
- * Every other phase returns the application config unchanged: the Fimo
14
- * connection is resolved by `FimoProvider` and the server runtime, not by this
15
- * config wrapper.
13
+ * Every phase additionally carries the file-tracing include for
14
+ * `.fimo/config.json` so `buildFimoMetadata` can read it in deployed SSR; the
15
+ * Fimo connection itself is resolved by `FimoProvider` and the server runtime,
16
+ * not by this config wrapper.
16
17
  */
17
18
  export declare function withFimo<TConfig extends object>(applicationConfig: FimoNextConfig<TConfig>): FimoNextConfigFactory<TConfig>;
18
19
  //# sourceMappingURL=config.d.ts.map
package/dist/config.js CHANGED
@@ -6,19 +6,33 @@ function readPreviewOrigins() {
6
6
  .map((origin) => origin.trim())
7
7
  .filter(Boolean);
8
8
  }
9
+ // FIMO-2335: `buildFimoMetadata` reads `.fimo/config.json` at request time in
10
+ // deployed SSR, but Next only traces files it can see statically — without
11
+ // this include the file is missing from the server bundle.
12
+ const FIMO_TRACING_INCLUDES = { '/**': ['.fimo/config.json'] };
13
+ function withConfigTracing(config) {
14
+ const application = config.outputFileTracingIncludes;
15
+ const outputFileTracingIncludes = { ...FIMO_TRACING_INCLUDES };
16
+ for (const [route, files] of Object.entries(application ?? {})) {
17
+ outputFileTracingIncludes[route] = [...(outputFileTracingIncludes[route] ?? []), ...files];
18
+ }
19
+ return { ...config, outputFileTracingIncludes };
20
+ }
9
21
  /**
10
22
  * Connect `next dev` to Fimo's hosted preview gateway. The platform supplies
11
23
  * the allowed preview origins at runtime, so applications do not need to know
12
24
  * which preview provider Fimo currently uses. When an application does not
13
25
  * configure Next's development indicator, hosted Preview hides it while local
14
26
  * development keeps Next's default. Explicit application config is preserved.
15
- * Every other phase returns the application config unchanged: the Fimo
16
- * connection is resolved by `FimoProvider` and the server runtime, not by this
17
- * config wrapper.
27
+ * Every phase additionally carries the file-tracing include for
28
+ * `.fimo/config.json` so `buildFimoMetadata` can read it in deployed SSR; the
29
+ * Fimo connection itself is resolved by `FimoProvider` and the server runtime,
30
+ * not by this config wrapper.
18
31
  */
19
32
  export function withFimo(applicationConfig) {
20
33
  return async (phase, context) => {
21
- const config = typeof applicationConfig === 'function' ? await applicationConfig(phase, context) : applicationConfig;
34
+ const applied = typeof applicationConfig === 'function' ? await applicationConfig(phase, context) : applicationConfig;
35
+ const config = withConfigTracing(applied);
22
36
  if (phase !== NEXT_DEVELOPMENT_PHASE) {
23
37
  return config;
24
38
  }
@@ -0,0 +1,17 @@
1
+ import type { Metadata, Viewport } from 'next';
2
+ /**
3
+ * Site-wide `Metadata` defaults resolved from `.fimo/config.json#seo` — the
4
+ * values edited in Studio's Settings → SEO. Wire it as the root layout's
5
+ * `generateMetadata`. Resolves the global (`/`) SEO only; page-level
6
+ * `metadata`/`generateMetadata` exports merge over these defaults, so
7
+ * per-page SEO stays application-owned. Returns `{}` when the project
8
+ * declares no SEO config.
9
+ */
10
+ export declare function buildFimoMetadata(rootDir?: string): Metadata;
11
+ /**
12
+ * Viewport counterpart of `buildFimoMetadata` — Next renders `theme-color`
13
+ * from the viewport export, not `Metadata`. Wire it as the root layout's
14
+ * `generateViewport`.
15
+ */
16
+ export declare function buildFimoViewport(rootDir?: string): Viewport;
17
+ //# sourceMappingURL=seo.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { getConfigServer } from 'fimo/config';
2
+ import { resolveSeoForPath } from 'fimo/seo';
3
+ function toMetadataBase(url) {
4
+ if (!url) {
5
+ return undefined;
6
+ }
7
+ try {
8
+ return new URL(url);
9
+ }
10
+ catch {
11
+ return undefined;
12
+ }
13
+ }
14
+ /**
15
+ * Site-wide `Metadata` defaults resolved from `.fimo/config.json#seo` — the
16
+ * values edited in Studio's Settings → SEO. Wire it as the root layout's
17
+ * `generateMetadata`. Resolves the global (`/`) SEO only; page-level
18
+ * `metadata`/`generateMetadata` exports merge over these defaults, so
19
+ * per-page SEO stays application-owned. Returns `{}` when the project
20
+ * declares no SEO config.
21
+ */
22
+ export function buildFimoMetadata(rootDir = process.cwd()) {
23
+ const seo = resolveSeoForPath('/', getConfigServer(rootDir));
24
+ if (!seo) {
25
+ return {};
26
+ }
27
+ const metadataBase = toMetadataBase(seo.url);
28
+ return {
29
+ ...(seo.title ? { title: seo.title } : {}),
30
+ ...(seo.description ? { description: seo.description } : {}),
31
+ ...(metadataBase ? { metadataBase, alternates: { canonical: './' } } : {}),
32
+ ...(seo.robots ? { robots: seo.robots } : {}),
33
+ ...(seo.favicon ? { icons: { icon: seo.favicon, apple: seo.favicon } } : {}),
34
+ openGraph: {
35
+ type: 'website',
36
+ ...(seo.siteName ? { siteName: seo.siteName } : {}),
37
+ ...(seo.title ? { title: seo.title } : {}),
38
+ ...(seo.description ? { description: seo.description } : {}),
39
+ ...(seo.image ? { images: [seo.image] } : {}),
40
+ ...(seo.locale ? { locale: seo.locale } : {}),
41
+ },
42
+ twitter: {
43
+ card: 'summary_large_image',
44
+ ...(seo.twitterSite ? { site: seo.twitterSite } : {}),
45
+ ...(seo.title ? { title: seo.title } : {}),
46
+ ...(seo.description ? { description: seo.description } : {}),
47
+ ...(seo.image ? { images: [seo.image] } : {}),
48
+ },
49
+ };
50
+ }
51
+ /**
52
+ * Viewport counterpart of `buildFimoMetadata` — Next renders `theme-color`
53
+ * from the viewport export, not `Metadata`. Wire it as the root layout's
54
+ * `generateViewport`.
55
+ */
56
+ export function buildFimoViewport(rootDir = process.cwd()) {
57
+ const seo = resolveSeoForPath('/', getConfigServer(rootDir));
58
+ return seo?.themeColor ? { themeColor: seo.themeColor } : {};
59
+ }
@@ -8,6 +8,7 @@ export type { CreateFimoOptions, NextContentRegistry } from './facade.js';
8
8
  export { FimoProvider } from './server-provider.js';
9
9
  export type { FimoProviderProps } from './server-provider.js';
10
10
  export { getLabels } from './labels.js';
11
+ export { buildFimoMetadata, buildFimoViewport } from './seo.js';
11
12
  export type { FormClient, FormSubmissionResult } from 'fimo/forms';
12
13
  export type { GetLabelsOptions, Labels, LabelsSnapshot } from 'fimo/labels';
13
14
  export type { FimoRichTextComponents, FimoRichTextMarkProps, FimoRichTextNodeProps, } from 'fimo-react/primitives/server';
@@ -8,6 +8,7 @@ export { Boolean, Date, DateTime, Image, Json, RichText, Video } from './primiti
8
8
  export { createFimo } from './facade.js';
9
9
  export { FimoProvider } from './server-provider.js';
10
10
  export { getLabels } from './labels.js';
11
+ export { buildFimoMetadata, buildFimoViewport } from './seo.js';
11
12
  export function createContentClient(config) {
12
13
  return createServerContentClient(config, nextServerContentRuntime);
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo-next",
3
- "version": "2.2.0-staging.8",
3
+ "version": "2.2.0",
4
4
  "description": "Fimo runtime for Next.js projects.",
5
5
  "files": [
6
6
  "dist/",
@@ -45,13 +45,13 @@
45
45
  "test:watch": "vitest"
46
46
  },
47
47
  "devDependencies": {
48
- "@fimo/tsconfig": "2.2.0-staging.8",
48
+ "@fimo/tsconfig": "2.2.0",
49
49
  "@tanstack/react-query": "^5.80.6",
50
50
  "@types/node": "22.18.6",
51
51
  "@types/react": "19.2.14",
52
52
  "@types/react-dom": "19.2.3",
53
- "fimo": "2.2.0-staging.8",
54
- "fimo-react": "2.2.0-staging.8",
53
+ "fimo": "2.2.0",
54
+ "fimo-react": "2.2.0",
55
55
  "next": "16.3.3",
56
56
  "react": "19.2.4",
57
57
  "react-dom": "19.2.4",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@tanstack/react-query": "^5.80.6",
63
- "fimo": "2.2.0-staging.8",
63
+ "fimo": ">=2.0.1",
64
64
  "fimo-react": ">=2.0.1",
65
65
  "next": "^15.0.0 || ^16.0.0",
66
66
  "react": "^18.2.0 || ^19.0.0",