base-themes 0.1.1 → 0.1.3
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/CHANGELOG.md +25 -0
- package/CODE_OF_CONDUCT.md +22 -0
- package/CONTRIBUTING.md +98 -0
- package/LICENSE +21 -0
- package/README.md +324 -5
- package/RELEASE.md +80 -0
- package/SECURITY.md +49 -0
- package/bin/base-themes.mjs +143 -0
- package/dist/base-themes.css +1 -1
- package/dist/base-themes.js +857 -302
- package/dist/llms-full.txt +288 -0
- package/dist/llms.txt +79 -0
- package/dist/types/blocks/AuthCard.d.ts +2 -0
- package/dist/types/blocks/CommandPaletteBlock.d.ts +2 -0
- package/dist/types/blocks/DashboardShell.d.ts +2 -0
- package/dist/types/blocks/DataTableBlock.d.ts +2 -0
- package/dist/types/blocks/PricingPanel.d.ts +2 -0
- package/dist/types/blocks/SettingsForm.d.ts +2 -0
- package/dist/types/blocks/TeamActivityFeed.d.ts +2 -0
- package/dist/types/blocks/ThemeShowcaseCard.d.ts +2 -0
- package/dist/types/blocks/index.d.ts +8 -0
- package/dist/types/components/ui/Input.d.ts +3 -0
- package/dist/types/components/ui/index.d.ts +1 -1
- package/dist/types/lib.d.ts +1 -0
- package/docs/adoption-dashboard.md +149 -0
- package/docs/analytics-setup.md +145 -0
- package/docs/community-gallery-proposal.md +64 -0
- package/docs/community-proof-telemetry.md +47 -0
- package/docs/contributor-issue-seeds.md +240 -0
- package/docs/registry-access-telemetry.md +87 -0
- package/docs/release-announcement-kit.md +229 -0
- package/docs/search-console-setup.md +111 -0
- package/docs/theme-token-contract.md +113 -0
- package/examples/dashboard/README.md +24 -0
- package/examples/dashboard/index.html +12 -0
- package/examples/dashboard/package-lock.json +1212 -0
- package/examples/dashboard/package.json +24 -0
- package/examples/dashboard/src/App.tsx +115 -0
- package/examples/dashboard/src/main.tsx +11 -0
- package/examples/dashboard/src/styles.css +129 -0
- package/examples/dashboard/src/vite-env.d.ts +4 -0
- package/examples/dashboard/tsconfig.app.json +23 -0
- package/examples/dashboard/tsconfig.json +7 -0
- package/examples/dashboard/tsconfig.node.json +15 -0
- package/examples/dashboard/vite.config.ts +6 -0
- package/examples/next/README.md +29 -0
- package/examples/next/app/base-themes-demo.tsx +70 -0
- package/examples/next/app/layout.tsx +16 -0
- package/examples/next/app/page.tsx +9 -0
- package/examples/next/app/styles.css +106 -0
- package/examples/next/next-env.d.ts +6 -0
- package/examples/next/next.config.ts +5 -0
- package/examples/next/package-lock.json +1199 -0
- package/examples/next/package.json +27 -0
- package/examples/next/tsconfig.json +36 -0
- package/examples/registry-copy/README.md +73 -0
- package/examples/registry-copy/plan-copy.mjs +130 -0
- package/examples/theme-customization/README.md +26 -0
- package/examples/theme-customization/index.html +12 -0
- package/examples/theme-customization/package-lock.json +1212 -0
- package/examples/theme-customization/package.json +24 -0
- package/examples/theme-customization/src/App.tsx +138 -0
- package/examples/theme-customization/src/main.tsx +11 -0
- package/examples/theme-customization/src/styles.css +138 -0
- package/examples/theme-customization/src/vite-env.d.ts +4 -0
- package/examples/theme-customization/tsconfig.app.json +23 -0
- package/examples/theme-customization/tsconfig.json +7 -0
- package/examples/theme-customization/tsconfig.node.json +15 -0
- package/examples/theme-customization/vite.config.ts +6 -0
- package/examples/vite/README.md +32 -0
- package/examples/vite/index.html +12 -0
- package/examples/vite/package-lock.json +1200 -0
- package/examples/vite/package.json +24 -0
- package/examples/vite/src/App.tsx +101 -0
- package/examples/vite/src/main.tsx +11 -0
- package/examples/vite/src/styles.css +125 -0
- package/examples/vite/src/vite-env.d.ts +4 -0
- package/examples/vite/tsconfig.app.json +23 -0
- package/examples/vite/tsconfig.json +7 -0
- package/examples/vite/tsconfig.node.json +15 -0
- package/examples/vite/vite.config.ts +6 -0
- package/llms-full.txt +288 -0
- package/llms.txt +79 -0
- package/package.json +157 -14
- package/public/previews/base-themes-bauhaus.png +0 -0
- package/public/previews/base-themes-bento.png +0 -0
- package/public/previews/base-themes-calm.png +0 -0
- package/public/previews/base-themes-cyberpunk.png +0 -0
- package/public/previews/base-themes-data-dense.png +0 -0
- package/public/previews/base-themes-editorial.png +0 -0
- package/public/previews/base-themes-enterprise.png +0 -0
- package/public/previews/base-themes-fluent.png +0 -0
- package/public/previews/base-themes-glass.png +0 -0
- package/public/previews/base-themes-linear.png +0 -0
- package/public/previews/base-themes-luxury.png +0 -0
- package/public/previews/base-themes-material.png +0 -0
- package/public/previews/base-themes-minimal.png +0 -0
- package/public/previews/base-themes-mono.png +0 -0
- package/public/previews/base-themes-neo-brutalism.png +0 -0
- package/public/previews/base-themes-playful.png +0 -0
- package/public/previews/base-themes-retro.png +0 -0
- package/public/previews/base-themes-shadcn.png +0 -0
- package/public/previews/base-themes-soft-ui.png +0 -0
- package/public/previews/base-themes-terminal.png +0 -0
- package/registry/items/accordion.json +101 -0
- package/registry/items/alert-dialog.json +107 -0
- package/registry/items/autocomplete.json +106 -0
- package/registry/items/avatar.json +101 -0
- package/registry/items/block-auth-card.json +105 -0
- package/registry/items/block-command-palette.json +99 -0
- package/registry/items/block-dashboard-shell.json +101 -0
- package/registry/items/block-data-table.json +99 -0
- package/registry/items/block-pricing-panel.json +99 -0
- package/registry/items/block-settings-form.json +107 -0
- package/registry/items/block-team-activity-feed.json +99 -0
- package/registry/items/block-theme-showcase-card.json +99 -0
- package/registry/items/button.json +102 -0
- package/registry/items/checkbox-group.json +106 -0
- package/registry/items/checkbox.json +102 -0
- package/registry/items/collapsible.json +101 -0
- package/registry/items/combobox.json +101 -0
- package/registry/items/context-menu.json +106 -0
- package/registry/items/csp-provider.json +96 -0
- package/registry/items/dialog.json +102 -0
- package/registry/items/direction-provider.json +101 -0
- package/registry/items/drawer.json +101 -0
- package/registry/items/field.json +101 -0
- package/registry/items/fieldset.json +101 -0
- package/registry/items/form.json +101 -0
- package/registry/items/input.json +102 -0
- package/registry/items/menu.json +101 -0
- package/registry/items/menubar.json +106 -0
- package/registry/items/meter.json +101 -0
- package/registry/items/navigation-menu.json +101 -0
- package/registry/items/number-field.json +101 -0
- package/registry/items/otp-field.json +101 -0
- package/registry/items/popover.json +102 -0
- package/registry/items/preview-card.json +101 -0
- package/registry/items/progress.json +101 -0
- package/registry/items/radio-group.json +102 -0
- package/registry/items/radio.json +101 -0
- package/registry/items/scroll-area.json +101 -0
- package/registry/items/select.json +102 -0
- package/registry/items/separator.json +101 -0
- package/registry/items/slider.json +102 -0
- package/registry/items/switch.json +102 -0
- package/registry/items/tabs.json +101 -0
- package/registry/items/theme-bauhaus.json +107 -0
- package/registry/items/theme-bento.json +107 -0
- package/registry/items/theme-calm.json +107 -0
- package/registry/items/theme-cyberpunk.json +108 -0
- package/registry/items/theme-data-dense.json +107 -0
- package/registry/items/theme-editorial.json +107 -0
- package/registry/items/theme-enterprise.json +108 -0
- package/registry/items/theme-fluent.json +107 -0
- package/registry/items/theme-glass.json +107 -0
- package/registry/items/theme-linear.json +107 -0
- package/registry/items/theme-luxury.json +107 -0
- package/registry/items/theme-material.json +107 -0
- package/registry/items/theme-minimal.json +107 -0
- package/registry/items/theme-mono.json +107 -0
- package/registry/items/theme-neo-brutalism.json +107 -0
- package/registry/items/theme-playful.json +107 -0
- package/registry/items/theme-retro.json +107 -0
- package/registry/items/theme-shadcn.json +107 -0
- package/registry/items/theme-soft-ui.json +107 -0
- package/registry/items/theme-terminal.json +107 -0
- package/registry/items/toast.json +106 -0
- package/registry/items/toggle-group.json +101 -0
- package/registry/items/toggle.json +101 -0
- package/registry/items/toolbar.json +101 -0
- package/registry/items/tooltip.json +102 -0
- package/registry/registry.json +564 -49
- package/registry/shadcn-registry.json +415 -0
- package/research/telemetry-fixtures/analytics-events.jsonl +9 -0
- package/research/telemetry-fixtures/bundle-report.json +44 -0
- package/research/telemetry-fixtures/community-proof.csv +5 -0
- package/research/telemetry-fixtures/registry-access.jsonl +10 -0
- package/research/telemetry-fixtures/search-console-export.csv +4 -0
- package/scripts/registry-plan.mjs +434 -0
- package/scripts/render-launch-actions.mjs +405 -0
- package/scripts/render-launch-status.mjs +373 -0
- package/scripts/render-release-announcement.mjs +329 -0
- package/scripts/verify-launch-readiness.mjs +415 -0
- package/scripts/verify-telemetry-fixtures.mjs +85 -0
- package/scripts/verify-telemetry-report.mjs +89 -0
- package/skills/base-themes/SKILL.md +156 -43
- package/src/blocks/AuthCard.tsx +29 -0
- package/src/blocks/Blocks.css +182 -0
- package/src/blocks/CommandPaletteBlock.tsx +32 -0
- package/src/blocks/DashboardShell.tsx +36 -0
- package/src/blocks/DataTableBlock.tsx +44 -0
- package/src/blocks/PricingPanel.tsx +28 -0
- package/src/blocks/SettingsForm.tsx +37 -0
- package/src/blocks/TeamActivityFeed.tsx +38 -0
- package/src/blocks/ThemeShowcaseCard.tsx +32 -0
- package/src/blocks/index.ts +8 -0
- package/src/components/ui/Accordion.css +42 -0
- package/src/components/ui/Accordion.tsx +41 -0
- package/src/components/ui/AlertDialog.css +40 -0
- package/src/components/ui/AlertDialog.tsx +52 -0
- package/src/components/ui/Autocomplete.css +3 -0
- package/src/components/ui/Autocomplete.tsx +50 -0
- package/src/components/ui/Avatar.css +45 -0
- package/src/components/ui/Avatar.tsx +36 -0
- package/src/components/ui/Button.css +79 -0
- package/src/components/ui/Button.tsx +20 -0
- package/src/components/ui/Checkbox.css +37 -0
- package/src/components/ui/Checkbox.tsx +32 -0
- package/src/components/ui/CheckboxGroup.tsx +21 -0
- package/src/components/ui/Collapsible.css +34 -0
- package/src/components/ui/Collapsible.tsx +29 -0
- package/src/components/ui/Combobox.css +75 -0
- package/src/components/ui/Combobox.tsx +53 -0
- package/src/components/ui/ContextMenu.css +9 -0
- package/src/components/ui/ContextMenu.tsx +47 -0
- package/src/components/ui/CspProvider.tsx +10 -0
- package/src/components/ui/Dialog.css +41 -0
- package/src/components/ui/Dialog.tsx +45 -0
- package/src/components/ui/DirectionProvider.tsx +17 -0
- package/src/components/ui/Drawer.css +77 -0
- package/src/components/ui/Drawer.tsx +56 -0
- package/src/components/ui/Field.css +19 -0
- package/src/components/ui/Field.tsx +24 -0
- package/src/components/ui/Fieldset.css +16 -0
- package/src/components/ui/Fieldset.tsx +19 -0
- package/src/components/ui/Form.css +5 -0
- package/src/components/ui/Form.tsx +12 -0
- package/src/components/ui/Input.css +50 -0
- package/src/components/ui/Input.tsx +62 -0
- package/src/components/ui/Menu.css +59 -0
- package/src/components/ui/Menu.tsx +50 -0
- package/src/components/ui/Menubar.css +26 -0
- package/src/components/ui/Menubar.tsx +42 -0
- package/src/components/ui/Meter.css +45 -0
- package/src/components/ui/Meter.tsx +37 -0
- package/src/components/ui/NavigationMenu.css +103 -0
- package/src/components/ui/NavigationMenu.tsx +64 -0
- package/src/components/ui/NumberField.css +38 -0
- package/src/components/ui/NumberField.tsx +28 -0
- package/src/components/ui/OtpField.css +28 -0
- package/src/components/ui/OtpField.tsx +24 -0
- package/src/components/ui/Popover.css +25 -0
- package/src/components/ui/Popover.tsx +37 -0
- package/src/components/ui/PreviewCard.css +33 -0
- package/src/components/ui/PreviewCard.tsx +43 -0
- package/src/components/ui/Progress.css +33 -0
- package/src/components/ui/Progress.tsx +28 -0
- package/src/components/ui/Radio.tsx +22 -0
- package/src/components/ui/RadioGroup.css +42 -0
- package/src/components/ui/RadioGroup.tsx +29 -0
- package/src/components/ui/ScrollArea.css +42 -0
- package/src/components/ui/ScrollArea.tsx +22 -0
- package/src/components/ui/Select.css +86 -0
- package/src/components/ui/Select.tsx +39 -0
- package/src/components/ui/Separator.css +14 -0
- package/src/components/ui/Separator.tsx +12 -0
- package/src/components/ui/Slider.css +39 -0
- package/src/components/ui/Slider.tsx +21 -0
- package/src/components/ui/Switch.css +45 -0
- package/src/components/ui/Switch.tsx +29 -0
- package/src/components/ui/Tabs.css +72 -0
- package/src/components/ui/Tabs.tsx +44 -0
- package/src/components/ui/Toast.css +75 -0
- package/src/components/ui/Toast.tsx +48 -0
- package/src/components/ui/Toggle.tsx +12 -0
- package/src/components/ui/ToggleGroup.css +35 -0
- package/src/components/ui/ToggleGroup.tsx +30 -0
- package/src/components/ui/Toolbar.css +60 -0
- package/src/components/ui/Toolbar.tsx +36 -0
- package/src/components/ui/Tooltip.css +14 -0
- package/src/components/ui/Tooltip.tsx +31 -0
- package/src/components/ui/index.ts +83 -0
- package/src/components/ui/useDirection.ts +1 -0
- package/src/components/ui/useToastManager.ts +11 -0
- package/src/docs/blockMeta.json +66 -0
- package/src/docs/componentMeta.json +322 -0
- package/src/docs/staticPageMeta.json +143 -0
- package/src/docs/themeMeta.json +22 -0
- package/src/styles/tokenContract.json +61 -0
- package/workers/analytics-receiver.mjs +170 -0
- package/wrangler.analytics.jsonc +12 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const allowedEvents = new Set([
|
|
2
|
+
'route_view',
|
|
3
|
+
'internal_navigation',
|
|
4
|
+
'install_command_copy',
|
|
5
|
+
'github_outbound_click',
|
|
6
|
+
'theme_style_cycle',
|
|
7
|
+
'theme_style_select',
|
|
8
|
+
'theme_snippet_copy',
|
|
9
|
+
'color_theme_toggle',
|
|
10
|
+
'block_share_copy',
|
|
11
|
+
])
|
|
12
|
+
|
|
13
|
+
const allowedProperties = new Set([
|
|
14
|
+
'block',
|
|
15
|
+
'campaign',
|
|
16
|
+
'component',
|
|
17
|
+
'content',
|
|
18
|
+
'detail',
|
|
19
|
+
'from',
|
|
20
|
+
'label',
|
|
21
|
+
'medium',
|
|
22
|
+
'path',
|
|
23
|
+
'source',
|
|
24
|
+
'target',
|
|
25
|
+
'themeStyle',
|
|
26
|
+
'to',
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
const defaultAllowedOrigins = [
|
|
30
|
+
'https://base-themes.bangwu.me',
|
|
31
|
+
'http://localhost:5175',
|
|
32
|
+
'http://localhost:5176',
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
function json(data, init = {}) {
|
|
36
|
+
return new Response(JSON.stringify(data), {
|
|
37
|
+
...init,
|
|
38
|
+
headers: {
|
|
39
|
+
'content-type': 'application/json; charset=utf-8',
|
|
40
|
+
...corsHeaders(init.request, init.env),
|
|
41
|
+
...init.headers,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getAllowedOrigins(env = {}) {
|
|
47
|
+
const configured = typeof env.ALLOWED_ORIGINS === 'string'
|
|
48
|
+
? env.ALLOWED_ORIGINS.split(',').map((origin) => origin.trim()).filter(Boolean)
|
|
49
|
+
: []
|
|
50
|
+
return configured.length ? configured : defaultAllowedOrigins
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function requestOriginAllowed(request, env = {}) {
|
|
54
|
+
const origin = request.headers.get('origin')
|
|
55
|
+
if (!origin) return true
|
|
56
|
+
return getAllowedOrigins(env).includes(origin)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function corsHeaders(request, env = {}) {
|
|
60
|
+
const origin = request?.headers.get('origin')
|
|
61
|
+
const allowedOrigin = origin && getAllowedOrigins(env).includes(origin) ? origin : defaultAllowedOrigins[0]
|
|
62
|
+
return {
|
|
63
|
+
'access-control-allow-origin': allowedOrigin,
|
|
64
|
+
'access-control-allow-methods': 'POST, OPTIONS',
|
|
65
|
+
'access-control-allow-headers': 'content-type',
|
|
66
|
+
'access-control-max-age': '86400',
|
|
67
|
+
vary: 'origin',
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function sanitizeString(value, maxLength) {
|
|
72
|
+
if (typeof value !== 'string') return undefined
|
|
73
|
+
const trimmed = value.trim()
|
|
74
|
+
if (!trimmed) return undefined
|
|
75
|
+
return trimmed.slice(0, maxLength)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function sanitizePath(value) {
|
|
79
|
+
const path = sanitizeString(value, 256)
|
|
80
|
+
if (!path || !path.startsWith('/')) return '/'
|
|
81
|
+
return path
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function sanitizeProperties(properties) {
|
|
85
|
+
if (!properties || typeof properties !== 'object' || Array.isArray(properties)) return {}
|
|
86
|
+
|
|
87
|
+
return Object.fromEntries(
|
|
88
|
+
Object.entries(properties)
|
|
89
|
+
.filter(([key, value]) => allowedProperties.has(key) && ['string', 'number', 'boolean'].includes(typeof value))
|
|
90
|
+
.map(([key, value]) => [key, typeof value === 'string' ? value.slice(0, 160) : value]),
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function parseEvent(body) {
|
|
95
|
+
if (!body || typeof body !== 'object' || Array.isArray(body)) {
|
|
96
|
+
return { error: 'Expected a JSON object.' }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const name = sanitizeString(body.name, 80)
|
|
100
|
+
if (!name || !allowedEvents.has(name)) {
|
|
101
|
+
return { error: 'Unknown event name.' }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const timestamp = sanitizeString(body.timestamp, 64) || new Date().toISOString()
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
event: {
|
|
108
|
+
name,
|
|
109
|
+
path: sanitizePath(body.path),
|
|
110
|
+
timestamp,
|
|
111
|
+
properties: sanitizeProperties(body.properties),
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function persistEvent(env, event) {
|
|
117
|
+
const line = JSON.stringify(event)
|
|
118
|
+
|
|
119
|
+
if (env.BASE_THEMES_ANALYTICS?.writeDataPoint) {
|
|
120
|
+
env.BASE_THEMES_ANALYTICS.writeDataPoint({
|
|
121
|
+
blobs: [event.name, event.path],
|
|
122
|
+
doubles: [1],
|
|
123
|
+
indexes: [event.name],
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (env.ANALYTICS_QUEUE?.send) {
|
|
128
|
+
await env.ANALYTICS_QUEUE.send(event)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log(line)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function handleAnalyticsRequest(request, env = {}) {
|
|
135
|
+
if (request.method === 'OPTIONS') {
|
|
136
|
+
return new Response(null, { status: requestOriginAllowed(request, env) ? 204 : 403, headers: corsHeaders(request, env) })
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!requestOriginAllowed(request, env)) {
|
|
140
|
+
return json({ error: 'Origin not allowed.' }, { status: 403, request, env })
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (request.method !== 'POST') {
|
|
144
|
+
return json({ error: 'Method not allowed.' }, { status: 405, request, env })
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const contentType = request.headers.get('content-type') || ''
|
|
148
|
+
if (!contentType.includes('application/json')) {
|
|
149
|
+
return json({ error: 'Expected application/json.' }, { status: 415, request, env })
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let body
|
|
153
|
+
try {
|
|
154
|
+
body = await request.json()
|
|
155
|
+
} catch {
|
|
156
|
+
return json({ error: 'Invalid JSON.' }, { status: 400, request, env })
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const result = parseEvent(body)
|
|
160
|
+
if (result.error) {
|
|
161
|
+
return json({ error: result.error }, { status: 400, request, env })
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
await persistEvent(env, result.event)
|
|
165
|
+
return json({ ok: true }, { request, env })
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export default {
|
|
169
|
+
fetch: handleAnalyticsRequest,
|
|
170
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
3
|
+
"name": "base-themes-analytics",
|
|
4
|
+
"main": "workers/analytics-receiver.mjs",
|
|
5
|
+
"compatibility_date": "2026-05-29",
|
|
6
|
+
"observability": {
|
|
7
|
+
"enabled": true
|
|
8
|
+
},
|
|
9
|
+
"vars": {
|
|
10
|
+
"ALLOWED_ORIGINS": "https://base-themes.bangwu.me,http://localhost:5175,http://localhost:5176"
|
|
11
|
+
}
|
|
12
|
+
}
|