@bagelink/blox 1.5.15 โ†’ 1.5.20

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 (107) hide show
  1. package/README.md +105 -1
  2. package/dist/blox.css +720 -68
  3. package/dist/components/base/Button.vue.d.ts.map +1 -1
  4. package/dist/components/base/Container.vue.d.ts.map +1 -1
  5. package/dist/components/base/Image.vue.d.ts.map +1 -1
  6. package/dist/components/base/Spacer.vue.d.ts.map +1 -1
  7. package/dist/components/base/Text.vue.d.ts.map +1 -1
  8. package/dist/components/base/Title.vue.d.ts.map +1 -1
  9. package/dist/components/blocks/BigImage.vue.d.ts +12 -0
  10. package/dist/components/blocks/BigImage.vue.d.ts.map +1 -0
  11. package/dist/components/blocks/BigQuote.vue.d.ts +14 -0
  12. package/dist/components/blocks/BigQuote.vue.d.ts.map +1 -0
  13. package/dist/components/blocks/BlockFooter.vue.d.ts +17 -0
  14. package/dist/components/blocks/BlockFooter.vue.d.ts.map +1 -0
  15. package/dist/components/blocks/BlockNav.vue.d.ts +22 -0
  16. package/dist/components/blocks/BlockNav.vue.d.ts.map +1 -0
  17. package/dist/components/blocks/Cards.vue.d.ts +18 -0
  18. package/dist/components/blocks/Cards.vue.d.ts.map +1 -0
  19. package/dist/components/blocks/Contact.vue.d.ts +22 -0
  20. package/dist/components/blocks/Contact.vue.d.ts.map +1 -0
  21. package/dist/components/blocks/CountDown.vue.d.ts +76 -0
  22. package/dist/components/blocks/CountDown.vue.d.ts.map +1 -0
  23. package/dist/components/blocks/Cta.vue.d.ts +15 -0
  24. package/dist/components/blocks/Cta.vue.d.ts.map +1 -0
  25. package/dist/components/blocks/Faq.vue.d.ts +20 -0
  26. package/dist/components/blocks/Faq.vue.d.ts.map +1 -0
  27. package/dist/components/blocks/Grid.vue.d.ts +24 -0
  28. package/dist/components/blocks/Grid.vue.d.ts.map +1 -0
  29. package/dist/components/blocks/Icons.vue.d.ts +16 -0
  30. package/dist/components/blocks/Icons.vue.d.ts.map +1 -0
  31. package/dist/components/blocks/IconsList.vue.d.ts +22 -0
  32. package/dist/components/blocks/IconsList.vue.d.ts.map +1 -0
  33. package/dist/components/blocks/ImageCarousel.vue.d.ts +16 -0
  34. package/dist/components/blocks/ImageCarousel.vue.d.ts.map +1 -0
  35. package/dist/components/blocks/ImageLinkBoxes.vue.d.ts +14 -0
  36. package/dist/components/blocks/ImageLinkBoxes.vue.d.ts.map +1 -0
  37. package/dist/components/blocks/Logos.vue.d.ts +17 -0
  38. package/dist/components/blocks/Logos.vue.d.ts.map +1 -0
  39. package/dist/components/blocks/PopUp.vue.d.ts +23 -0
  40. package/dist/components/blocks/PopUp.vue.d.ts.map +1 -0
  41. package/dist/components/blocks/PriceTable.vue.d.ts +24 -0
  42. package/dist/components/blocks/PriceTable.vue.d.ts.map +1 -0
  43. package/dist/components/blocks/Space.vue.d.ts +25 -0
  44. package/dist/components/blocks/Space.vue.d.ts.map +1 -0
  45. package/dist/components/blocks/Tabs.vue.d.ts +15 -0
  46. package/dist/components/blocks/Tabs.vue.d.ts.map +1 -0
  47. package/dist/components/blocks/Team.vue.d.ts +19 -0
  48. package/dist/components/blocks/Team.vue.d.ts.map +1 -0
  49. package/dist/components/blocks/Testimonials.vue.d.ts +18 -0
  50. package/dist/components/blocks/Testimonials.vue.d.ts.map +1 -0
  51. package/dist/components/blocks/Text.vue.d.ts +10 -0
  52. package/dist/components/blocks/Text.vue.d.ts.map +1 -0
  53. package/dist/components/blocks/TextImage.vue.d.ts +20 -0
  54. package/dist/components/blocks/TextImage.vue.d.ts.map +1 -0
  55. package/dist/components/blocks/TextSide.vue.d.ts +19 -0
  56. package/dist/components/blocks/TextSide.vue.d.ts.map +1 -0
  57. package/dist/components/blocks/Title.vue.d.ts +16 -0
  58. package/dist/components/blocks/Title.vue.d.ts.map +1 -0
  59. package/dist/components/blocks/TitleSide.vue.d.ts +21 -0
  60. package/dist/components/blocks/TitleSide.vue.d.ts.map +1 -0
  61. package/dist/components/blocks/VideoBox.vue.d.ts +15 -0
  62. package/dist/components/blocks/VideoBox.vue.d.ts.map +1 -0
  63. package/dist/components/blocks/blocks.d.ts +27 -0
  64. package/dist/components/blocks/blocks.d.ts.map +1 -0
  65. package/dist/components/index.d.ts +4 -3
  66. package/dist/components/index.d.ts.map +1 -1
  67. package/dist/config/baseComponents.d.ts +12 -2
  68. package/dist/config/baseComponents.d.ts.map +1 -1
  69. package/dist/config/blockComponents.d.ts +41 -0
  70. package/dist/config/blockComponents.d.ts.map +1 -0
  71. package/dist/core/communication.d.ts.map +1 -1
  72. package/dist/core/registry.d.ts.map +1 -1
  73. package/dist/core/renderer.d.ts.map +1 -1
  74. package/dist/core/types.d.ts.map +1 -1
  75. package/dist/index.cjs +9420 -480
  76. package/dist/index.d.ts +4 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.mjs +9325 -478
  79. package/dist/setup.d.ts +114 -6
  80. package/dist/setup.d.ts.map +1 -1
  81. package/dist/utils/componentPreviewGenerator.d.ts +113 -0
  82. package/dist/utils/componentPreviewGenerator.d.ts.map +1 -0
  83. package/dist/utils/normalizer.d.ts.map +1 -1
  84. package/dist/utils/styles.d.ts.map +1 -1
  85. package/dist/views/ExternalPreview.vue.d.ts.map +1 -1
  86. package/dist/views/RenderPage.vue.d.ts.map +1 -1
  87. package/package.json +5 -2
  88. package/components/base/Button.vue +0 -140
  89. package/components/base/Container.vue +0 -64
  90. package/components/base/Image.vue +0 -75
  91. package/components/base/Spacer.vue +0 -33
  92. package/components/base/Text.vue +0 -37
  93. package/components/base/Title.vue +0 -55
  94. package/components/index.ts +0 -20
  95. package/config/baseComponents.ts +0 -342
  96. package/core/communication.ts +0 -140
  97. package/core/registry.ts +0 -108
  98. package/core/renderer.ts +0 -217
  99. package/core/types.ts +0 -148
  100. package/dist/vite.config.d.ts +0 -3
  101. package/dist/vite.config.d.ts.map +0 -1
  102. package/index.ts +0 -33
  103. package/setup.ts +0 -56
  104. package/utils/normalizer.ts +0 -74
  105. package/utils/styles.ts +0 -228
  106. package/views/ExternalPreview.vue +0 -420
  107. package/views/RenderPage.vue +0 -127
