@marvalt/digivalt-core 0.2.26 → 0.2.28

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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Prefix a root-absolute path with Vite's `import.meta.env.BASE_URL`.
3
+ * Used so Pages Function URLs (`/api/...`) work when the app is built with a non-root `base`
4
+ * (e.g. path mounts via digivalt-uworker).
5
+ *
6
+ * - Absolute http(s) URLs and protocol-relative URLs are returned unchanged.
7
+ * - Empty / unset BASE_URL (`/` or `./`) leaves root-absolute paths as-is.
8
+ */
9
+ export declare function withBasePath(path: string): string;
@@ -1 +1,2 @@
1
1
  export * from './passwordUtils';
2
+ export * from './basePath';
@@ -1,54 +1,54 @@
1
- # Cloudflare Stream (DigiValt)
2
-
3
- Consume videos offloaded by **vibune-cloudflare-videos** via the WordPress REST field `cloudflare_stream` on media attachments.
4
-
5
- ## Import
6
-
7
- ```ts
8
- import {
9
- CloudflareStreamPlayer,
10
- resolveCloudflareStream,
11
- isCloudflareStreamReady,
12
- recommendedStreamPreconnectHosts,
13
- } from '@marvalt/digivalt-core/media';
14
- ```
15
-
16
- ## Static / generated media
17
-
18
- Media JSON from `@marvalt/wadapter` keeps the full REST object. Once the WP plugin is active:
19
-
20
- ```ts
21
- const media = /* item from wordpress media list */;
22
- const stream = resolveCloudflareStream(media);
23
-
24
- if (isCloudflareStreamReady(stream)) {
25
- // stream.iframe, stream.playback.hls, stream.thumbnail, …
26
- }
27
- ```
28
-
29
- ## Player
30
-
31
- ```tsx
32
- <CloudflareStreamPlayer
33
- stream={resolveCloudflareStream(media)}
34
- title={media.title?.rendered ?? 'Video'}
35
- autoplay={false}
36
- muted={false}
37
- />
38
- ```
39
-
40
- - Loads the Stream **iframe** only when `ready` is true.
41
- - Otherwise shows `thumbnail` (or `posterFallback`).
42
-
43
- ## Preconnect
44
-
45
- ```ts
46
- recommendedStreamPreconnectHosts(stream?.iframe);
47
- // also: recommendedPreconnectHosts from @marvalt/digivalt-core/seo accepts Stream hosts
48
- ```
49
-
50
- ## Requirements
51
-
52
- - WordPress plugin **vibune-cloudflare-videos** active and configured
53
- - `@marvalt/wadapter` ≥ **2.3.60** (typed `cloudflare_stream`)
54
- - `@marvalt/digivalt-core` ≥ **0.2.26**
1
+ # Cloudflare Stream (DigiValt)
2
+
3
+ Consume videos offloaded by **vibune-cloudflare-videos** via the WordPress REST field `cloudflare_stream` on media attachments.
4
+
5
+ ## Import
6
+
7
+ ```ts
8
+ import {
9
+ CloudflareStreamPlayer,
10
+ resolveCloudflareStream,
11
+ isCloudflareStreamReady,
12
+ recommendedStreamPreconnectHosts,
13
+ } from '@marvalt/digivalt-core/media';
14
+ ```
15
+
16
+ ## Static / generated media
17
+
18
+ Media JSON from `@marvalt/wadapter` keeps the full REST object. Once the WP plugin is active:
19
+
20
+ ```ts
21
+ const media = /* item from wordpress media list */;
22
+ const stream = resolveCloudflareStream(media);
23
+
24
+ if (isCloudflareStreamReady(stream)) {
25
+ // stream.iframe, stream.playback.hls, stream.thumbnail, …
26
+ }
27
+ ```
28
+
29
+ ## Player
30
+
31
+ ```tsx
32
+ <CloudflareStreamPlayer
33
+ stream={resolveCloudflareStream(media)}
34
+ title={media.title?.rendered ?? 'Video'}
35
+ autoplay={false}
36
+ muted={false}
37
+ />
38
+ ```
39
+
40
+ - Loads the Stream **iframe** only when `ready` is true.
41
+ - Otherwise shows `thumbnail` (or `posterFallback`).
42
+
43
+ ## Preconnect
44
+
45
+ ```ts
46
+ recommendedStreamPreconnectHosts(stream?.iframe);
47
+ // also: recommendedPreconnectHosts from @marvalt/digivalt-core/seo accepts Stream hosts
48
+ ```
49
+
50
+ ## Requirements
51
+
52
+ - WordPress plugin **vibune-cloudflare-videos** active and configured
53
+ - `@marvalt/wadapter` ≥ **2.3.60** (typed `cloudflare_stream`)
54
+ - `@marvalt/digivalt-core` ≥ **0.2.26**
@@ -49,7 +49,8 @@ Align **`name`** in `wrangler.toml` with your **Cloudflare Pages** project. Loca
49
49
 
