@djangocfg/layouts 2.0.6 → 2.0.8
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/README.md +65 -6
- package/package.json +14 -13
- package/src/auth/hooks/index.ts +1 -0
- package/src/auth/hooks/useGithubAuth.ts +183 -0
- package/src/layouts/AuthLayout/AuthContext.tsx +2 -0
- package/src/layouts/AuthLayout/AuthLayout.tsx +22 -5
- package/src/layouts/AuthLayout/IdentifierForm.tsx +4 -0
- package/src/layouts/AuthLayout/OAuthCallback.tsx +172 -0
- package/src/layouts/AuthLayout/OAuthProviders.tsx +85 -0
- package/src/layouts/AuthLayout/index.ts +4 -0
- package/src/layouts/AuthLayout/types.ts +4 -0
- package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +3 -22
- package/src/layouts/SupportLayout/components/MessageList.tsx +1 -1
- package/src/layouts/SupportLayout/components/TicketList.tsx +1 -1
- package/src/snippets/Analytics/events.ts +5 -0
- package/src/snippets/Chat/components/MessageList.tsx +1 -1
- package/src/snippets/Chat/components/SessionList.tsx +1 -1
- package/src/snippets/McpChat/components/AIChatWidget.tsx +268 -0
- package/src/snippets/McpChat/components/ChatMessages.tsx +151 -0
- package/src/snippets/McpChat/components/ChatPanel.tsx +126 -0
- package/src/snippets/McpChat/components/ChatSidebar.tsx +119 -0
- package/src/snippets/McpChat/components/ChatWidget.tsx +134 -0
- package/src/snippets/McpChat/components/MessageBubble.tsx +125 -0
- package/src/snippets/McpChat/components/MessageInput.tsx +139 -0
- package/src/snippets/McpChat/components/index.ts +22 -0
- package/src/snippets/McpChat/config.ts +35 -0
- package/src/snippets/McpChat/context/AIChatContext.tsx +245 -0
- package/src/snippets/McpChat/context/ChatContext.tsx +350 -0
- package/src/snippets/McpChat/context/index.ts +7 -0
- package/src/snippets/McpChat/hooks/index.ts +5 -0
- package/src/snippets/McpChat/hooks/useAIChat.ts +487 -0
- package/src/snippets/McpChat/hooks/useChatLayout.ts +329 -0
- package/src/snippets/McpChat/index.ts +76 -0
- package/src/snippets/McpChat/types.ts +141 -0
- package/src/snippets/index.ts +32 -0
- package/src/utils/index.ts +0 -1
- package/src/utils/og-image.ts +0 -169
package/src/utils/og-image.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OG Image URL Generation Utilities
|
|
3
|
-
*
|
|
4
|
-
* Client-side utilities for generating OG image URLs.
|
|
5
|
-
* Moved from @djangocfg/nextjs to keep nextjs package server-only.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Encode string to base64 with Unicode support
|
|
10
|
-
* Works in both browser and Node.js environments
|
|
11
|
-
*/
|
|
12
|
-
function encodeBase64(str: string): string {
|
|
13
|
-
// Node.js environment
|
|
14
|
-
if (typeof Buffer !== 'undefined') {
|
|
15
|
-
return Buffer.from(str, 'utf-8').toString('base64');
|
|
16
|
-
}
|
|
17
|
-
// Browser environment - handle Unicode via UTF-8 encoding
|
|
18
|
-
return btoa(unescape(encodeURIComponent(str)));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* OG Image URL parameters
|
|
23
|
-
* All parameters can be encoded in URL via base64
|
|
24
|
-
*/
|
|
25
|
-
export interface OgImageUrlParams {
|
|
26
|
-
/** Page title */
|
|
27
|
-
title: string;
|
|
28
|
-
/** Page description (optional) */
|
|
29
|
-
description?: string;
|
|
30
|
-
/** Site name (optional) */
|
|
31
|
-
siteName?: string;
|
|
32
|
-
/** Logo URL (optional) */
|
|
33
|
-
logo?: string;
|
|
34
|
-
/** Background type: 'gradient' or 'solid' */
|
|
35
|
-
backgroundType?: 'gradient' | 'solid';
|
|
36
|
-
/** Gradient start color (hex) */
|
|
37
|
-
gradientStart?: string;
|
|
38
|
-
/** Gradient end color (hex) */
|
|
39
|
-
gradientEnd?: string;
|
|
40
|
-
/** Background color (for solid type) */
|
|
41
|
-
backgroundColor?: string;
|
|
42
|
-
/** Title font size (px) */
|
|
43
|
-
titleSize?: number;
|
|
44
|
-
/** Title font weight */
|
|
45
|
-
titleWeight?: number;
|
|
46
|
-
/** Title text color */
|
|
47
|
-
titleColor?: string;
|
|
48
|
-
/** Description font size (px) */
|
|
49
|
-
descriptionSize?: number;
|
|
50
|
-
/** Description text color */
|
|
51
|
-
descriptionColor?: string;
|
|
52
|
-
/** Site name font size (px) */
|
|
53
|
-
siteNameSize?: number;
|
|
54
|
-
/** Site name text color */
|
|
55
|
-
siteNameColor?: string;
|
|
56
|
-
/** Padding (px) */
|
|
57
|
-
padding?: number;
|
|
58
|
-
/** Logo size (px) */
|
|
59
|
-
logoSize?: number;
|
|
60
|
-
/** Show logo flag */
|
|
61
|
-
showLogo?: boolean;
|
|
62
|
-
/** Show site name flag */
|
|
63
|
-
showSiteName?: boolean;
|
|
64
|
-
/** Additional custom parameters */
|
|
65
|
-
[key: string]: string | number | boolean | undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Generate OG image URL with query parameters or base64 encoding
|
|
70
|
-
*
|
|
71
|
-
* @param baseUrl - Base URL of the OG image API route (e.g., '/api/og' or 'https://example.com/api/og')
|
|
72
|
-
* @param params - URL parameters for the OG image
|
|
73
|
-
* @param useBase64 - If true, encode params as base64 for safer URLs (default: true)
|
|
74
|
-
* @returns Complete OG image URL with encoded parameters
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* // Base64 encoding (safe, default) - all parameters can be encoded
|
|
79
|
-
* const url = generateOgImageUrl('/api/og', {
|
|
80
|
-
* title: 'My Page Title',
|
|
81
|
-
* description: 'Page description here',
|
|
82
|
-
* siteName: 'My Site',
|
|
83
|
-
* });
|
|
84
|
-
* // Result: /api/og/[base64-encoded-json]
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
export function generateOgImageUrl(
|
|
88
|
-
baseUrl: string,
|
|
89
|
-
params: OgImageUrlParams,
|
|
90
|
-
useBase64: boolean = true
|
|
91
|
-
): string {
|
|
92
|
-
if (useBase64) {
|
|
93
|
-
// Clean params - remove undefined/null/empty values
|
|
94
|
-
const cleanParams: Record<string, string | number | boolean> = {};
|
|
95
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
96
|
-
if (value !== undefined && value !== null && value !== '') {
|
|
97
|
-
cleanParams[key] = value;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Encode as base64 (Unicode-safe)
|
|
102
|
-
const jsonString = JSON.stringify(cleanParams);
|
|
103
|
-
const base64Data = encodeBase64(jsonString);
|
|
104
|
-
|
|
105
|
-
// CRITICAL: Use path parameter instead of query parameter
|
|
106
|
-
// Next.js strips query params in internal requests for metadata generation
|
|
107
|
-
// Using /api/og/[data] instead of /api/og?data=... preserves the data
|
|
108
|
-
return `${baseUrl}/${base64Data}`;
|
|
109
|
-
} else {
|
|
110
|
-
// Legacy query params mode
|
|
111
|
-
const searchParams = new URLSearchParams();
|
|
112
|
-
|
|
113
|
-
// Add all defined parameters
|
|
114
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
115
|
-
if (value !== undefined && value !== null && value !== '') {
|
|
116
|
-
searchParams.append(key, String(value));
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const query = searchParams.toString();
|
|
121
|
-
return query ? `${baseUrl}?${query}` : baseUrl;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get absolute OG image URL from relative path
|
|
127
|
-
*
|
|
128
|
-
* Useful for generating absolute URLs required by Open Graph meta tags
|
|
129
|
-
*
|
|
130
|
-
* @param relativePath - Relative OG image path (e.g., '/api/og?title=Hello')
|
|
131
|
-
* @param siteUrl - Base site URL (e.g., 'https://example.com')
|
|
132
|
-
* @returns Absolute URL
|
|
133
|
-
*/
|
|
134
|
-
export function getAbsoluteOgImageUrl(
|
|
135
|
-
relativePath: string,
|
|
136
|
-
siteUrl: string
|
|
137
|
-
): string {
|
|
138
|
-
// Remove trailing slash from site URL
|
|
139
|
-
const cleanSiteUrl = siteUrl.replace(/\/$/, '');
|
|
140
|
-
|
|
141
|
-
// Ensure relative path starts with /
|
|
142
|
-
const cleanPath = relativePath.startsWith('/')
|
|
143
|
-
? relativePath
|
|
144
|
-
: `/${relativePath}`;
|
|
145
|
-
|
|
146
|
-
return `${cleanSiteUrl}${cleanPath}`;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Create OG image URL builder with preset configuration
|
|
151
|
-
*
|
|
152
|
-
* Useful when you want to reuse the same base URL and default parameters
|
|
153
|
-
*
|
|
154
|
-
* @param baseUrl - Base URL of the OG image API route
|
|
155
|
-
* @param defaults - Default parameters to merge with each URL generation
|
|
156
|
-
* @returns URL builder function
|
|
157
|
-
*/
|
|
158
|
-
export function createOgImageUrlBuilder(
|
|
159
|
-
baseUrl: string,
|
|
160
|
-
defaults: Partial<OgImageUrlParams> = {}
|
|
161
|
-
) {
|
|
162
|
-
return (params: OgImageUrlParams): string => {
|
|
163
|
-
return generateOgImageUrl(baseUrl, {
|
|
164
|
-
...defaults,
|
|
165
|
-
...params,
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|