@rimelight/ui 0.0.2 → 0.0.4
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 +6 -3
- package/src/components/carousel/carousel-script.ts +188 -188
- package/src/components/carousel/index.ts +1 -1
- package/src/components/input-otp/InputOtpTypes.ts +6 -6
- package/src/components/radio-group/RadioGroupTypes.ts +6 -6
- package/src/components/select/SelectTypes.ts +13 -13
- package/src/components/switch/SwitchTypes.ts +6 -6
- package/src/components/toast/index.ts +1 -1
- package/src/components/toast/toast-manager.ts +234 -234
- package/src/components/toggle/ToggleTypes.ts +14 -14
- package/src/config/cookies.ts +5 -5
- package/src/config/index.ts +3 -3
- package/src/config/links.ts +4 -4
- package/src/config/site.config.ts +27 -45
- package/src/domain/cms/index.ts +1 -1
- package/src/domain/cms/types.ts +20 -20
- package/src/domain/i18n/constants.ts +21 -21
- package/src/domain/i18n/cookie-storage.ts +13 -13
- package/src/domain/i18n/country-to-locale-map.ts +67 -67
- package/src/domain/i18n/fetcher.ts +278 -268
- package/src/domain/i18n/flags.ts +16 -16
- package/src/domain/i18n/format.ts +90 -90
- package/src/domain/i18n/index.ts +10 -10
- package/src/domain/i18n/middleware/i18n.ts +161 -160
- package/src/domain/i18n/resolve-locale.ts +55 -55
- package/src/domain/i18n/schema.ts +29 -29
- package/src/domain/index.ts +4 -4
- package/src/domain/seo/constants.ts +6 -20
- package/src/domain/seo/index.ts +3 -3
- package/src/domain/seo/services/index.ts +3 -3
- package/src/domain/seo/services/llms.ts +56 -53
- package/src/domain/seo/services/robots.ts +12 -12
- package/src/domain/seo/services/sitemap.ts +56 -56
- package/src/domain/seo/utils.ts +36 -37
- package/src/domain/theme/constants.ts +6 -6
- package/src/domain/theme/index.ts +2 -2
- package/src/domain/theme/schema.ts +10 -10
- package/src/env.d.ts +49 -49
- package/src/integrations/index.ts +1 -0
- package/src/integrations/sri.ts +92 -0
- package/src/lib/component-preview.ts +73 -73
- package/src/lib/index.ts +6 -6
- package/src/lib/remark/remark-modified-time.ts +13 -13
- package/src/lib/showcase-preview-elements.ts +408 -408
- package/src/lib/showcase-renderer.ts +218 -218
- package/src/lib/showcase-utils.ts +189 -189
- package/src/lib/turnstile.ts +35 -35
- package/src/lib/utils/starwind/positioning.ts +318 -318
- package/src/locales/de/blog.json +9 -9
- package/src/locales/de/common.json +19 -19
- package/src/locales/de/errors.json +6 -6
- package/src/locales/de/home.json +20 -20
- package/src/locales/de/messages.json +8 -8
- package/src/locales/de/nav.json +13 -13
- package/src/locales/de/projects.json +9 -9
- package/src/locales/de/services.json +43 -43
- package/src/locales/en/blog.json +9 -9
- package/src/locales/en/chat.json +29 -29
- package/src/locales/en/common.json +19 -19
- package/src/locales/en/cookie_notice.json +11 -11
- package/src/locales/en/editor.json +24 -24
- package/src/locales/en/errors.json +6 -6
- package/src/locales/en/home.json +20 -20
- package/src/locales/en/messages.json +8 -8
- package/src/locales/en/nav.json +13 -13
- package/src/locales/en/projects.json +9 -9
- package/src/locales/en/services.json +43 -43
- package/src/locales/es/blog.json +9 -9
- package/src/locales/es/common.json +19 -19
- package/src/locales/es/errors.json +6 -6
- package/src/locales/es/home.json +20 -20
- package/src/locales/es/messages.json +8 -8
- package/src/locales/es/nav.json +13 -13
- package/src/locales/es/projects.json +9 -9
- package/src/locales/es/services.json +43 -43
- package/src/locales/ja/blog.json +9 -9
- package/src/locales/ja/common.json +19 -19
- package/src/locales/ja/errors.json +6 -6
- package/src/locales/ja/home.json +20 -20
- package/src/locales/ja/messages.json +8 -8
- package/src/locales/ja/nav.json +13 -13
- package/src/locales/ja/projects.json +9 -9
- package/src/locales/ja/services.json +43 -43
- package/src/locales/pt/blog.json +9 -9
- package/src/locales/pt/chat.json +29 -29
- package/src/locales/pt/common.json +19 -19
- package/src/locales/pt/cookie_notice.json +11 -11
- package/src/locales/pt/editor.json +24 -24
- package/src/locales/pt/errors.json +6 -6
- package/src/locales/pt/home.json +20 -20
- package/src/locales/pt/messages.json +8 -8
- package/src/locales/pt/nav.json +13 -13
- package/src/locales/pt/projects.json +9 -9
- package/src/locales/pt/services.json +43 -43
- package/src/middleware/index.ts +2 -0
- package/src/middleware/security.ts +15 -0
- package/src/middleware/sri.ts +78 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/server/cookies.ts +98 -98
- package/src/utils/server/index.ts +1 -1
- package/src/utils/shared/deep-merge.ts +36 -36
- package/src/utils/shared/embed.ts +105 -105
- package/src/utils/shared/index.ts +3 -3
- package/src/utils/shared/parse-boolean.ts +14 -14
- package/worker-configuration.d.ts +0 -14791
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// Locales Configuration
|
|
2
|
-
export const SUPPORTED_LOCALES = ["en", "pt", "ja", "de", "es"] as const
|
|
3
|
-
export type SupportedLocales = (typeof SUPPORTED_LOCALES)[number]
|
|
4
|
-
|
|
5
|
-
// Default locale
|
|
6
|
-
export const DEFAULT_LOCALE: SupportedLocales = "en"
|
|
7
|
-
|
|
8
|
-
// Missing translation banner flag
|
|
9
|
-
export const ENABLE_MISSING_TRANSLATION_BANNER = true
|
|
10
|
-
|
|
11
|
-
// UI Labels
|
|
12
|
-
export const LANGUAGES: Record<SupportedLocales, string> = {
|
|
13
|
-
en: "English",
|
|
14
|
-
pt: "Português",
|
|
15
|
-
ja: "日本語",
|
|
16
|
-
de: "Deutsch",
|
|
17
|
-
es: "Español"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Cookie name
|
|
21
|
-
export const LANG_COOKIE_NAME = "lang"
|
|
1
|
+
// Locales Configuration
|
|
2
|
+
export const SUPPORTED_LOCALES = ["en", "pt", "ja", "de", "es"] as const
|
|
3
|
+
export type SupportedLocales = (typeof SUPPORTED_LOCALES)[number]
|
|
4
|
+
|
|
5
|
+
// Default locale
|
|
6
|
+
export const DEFAULT_LOCALE: SupportedLocales = "en"
|
|
7
|
+
|
|
8
|
+
// Missing translation banner flag
|
|
9
|
+
export const ENABLE_MISSING_TRANSLATION_BANNER = true
|
|
10
|
+
|
|
11
|
+
// UI Labels
|
|
12
|
+
export const LANGUAGES: Record<SupportedLocales, string> = {
|
|
13
|
+
en: "English",
|
|
14
|
+
pt: "Português",
|
|
15
|
+
ja: "日本語",
|
|
16
|
+
de: "Deutsch",
|
|
17
|
+
es: "Español"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Cookie name
|
|
21
|
+
export const LANG_COOKIE_NAME = "lang"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type AstroCookies } from "astro"
|
|
2
|
-
|
|
3
|
-
import { type Locale, LocaleSchema } from "./schema"
|
|
4
|
-
import { setCookie, getCookieWithSchema } from "../../utils/server/cookies"
|
|
5
|
-
import { LANG_COOKIE_NAME } from "./constants"
|
|
6
|
-
|
|
7
|
-
export function setCookieLang(cookies: AstroCookies, locale: Locale) {
|
|
8
|
-
setCookie(cookies, LANG_COOKIE_NAME, locale)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getCookieLang(cookies: AstroCookies): Locale | null {
|
|
12
|
-
return getCookieWithSchema(cookies, LANG_COOKIE_NAME, LocaleSchema)
|
|
13
|
-
}
|
|
1
|
+
import { type AstroCookies } from "astro"
|
|
2
|
+
|
|
3
|
+
import { type Locale, LocaleSchema } from "./schema"
|
|
4
|
+
import { setCookie, getCookieWithSchema } from "../../utils/server/cookies"
|
|
5
|
+
import { LANG_COOKIE_NAME } from "./constants"
|
|
6
|
+
|
|
7
|
+
export function setCookieLang(cookies: AstroCookies, locale: Locale) {
|
|
8
|
+
setCookie(cookies, LANG_COOKIE_NAME, locale)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getCookieLang(cookies: AstroCookies): Locale | null {
|
|
12
|
+
return getCookieWithSchema(cookies, LANG_COOKIE_NAME, LocaleSchema)
|
|
13
|
+
}
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import type { Locale } from "./schema.ts"
|
|
2
|
-
|
|
3
|
-
// Key: ISO 3166-1 Alpha-2 Country Code (from request.cf.country)
|
|
4
|
-
// Value: The optimal language to serve
|
|
5
|
-
const GEO_MAP: Record<string, Locale> = {
|
|
6
|
-
// --- ANGLOSPHERE (Explicitly set to EN) ---
|
|
7
|
-
US: "en", // United States
|
|
8
|
-
GB: "en", // United Kingdom
|
|
9
|
-
AU: "en", // Australia
|
|
10
|
-
NZ: "en", // New Zealand
|
|
11
|
-
IE: "en", // Ireland
|
|
12
|
-
CA: "en", // Canada (Majority EN, fallbacks handle FR better via Accept-Language headers)
|
|
13
|
-
|
|
14
|
-
// --- DACH (German) ---
|
|
15
|
-
DE: "de",
|
|
16
|
-
AT: "de",
|
|
17
|
-
CH: "de",
|
|
18
|
-
LI: "de",
|
|
19
|
-
|
|
20
|
-
// --- LATAM + SPAIN ---
|
|
21
|
-
ES: "es",
|
|
22
|
-
MX: "es",
|
|
23
|
-
AR: "es",
|
|
24
|
-
CO: "es",
|
|
25
|
-
CL: "es",
|
|
26
|
-
PE: "es",
|
|
27
|
-
VE: "es",
|
|
28
|
-
GT: "es",
|
|
29
|
-
EC: "es",
|
|
30
|
-
|
|
31
|
-
// Asia
|
|
32
|
-
JP: "ja",
|
|
33
|
-
|
|
34
|
-
// --- LUSOPHONE (Portuguese) ---
|
|
35
|
-
PT: "pt",
|
|
36
|
-
BR: "pt",
|
|
37
|
-
AO: "pt",
|
|
38
|
-
MZ: "pt"
|
|
39
|
-
|
|
40
|
-
// --- FRANCOPHONE ---
|
|
41
|
-
// FR: 'fr',
|
|
42
|
-
// BE: 'fr',
|
|
43
|
-
// MC: 'fr',
|
|
44
|
-
// SN: 'fr',
|
|
45
|
-
|
|
46
|
-
// --- SLAVIC / POST-SOVIET ---
|
|
47
|
-
// UA: 'uk',
|
|
48
|
-
// RU: 'ru',
|
|
49
|
-
// KZ: 'ru',
|
|
50
|
-
// BY: 'ru',
|
|
51
|
-
|
|
52
|
-
// Add other mappings as needed...
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Maps a Cloudflare Country Code to a supported App Locale. Returns undefined if no direct mapping
|
|
57
|
-
* exists (falling back to default strategy).
|
|
58
|
-
*/
|
|
59
|
-
export function mapCountryToLocale(country: unknown): string | undefined {
|
|
60
|
-
// Safety: In dev mode (localhost), 'country' might be null or undefined.
|
|
61
|
-
if (typeof country !== "string") return undefined
|
|
62
|
-
|
|
63
|
-
// Cloudflare always sends uppercase (e.g., 'US', 'DE'), but safety first.
|
|
64
|
-
const code = country.toUpperCase()
|
|
65
|
-
|
|
66
|
-
return GEO_MAP[code]
|
|
67
|
-
}
|
|
1
|
+
import type { Locale } from "./schema.ts"
|
|
2
|
+
|
|
3
|
+
// Key: ISO 3166-1 Alpha-2 Country Code (from request.cf.country)
|
|
4
|
+
// Value: The optimal language to serve
|
|
5
|
+
const GEO_MAP: Record<string, Locale> = {
|
|
6
|
+
// --- ANGLOSPHERE (Explicitly set to EN) ---
|
|
7
|
+
US: "en", // United States
|
|
8
|
+
GB: "en", // United Kingdom
|
|
9
|
+
AU: "en", // Australia
|
|
10
|
+
NZ: "en", // New Zealand
|
|
11
|
+
IE: "en", // Ireland
|
|
12
|
+
CA: "en", // Canada (Majority EN, fallbacks handle FR better via Accept-Language headers)
|
|
13
|
+
|
|
14
|
+
// --- DACH (German) ---
|
|
15
|
+
DE: "de",
|
|
16
|
+
AT: "de",
|
|
17
|
+
CH: "de",
|
|
18
|
+
LI: "de",
|
|
19
|
+
|
|
20
|
+
// --- LATAM + SPAIN ---
|
|
21
|
+
ES: "es",
|
|
22
|
+
MX: "es",
|
|
23
|
+
AR: "es",
|
|
24
|
+
CO: "es",
|
|
25
|
+
CL: "es",
|
|
26
|
+
PE: "es",
|
|
27
|
+
VE: "es",
|
|
28
|
+
GT: "es",
|
|
29
|
+
EC: "es",
|
|
30
|
+
|
|
31
|
+
// Asia
|
|
32
|
+
JP: "ja",
|
|
33
|
+
|
|
34
|
+
// --- LUSOPHONE (Portuguese) ---
|
|
35
|
+
PT: "pt",
|
|
36
|
+
BR: "pt",
|
|
37
|
+
AO: "pt",
|
|
38
|
+
MZ: "pt"
|
|
39
|
+
|
|
40
|
+
// --- FRANCOPHONE ---
|
|
41
|
+
// FR: 'fr',
|
|
42
|
+
// BE: 'fr',
|
|
43
|
+
// MC: 'fr',
|
|
44
|
+
// SN: 'fr',
|
|
45
|
+
|
|
46
|
+
// --- SLAVIC / POST-SOVIET ---
|
|
47
|
+
// UA: 'uk',
|
|
48
|
+
// RU: 'ru',
|
|
49
|
+
// KZ: 'ru',
|
|
50
|
+
// BY: 'ru',
|
|
51
|
+
|
|
52
|
+
// Add other mappings as needed...
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Maps a Cloudflare Country Code to a supported App Locale. Returns undefined if no direct mapping
|
|
57
|
+
* exists (falling back to default strategy).
|
|
58
|
+
*/
|
|
59
|
+
export function mapCountryToLocale(country: unknown): string | undefined {
|
|
60
|
+
// Safety: In dev mode (localhost), 'country' might be null or undefined.
|
|
61
|
+
if (typeof country !== "string") return undefined
|
|
62
|
+
|
|
63
|
+
// Cloudflare always sends uppercase (e.g., 'US', 'DE'), but safety first.
|
|
64
|
+
const code = country.toUpperCase()
|
|
65
|
+
|
|
66
|
+
return GEO_MAP[code]
|
|
67
|
+
}
|