@altafusion/fugue-content 0.0.0-stage → 0.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +352 -2
  4. package/app/components/FugueContent404Page.vue +48 -0
  5. package/app/components/FugueContentAuthSignOut.vue +16 -0
  6. package/app/components/FugueContentContentPage.vue +33 -0
  7. package/app/components/FugueContentEditContent.vue +76 -0
  8. package/app/components/FugueContentEditorMenu.vue +60 -0
  9. package/app/components/FugueContentFooterActions.vue +32 -0
  10. package/app/components/FugueContentFragment.vue +53 -0
  11. package/app/components/FugueContentHeaderActions.vue +37 -0
  12. package/app/components/FugueContentLandingPage.vue +69 -0
  13. package/app/components/FugueContentLayoutArticle.vue +22 -0
  14. package/app/components/FugueContentLayoutArticleAside.vue +88 -0
  15. package/app/components/FugueContentLayoutLanding.vue +5 -0
  16. package/app/components/LandingHeroMedia.vue +91 -0
  17. package/app/components/content/CallToAction.vue +35 -0
  18. package/app/components/content/Hero.vue +34 -0
  19. package/app/composables/useFugueContentCatchAllRoute.ts +91 -0
  20. package/app/composables/useFugueContentFragment.ts +70 -0
  21. package/app/composables/useFugueContentI18n.ts +77 -0
  22. package/app/composables/useFugueContentLanding.ts +24 -0
  23. package/app/composables/useFugueContentPage.ts +37 -0
  24. package/app/composables/useFugueContentSettings.ts +140 -0
  25. package/app/composables/useFugueContentStudioEdit.ts +38 -0
  26. package/app/pages/[...slug].vue +7 -0
  27. package/app/pages/fragments/[slug].vue +25 -0
  28. package/app/pages/index.vue +7 -0
  29. package/app/pages/login.vue +70 -0
  30. package/app/plugins/auth-session-sync.client.ts +33 -0
  31. package/app/plugins/landing-component-registry.ts +15 -0
  32. package/app/plugins/landing-nav.ts +26 -0
  33. package/app/plugins/qe-tools.client.ts +28 -0
  34. package/app/plugins/seo-defaults.ts +4 -0
  35. package/app/plugins/settings-bridge.ts +14 -0
  36. package/app/plugins/shell-display-name.ts +18 -0
  37. package/app/plugins/studio-auto-open.client.ts +30 -0
  38. package/app/plugins/studio-dev-shortcut.client.ts +24 -0
  39. package/app/plugins/studio-footer-actions.client.ts +27 -0
  40. package/app/plugins/studio-footer-actions.server.ts +11 -0
  41. package/app/plugins/studio-hash-cleanup.client.ts +12 -0
  42. package/app/plugins/studio-header-actions.client.ts +30 -0
  43. package/app/plugins/studio-header-actions.server.ts +13 -0
  44. package/app/utils/studio-mount.ts +72 -0
  45. package/composables/useFugueContentAuthMode.ts +16 -0
  46. package/composables/useFugueContentAuthSignOut.ts +82 -0
  47. package/composables/useFugueContentPeekSession.ts +31 -0
  48. package/composables/useFugueContentStudioEditorEntry.ts +112 -0
  49. package/composables/useFugueContentStudioSession.ts +81 -0
  50. package/content.config.ts +199 -0
  51. package/content.d.ts +25 -0
  52. package/eslint.config.mjs +4 -0
  53. package/lib/404-defaults.ts +41 -0
  54. package/lib/article-i18n.ts +10 -0
  55. package/lib/auth-resolve.ts +74 -0
  56. package/lib/auth-utils.ts +44 -0
  57. package/lib/define-site.ts +156 -0
  58. package/lib/header-actions-registration.ts +42 -0
  59. package/lib/i18n-locales.ts +22 -0
  60. package/lib/i18n-utils.ts +136 -0
  61. package/lib/i18n.ts +2 -0
  62. package/lib/landing.ts +129 -0
  63. package/lib/login-redirect.ts +12 -0
  64. package/lib/netlify-ssr.ts +113 -0
  65. package/lib/page-toc.ts +14 -0
  66. package/lib/qe-tools/index.ts +36 -0
  67. package/lib/qe-tools/studio-drafts.ts +315 -0
  68. package/lib/qe-tools/types.ts +14 -0
  69. package/lib/settings-state.ts +1 -0
  70. package/lib/site-config-registry.ts +80 -0
  71. package/lib/studio-activation-gated.d.ts +20 -0
  72. package/lib/studio-activation-gated.js +127 -0
  73. package/lib/studio-auto-open.ts +26 -0
  74. package/lib/studio-cookies.d.ts +10 -0
  75. package/lib/studio-cookies.js +11 -0
  76. package/lib/studio-document-edit.ts +61 -0
  77. package/lib/studio-editor-visibility.ts +54 -0
  78. package/lib/studio-open.ts +7 -0
  79. package/lib/studio-session.ts +91 -0
  80. package/modules/i18n.ts +80 -0
  81. package/modules/landing-components.ts +95 -0
  82. package/modules/studio-auth-gate.ts +48 -0
  83. package/modules/studio-entry.ts +23 -0
  84. package/nuxt.config.ts +90 -0
  85. package/package.json +66 -3
  86. package/schemas/site-settings.schema.json +127 -0
  87. package/server/middleware/studio-oauth-redirect.ts +36 -0
  88. package/server/middleware/studio-provider-check.ts +59 -0
  89. package/server/plugins/studio-hash-cleanup.ts +8 -0
  90. package/tsconfig.build.json +22 -0
  91. package/tsconfig.json +20 -0
  92. package/types/site.ts +79 -0
