Skip to content

Commit af862bd

Browse files
refactor: use Iteration to Simplify Component Registration (#61)
Co-authored-by: snowbitx <snowbitx@gmail.com>
1 parent 12e3f2a commit af862bd

File tree

1 file changed

+6
-84
lines changed

1 file changed

+6
-84
lines changed

apps/www/plugins/ai-elements.ts

Lines changed: 6 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,15 @@
1-
import {
2-
Artifact,
3-
ChainOfThought,
4-
Checkpoint,
5-
CodeBlock,
6-
CodeBlockDark,
7-
Confirmation,
8-
ConfirmationAccepted,
9-
ConfirmationRejected,
10-
ConfirmationRequest,
11-
Context,
12-
Conversation,
13-
Image,
14-
InlineCitation,
15-
Loader,
16-
LoaderCustomStyling,
17-
LoaderSizes,
18-
Message,
19-
ModelSelector,
20-
OpenInChat,
21-
Plan,
22-
PromptInput,
23-
Queue,
24-
QueueCustom,
25-
QueuePromptInput,
26-
Reasoning,
27-
Shimmer,
28-
ShimmerCustomElements,
29-
ShimmerDurations,
30-
Sources,
31-
SourcesCustomRendering,
32-
Suggestion,
33-
SuggestionAiInput,
34-
Task,
35-
Tool,
36-
ToolInputAvailable,
37-
ToolInputStreaming,
38-
ToolOutputAvailable,
39-
ToolOutputError,
40-
WebPreview,
41-
Workflow,
42-
} from '@repo/examples'
43-
1+
import type { NuxtApp } from 'nuxt/app'
2+
import * as Components from '@repo/examples'
443
import ComponentLoader from '@/components/ComponentLoader.vue'
454
import ComponentViewer from '@/components/ComponentViewer.vue'
465

47-
export default defineNuxtPlugin((nuxtApp) => {
6+
export default defineNuxtPlugin((nuxtApp: NuxtApp) => {
487
const { vueApp } = nuxtApp
498

509
vueApp.component('ComponentLoader', ComponentLoader)
5110
vueApp.component('ComponentViewer', ComponentViewer)
5211

53-
vueApp.component('Artifact', Artifact)
54-
vueApp.component('Message', Message)
55-
vueApp.component('PromptInput', PromptInput)
56-
vueApp.component('Conversation', Conversation)
57-
vueApp.component('Image', Image)
58-
vueApp.component('Shimmer', Shimmer)
59-
vueApp.component('ShimmerCustomElements', ShimmerCustomElements)
60-
vueApp.component('ShimmerDurations', ShimmerDurations)
61-
vueApp.component('Sources', Sources)
62-
vueApp.component('SourcesCustomRendering', SourcesCustomRendering)
63-
vueApp.component('Task', Task)
64-
vueApp.component('Suggestion', Suggestion)
65-
vueApp.component('SuggestionAiInput', SuggestionAiInput)
66-
vueApp.component('OpenInChat', OpenInChat)
67-
vueApp.component('Loader', Loader)
68-
vueApp.component('LoaderCustomStyling', LoaderCustomStyling)
69-
vueApp.component('LoaderSizes', LoaderSizes)
70-
vueApp.component('ChainOfThought', ChainOfThought)
71-
vueApp.component('QueueCustom', QueueCustom)
72-
vueApp.component('Queue', Queue)
73-
vueApp.component('QueuePromptInput', QueuePromptInput)
74-
vueApp.component('Plan', Plan)
75-
vueApp.component('InlineCitation', InlineCitation)
76-
vueApp.component('CodeBlock', CodeBlock)
77-
vueApp.component('CodeBlockDark', CodeBlockDark)
78-
vueApp.component('Checkpoint', Checkpoint)
79-
vueApp.component('Workflow', Workflow)
80-
vueApp.component('Tool', Tool)
81-
vueApp.component('ToolInputStreaming', ToolInputStreaming)
82-
vueApp.component('ToolInputAvailable', ToolInputAvailable)
83-
vueApp.component('ToolOutputAvailable', ToolOutputAvailable)
84-
vueApp.component('ToolOutputError', ToolOutputError)
85-
vueApp.component('ModelSelector', ModelSelector)
86-
vueApp.component('Context', Context)
87-
vueApp.component('Confirmation', Confirmation)
88-
vueApp.component('ConfirmationAccepted', ConfirmationAccepted)
89-
vueApp.component('ConfirmationRejected', ConfirmationRejected)
90-
vueApp.component('ConfirmationRequest', ConfirmationRequest)
91-
vueApp.component('Reasoning', Reasoning)
92-
vueApp.component('WebPreview', WebPreview)
12+
Object.entries(Components).forEach(([name, component]) => {
13+
vueApp.component(name, component)
14+
})
9315
})

0 commit comments

Comments
 (0)