@@ -1,55 +0,0 @@
1
- <script setup lang="ts">
2
- /**
3
- * Base Title Component
4
- *
5
- * Renders headings with customizable tag and styling
6
- */
7
-
8
- interface Props {
9
- title?: string
10
- subTitle?: string
11
- tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
12
- align?: 'left' | 'center' | 'right'
13
- }
14
-
15
- const { title = '', subTitle = '', tag = 'h2', align = 'left' } = defineProps<Props>()
16
- </script>
17
-
18
- <template>
19
- <div :class="`title-wrapper text-align-${align}`">
20
- <component :is="tag" v-if="title" class="title">
21
- {{ title }}
22
- </component>
23
- <p v-if="subTitle" class="subtitle">
24
- {{ subTitle }}
25
- </p>
26
- </div>
27
- </template>
28
-
29
- <style scoped>
30
- .title-wrapper {
31
- margin-bottom: 1rem;
32
- }
33
-
34
- .title {
35
- margin: 0 0 0.5rem 0;
36
- line-height: 1.2;
37
- }
38
-
39
- .subtitle {
40
- margin: 0;
41
- opacity: 0.8;
42
- }
43
-
44
- .text-align-left {
45
- text-align: left;
46
- }
47
-
48
- .text-align-center {
49
- text-align: center;
50
- }
51
-
52
- .text-align-right {
53
- text-align: right;
54
- }
55
- </style>
@@ -1,20 +0,0 @@
1
- /**
2
- * Component Exports
3
- *
4
- * Export all base components for easy importing
5
- */
6
-
7
- export { default as Button } from './base/Button.vue'
8
- export * from './base/Button.vue'
9
- export { default as Container } from './base/Container.vue'
10
- export * from './base/Container.vue'
11
- export { default as Image } from './base/Image.vue'
12
- export * from './base/Image.vue'
13
-
14
- export { default as Spacer } from './base/Spacer.vue'
15
- export * from './base/Spacer.vue'
16
- export { default as Text } from './base/Text.vue'
17
- // Re-export for convenience
18
- export * from './base/Text.vue'
19
- export { default as Title } from './base/Title.vue'
20
- export * from './base/Title.vue'
@@ -1,342 +0,0 @@
1
- /**
2
- * Base Component Configuration
3
- *
4
- * Defines all built-in components with their Vue components and editor schemas
5
- */
6
-
7
- import type { ComponentConstructor } from '../core/types'
8
-
9
- import Button from '../components/base/Button.vue'
10
- import Container from '../components/base/Container.vue'
11
- import Image from '../components/base/Image.vue'
12
- import Spacer from '../components/base/Spacer.vue'
13
- // Import base components
14
- import Text from '../components/base/Text.vue'
15
- import Title from '../components/base/Title.vue'
16
-
17
- export interface ComponentSchema {
18
- type: 'text' | 'richtext' | 'number' | 'checkbox' | 'select' | 'upload' | 'color' | 'array' | 'row'
19
- key: string
20
- label: string
21
- defaultValue?: any
22
- options?: Array<{ label: string, value: any }>
23
- height?: string | number
24
- fields?: ComponentSchema[] // For array and row types
25
- class?: string
26
- placeholder?: string
27
- [key: string]: any
28
- }
29
-
30
- export interface ComponentConfig {
31
- id: string
32
- label: string
33
- icon: string
34
- img?: string
35
- order?: number
36
- component: ComponentConstructor
37
- content?: ComponentSchema[] // Content editing schema
38
- settings?: ComponentSchema[] // Settings schema
39
- }
40
-
41
- /**
42
- * Base component configurations
43
- */
44
- export const baseComponentConfigs: ComponentConfig[] = [
45
- {
46
- id: 'Text',
47
- label: 'Text',
48
- icon: 'text_fields',
49
- order: 10,
50
- component: Text,
51
- content: [
52
- {
53
- type: 'richtext',
54
- key: 'content',
55
- label: 'Content',
56
- defaultValue: '<p>Enter your text here...</p>',
57
- height: 200,
58
- },
59
- ],
60
- settings: [
61
- {
62
- type: 'select',
63
- key: 'tag',
64
- label: 'HTML Tag',
65
- defaultValue: 'div',
66
- options: [
67
- { label: 'Div', value: 'div' },
68
- { label: 'Paragraph', value: 'p' },
69
- { label: 'Span', value: 'span' },
70
- { label: 'Article', value: 'article' },
71
- { label: 'Section', value: 'section' },
72
- ],
73
- },
74
- {
75
- type: 'select',
76
- key: 'align',
77
- label: 'Text Alignment',
78
- defaultValue: 'left',
79
- options: [
80
- { label: 'Left', value: 'left' },
81
- { label: 'Center', value: 'center' },
82
- { label: 'Right', value: 'right' },
83
- { label: 'Justify', value: 'justify' },
84
- ],
85
- },
86
- ],
87
- },
88
- {
89
- id: 'Title',
90
- label: 'Title',
91
- icon: 'title',
92
- order: 5,
93
- component: Title,
94
- content: [
95
- {
96
- type: 'text',
97
- key: 'title',
98
- label: 'Title',
99
- defaultValue: 'Your Title Here',
100
- },
101
- {
102
- type: 'text',
103
- key: 'subtitle',
104
- label: 'Subtitle',
105
- defaultValue: '',
106
- },
107
- ],
108
- settings: [
109
- {
110
- type: 'select',
111
- key: 'tag',
112
- label: 'Heading Tag',
113
- defaultValue: 'h2',
114
- options: [
115
- { label: 'H1', value: 'h1' },
116
- { label: 'H2', value: 'h2' },
117
- { label: 'H3', value: 'h3' },
118
- { label: 'H4', value: 'h4' },
119
- { label: 'H5', value: 'h5' },
120
- { label: 'H6', value: 'h6' },
121
- ],
122
- },
123
- {
124
- type: 'select',
125
- key: 'align',
126
- label: 'Text Alignment',
127
- defaultValue: 'center',
128
- options: [
129
- { label: 'Left', value: 'left' },
130
- { label: 'Center', value: 'center' },
131
- { label: 'Right', value: 'right' },
132
- ],
133
- },
134
- {
135
- type: 'number',
136
- key: 'size',
137
- label: 'Font Size (px)',
138
- defaultValue: 32,
139
- },
140
- ],
141
- },
142
- {
143
- id: 'Button',
144
- label: 'Button',
145
- icon: 'smart_button',
146
- order: 15,
147
- component: Button,
148
- content: [
149
- {
150
- type: 'text',
151
- key: 'btnTxt',
152
- label: 'Button Text',
153
- defaultValue: 'Click Me',
154
- },
155
- {
156
- type: 'text',
157
- key: 'btnUrl',
158
- label: 'Button URL',
159
- defaultValue: '#',
160
- },
161
- ],
162
- settings: [
163
- {
164
- type: 'select',
165
- key: 'variant',
166
- label: 'Button Style',
167
- defaultValue: 'primary',
168
- options: [
169
- { label: 'Primary', value: 'primary' },
170
- { label: 'Secondary', value: 'secondary' },
171
- { label: 'Outline', value: 'outline' },
172
- { label: 'Ghost', value: 'ghost' },
173
- ],
174
- },
175
- {
176
- type: 'select',
177
- key: 'size',
178
- label: 'Size',
179
- defaultValue: 'md',
180
- options: [
181
- { label: 'Small', value: 'sm' },
182
- { label: 'Medium', value: 'md' },
183
- { label: 'Large', value: 'lg' },
184
- ],
185
- },
186
- {
187
- type: 'select',
188
- key: 'align',
189
- label: 'Alignment',
190
- defaultValue: 'left',
191
- options: [
192
- { label: 'Left', value: 'left' },
193
- { label: 'Center', value: 'center' },
194
- { label: 'Right', value: 'right' },
195
- ],
196
- },
197
- {
198
- type: 'checkbox',
199
- key: 'fullWidth',
200
- label: 'Full Width',
201
- defaultValue: false,
202
- },
203
- {
204
- type: 'select',
205
- key: 'btnTarget',
206
- label: 'Link Target',
207
- defaultValue: '_self',
208
- options: [
209
- { label: 'Same Window', value: '_self' },
210
- { label: 'New Window', value: '_blank' },
211
- ],
212
- },
213
- ],
214
- },
215
- {
216
- id: 'Image',
217
- label: 'Image',
218
- icon: 'image',
219
- order: 20,
220
- component: Image,
221
- content: [
222
- {
223
- type: 'upload',
224
- key: 'src',
225
- label: 'Image',
226
- defaultValue: '',
227
- height: 200,
228
- },
229
- {
230
- type: 'text',
231
- key: 'alt',
232
- label: 'Alt Text',
233
- defaultValue: '',
234
- },
235
- ],
236
- settings: [
237
- {
238
- type: 'select',
239
- key: 'objectFit',
240
- label: 'Object Fit',
241
- defaultValue: 'cover',
242
- options: [
243
- { label: 'Cover', value: 'cover' },
244
- { label: 'Contain', value: 'contain' },
245
- { label: 'Fill', value: 'fill' },
246
- { label: 'None', value: 'none' },
247
- { label: 'Scale Down', value: 'scale-down' },
248
- ],
249
- },
250
- {
251
- type: 'number',
252
- key: 'maxWidth',
253
- label: 'Max Width (px)',
254
- defaultValue: null,
255
- },
256
- {
257
- type: 'number',
258
- key: 'height',
259
- label: 'Height (px)',
260
- defaultValue: null,
261
- },
262
- {
263
- type: 'select',
264
- key: 'align',
265
- label: 'Alignment',
266
- defaultValue: 'center',
267
- options: [
268
- { label: 'Left', value: 'left' },
269
- { label: 'Center', value: 'center' },
270
- { label: 'Right', value: 'right' },
271
- ],
272
- },
273
- ],
274
- },
275
- {
276
- id: 'Spacer',
277
- label: 'Spacer',
278
- icon: 'height',
279
- order: 25,
280
- component: Spacer,
281
- content: [],
282
- settings: [
283
- {
284
- type: 'number',
285
- key: 'height',
286
- label: 'Height (px)',
287
- defaultValue: 40,
288
- },
289
- ],
290
- },
291
- {
292
- id: 'Container',
293
- label: 'Container',
294
- icon: 'view_module',
295
- order: 30,
296
- component: Container,
297
- content: [
298
- {
299
- type: 'richtext',
300
- key: 'content',
301
- label: 'Content',
302
- defaultValue: '<p>Container content...</p>',
303
- height: 200,
304
- },
305
- ],
306
- settings: [
307
- {
308
- type: 'select',
309
- key: 'maxWidth',
310
- label: 'Max Width',
311
- defaultValue: 'lg',
312
- options: [
313
- { label: 'Small (640px)', value: 'sm' },
314
- { label: 'Medium (768px)', value: 'md' },
315
- { label: 'Large (1024px)', value: 'lg' },
316
- { label: 'Extra Large (1280px)', value: 'xl' },
317
- { label: 'Full Width', value: 'full' },
318
- ],
319
- },
320
- {
321
- type: 'checkbox',
322
- key: 'centered',
323
- label: 'Center Content',
324
- defaultValue: true,
325
- },
326
- ],
327
- },
328
- ]
329
-
330
- /**
331
- * Get all base component configurations
332
- */
333
- export function getBaseComponentConfigs(): ComponentConfig[] {
334
- return baseComponentConfigs
335
- }
336
-
337
- /**
338
- * Get a base component configuration by ID
339
- */
340
- export function getBaseComponentConfig(id: string): ComponentConfig | undefined {
341
- return baseComponentConfigs.find(config => config.id === id)
342
- }
@@ -1,140 +0,0 @@
1
- /**
2
- * PostMessage Communication Protocol
3
- *
4
- * Handles secure communication between editor and external preview
5
- */
6
-
7
- import type { EditorMessage, MessageType } from './types'
8
-
9
- export type MessageHandler = (message: EditorMessage) => void
10
-
11
- interface CommunicationConfig {
12
- origin: string // Allowed origin for security
13
- targetWindow?: Window // Target window for sending messages
14
- onMessage?: MessageHandler
15
- }
16
-
17
- export class CommunicationBridge {
18
- private origin: string
19
- private targetWindow: Window
20
- private handlers: Map<MessageType, Set<MessageHandler>>
21
- private boundMessageHandler: (event: MessageEvent) => void
22
-
23
- constructor(config: CommunicationConfig) {
24
- this.origin = config.origin
25
- this.targetWindow = config.targetWindow || window.parent
26
- this.handlers = new Map()
27
- this.boundMessageHandler = this.handleMessage.bind(this)
28
-
29
- // Setup listener
30
- window.addEventListener('message', this.boundMessageHandler)
31
-
32
- console.log(`๐ŸŒ‰ Communication bridge initialized for origin: ${this.origin}`)
33
- }
34
-
35
- /**
36
- * Handle incoming messages
37
- */
38
- private handleMessage(event: MessageEvent): void {
39
- // Security: verify origin
40
- if (this.origin !== '*' && event.origin !== this.origin) {
41
- console.warn(`โš ๏ธ Rejected message from unauthorized origin: ${event.origin}`)
42
- return
43
- }
44
-
45
- const { type, message, data, isMobile } = event.data as EditorMessage
46
-
47
- if (!type) {
48
- // Not a valid editor message
49
- return
50
- }
51
-
52
- console.log(`๐Ÿ“จ Received message: ${type}`, { message, data, isMobile })
53
-
54
- // Call registered handlers for this message type
55
- const typeHandlers = this.handlers.get(type as MessageType)
56
- if (typeHandlers) {
57
- typeHandlers.forEach((handler) => {
58
- try {
59
- handler({ type: type as MessageType, message, data, isMobile })
60
- } catch (error) {
61
- console.error(`Error in handler for ${type}:`, error)
62
- }
63
- })
64
- }
65
-
66
- // Call global handlers
67
- const globalHandlers = this.handlers.get('*' as MessageType)
68
- if (globalHandlers) {
69
- globalHandlers.forEach((handler) => {
70
- try {
71
- handler({ type: type as MessageType, message, data, isMobile })
72
- } catch (error) {
73
- console.error('Error in global handler:', error)
74
- }
75
- })
76
- }
77
- }
78
-
79
- /**
80
- * Register a handler for a specific message type
81
- */
82
- on(type: MessageType | '*', handler: MessageHandler): () => void {
83
- if (!this.handlers.has(type as MessageType)) {
84
- this.handlers.set(type as MessageType, new Set())
85
- }
86
-
87
- this.handlers.get(type as MessageType)!.add(handler)
88
-
89
- // Return unsubscribe function
90
- return () => { this.off(type, handler) }
91
- }
92
-
93
- /**
94
- * Unregister a handler
95
- */
96
- off(type: MessageType | '*', handler: MessageHandler): void {
97
- const typeHandlers = this.handlers.get(type as MessageType)
98
- if (typeHandlers) {
99
- typeHandlers.delete(handler)
100
- }
101
- }
102
-
103
- /**
104
- * Send a message to the target window (editor)
105
- */
106
- send(type: MessageType, message?: any, data?: any): void {
107
- const payload: EditorMessage = { type, message, data }
108
- this.targetWindow.postMessage(payload, this.origin === '*' ? '*' : this.origin)
109
- console.log(`๐Ÿ“ค Sent message: ${type}`, payload)
110
- }
111
-
112
- /**
113
- * Cleanup
114
- */
115
- destroy(): void {
116
- window.removeEventListener('message', this.boundMessageHandler)
117
- this.handlers.clear()
118
- console.log('๐Ÿงน Communication bridge destroyed')
119
- }
120
- }
121
-
122
- /**
123
- * Create a communication bridge instance
124
- */
125
- export function createCommunicationBridge(config: CommunicationConfig): CommunicationBridge {
126
- return new CommunicationBridge(config)
127
- }
128
-
129
- /**
130
- * Simple send helper for one-off messages
131
- */
132
- export function sendMessage(
133
- type: MessageType,
134
- message?: any,
135
- targetWindow: Window = window.parent,
136
- origin: string = '*'
137
- ): void {
138
- const payload: EditorMessage = { type, message }
139
- targetWindow.postMessage(payload, origin)
140
- }
package/core/registry.ts DELETED
@@ -1,108 +0,0 @@
1
- /**
2
- * Component Registry System
3
- *
4
- * Allows external sites to register their own component implementations
5
- * that map to the block types from the editor.
6
- */
7
-
8
- import type { ComponentRegistry, ComponentConstructor } from './types'
9
-
10
- // Global registry
11
- const registry: ComponentRegistry = {}
12
-
13
- /**
14
- * Register a component for a specific block type
15
- * @param type - The block type (e.g., 'Text', 'Button', 'Hero')
16
- * @param component - The Vue component to render
17
- */
18
- export function registerComponent(type: string, component: ComponentConstructor): void {
19
- if (registry[type]) {
20
- console.warn(`Component "${type}" is already registered. Overwriting...`)
21
- }
22
- registry[type] = component
23
- console.log(`โœ… Registered component: ${type}`)
24
- }
25
-
26
- /**
27
- * Register multiple components at once
28
- * @param components - Object mapping block types to components
29
- */
30
- export function registerComponents(components: ComponentRegistry): void {
31
- Object.entries(components).forEach(([type, component]) => {
32
- registerComponent(type, component)
33
- })
34
- }
35
-
36
- /**
37
- * Get a registered component by type
38
- * @param type - The block type
39
- * @returns The component or undefined if not found
40
- */
41
- export function getComponent(type: string): ComponentConstructor | undefined {
42
- return registry[type]
43
- }
44
-
45
- /**
46
- * Check if a component type is registered
47
- * @param type - The block type
48
- * @returns True if registered
49
- */
50
- export function hasComponent(type: string): boolean {
51
- return type in registry
52
- }
53
-
54
- /**
55
- * Get all registered components
56
- * @returns The full registry
57
- */
58
- export function getAllComponents(): ComponentRegistry {
59
- return { ...registry }
60
- }
61
-
62
- /**
63
- * Unregister a component
64
- * @param type - The block type to remove
65
- */
66
- export function unregisterComponent(type: string): void {
67
- delete registry[type]
68
- console.log(`โŒ Unregistered component: ${type}`)
69
- }
70
-
71
- /**
72
- * Clear all registered components
73
- */
74
- export function clearRegistry(): void {
75
- Object.keys(registry).forEach(key => delete registry[key])
76
- console.log('๐Ÿ—‘๏ธ Registry cleared')
77
- }
78
-
79
- /**
80
- * Get a list of all registered component types
81
- * @returns Array of registered type names
82
- */
83
- export function getRegisteredTypes(): string[] {
84
- return Object.keys(registry)
85
- }
86
-
87
- /**
88
- * Create a namespaced registry for multi-tenant scenarios
89
- */
90
- export function createNamespacedRegistry(namespace: string) {
91
- const namespacedRegistry: ComponentRegistry = {}
92
-
93
- return {
94
- register: (type: string, component: ComponentConstructor) => {
95
- const key = `${namespace}:${type}`
96
- namespacedRegistry[key] = component
97
- registry[key] = component
98
- },
99
- get: (type: string) => {
100
- const key = `${namespace}:${type}`
101
- return namespacedRegistry[key]
102
- },
103
- getAll: () => ({ ...namespacedRegistry }),
104
- }
105
- }
106
-
107
- // Export the registry for debugging purposes
108
- export { registry }