50
50
  | Area | Notes |
51
51
  |------|--------|
52
- | **WordPress / static gen** | `VITE_WORDPRESS_API_URL`, `VITE_AUTH_MODE`, `VITE_CLOUDFLARE_WORKER_URL`, `VITE_LOCAL_DEVELOPMENT`, `VITE_ENABLED_POST_TYPES`, `VITE_DEFAULT_MAX_ITEMS`, `VITE_USE_DSTYLER`, `VITE_FRONTEND_ID` / `VITE_FRONTEND_NAME` — used by hooks, generators, and `getIntegrationConfig` / `getAppEnvironmentConfig`. **`google_reviews`** in `VITE_ENABLED_POST_TYPES` is a pseudo-type (not a WordPress CPT): it opt-in enables build-time fetch of `public/google-reviews-data.json` via the `vibune-google-reviews` plugin. |
52
+ | **Path mounts (digivalt-uworker)** | Consumer apps only: set Vite `base` (e.g. `/landing-page/`) and React Router `basename` to match the Worker `BASE_PATH`. Form/API helpers in this package use `withBasePath()` so `/api/*` follows `import.meta.env.BASE_URL`. See [PATH-MOUNT.md](./PATH-MOUNT.md). `digivalt-landing` stays root-hosted. |
53
+ | **WordPress / static gen** | `VITE_WORDPRESS_API_URL`, `VITE_AUTH_MODE`, `VITE_CLOUDFLARE_WORKER_URL`, `VITE_LOCAL_DEVELOPMENT`, `VITE_ENABLED_POST_TYPES`, `VITE_DEFAULT_MAX_ITEMS`, `VITE_USE_DSTYLER`, `VITE_FRONTEND_ID` / `VITE_FRONTEND_NAME` — used by hooks, generators, and `getIntegrationConfig` / `getAppEnvironmentConfig`. **`VITE_FRONTEND_ID`** also selects DigiValt menu locations `{id}-header` / `{id}-footer` (fallback `default-*`). **`google_reviews`** in `VITE_ENABLED_POST_TYPES` is a pseudo-type (not a WordPress CPT): it opt-in enables build-time fetch of `public/google-reviews-data.json` via the `vibune-google-reviews` plugin. |
53
54
  | **Theme** | `VITE_THEME` — optional; see `loadTheme` in `config/themes`. |
54
55
  | **Integrations (URLs often public; secrets in `.env.local`)** | Mautic, SuiteCRM, Supabase, Chatwoot, Gravity Forms — see `getIntegrationConfig` in `src/config/integrations.ts`. `VITE_SUITECRM_TOKEN_URL` is optional for non-default OAuth token endpoints (`environment.ts`). |
55
56
  | **SEO** | `VITE_SEO_*` — see [SEO-PERFORMANCE.md](./SEO-PERFORMANCE.md) and `getSEOConfig`. |
@@ -76,8 +76,8 @@ Import from `@marvalt/digivalt-core/generators` only:
76
76
 
77
77
  After `loadWordPressData()` from `@marvalt/digivalt-core/static`, wire the app shell and routes using WordPress static data:
78
78
 
79
- 1. Menus from `getNavigationMenu()` / `getMenuById()` (+ `getParsedHeader()` / `getHeaderMenuId()`).
80
- 2. Header/footer template blocks from `getHeader()` / `getFooter()`.
79
+ 1. Menus from `getNavigationMenu()` / `getFooterNavigationMenu()` / `getMenuById()` (+ `getParsedHeader()` / `getHeaderMenuId()` / `getFooterMenuId()`). Assign classic menus in WP under **Appearance → Menus → Manage Locations** (`{frontendId}-header|footer`, then `default-*`).
80
+ 2. Optional header/footer template blocks from `getHeader()` / `getFooter()` (legacy). Prefer app-owned chrome + location menus for multi-frontend.
81
81
  3. Site identity from `getSiteSettings()` / `getLogoUrl()` / `getSiteIconUrl()`.
82
82
  4. Theme styles from `getWordPressData().theme_styles` mapped into app styling/tokens.