@@ -0,0 +1,113 @@
1
+ import type { NuxtConfig } from 'nuxt/schema'
2
+ import process from 'node:process'
3
+ import { isAuthEnabledAtBuild } from '@altafusion/fugue-simple-auth/lib/env'
4
+
5
+ /** Netlify sets NETLIFY; NETLIFY_CI covers some CI/build-runner paths. */
6
+ function isNetlifyBuild(): boolean {
7
+ return Boolean(process.env.NETLIFY || process.env.NETLIFY_CI)
8
+ }
9
+
10
+ function isNuxtGenerate(): boolean {
11
+ return process.argv.includes('generate')
12
+ }
13
+
14
+ const VUE_SSR_INLINE = ['vue', '@vue/server-renderer', 'vue/server-renderer'] as const
15
+
16
+ interface NitroExternals { inline?: (string | RegExp)[] }
17
+
18
+ function mergeInlineExternals(
19
+ externals: NitroExternals | undefined,
20
+ additions: readonly string[]
21
+ ): NitroExternals {
22
+ const existing = externals?.inline ?? []
23
+ const inline = [
24
+ ...existing,
25
+ ...additions
26
+ ]
27
+ return {
28
+ ...externals,
29
+ inline: [
30
+ ...new Set(inline)
31
+ ]
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Netlify SSR for Studio-only apps (no fugue-simple-auth peek gate).
37
+ * Enabled when **`SITE_AUTH_ENABLED=true`** at build — same flag as auth-gated sites.
38
+ */
39
+ export function buildFugueContentSiteNetlifySsrConfig(envPrefix = 'SITE'): NuxtConfig | undefined {
40
+ if (!isAuthEnabledAtBuild(envPrefix))
41
+ return undefined
42
+
43
+ if (isNuxtGenerate())
44
+ return undefined
45
+
46
+ return {
47
+ experimental: {
48
+ externalVue: false
49
+ },
50
+ routeRules: {
51
+ '/**': { ssr: true, prerender: false }
52
+ },
53
+ nitro: {
54
+ ...(isNetlifyBuild()
55
+ ? { preset: 'netlify' as const }
56
+ : {}),
57
+ prerender: {
58
+ crawlLinks: false
59
+ },
60
+ externals: mergeInlineExternals(undefined, VUE_SSR_INLINE)
61
+ },
62
+ hooks: {
63
+ 'build:done': () => {
64
+ if (isNetlifyBuild() && isNuxtGenerate()) {
65
+ console.warn(
66
+ '[fugue-content-site] SITE_AUTH_ENABLED is set but the build used `nuxt generate`. '
67
+ + 'Studio OAuth requires `nuxt build` + Netlify SSR.'
68
+ )
69
+ }
70
+ },
71
+ 'nitro:config': (nitroConfig) => {
72
+ nitroConfig.prerender = {
73
+ ...nitroConfig.prerender,
74
+ crawlLinks: false
75
+ }
76
+
77
+ if (isNetlifyBuild()) {
78
+ nitroConfig.preset = nitroConfig.preset ?? 'netlify'
79
+ nitroConfig.externals = mergeInlineExternals(
80
+ nitroConfig.externals as NitroExternals | undefined,
81
+ VUE_SSR_INLINE
82
+ ) as typeof nitroConfig.externals
83
+ }
84
+ },
85
+ 'nitro:build:public-assets': async (nitro) => {
86
+ if (!isNetlifyBuild())
87
+ return
88
+
89
+ const { readFile, writeFile } = await import('node:fs/promises')
90
+ const { join } = await import('node:path')
91
+ const redirectsPath = join(nitro.options.output.publicDir, '_redirects')
92
+ const catchAll = [
93
+ '/_nuxt/* /_nuxt/:splat 200',
94
+ '/* /.netlify/functions/server 200'
95
+ ].join('\n')
96
+
97
+ let existing = ''
98
+ try {
99
+ existing = await readFile(redirectsPath, 'utf8')
100
+ } catch {
101
+ // no existing redirects file
102
+ }
103
+
104
+ if (!/^\/\* /m.test(existing)) {
105
+ const contents = existing.trim()
106
+ ? `${existing.trim()}\n${catchAll}\n`
107
+ : `${catchAll}\n`
108
+ await writeFile(redirectsPath, contents)
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
@@ -0,0 +1,14 @@
1
+ /** Shape of Nuxt Content `body.toc` on parsed markdown pages. */
2
+ export interface FugueContentPageTocLink {
3
+ id: string
4
+ depth: number
5
+ text: string
6
+ }
7
+
8
+ export function fugueContentPageTocLinks(body: unknown): FugueContentPageTocLink[] {
9
+ if (!body || typeof body !== 'object')
10
+ return []
11
+
12
+ const toc = (body as { toc?: { links?: FugueContentPageTocLink[] } }).toc
13
+ return toc?.links ?? []
14
+ }
@@ -0,0 +1,36 @@
1
+ /* eslint-disable no-console -- console API is the operator surface for qeTools */
2
+
3
+ import type { QeTools } from './types'
4
+ import { createStudioDraftsApi } from './studio-drafts'
5
+
6
+ export { createStudioDraftsApi, STUDIO_DRAFT_DB } from './studio-drafts'
7
+ export type {
8
+ StudioDraftKind,
9
+ StudioDraftRecord,
10
+ StudioDraftsApi,
11
+ StudioDraftStatus,
12
+ StudioDraftSummary
13
+ } from './studio-drafts'
14
+ export type { QeTools } from './types'
15
+
16
+ export function createQeTools(): QeTools {
17
+ const studioDrafts = createStudioDraftsApi()
18
+
19
+ return {
20
+ studioDrafts,
21
+ help() {
22
+ console.info(`qeTools — Fugue Content troubleshooting (browser console)
23
+
24
+ Studio drafts (IndexedDB on production Netlify — not local dev disk):
25
+ await qeTools.studioDrafts.list()
26
+ await qeTools.studioDrafts.get('en/fragments/location.md')
27
+ await qeTools.studioDrafts.deleteOne('en/fragments/location.md')
28
+ await qeTools.studioDrafts.deleteMatching('location')
29
+ await qeTools.studioDrafts.clearAll()
30
+ await qeTools.studioDrafts.clearMedia()
31
+
32
+ After delete/clear: hard refresh (Cmd+Shift+R / Ctrl+Shift+R).
33
+ Docs: developer-docs User Content Workflows → Undo and Revert`)
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Browser-only helpers for Nuxt Studio draft storage (IndexedDB).
3
+ * Used by operators when Studio "Revert changes" fails or drafts persist unexpectedly.
4
+ *
5
+ * @see developer-docs User Content Workflows — Draft Layer (Production)
6
+ */
7
+
8
+ /* eslint-disable no-console -- console API is the operator surface for qeTools */
9
+
10
+ /** Matches nuxt-studio client storage (`studio-v1-${kind}` / store `drafts`). */
11
+ export const STUDIO_DRAFT_DB = {
12
+ document: 'studio-v1-document',
13
+ media: 'studio-v1-media',
14
+ store: 'drafts'
15
+ } as const
16
+
17
+ export type StudioDraftKind = 'document' | 'media'
18
+
19
+ export type StudioDraftStatus = 'deleted' | 'created' | 'updated' | 'pristine'
20
+
21
+ export interface StudioDraftSummary {
22
+ key: string
23
+ fsPath?: string
24
+ status?: StudioDraftStatus
25
+ }
26
+
27
+ export interface StudioDraftRecord {
28
+ fsPath?: string
29
+ status?: StudioDraftStatus
30
+ modified?: unknown
31
+ original?: unknown
32
+ remoteFile?: unknown
33
+ conflict?: unknown
34
+ formattingApplied?: boolean
35
+ }
36
+
37
+ export interface StudioDraftsListOptions {
38
+ kind?: StudioDraftKind
39
+ }
40
+
41
+ export interface StudioDraftsDeleteOptions {
42
+ kind?: StudioDraftKind
43
+ }
44
+
45
+ export interface StudioDraftsClearOptions {
46
+ /** When true (default), clears document + media draft stores. */
47
+ includeMedia?: boolean
48
+ }
49
+
50
+ export interface StudioDraftsApi {
51
+ /** List unpublished content file drafts (default) or media drafts. */
52
+ list: (_options?: StudioDraftsListOptions) => Promise<StudioDraftSummary[]>
53
+ /** Fetch one draft record by IndexedDB key (usually the content fsPath). */
54
+ get: (_key: string, _options?: StudioDraftsDeleteOptions) => Promise<StudioDraftRecord | undefined>
55
+ /** Remove one draft; hard-refresh the page afterward to clear Studio in-memory merge. */
56
+ deleteOne: (_key: string, _options?: StudioDraftsDeleteOptions) => Promise<void>
57
+ /** Remove drafts whose key contains `substring` (e.g. `"location"`). */
58
+ deleteMatching: (_substring: string, _options?: StudioDraftsDeleteOptions) => Promise<StudioDraftSummary[]>
59
+ /** Clear all document drafts (and media when `includeMedia` is true). */
60
+ clearAll: (_options?: StudioDraftsClearOptions) => Promise<void>
61
+ /** Clear media drafts only. */
62
+ clearMedia: () => Promise<void>
63
+ /** Log hard-refresh reminder (does not reload automatically). */
64
+ hardRefreshHint: () => void
65
+ }
66
+
67
+ export interface StudioDraftStorageStatus {
68
+ available: boolean
69
+ dbName: string
70
+ kind: StudioDraftKind
71
+ /** Set when `available` is false — e.g. local dev uses disk, not IndexedDB drafts. */
72
+ reason?: string
73
+ }
74
+
75
+ const PRODUCTION_DRAFTS_HINT
76
+ = 'IndexedDB drafts exist on production (Netlify) after Studio saves unpublished edits. Local dev writes directly to disk — use git restore for local undo.'
77
+
78
+ function dbNameForKind(kind: StudioDraftKind): string {
79
+ return kind === 'media'
80
+ ? STUDIO_DRAFT_DB.media
81
+ : STUDIO_DRAFT_DB.document
82
+ }
83
+
84
+ /** Exported for unit tests. */
85
+ export function hasStudioDraftObjectStore(db: Pick<IDBDatabase, 'objectStoreNames'>): boolean {
86
+ return db.objectStoreNames.contains(STUDIO_DRAFT_DB.store)
87
+ }
88
+
89
+ async function getDraftStorageStatus(kind: StudioDraftKind): Promise<StudioDraftStorageStatus> {
90
+ const dbName = dbNameForKind(kind)
91
+ try {
92
+ const db = await openDb(dbName)
93
+ try {
94
+ if (hasStudioDraftObjectStore(db))
95
+ return { available: true, dbName, kind }
96
+
97
+ return {
98
+ available: false,
99
+ dbName,
100
+ kind,
101
+ reason: db.objectStoreNames.length === 0
102
+ ? PRODUCTION_DRAFTS_HINT
103
+ : `Database "${dbName}" exists but has no "${STUDIO_DRAFT_DB.store}" store. ${PRODUCTION_DRAFTS_HINT}`
104
+ }
105
+ } finally {
106
+ db.close()
107
+ }
108
+ } catch {
109
+ return {
110
+ available: false,
111
+ dbName,
112
+ kind,
113
+ reason: PRODUCTION_DRAFTS_HINT
114
+ }
115
+ }
116
+ }
117
+
118
+ function warnDraftStorageUnavailable(status: StudioDraftStorageStatus): void {
119
+ console.warn(`[qeTools.studioDrafts] No draft store at ${status.dbName}. ${status.reason ?? PRODUCTION_DRAFTS_HINT}`)
120
+ }
121
+
122
+ function openDb(dbName: string): Promise<IDBDatabase> {
123
+ return new Promise((resolve, reject) => {
124
+ const request = indexedDB.open(dbName)
125
+ request.onerror = () => reject(request.error ?? new Error(`Failed to open IndexedDB: ${dbName}`))
126
+ request.onsuccess = () => resolve(request.result)
127
+ })
128
+ }
129
+
130
+ async function runTransaction<T>(
131
+ dbName: string,
132
+ mode: IDBTransactionMode,
133
+ fn: (_store: IDBObjectStore) => Promise<T> | T
134
+ ): Promise<T> {
135
+ const db = await openDb(dbName)
136
+ if (!hasStudioDraftObjectStore(db)) {
137
+ db.close()
138
+ throw new Error(`Missing object store "${STUDIO_DRAFT_DB.store}" in ${dbName}`)
139
+ }
140
+
141
+ try {
142
+ const tx = db.transaction(STUDIO_DRAFT_DB.store, mode)
143
+ const store = tx.objectStore(STUDIO_DRAFT_DB.store)
144
+ const result = await Promise.resolve(fn(store))
145
+ await new Promise<void>((resolve, reject) => {
146
+ tx.oncomplete = () => resolve()
147
+ tx.onerror = () => reject(tx.error ?? new Error(`IndexedDB transaction failed: ${dbName}`))
148
+ })
149
+ return result
150
+ } finally {
151
+ db.close()
152
+ }
153
+ }
154
+
155
+ function idbRequest<T>(request: IDBRequest<T>): Promise<T> {
156
+ return new Promise((resolve, reject) => {
157
+ request.onsuccess = () => resolve(request.result)
158
+ request.onerror = () => reject(request.error ?? new Error('IndexedDB request failed'))
159
+ })
160
+ }
161
+
162
+ function summarizeDraft(key: IDBValidKey, record: StudioDraftRecord | undefined): StudioDraftSummary {
163
+ return {
164
+ key: String(key),
165
+ fsPath: record?.fsPath,
166
+ status: record?.status
167
+ }
168
+ }
169
+
170
+ /** Exported for unit tests. */
171
+ export function filterDraftKeys(keys: string[], substring: string): string[] {
172
+ if (!substring)
173
+ return keys
174
+ return keys.filter(key => key.includes(substring))
175
+ }
176
+
177
+ async function listDrafts(kind: StudioDraftKind): Promise<StudioDraftSummary[]> {
178
+ const status = await getDraftStorageStatus(kind)
179
+ if (!status.available) {
180
+ warnDraftStorageUnavailable(status)
181
+ return []
182
+ }
183
+
184
+ const dbName = dbNameForKind(kind)
185
+ return runTransaction(dbName, 'readonly', async (store) => {
186
+ const keys = await idbRequest(store.getAllKeys())
187
+ const rows = await Promise.all(
188
+ keys.map(async (key) => {
189
+ const record = await idbRequest(store.get(key)) as StudioDraftRecord | undefined
190
+ return summarizeDraft(key, record)
191
+ })
192
+ )
193
+ return rows
194
+ })
195
+ }
196
+
197
+ async function getDraft(key: string, kind: StudioDraftKind): Promise<StudioDraftRecord | undefined> {
198
+ const status = await getDraftStorageStatus(kind)
199
+ if (!status.available) {
200
+ warnDraftStorageUnavailable(status)
201
+ return undefined
202
+ }
203
+
204
+ const dbName = dbNameForKind(kind)
205
+ return runTransaction(dbName, 'readonly', store => idbRequest(store.get(key)) as Promise<StudioDraftRecord | undefined>)
206
+ }
207
+
208
+ async function deleteDraft(key: string, kind: StudioDraftKind): Promise<boolean> {
209
+ const status = await getDraftStorageStatus(kind)
210
+ if (!status.available) {
211
+ warnDraftStorageUnavailable(status)
212
+ return false
213
+ }
214
+
215
+ const dbName = dbNameForKind(kind)
216
+ await runTransaction(dbName, 'readwrite', store => idbRequest(store.delete(key)))
217
+ return true
218
+ }
219
+
220
+ async function clearDraftStore(kind: StudioDraftKind): Promise<boolean> {
221
+ const status = await getDraftStorageStatus(kind)
222
+ if (!status.available) {
223
+ warnDraftStorageUnavailable(status)
224
+ return false
225
+ }
226
+
227
+ const dbName = dbNameForKind(kind)
228
+ await runTransaction(dbName, 'readwrite', store => idbRequest(store.clear()))
229
+ return true
230
+ }
231
+
232
+ export function createStudioDraftsApi(): StudioDraftsApi {
233
+ const hardRefreshHint = () => {
234
+ console.info(
235
+ '[qeTools.studioDrafts] Hard refresh the page (Cmd+Shift+R / Ctrl+Shift+R) so Studio reloads from the last deploy.'
236
+ )
237
+ }
238
+
239
+ return {
240
+ async list(options) {
241
+ const kind = options?.kind ?? 'document'
242
+ const rows = await listDrafts(kind)
243
+ console.table(rows)
244
+ return rows
245
+ },
246
+
247
+ get(key, options) {
248
+ return getDraft(key, options?.kind ?? 'document')
249
+ },
250
+
251
+ async deleteOne(key, options) {
252
+ const deleted = await deleteDraft(key, options?.kind ?? 'document')
253
+ if (!deleted)
254
+ return
255
+
256
+ console.info('[qeTools.studioDrafts] Deleted draft:', key)
257
+ hardRefreshHint()
258
+ },
259
+
260
+ async deleteMatching(substring, options) {
261
+ const kind = options?.kind ?? 'document'
262
+ const rows = await listDrafts(kind)
263
+
264
+ if (!rows.length) {
265
+ const status = await getDraftStorageStatus(kind)
266
+ if (!status.available)
267
+ return []
268
+
269
+ console.warn('[qeTools.studioDrafts] No drafts in store.')
270
+ return []
271
+ }
272
+
273
+ const hits = rows.filter(row => filterDraftKeys([row.key], substring).length > 0)
274
+
275
+ if (!hits.length) {
276
+ console.warn('[qeTools.studioDrafts] No keys matching:', substring)
277
+ return []
278
+ }
279
+
280
+ for (const row of hits)
281
+ await deleteDraft(row.key, kind)
282
+
283
+ console.info('[qeTools.studioDrafts] Deleted', hits.length, 'draft(s).')
284
+ hardRefreshHint()
285
+ return hits
286
+ },
287
+
288
+ async clearAll(options) {
289
+ const clearedDocument = await clearDraftStore('document')
290
+ const clearedMedia = options?.includeMedia !== false
291
+ ? await clearDraftStore('media')
292
+ : true
293
+
294
+ if (!clearedDocument && !clearedMedia)
295
+ return
296
+
297
+ const scope = options?.includeMedia === false
298
+ ? 'document drafts'
299
+ : 'document + media drafts'
300
+ console.info(`[qeTools.studioDrafts] Cleared ${scope}.`)
301
+ hardRefreshHint()
302
+ },
303
+
304
+ async clearMedia() {
305
+ const cleared = await clearDraftStore('media')
306
+ if (!cleared)
307
+ return
308
+
309
+ console.info('[qeTools.studioDrafts] Cleared media drafts.')
310
+ hardRefreshHint()
311
+ },
312
+
313
+ hardRefreshHint
314
+ }
315
+ }
@@ -0,0 +1,14 @@
1
+ import type { StudioDraftsApi } from './studio-drafts'
2
+
3
+ export interface QeTools {
4
+ studioDrafts: StudioDraftsApi
5
+ help: () => void
6
+ }
7
+
8
+ declare global {
9
+ interface Window {
10
+ qeTools?: QeTools
11
+ }
12
+ }
13
+
14
+ export {}
@@ -0,0 +1 @@
1
+ export const FUGUE_CONTENT_SETTINGS_STATE = 'fugue-content:settings'
@@ -0,0 +1,80 @@
1
+ import type { FugueContentSiteAuthConfig, FugueContentSiteAuthMode, FugueContentSiteStudioConfig } from '../types/site'
2
+
3
+ /**
4
+ * Shared builders for Fugue Content consumer `site.config.ts` registries.
5
+ *
6
+ * Each app keeps its own registry file (section exports + combined `siteConfig`).
7
+ * `nuxt.config.ts` stays a thin entry that calls `defineFugueContentSite(siteConfig, siteConfigTheme)`.
8
+ */
9
+
10
+ function envPrefixSlug(envPrefix: string): string {
11
+ return envPrefix.toLowerCase().replace(/_/g, '-')
12
+ }
13
+
14
+ /** Manifest auth strategy — see **`FugueContentSiteAuthMode`** in `@altafusion/fugue-content/types`. */
15
+ export function fugueContentAuthModeSection(authMode: FugueContentSiteAuthMode): { authMode: FugueContentSiteAuthMode } {
16
+ return { authMode }
17
+ }
18
+
19
+ /**
20
+ * Optional fugue-simple-auth peek gate for Fugue Content (Netlify SSR + Studio).
21
+ * Default peek scope **`routes`** — public site is open; **`SITE_ACCESS_KEY`** gates Studio only.
22
+ * Use peek scope **`mode: 'full'`** for a pre-launch lock on the whole site.
23
+ *
24
+ * Pair with **`authMode: 'peek'`** (or **`auto`** when only peek env is set). For Google-only
25
+ * pilots, use **`fugueContentAuthModeSection('studio')`** instead and omit this section.
26
+ */
27
+ export function fugueContentAuthSection(options: {
28
+ /** Defaults to `SITE` → `SITE_ACCESS_KEY`, `SITE_AUTH_ENABLED` (one Netlify site per app). */
29
+ envPrefix?: string
30
+ /**
31
+ * Cookie/session identity slug — defaults to env prefix slug.
32
+ * Set per app (e.g. `my-site`) when multiple Fugue Content apps share `SITE_*` env on localhost.
33
+ */
34
+ cookieSlug?: string
35
+ mode?: FugueContentSiteAuthConfig['mode']
36
+ loginDescription?: string
37
+ cookieName?: string
38
+ sessionLabel?: string
39
+ protectedRoutes?: string[]
40
+ } = {}): { auth: FugueContentSiteAuthConfig } {
41
+ const envPrefix = options.envPrefix ?? 'SITE'
42
+ const cookieSlug = options.cookieSlug ?? envPrefixSlug(envPrefix)
43
+
44
+ return {
45
+ auth: {
46
+ envPrefix,
47
+ mode: options.mode ?? 'routes',
48
+ cookieName: options.cookieName ?? `${cookieSlug}-auth`,
49
+ sessionLabel: options.sessionLabel ?? `${cookieSlug}-authenticated`,
50
+ loginDescription:
51
+ options.loginDescription ?? 'Enter the access key to open the content editor.',
52
+ ...(options.protectedRoutes?.length
53
+ ? { protectedRoutes: options.protectedRoutes }
54
+ : {})
55
+ }
56
+ }
57
+ }
58
+
59
+ /** Standard Nuxt Studio block for monorepo Fugue Content apps. */
60
+ export function fugueContentStudioSection(options: {
61
+ rootDir: string
62
+ messagePrefix: string
63
+ }): { studio: FugueContentSiteStudioConfig } {
64
+ return {
65
+ studio: {
66
+ repository: {
67
+ owner: 'altafusion',
68
+ repo: 'altafusion-monorepo',
69
+ branch: 'main',
70
+ rootDir: options.rootDir
71
+ },
72
+ editors: { provider: 'google' },
73
+ git: {
74
+ commit: {
75
+ messagePrefix: options.messagePrefix
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,20 @@
1
+ /** Types for `studio-activation-gated.js`. */
2
+
3
+ /** The editor session handed to the Studio host; the dev user has a fixed shape, production users come from the session route. */
4
+ export interface StudioActivationUser {
5
+ provider?: string
6
+ email?: string
7
+ name?: string
8
+ accessToken?: string
9
+ providerId?: string
10
+ avatar?: string
11
+ [key: string]: unknown
12
+ }
13
+
14
+ /** Activates Studio once the access-key session is valid; resolves true when the Studio host is mounted. */
15
+ export declare function ensureStudioActivation(): Promise<boolean>
16
+
17
+ /** Registers the Studio activation for the current session (dev shortcut, production session check, or Cmd+. login). */
18
+ export declare function defineStudioActivationPlugin(
19
+ onStudioActivation: (user: StudioActivationUser) => unknown
20
+ ): Promise<void>