@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.
Files changed (105) hide show
  1. package/package.json +6 -3
  2. package/src/components/carousel/carousel-script.ts +188 -188
  3. package/src/components/carousel/index.ts +1 -1
  4. package/src/components/input-otp/InputOtpTypes.ts +6 -6
  5. package/src/components/radio-group/RadioGroupTypes.ts +6 -6
  6. package/src/components/select/SelectTypes.ts +13 -13
  7. package/src/components/switch/SwitchTypes.ts +6 -6
  8. package/src/components/toast/index.ts +1 -1
  9. package/src/components/toast/toast-manager.ts +234 -234
  10. package/src/components/toggle/ToggleTypes.ts +14 -14
  11. package/src/config/cookies.ts +5 -5
  12. package/src/config/index.ts +3 -3
  13. package/src/config/links.ts +4 -4
  14. package/src/config/site.config.ts +27 -45
  15. package/src/domain/cms/index.ts +1 -1
  16. package/src/domain/cms/types.ts +20 -20
  17. package/src/domain/i18n/constants.ts +21 -21
  18. package/src/domain/i18n/cookie-storage.ts +13 -13
  19. package/src/domain/i18n/country-to-locale-map.ts +67 -67
  20. package/src/domain/i18n/fetcher.ts +278 -268
  21. package/src/domain/i18n/flags.ts +16 -16
  22. package/src/domain/i18n/format.ts +90 -90
  23. package/src/domain/i18n/index.ts +10 -10
  24. package/src/domain/i18n/middleware/i18n.ts +161 -160
  25. package/src/domain/i18n/resolve-locale.ts +55 -55
  26. package/src/domain/i18n/schema.ts +29 -29
  27. package/src/domain/index.ts +4 -4
  28. package/src/domain/seo/constants.ts +6 -20
  29. package/src/domain/seo/index.ts +3 -3
  30. package/src/domain/seo/services/index.ts +3 -3
  31. package/src/domain/seo/services/llms.ts +56 -53
  32. package/src/domain/seo/services/robots.ts +12 -12
  33. package/src/domain/seo/services/sitemap.ts +56 -56
  34. package/src/domain/seo/utils.ts +36 -37
  35. package/src/domain/theme/constants.ts +6 -6
  36. package/src/domain/theme/index.ts +2 -2
  37. package/src/domain/theme/schema.ts +10 -10
  38. package/src/env.d.ts +49 -49
  39. package/src/integrations/index.ts +1 -0
  40. package/src/integrations/sri.ts +92 -0
  41. package/src/lib/component-preview.ts +73 -73
  42. package/src/lib/index.ts +6 -6
  43. package/src/lib/remark/remark-modified-time.ts +13 -13
  44. package/src/lib/showcase-preview-elements.ts +408 -408
  45. package/src/lib/showcase-renderer.ts +218 -218
  46. package/src/lib/showcase-utils.ts +189 -189
  47. package/src/lib/turnstile.ts +35 -35
  48. package/src/lib/utils/starwind/positioning.ts +318 -318
  49. package/src/locales/de/blog.json +9 -9
  50. package/src/locales/de/common.json +19 -19
  51. package/src/locales/de/errors.json +6 -6
  52. package/src/locales/de/home.json +20 -20
  53. package/src/locales/de/messages.json +8 -8
  54. package/src/locales/de/nav.json +13 -13
  55. package/src/locales/de/projects.json +9 -9
  56. package/src/locales/de/services.json +43 -43
  57. package/src/locales/en/blog.json +9 -9
  58. package/src/locales/en/chat.json +29 -29
  59. package/src/locales/en/common.json +19 -19
  60. package/src/locales/en/cookie_notice.json +11 -11
  61. package/src/locales/en/editor.json +24 -24
  62. package/src/locales/en/errors.json +6 -6
  63. package/src/locales/en/home.json +20 -20
  64. package/src/locales/en/messages.json +8 -8
  65. package/src/locales/en/nav.json +13 -13
  66. package/src/locales/en/projects.json +9 -9
  67. package/src/locales/en/services.json +43 -43
  68. package/src/locales/es/blog.json +9 -9
  69. package/src/locales/es/common.json +19 -19
  70. package/src/locales/es/errors.json +6 -6
  71. package/src/locales/es/home.json +20 -20
  72. package/src/locales/es/messages.json +8 -8
  73. package/src/locales/es/nav.json +13 -13
  74. package/src/locales/es/projects.json +9 -9
  75. package/src/locales/es/services.json +43 -43
  76. package/src/locales/ja/blog.json +9 -9
  77. package/src/locales/ja/common.json +19 -19
  78. package/src/locales/ja/errors.json +6 -6
  79. package/src/locales/ja/home.json +20 -20
  80. package/src/locales/ja/messages.json +8 -8
  81. package/src/locales/ja/nav.json +13 -13
  82. package/src/locales/ja/projects.json +9 -9
  83. package/src/locales/ja/services.json +43 -43
  84. package/src/locales/pt/blog.json +9 -9
  85. package/src/locales/pt/chat.json +29 -29
  86. package/src/locales/pt/common.json +19 -19
  87. package/src/locales/pt/cookie_notice.json +11 -11
  88. package/src/locales/pt/editor.json +24 -24
  89. package/src/locales/pt/errors.json +6 -6
  90. package/src/locales/pt/home.json +20 -20
  91. package/src/locales/pt/messages.json +8 -8
  92. package/src/locales/pt/nav.json +13 -13
  93. package/src/locales/pt/projects.json +9 -9
  94. package/src/locales/pt/services.json +43 -43
  95. package/src/middleware/index.ts +2 -0
  96. package/src/middleware/security.ts +15 -0
  97. package/src/middleware/sri.ts +78 -0
  98. package/src/utils/index.ts +2 -2
  99. package/src/utils/server/cookies.ts +98 -98
  100. package/src/utils/server/index.ts +1 -1
  101. package/src/utils/shared/deep-merge.ts +36 -36
  102. package/src/utils/shared/embed.ts +105 -105
  103. package/src/utils/shared/index.ts +3 -3
  104. package/src/utils/shared/parse-boolean.ts +14 -14
  105. package/worker-configuration.d.ts +0 -14791