83
83
  5. Pages/posts/CPT routes from `getWordPressPages()`, `getWordPressPageBySlug()`, `getWordPressPosts()`, and `front_page`.
@@ -0,0 +1,43 @@
1
+ # Path mounts (digivalt-uworker)
2
+
3
+ Serve a DigiValt Cloudflare Pages app under a path on another hostname (e.g. WordPress at `https://domain.tld`, DigiValt at `https://domain.tld/landing-page`) using the **digivalt-uworker** Worker.
4
+
5
+ ## Responsibilities
6
+
7
+ | Layer | Job |
8
+ |-------|-----|
9
+ | **digivalt-uworker** | Env `ORIGIN` + `BASE_PATH`; strip/prefix paths; rewrite `Location` + light HTML `href`/`src`/`action` |
10
+ | **Consumer DigiValt app** | Vite `base`, React Router `basename`, `VITE_SEO_SITE_URL` |
11
+ | **@marvalt/digivalt-core** | `withBasePath()` so browser `/api/*` (Gravity Forms, Mautic, etc.) follow `import.meta.env.BASE_URL` |
12
+
13
+ `digivalt-landing` is **not** path-mounted; keep it root-hosted. Use a separate DigiValt project for path mounts.
14
+
15
+ ## Consumer app setup
16
+
17
+ 1. Vite (`vite.config.ts`):
18
+
19
+ ```ts
20
+ base: process.env.VITE_BASE_PATH
21
+ ? `${process.env.VITE_BASE_PATH.replace(/\/$/, '')}/`
22
+ : '/',
23
+ ```
24
+
25
+ 2. React Router: `BrowserRouter basename={import.meta.env.BASE_URL.replace(/\/$/, '') || undefined}`
26
+
27
+ 3. Env: `VITE_SEO_SITE_URL=https://domain.tld/landing-page` (public URL, including path)
28
+
29
+ 4. Depend on `@marvalt/digivalt-core` **≥ 0.2.27**
30
+
31
+ 5. Deploy Pages, then point digivalt-uworker `ORIGIN` at that Pages URL and `BASE_PATH` at `/landing-page`
32
+
33
+ ## Import helper
34
+
35
+ ```ts
36
+ import { withBasePath } from '@marvalt/digivalt-core/services';
37
+ // e.g. fetch(withBasePath('/api/custom'))
38
+ ```
39
+
40
+ ## Caveats
41
+
42
+ - One Pages build = one base path. Pages apex (`*.pages.dev/`) looks broken; `*.pages.dev/landing-page/` usually works.
43
+ - Absolute URLs inside generated WordPress HTML are not rewritten by the Worker.
package/docs/README.md CHANGED
@@ -8,6 +8,7 @@ Read these in order for DigiValt app setup, deploy, and SEO.
8
8
  | [AI-LOCAL-WORDPRESS-BOOTSTRAP.md](./AI-LOCAL-WORDPRESS-BOOTSTRAP.md) | Humans | Local WordPress handover runbook |
9
9
  | [LOVABLE-MASTER-PROMPT.md](./LOVABLE-MASTER-PROMPT.md) | AI tools | Tool-agnostic scaffold prompt |
10
10
  | [SEO-PERFORMANCE.md](./SEO-PERFORMANCE.md) | Devs | `DigiValtSeoHead`, sitemap, `VITE_SEO_*`, performance |
11
+ | [PATH-MOUNT.md](./PATH-MOUNT.md) | Devs | Path mounts via digivalt-uworker + Vite `base` + `withBasePath` |
11
12
  | [CLOUDFLARE-STREAM.md](./CLOUDFLARE-STREAM.md) | Devs | Stream helpers + `CloudflareStreamPlayer` (`/media`) |
12
13
 
13
14
  Package root [README.md](../README.md) covers `digivalt-init`, generators, and entry points.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marvalt/digivalt-core",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "Core glue logic and shared context for DigiVAlt frontend applications",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "main": "dist/index.cjs",
@@ -116,7 +116,7 @@
116
116
  "@marvalt/sadapter": "^0.1.5",
117
117
  "@marvalt/shcoder": "^0.1.35",
118
118
  "@marvalt/tadapter": "^1.0.12",
119
- "@marvalt/wadapter": "^2.3.60",
119
+ "@marvalt/wadapter": "^2.3.61",
120
120
  "@marvalt/wparser": "^0.1.79",
121
121
  "@radix-ui/react-toast": "^1.2.15",
122
122
  "class-variance-authority": "^0.7.1",