@rimelight/ui 0.0.34 → 0.0.36
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 +1 -0
- package/package.json +19 -24
- package/src/components/astro/RLAAccordion.astro +94 -18
- package/src/components/astro/RLAAvatar.astro +135 -68
- package/src/components/astro/RLABadge.astro +4 -2
- package/src/components/astro/RLABanner.astro +138 -23
- package/src/components/astro/RLABreadcrumb.astro +13 -0
- package/src/components/astro/RLAButton.astro +8 -4
- package/src/components/astro/RLACallout.astro +112 -0
- package/src/components/astro/RLACard.astro +6 -5
- package/src/components/astro/RLACarousel.astro +104 -75
- package/src/components/astro/RLAChart.astro +4 -1
- package/src/components/astro/RLAChip.astro +11 -5
- package/src/components/astro/RLACollapsible.astro +4 -1
- package/src/components/astro/RLAColorArea.astro +432 -0
- package/src/components/astro/RLAColorField.astro +300 -0
- package/src/components/astro/RLAColorSlider.astro +413 -0
- package/src/components/astro/RLAConfirm.astro +13 -11
- package/src/components/astro/RLACopyMarkdown.astro +78 -0
- package/src/components/astro/RLADate.astro +30 -0
- package/src/components/astro/RLADrawer.astro +50 -3
- package/src/components/astro/RLADropdownMenu.astro +78 -51
- package/src/components/astro/RLAFieldGroup.astro +4 -1
- package/src/components/astro/RLAFileUpload.astro +114 -100
- package/src/components/astro/RLAFooter.astro +2 -1
- package/src/components/astro/RLAFormField.astro +10 -6
- package/src/components/astro/RLAGrid.astro +31 -39
- package/src/components/astro/RLAHead.astro +139 -39
- package/src/components/astro/RLAHeader.astro +2 -1
- package/src/components/astro/RLAImage.astro +274 -251
- package/src/components/astro/RLAInput.astro +14 -9
- package/src/components/astro/RLAInputMenu.astro +119 -83
- package/src/components/astro/RLAKbd.astro +5 -5
- package/src/components/astro/RLALayoutGrid.astro +395 -0
- package/src/components/astro/RLALink.astro +23 -1
- package/src/components/astro/RLALinkGroup.astro +99 -99
- package/src/components/astro/RLALocaleSelector.astro +34 -41
- package/src/components/astro/RLALogo.astro +117 -90
- package/src/components/astro/RLAModal.astro +48 -18
- package/src/components/astro/RLANavigationMenu.astro +381 -326
- package/src/components/astro/{RLADocsPackageManagers.astro → RLAPackageManagers.astro} +81 -87
- package/src/components/astro/RLAPageSection.astro +4 -2
- package/src/components/astro/RLAPopover.astro +4 -3
- package/src/components/astro/RLAPost.astro +11 -2
- package/src/components/astro/RLAScrollArea.astro +4 -1
- package/src/components/astro/RLAScrollToTop.astro +200 -172
- package/src/components/astro/RLASearch.astro +282 -0
- package/src/components/astro/RLASelect.astro +78 -55
- package/src/components/astro/RLASeparator.astro +11 -6
- package/src/components/astro/RLAShare.astro +60 -0
- package/src/components/astro/RLAShortcuts.astro +429 -0
- package/src/components/astro/RLASidebar.astro +158 -212
- package/src/components/astro/RLASlideover.astro +47 -17
- package/src/components/astro/RLASplitter.astro +194 -141
- package/src/components/astro/RLASteps.astro +118 -71
- package/src/components/astro/RLASurround.astro +39 -0
- package/src/components/astro/RLATable.astro +4 -1
- package/src/components/astro/RLATableOfContents.astro +109 -23
- package/src/components/astro/RLATabs.astro +147 -133
- package/src/components/astro/RLATextarea.astro +4 -1
- package/src/components/astro/RLAThemeSelector.astro +105 -76
- package/src/components/astro/RLAToast.astro +35 -21
- package/src/components/vue/RLVBanner.vue +230 -0
- package/src/components/vue/RLVButton.vue +3 -2
- package/src/components/vue/RLVCheckbox.vue +4 -2
- package/src/components/vue/RLVFooter.vue +3 -2
- package/src/components/vue/RLVHeader.vue +3 -2
- package/src/components/vue/RLVIcon.vue +4 -2
- package/src/components/vue/RLVInput.vue +5 -4
- package/src/components/vue/RLVLogo.vue +25 -3
- package/src/components/vue/RLVPlaceholder.vue +3 -2
- package/src/components/vue/RLVPost.vue +8 -2
- package/src/components/vue/RLVProgress.vue +60 -0
- package/src/components/vue/RLVScrollToTop.vue +65 -52
- package/src/components/vue/RLVSection.vue +14 -13
- package/src/components/vue/RLVToast.vue +17 -4
- package/src/composables/index.ts +1 -0
- package/src/composables/useHeaderStore.ts +1 -0
- package/src/composables/useShortcuts.ts +11 -0
- package/src/config/security.ts +43 -36
- package/src/config/site.config.ts +1 -0
- package/src/docs/components/ApiChangelog.astro +147 -0
- package/src/{plugins/starlightDocsApi → docs}/components/ApiEmits.astro +4 -4
- package/src/{plugins/starlightDocsApi → docs}/components/ApiProps.astro +4 -4
- package/src/{plugins/starlightDocsApi → docs}/components/ApiSlots.astro +4 -4
- package/src/docs/components/ApiTheme.astro +100 -0
- package/src/docs/extractAll.ts +94 -0
- package/src/docs/extractors/extractAstro.ts +69 -0
- package/src/docs/extractors/extractTheme.ts +56 -0
- package/src/{plugins/starlightDocsApi/extract-vue.ts → docs/extractors/extractVue.ts} +164 -15
- package/src/{plugins/starlightDocsApi → docs}/utils.ts +1 -2
- package/src/env.d.ts +0 -12
- package/src/integrations/ui.ts +35 -19
- package/src/middleware/security.ts +75 -19
- package/src/presets/index.ts +118 -293
- package/src/styles/index.css +0 -2
- package/src/themes/accordion.theme.ts +29 -3
- package/src/themes/aspect-ratio.theme.ts +1 -1
- package/src/themes/avatar-group.theme.ts +1 -1
- package/src/themes/avatar.theme.ts +2 -2
- package/src/themes/badge.theme.ts +2 -3
- package/src/themes/banner.theme.ts +40 -4
- package/src/themes/breadcrumb.theme.ts +1 -1
- package/src/themes/button.theme.ts +21 -22
- package/src/themes/{alert.theme.ts → callout.theme.ts} +12 -39
- package/src/themes/card.theme.ts +17 -9
- package/src/themes/carousel.theme.ts +1 -1
- package/src/themes/checkbox.theme.ts +1 -2
- package/src/themes/chip.theme.ts +2 -3
- package/src/themes/color-area.theme.ts +33 -0
- package/src/themes/color-field.theme.ts +32 -0
- package/src/themes/color-slider.theme.ts +34 -0
- package/src/themes/confirm.theme.ts +1 -1
- package/src/themes/container.theme.ts +1 -1
- package/src/themes/drawer.theme.ts +1 -1
- package/src/themes/footer.theme.ts +2 -2
- package/src/themes/grid.theme.ts +38 -0
- package/src/themes/header.theme.ts +4 -3
- package/src/themes/hover-card.theme.ts +1 -1
- package/src/themes/image.theme.ts +11 -1
- package/src/themes/input.theme.ts +7 -1
- package/src/themes/kbd.theme.ts +2 -3
- package/src/themes/label.theme.ts +1 -1
- package/src/themes/layout-grid.theme.ts +16 -0
- package/src/themes/link-group.theme.ts +0 -4
- package/src/themes/marquee.theme.ts +1 -1
- package/src/themes/modal.theme.ts +1 -1
- package/src/themes/navigation-menu.theme.ts +2 -2
- package/src/themes/page-section.theme.ts +4 -2
- package/src/themes/pagination.theme.ts +1 -1
- package/src/themes/pin-input.theme.ts +1 -1
- package/src/themes/popover.theme.ts +1 -1
- package/src/themes/post.theme.ts +23 -3
- package/src/themes/progress.theme.ts +1 -2
- package/src/themes/scroll-to-top.theme.ts +2 -3
- package/src/themes/search.theme.ts +64 -0
- package/src/themes/separator.theme.ts +1 -1
- package/src/themes/slideover.theme.ts +1 -1
- package/src/themes/slider.theme.ts +1 -2
- package/src/themes/spinner.theme.ts +1 -2
- package/src/themes/{megamenu.theme.ts → steps.theme.ts} +3 -3
- package/src/themes/sticky-surface.theme.ts +1 -1
- package/src/themes/switch.theme.ts +1 -2
- package/src/themes/table-of-contents.theme.ts +21 -2
- package/src/themes/timeline.theme.ts +7 -2
- package/src/themes/toast.theme.ts +1 -1
- package/src/types/components/accordion.ts +35 -2
- package/src/types/components/avatar.ts +16 -0
- package/src/types/components/banner.ts +42 -0
- package/src/types/components/button.ts +3 -4
- package/src/types/components/{alert.ts → callout.ts} +6 -6
- package/src/types/components/color-area.ts +19 -0
- package/src/types/components/color-field.ts +21 -0
- package/src/types/components/color-slider.ts +20 -0
- package/src/types/components/grid.ts +23 -0
- package/src/types/components/input.ts +4 -0
- package/src/types/components/layout-grid.ts +145 -0
- package/src/types/components/link-group.ts +4 -2
- package/src/types/components/link.ts +15 -0
- package/src/types/components/logo.ts +3 -3
- package/src/types/components/post.ts +12 -0
- package/src/types/components/search.ts +29 -0
- package/src/types/components/sidebar.ts +2 -6
- package/src/types/components/{megamenu.ts → steps.ts} +7 -1
- package/src/types/components/table-of-contents.ts +22 -0
- package/src/types/components/toast.ts +4 -0
- package/src/types/docs.ts +40 -0
- package/src/types/index.ts +151 -1
- package/src/types/theme.ts +6 -6
- package/src/utils/color.ts +165 -0
- package/src/utils/docs.ts +260 -110
- package/src/utils/headerStack.ts +24 -4
- package/src/utils/index.ts +2 -0
- package/src/utils/shortcuts.ts +322 -0
- package/src/components/TableOfContents.astro +0 -107
- package/src/components/astro/RLAAlert.astro +0 -93
- package/src/components/astro/RLAChangelog.astro +0 -23
- package/src/components/astro/RLAMegamenu.astro +0 -23
- package/src/plugins/index.ts +0 -2
- package/src/plugins/starlightDocsApi/components/ApiTheme.astro +0 -27
- package/src/plugins/starlightDocsApi/index.ts +0 -272
- package/src/styles/prism.css +0 -42
- package/src/themes/changelog.theme.ts +0 -13
- package/src/types/components/index.ts +0 -134
- /package/src/{plugins/starlightDocsApi → docs}/types.ts +0 -0
package/src/integrations/ui.ts
CHANGED
|
@@ -10,13 +10,24 @@ import rimelightUiPreset, {
|
|
|
10
10
|
type ColorConfigValue,
|
|
11
11
|
type RimelightPresetOptions
|
|
12
12
|
} from "../presets"
|
|
13
|
+
import { extractAllMeta } from "../docs/extractAll"
|
|
14
|
+
import virtual from "vite-plugin-virtual"
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
export interface CategoryConfig {
|
|
17
|
+
label: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface UIConfigOverrides {
|
|
21
|
+
[key: string]: Partial<ComponentTheme>
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
export interface UIOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for keyboard shortcuts.
|
|
27
|
+
*/
|
|
28
|
+
shortcuts?: {
|
|
29
|
+
categories?: Record<string, CategoryConfig>
|
|
30
|
+
}
|
|
20
31
|
/**
|
|
21
32
|
* Configuration for the Logo component variants.
|
|
22
33
|
*/
|
|
@@ -40,20 +51,21 @@ export interface UIOptions {
|
|
|
40
51
|
/**
|
|
41
52
|
* Custom colors. Each color can be:
|
|
42
53
|
*
|
|
43
|
-
* - **Flat format**: `{ "500": "#7146ff", "600": "#6222ff" }` — used
|
|
44
|
-
*
|
|
45
|
-
* - **Mode format**:
|
|
46
|
-
*
|
|
54
|
+
* - **Flat format**: `{ "500": "#7146ff", "600": "#6222ff" }` — used as the base for autogenerated
|
|
55
|
+
* light and dark shades via `color-mix(in oklch, ...)`.
|
|
56
|
+
* - **Mode format**: provide explicit `light` and/or `dark` buckets to control each scheme
|
|
57
|
+
* independently:
|
|
47
58
|
*
|
|
48
59
|
* ```ts
|
|
49
|
-
* {
|
|
60
|
+
* { light: { "500": "#0064d7" }, dark: { "500": "#60a5fa" } }
|
|
50
61
|
* ```
|
|
51
62
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
63
|
+
* Shades fall back through: **mode bucket → flat → light → dark**. Defining only one side
|
|
64
|
+
* autogenerates the other when `autogenerateColorModes` is enabled.
|
|
54
65
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
66
|
+
* To pin a component to a specific scheme, use `theme="light"` or `theme="dark"` on the component
|
|
67
|
+
* — this sets `color-scheme` natively on the element, causing all `light-dark()` variables to
|
|
68
|
+
* resolve to the correct side.
|
|
57
69
|
*/
|
|
58
70
|
colors?: Record<
|
|
59
71
|
string,
|
|
@@ -61,7 +73,6 @@ export interface UIOptions {
|
|
|
61
73
|
| {
|
|
62
74
|
light?: Record<string, string>
|
|
63
75
|
dark?: Record<string, string>
|
|
64
|
-
flat?: Record<string, string>
|
|
65
76
|
}
|
|
66
77
|
>
|
|
67
78
|
/**
|
|
@@ -119,13 +130,15 @@ export function ui(options: UIOptions = {}): AstroIntegration[] {
|
|
|
119
130
|
const resolvedConfig = {
|
|
120
131
|
...resolvedUI,
|
|
121
132
|
logos: options.logos ?? {},
|
|
122
|
-
colors: mergedColors
|
|
133
|
+
colors: mergedColors,
|
|
134
|
+
shortcuts: options.shortcuts ?? {}
|
|
123
135
|
}
|
|
124
136
|
|
|
125
137
|
const virtualModuleId = "virtual:rimelight-ui"
|
|
126
138
|
const resolvedVirtualModuleId = "\0" + virtualModuleId
|
|
127
139
|
|
|
128
|
-
function setViteConfig(updateConfig: (config: Record<string, unknown>) => void) {
|
|
140
|
+
async function setViteConfig(updateConfig: (config: Record<string, unknown>) => void) {
|
|
141
|
+
const docsMeta = await extractAllMeta()
|
|
129
142
|
updateConfig({
|
|
130
143
|
vite: {
|
|
131
144
|
optimizeDeps: {
|
|
@@ -148,7 +161,10 @@ export function ui(options: UIOptions = {}): AstroIntegration[] {
|
|
|
148
161
|
}
|
|
149
162
|
return null
|
|
150
163
|
}
|
|
151
|
-
}
|
|
164
|
+
},
|
|
165
|
+
virtual({
|
|
166
|
+
"virtual:rimelight-ui-docs-meta": `export default ${JSON.stringify(docsMeta)}`
|
|
167
|
+
})
|
|
152
168
|
]
|
|
153
169
|
}
|
|
154
170
|
})
|
|
@@ -157,9 +173,9 @@ export function ui(options: UIOptions = {}): AstroIntegration[] {
|
|
|
157
173
|
const rimelightUIIntegration: AstroIntegration = {
|
|
158
174
|
name: "@rimelight/ui",
|
|
159
175
|
hooks: {
|
|
160
|
-
"astro:config:setup": ({ updateConfig, logger }) => {
|
|
176
|
+
"astro:config:setup": async ({ updateConfig, logger }) => {
|
|
161
177
|
logger.info("Initializing @rimelight/ui core")
|
|
162
|
-
setViteConfig(updateConfig)
|
|
178
|
+
await setViteConfig(updateConfig)
|
|
163
179
|
}
|
|
164
180
|
}
|
|
165
181
|
}
|
|
@@ -8,17 +8,30 @@ function assertManifest(obj: unknown): asserts obj is Record<string, string> {
|
|
|
8
8
|
if (!obj || typeof obj !== "object") throw new Error("Expected manifest")
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function addSecurityHeaders(response: Response): Response {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
function addSecurityHeaders(response: Response, origin?: string): Response {
|
|
12
|
+
const headers = new Headers(response.headers)
|
|
13
|
+
headers.set("Referrer-Policy", "strict-origin-when-cross-origin")
|
|
14
|
+
headers.set("X-Content-Type-Options", "nosniff")
|
|
15
|
+
headers.set("X-Frame-Options", "DENY")
|
|
16
|
+
headers.set("Cross-Origin-Resource-Policy", "same-origin")
|
|
17
|
+
headers.set("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload")
|
|
18
|
+
headers.set("Permissions-Policy", "camera=(), microphone=(), geolocation=(), payment=(), usb=()")
|
|
19
|
+
if (origin) {
|
|
20
|
+
headers.set(
|
|
21
|
+
"Link",
|
|
22
|
+
[
|
|
23
|
+
`<${origin}/sitemap-index.xml>; rel="sitemap"`,
|
|
24
|
+
`<${origin}/llms.txt>; rel="llms"`,
|
|
25
|
+
`<${origin}/.well-known/api-catalog>; rel="api-catalog"`,
|
|
26
|
+
`<${origin}/rss.xml>; rel="alternate"; type="application/rss+xml"`
|
|
27
|
+
].join(", ")
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
return new Response(response.body, {
|
|
31
|
+
status: response.status,
|
|
32
|
+
statusText: response.statusText,
|
|
33
|
+
headers
|
|
34
|
+
})
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
/**
|
|
@@ -34,14 +47,42 @@ export const security = defineMiddleware(async (context, next) => {
|
|
|
34
47
|
const response = await next()
|
|
35
48
|
const contentType = response.headers.get("content-type") || ""
|
|
36
49
|
|
|
37
|
-
if (
|
|
38
|
-
|
|
50
|
+
if (import.meta.env.DEV) {
|
|
51
|
+
if (!contentType.includes("text/html")) {
|
|
52
|
+
return addSecurityHeaders(response, context.url.origin)
|
|
53
|
+
}
|
|
54
|
+
const cleanHeaders = new Headers(response.headers)
|
|
55
|
+
cleanHeaders.delete("content-security-policy")
|
|
56
|
+
let modifiedHtml = await response.text()
|
|
57
|
+
modifiedHtml = modifiedHtml.replace(
|
|
58
|
+
/<meta\s[^>]*http-equiv\s*=\s*["']?content-security-policy[^>]*>/gi,
|
|
59
|
+
""
|
|
60
|
+
)
|
|
61
|
+
return addSecurityHeaders(
|
|
62
|
+
new Response(modifiedHtml, {
|
|
63
|
+
status: response.status,
|
|
64
|
+
statusText: response.statusText,
|
|
65
|
+
headers: cleanHeaders
|
|
66
|
+
}),
|
|
67
|
+
context.url.origin
|
|
68
|
+
)
|
|
39
69
|
}
|
|
40
70
|
|
|
41
|
-
|
|
42
|
-
const nonceValue = cspHeader ? crypto.randomUUID().replace(/-/g, "") : null
|
|
71
|
+
let cspHeader = response.headers.get("content-security-policy")
|
|
43
72
|
const newHeaders = new Headers(response.headers)
|
|
44
73
|
|
|
74
|
+
if (cspHeader) {
|
|
75
|
+
// Unescape HTML entities (like ' or ' to ') that Astro's native CSP generation mistakenly puts in the header
|
|
76
|
+
cspHeader = cspHeader
|
|
77
|
+
.replace(/�*39;/g, "'")
|
|
78
|
+
.replace(/�*27;/gi, "'")
|
|
79
|
+
.replace(/"/g, '"')
|
|
80
|
+
.replace(/&/g, "&")
|
|
81
|
+
newHeaders.set("content-security-policy", cspHeader)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const nonceValue = cspHeader ? crypto.randomUUID().replace(/-/g, "") : null
|
|
85
|
+
|
|
45
86
|
if (cspHeader && nonceValue) {
|
|
46
87
|
let newCsp = cspHeader
|
|
47
88
|
if (newCsp.includes("script-src ")) {
|
|
@@ -77,6 +118,11 @@ export const security = defineMiddleware(async (context, next) => {
|
|
|
77
118
|
}
|
|
78
119
|
}
|
|
79
120
|
})
|
|
121
|
+
.on('meta[http-equiv="content-security-policy" i]', {
|
|
122
|
+
element(el: any) {
|
|
123
|
+
el.remove()
|
|
124
|
+
}
|
|
125
|
+
})
|
|
80
126
|
|
|
81
127
|
if (nonceValue) {
|
|
82
128
|
rewriter = rewriter
|
|
@@ -106,12 +152,19 @@ export const security = defineMiddleware(async (context, next) => {
|
|
|
106
152
|
statusText: response.statusText,
|
|
107
153
|
headers: newHeaders
|
|
108
154
|
})
|
|
109
|
-
)
|
|
155
|
+
),
|
|
156
|
+
context.url.origin
|
|
110
157
|
)
|
|
111
158
|
}
|
|
112
159
|
|
|
113
160
|
let modifiedHtml = await response.text()
|
|
114
161
|
|
|
162
|
+
// Remove Astro-injected CSP meta tag to prevent duplicate CSP headers and HTML escaping errors
|
|
163
|
+
modifiedHtml = modifiedHtml.replace(
|
|
164
|
+
/<meta\s[^>]*http-equiv\s*=\s*["']?content-security-policy[^>]*>/gi,
|
|
165
|
+
""
|
|
166
|
+
)
|
|
167
|
+
|
|
115
168
|
assertManifest(manifest)
|
|
116
169
|
|
|
117
170
|
const entries = Object.entries(manifest)
|
|
@@ -132,7 +185,10 @@ export const security = defineMiddleware(async (context, next) => {
|
|
|
132
185
|
}
|
|
133
186
|
|
|
134
187
|
if (nonceValue) {
|
|
135
|
-
modifiedHtml = modifiedHtml.replace(
|
|
188
|
+
modifiedHtml = modifiedHtml.replace(
|
|
189
|
+
/<head([^>]*)>/i,
|
|
190
|
+
`<head$1>\n<meta name="csp-nonce" content="${nonceValue}">`
|
|
191
|
+
)
|
|
136
192
|
modifiedHtml = modifiedHtml.replace(
|
|
137
193
|
/<script(?![^>]*nonce=)([^>]*)>/gi,
|
|
138
194
|
`<script$1 nonce="${nonceValue}">`
|
|
@@ -148,7 +204,7 @@ export const security = defineMiddleware(async (context, next) => {
|
|
|
148
204
|
status: response.status,
|
|
149
205
|
statusText: response.statusText,
|
|
150
206
|
headers: newHeaders
|
|
151
|
-
})
|
|
207
|
+
}),
|
|
208
|
+
context.url.origin
|
|
152
209
|
)
|
|
153
210
|
})
|
|
154
|
-
|