@@ -1,218 +1,218 @@
1
- /**
2
- * Dynamic Component Renderer for Showcase
3
- *
4
- * This module handles runtime prop updates for Astro components in the showcase. It works by
5
- * re-rendering the component with updated props using Astro's client:only components.
6
- */
7
-
8
- export interface PropState {
9
- value: any
10
- omitted: boolean
11
- }
12
-
13
- export interface PropDefinition {
14
- name: string
15
- type: string
16
- default?: any
17
- description?: string
18
- kind: "string" | "number" | "boolean" | "enum" | "array" | "object" | "function"
19
- enumValues?: string[]
20
- }
21
-
22
- function makePropDefinition(
23
- name: string,
24
- type: string,
25
- kind: PropDefinition["kind"],
26
- defaultValue: any,
27
- description: string | undefined,
28
- enumValues: string[] | undefined
29
- ): PropDefinition {
30
- const result: PropDefinition = {
31
- name,
32
- type,
33
- kind
34
- }
35
- if (defaultValue !== undefined) result.default = defaultValue
36
- if (description !== undefined) result.description = description
37
- if (enumValues !== undefined) result.enumValues = enumValues
38
- return result
39
- }
40
-
41
- function assertPropInfo(
42
- obj: unknown
43
- ): asserts obj is { type?: string; default?: unknown; description?: string } {
44
- if (!obj || typeof obj !== "object") throw new Error("Expected prop info")
45
- }
46
-
47
- /**
48
- * Parse a component's props from its exported interface or default export This is a helper to
49
- * extract prop metadata at build time
50
- */
51
- export function parseComponentProps(_componentModule: any): PropDefinition[] {
52
- const props: PropDefinition[] = []
53
-
54
- // Try to get props from component's default export or metadata
55
- if (_componentModule?.metadata?.props) {
56
- const metadataProps = _componentModule.metadata.props
57
- for (const [name, info] of Object.entries(metadataProps)) {
58
- assertPropInfo(info)
59
- const propInfo = info
60
- props.push(
61
- makePropDefinition(
62
- name,
63
- propInfo.type || "unknown",
64
- inferPropKind(propInfo.type || "unknown"),
65
- propInfo.default,
66
- propInfo.description,
67
- extractEnumValues(propInfo.type || "")
68
- )
69
- )
70
- }
71
- }
72
-
73
- return props
74
- }
75
-
76
- /**
77
- * Infer the prop kind from TypeScript type string
78
- */
79
- function inferPropKind(typeString: string): PropDefinition["kind"] {
80
- if (!typeString) return "string"
81
-
82
- const type = typeString.toLowerCase()
83
-
84
- if (type === "boolean") return "boolean"
85
- if (type === "number") return "number"
86
- if (type === "string") return "string"
87
- if (type.includes("[]") || type === "array") return "array"
88
- if (type.includes("|") && !type.includes("=>")) {
89
- // Union type - likely an enum
90
- return "enum"
91
- }
92
- if (type.includes("=>")) return "function"
93
- if (type.startsWith("{") || type === "object" || type === "record") return "object"
94
-
95
- return "string"
96
- }
97
-
98
- /**
99
- * Extract enum values from a union type string
100
- */
101
- function extractEnumValues(typeString: string): string[] | undefined {
102
- if (!typeString || !typeString.includes("|")) return undefined
103
-
104
- // Parse union types like: "'default' | 'primary' | 'secondary'"
105
- const matches = typeString.match(/'([^']+)'|"([^"]+)"/g)
106
- if (matches) {
107
- return matches.map((m) => m.replace(/['"]/g, ""))
108
- }
109
-
110
- return undefined
111
- }
112
-
113
- /**
114
- * Generate default prop definitions for common component patterns
115
- */
116
- export function generatePropDefinitions(
117
- _componentName: string,
118
- options: {
119
- stringProps?: string[]
120
- booleanProps?: string[]
121
- enumProps?: Record<string, string[]>
122
- defaultProps?: Record<string, any>
123
- descriptions?: Record<string, string>
124
- } = {}
125
- ): PropDefinition[] {
126
- const props: PropDefinition[] = []
127
-
128
- // Add string props
129
- options.stringProps?.forEach((name) => {
130
- props.push(
131
- makePropDefinition(
132
- name,
133
- "string",
134
- "string",
135
- options.defaultProps?.[name],
136
- options.descriptions?.[name],
137
- undefined
138
- )
139
- )
140
- })
141
-
142
- // Add boolean props
143
- options.booleanProps?.forEach((name) => {
144
- props.push(
145
- makePropDefinition(
146
- name,
147
- "boolean",
148
- "boolean",
149
- options.defaultProps?.[name],
150
- options.descriptions?.[name],
151
- undefined
152
- )
153
- )
154
- })
155
-
156
- // Add enum props
157
- if (options.enumProps) {
158
- Object.entries(options.enumProps).forEach(([name, values]) => {
159
- props.push(
160
- makePropDefinition(
161
- name,
162
- values.map((v) => `'${v}'`).join(" | "),
163
- "enum",
164
- options.defaultProps?.[name],
165
- options.descriptions?.[name],
166
- values
167
- )
168
- )
169
- })
170
- }
171
-
172
- return props
173
- }
174
-
175
- /**
176
- * Create a render function for a component This returns HTML string that can be injected into the
177
- * preview container
178
- */
179
- export function createRenderer(_componentModule: any) {
180
- return function render(_props: Record<string, any>): string {
181
- // For Astro components, we need to use their rendering mechanism
182
- // This is a placeholder - actual implementation depends on how components are structured
183
- return `<div data-component-render="true" data-props="${encodeURIComponent(JSON.stringify(_props))}"></div>`
184
- }
185
- }
186
-
187
- /**
188
- * Helper to build common prop configurations
189
- */
190
- export const PropConfigs = {
191
- /**
192
- * Standard variant/size props for UI components
193
- */
194
- ui: {
195
- variant: {
196
- values: ["default", "primary", "secondary", "outline", "ghost"] as string[],
197
- default: "default"
198
- },
199
- size: {
200
- values: ["sm", "md", "lg"] as string[],
201
- default: "md"
202
- }
203
- },
204
-
205
- /**
206
- * Layout props
207
- */
208
- layout: {
209
- orientation: {
210
- values: ["vertical", "horizontal"] as string[],
211
- default: "vertical"
212
- },
213
- alignment: {
214
- values: ["left", "center", "right"] as string[],
215
- default: "center"
216
- }
217
- }
218
- }
1
+ /**
2
+ * Dynamic Component Renderer for Showcase
3
+ *
4
+ * This module handles runtime prop updates for Astro components in the showcase. It works by
5
+ * re-rendering the component with updated props using Astro's client:only components.
6
+ */
7
+
8
+ export interface PropState {
9
+ value: any
10
+ omitted: boolean
11
+ }
12
+
13
+ export interface PropDefinition {
14
+ name: string
15
+ type: string
16
+ default?: any
17
+ description?: string
18
+ kind: "string" | "number" | "boolean" | "enum" | "array" | "object" | "function"
19
+ enumValues?: string[]
20
+ }
21
+
22
+ function makePropDefinition(
23
+ name: string,
24
+ type: string,
25
+ kind: PropDefinition["kind"],
26
+ defaultValue: any,
27
+ description: string | undefined,
28
+ enumValues: string[] | undefined
29
+ ): PropDefinition {
30
+ const result: PropDefinition = {
31
+ name,
32
+ type,
33
+ kind
34
+ }
35
+ if (defaultValue !== undefined) result.default = defaultValue
36
+ if (description !== undefined) result.description = description
37
+ if (enumValues !== undefined) result.enumValues = enumValues
38
+ return result
39
+ }
40
+
41
+ function assertPropInfo(
42
+ obj: unknown
43
+ ): asserts obj is { type?: string; default?: unknown; description?: string } {
44
+ if (!obj || typeof obj !== "object") throw new Error("Expected prop info")
45
+ }
46
+
47
+ /**
48
+ * Parse a component's props from its exported interface or default export This is a helper to
49
+ * extract prop metadata at build time
50
+ */
51
+ export function parseComponentProps(_componentModule: any): PropDefinition[] {
52
+ const props: PropDefinition[] = []
53
+
54
+ // Try to get props from component's default export or metadata
55
+ if (_componentModule?.metadata?.props) {
56
+ const metadataProps = _componentModule.metadata.props
57
+ for (const [name, info] of Object.entries(metadataProps)) {
58
+ assertPropInfo(info)
59
+ const propInfo = info
60
+ props.push(
61
+ makePropDefinition(
62
+ name,
63
+ propInfo.type || "unknown",
64
+ inferPropKind(propInfo.type || "unknown"),
65
+ propInfo.default,
66
+ propInfo.description,
67
+ extractEnumValues(propInfo.type || "")
68
+ )
69
+ )
70
+ }
71
+ }
72
+
73
+ return props
74
+ }
75
+
76
+ /**
77
+ * Infer the prop kind from TypeScript type string
78
+ */
79
+ function inferPropKind(typeString: string): PropDefinition["kind"] {
80
+ if (!typeString) return "string"
81
+
82
+ const type = typeString.toLowerCase()
83
+
84
+ if (type === "boolean") return "boolean"
85
+ if (type === "number") return "number"
86
+ if (type === "string") return "string"
87
+ if (type.includes("[]") || type === "array") return "array"
88
+ if (type.includes("|") && !type.includes("=>")) {
89
+ // Union type - likely an enum
90
+ return "enum"
91
+ }
92
+ if (type.includes("=>")) return "function"
93
+ if (type.startsWith("{") || type === "object" || type === "record") return "object"
94
+
95
+ return "string"
96
+ }
97
+
98
+ /**
99
+ * Extract enum values from a union type string
100
+ */
101
+ function extractEnumValues(typeString: string): string[] | undefined {
102
+ if (!typeString || !typeString.includes("|")) return undefined
103
+
104
+ // Parse union types like: "'default' | 'primary' | 'secondary'"
105
+ const matches = typeString.match(/'([^']+)'|"([^"]+)"/g)
106
+ if (matches) {
107
+ return matches.map((m) => m.replace(/['"]/g, ""))
108
+ }
109
+
110
+ return undefined
111
+ }
112
+
113
+ /**
114
+ * Generate default prop definitions for common component patterns
115
+ */
116
+ export function generatePropDefinitions(
117
+ _componentName: string,
118
+ options: {
119
+ stringProps?: string[]
120
+ booleanProps?: string[]
121
+ enumProps?: Record<string, string[]>
122
+ defaultProps?: Record<string, any>
123
+ descriptions?: Record<string, string>
124
+ } = {}
125
+ ): PropDefinition[] {
126
+ const props: PropDefinition[] = []
127
+
128
+ // Add string props
129
+ options.stringProps?.forEach((name) => {
130
+ props.push(
131
+ makePropDefinition(
132
+ name,
133
+ "string",
134
+ "string",
135
+ options.defaultProps?.[name],
136
+ options.descriptions?.[name],
137
+ undefined
138
+ )
139
+ )
140
+ })
141
+
142
+ // Add boolean props
143
+ options.booleanProps?.forEach((name) => {
144
+ props.push(
145
+ makePropDefinition(
146
+ name,
147
+ "boolean",
148
+ "boolean",
149
+ options.defaultProps?.[name],
150
+ options.descriptions?.[name],
151
+ undefined
152
+ )
153
+ )
154
+ })
155
+
156
+ // Add enum props
157
+ if (options.enumProps) {
158
+ Object.entries(options.enumProps).forEach(([name, values]) => {
159
+ props.push(
160
+ makePropDefinition(
161
+ name,
162
+ values.map((v) => `'${v}'`).join(" | "),
163
+ "enum",
164
+ options.defaultProps?.[name],
165
+ options.descriptions?.[name],
166
+ values
167
+ )
168
+ )
169
+ })
170
+ }
171
+
172
+ return props
173
+ }
174
+
175
+ /**
176
+ * Create a render function for a component This returns HTML string that can be injected into the
177
+ * preview container
178
+ */
179
+ export function createRenderer(_componentModule: any) {
180
+ return function render(_props: Record<string, any>): string {
181
+ // For Astro components, we need to use their rendering mechanism
182
+ // This is a placeholder - actual implementation depends on how components are structured
183
+ return `<div data-component-render="true" data-props="${encodeURIComponent(JSON.stringify(_props))}"></div>`
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Helper to build common prop configurations
189
+ */
190
+ export const PropConfigs = {
191
+ /**
192
+ * Standard variant/size props for UI components
193
+ */
194
+ ui: {
195
+ variant: {
196
+ values: ["default", "primary", "secondary", "outline", "ghost"] as string[],
197
+ default: "default"
198
+ },
199
+ size: {
200
+ values: ["sm", "md", "lg"] as string[],
201
+ default: "md"
202
+ }
203
+ },
204
+
205
+ /**
206
+ * Layout props
207
+ */
208
+ layout: {
209
+ orientation: {
210
+ values: ["vertical", "horizontal"] as string[],
211
+ default: "vertical"
212
+ },
213
+ alignment: {
214
+ values: ["left", "center", "right"] as string[],
215
+ default: "center"
216
+ }
217
+ }
218
+ }