@decocms/apps 1.3.0 → 1.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/apps",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "description": "Deco commerce apps for TanStack Start - Shopify, VTEX, commerce types, analytics utils",
6
6
  "exports": {
@@ -58,7 +58,9 @@
58
58
  "./website/matchers/*": "./website/matchers/*.ts",
59
59
  "./website/flags/*": "./website/flags/*.ts",
60
60
  "./website/flags/multivariate/*": "./website/flags/multivariate/*.ts",
61
- "./website/utils/*": "./website/utils/*.ts"
61
+ "./website/utils/*": "./website/utils/*.ts",
62
+ "./website/sections/*": "./website/sections/*.tsx",
63
+ "./website/sections/Seo/*": "./website/sections/Seo/*.tsx"
62
64
  },
63
65
  "scripts": {
64
66
  "generate:manifests": "tsx scripts/generate-manifests.ts",
package/website/client.ts CHANGED
@@ -1,20 +1,21 @@
1
1
  /**
2
2
  * Website app singleton configuration.
3
3
  *
4
- * Follows the same pattern as vtex/client.ts and resend/client.ts.
4
+ * Uses globalThis to survive Vite module duplication (optimized deps
5
+ * vs raw source imports can create separate module instances).
5
6
  */
6
7
 
7
8
  import type { WebsiteConfig } from "./types";
8
9
 
9
- let _config: WebsiteConfig | null = null;
10
+ const G = globalThis as unknown as { __decoWebsiteConfig?: WebsiteConfig };
10
11
 
11
12
  export function configureWebsite(config: WebsiteConfig): void {
12
- _config = config;
13
+ G.__decoWebsiteConfig = config;
13
14
  }
14
15
 
15
16
  export function getWebsiteConfig(): WebsiteConfig {
16
- if (!_config) {
17
+ if (!G.__decoWebsiteConfig) {
17
18
  throw new Error("Website app not configured. Call configureWebsite() first.");
18
19
  }
19
- return _config;
20
+ return G.__decoWebsiteConfig;
20
21
  }
@@ -1,3 +1,4 @@
1
+ import { getWebsiteConfig } from "../../client";
1
2
  import SeoComponent, {
2
3
  renderTemplateString,
3
4
  type SEOSection,
@@ -12,16 +13,28 @@ type Props = Pick<
12
13
 
13
14
  /**
14
15
  * Loader that merges page-level SEO props with app-level defaults.
15
- * The framework calls this with the WebsiteConfig from the app state.
16
+ * When called by the framework, `seo` comes from the app state.
17
+ * When called standalone (e.g. asJson handler), falls back to the
18
+ * globalThis-backed singleton set by `configureWebsite()`.
16
19
  */
17
20
  export function loader(props: Props, seo?: WebsiteConfig["seo"]) {
21
+ const resolvedSeo =
22
+ seo ??
23
+ (() => {
24
+ try {
25
+ return getWebsiteConfig().seo;
26
+ } catch {
27
+ return undefined;
28
+ }
29
+ })();
30
+
18
31
  const {
19
32
  titleTemplate = "",
20
33
  descriptionTemplate = "",
21
34
  title: appTitle = "",
22
35
  description: appDescription = "",
23
36
  ...seoSiteProps
24
- } = seo ?? {};
37
+ } = resolvedSeo ?? {};
25
38
 
26
39
  const { title: _title, description: _description, ...seoProps } = props;
27
40