artifactuse 0.1.0
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/LICENSE +21 -0
- package/README.md +771 -0
- package/dist/core/bridge.d.ts +37 -0
- package/dist/core/detector.d.ts +134 -0
- package/dist/core/highlight.d.ts +53 -0
- package/dist/core/index.d.ts +124 -0
- package/dist/core/processors/audio.d.ts +36 -0
- package/dist/core/processors/audioPlayer.d.ts +39 -0
- package/dist/core/processors/codeEmbed.d.ts +58 -0
- package/dist/core/processors/dataViz.d.ts +28 -0
- package/dist/core/processors/design.d.ts +50 -0
- package/dist/core/processors/document.d.ts +38 -0
- package/dist/core/processors/image.d.ts +23 -0
- package/dist/core/processors/index.d.ts +62 -0
- package/dist/core/processors/interactive.d.ts +57 -0
- package/dist/core/processors/map.d.ts +29 -0
- package/dist/core/processors/math.d.ts +75 -0
- package/dist/core/processors/mermaid.d.ts +72 -0
- package/dist/core/processors/social.d.ts +63 -0
- package/dist/core/processors/table.d.ts +43 -0
- package/dist/core/processors/video.d.ts +69 -0
- package/dist/core/state.d.ts +37 -0
- package/dist/core/theme.d.ts +109 -0
- package/dist/index-_nD5FZzs.js +4300 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +115 -0
- package/dist/jszip.min-CdmYyw5L.js +2324 -0
- package/dist/react/ArtifactuseAgentMessage.d.ts +31 -0
- package/dist/react/ArtifactuseCard.d.ts +13 -0
- package/dist/react/ArtifactuseInlineForm.d.ts +16 -0
- package/dist/react/ArtifactusePanel.d.ts +12 -0
- package/dist/react/ArtifactusePanelToggle.d.ts +8 -0
- package/dist/react/ArtifactuseSocialPreview.d.ts +6 -0
- package/dist/react/ArtifactuseViewer.d.ts +14 -0
- package/dist/react/index.d.ts +108 -0
- package/dist/react/index.js +1387 -0
- package/dist/svelte/index.d.ts +439 -0
- package/dist/svelte/index.js +2556 -0
- package/dist/vue/index.d.ts +296 -0
- package/dist/vue/index.js +2745 -0
- package/dist/vue2/composables.d.ts +291 -0
- package/dist/vue2/index.d.ts +10 -0
- package/dist/vue2/index.js +27979 -0
- package/package.json +127 -0
package/README.md
ADDED
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
# Artifactuse
|
|
2
|
+
|
|
3
|
+
**The Artifact SDK for AI Agents** - Turn AI outputs into interactive experiences.
|
|
4
|
+
|
|
5
|
+
Artifactuse is a lightweight SDK that transforms AI-generated content into rich, interactive artifacts. Support for code previews, video editors, canvas/whiteboards, forms, social media previews, and more.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- ๐จ **Rich Content Detection** - Automatically detect and render code blocks, images, videos, maps, embeds, and more
|
|
10
|
+
- ๐ฆ **Artifact Cards** - Beautiful inline cards for code artifacts
|
|
11
|
+
- ๐ผ๏ธ **Media Lightbox** - Click images and PDFs to view fullscreen with zoom and download
|
|
12
|
+
- ๐ฅ๏ธ **Panel Viewer** - Side panel with preview, code view, and split mode
|
|
13
|
+
- ๐ **Interactive Forms** - Inline and panel forms with 17+ field types, auto-collapse after submission
|
|
14
|
+
- ๐ฑ **Social Previews** - Platform-accurate previews for Twitter, LinkedIn, Instagram, and more
|
|
15
|
+
- ๐ **Theme Support** - Dark/light mode with customizable colors
|
|
16
|
+
- ๐ **Framework Agnostic** - Works with Vue 3, Vue 2, React, Svelte, or vanilla JS
|
|
17
|
+
- ๐ก **Event System** - Hook into AI requests, form submissions, exports
|
|
18
|
+
- โ๏ธ **Cloud Ready** - Built for SaaS integration
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install artifactuse
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Syntax Highlighting (Optional)
|
|
27
|
+
|
|
28
|
+
For code syntax highlighting in the panel, include Prism.js:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install prismjs
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import Prism from 'prismjs'
|
|
36
|
+
// Import languages you need
|
|
37
|
+
import 'prismjs/components/prism-javascript'
|
|
38
|
+
import 'prismjs/components/prism-typescript'
|
|
39
|
+
import 'prismjs/components/prism-python'
|
|
40
|
+
import 'prismjs/components/prism-jsx'
|
|
41
|
+
|
|
42
|
+
// Import a Prism theme of your choice
|
|
43
|
+
import 'prismjs/themes/prism-tomorrow.css' // dark theme
|
|
44
|
+
// or 'prismjs/themes/prism.css' // light theme
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or use CDN:
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<script src="https://cdn.jsdelivr.net/npm/prismjs@1/prism.min.js"></script>
|
|
51
|
+
<script src="https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-javascript.min.js"></script>
|
|
52
|
+
<link href="https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism-tomorrow.css" rel="stylesheet" />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quick Start (Vue 3 / Nuxt 3)
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<template>
|
|
59
|
+
<div class="app-container">
|
|
60
|
+
<div class="chat">
|
|
61
|
+
<!-- Render AI messages with artifact detection -->
|
|
62
|
+
<ArtifactuseAgentMessage
|
|
63
|
+
v-for="(msg, index) in messages"
|
|
64
|
+
:key="msg.id"
|
|
65
|
+
:content="msg.content"
|
|
66
|
+
:message-id="msg.id"
|
|
67
|
+
:is-last-message="index === messages.length - 1"
|
|
68
|
+
@form-submit="handleFormSubmit"
|
|
69
|
+
@social-copy="handleSocialCopy"
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<!-- Toggle button with badge -->
|
|
73
|
+
<ArtifactusePanelToggle />
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<!-- Artifact panel (side panel for previews) -->
|
|
77
|
+
<ArtifactusePanel @ai-request="handleAIRequest" />
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
81
|
+
<script setup>
|
|
82
|
+
import { ref } from 'vue';
|
|
83
|
+
import {
|
|
84
|
+
ArtifactuseAgentMessage,
|
|
85
|
+
ArtifactusePanel,
|
|
86
|
+
ArtifactusePanelToggle,
|
|
87
|
+
provideArtifactuse
|
|
88
|
+
} from 'artifactuse/vue';
|
|
89
|
+
import 'artifactuse/styles';
|
|
90
|
+
|
|
91
|
+
// Initialize Artifactuse
|
|
92
|
+
provideArtifactuse({
|
|
93
|
+
theme: 'dark',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const messages = ref([]);
|
|
97
|
+
|
|
98
|
+
// Handle form submissions from inline forms
|
|
99
|
+
function handleFormSubmit({ formId, values }) {
|
|
100
|
+
console.log('Form submitted:', formId, values);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Handle social preview copy
|
|
104
|
+
function handleSocialCopy({ platform, text }) {
|
|
105
|
+
console.log('Copied:', platform, text);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Handle AI requests from panel artifacts
|
|
109
|
+
async function handleAIRequest({ prompt, context }) {
|
|
110
|
+
const response = await yourAI.chat(prompt);
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style>
|
|
115
|
+
html, body {
|
|
116
|
+
margin: 0;
|
|
117
|
+
padding: 0;
|
|
118
|
+
height: 100%;
|
|
119
|
+
overflow: hidden;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#app {
|
|
123
|
+
height: 100%;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.app-container {
|
|
127
|
+
display: flex;
|
|
128
|
+
height: 100%;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.chat {
|
|
133
|
+
flex: 1;
|
|
134
|
+
padding: 20px;
|
|
135
|
+
min-width: 0;
|
|
136
|
+
overflow-y: auto;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Quick Start (Vue 2.7 / Nuxt 2)
|
|
142
|
+
|
|
143
|
+
```vue
|
|
144
|
+
<template>
|
|
145
|
+
<div class="app-container">
|
|
146
|
+
<div class="chat">
|
|
147
|
+
<ArtifactuseAgentMessage
|
|
148
|
+
v-for="(msg, index) in messages"
|
|
149
|
+
:key="msg.id"
|
|
150
|
+
:content="msg.content"
|
|
151
|
+
:message-id="msg.id"
|
|
152
|
+
:is-last-message="index === messages.length - 1"
|
|
153
|
+
@form-submit="handleFormSubmit"
|
|
154
|
+
@social-copy="handleSocialCopy"
|
|
155
|
+
/>
|
|
156
|
+
|
|
157
|
+
<ArtifactusePanelToggle />
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<ArtifactusePanel @ai-request="handleAIRequest" />
|
|
161
|
+
|
|
162
|
+
<!-- Required: Portal target for fullscreen/mobile -->
|
|
163
|
+
<portal-target name="artifactuse" />
|
|
164
|
+
</div>
|
|
165
|
+
</template>
|
|
166
|
+
|
|
167
|
+
<script>
|
|
168
|
+
import {
|
|
169
|
+
ArtifactuseAgentMessage,
|
|
170
|
+
ArtifactusePanel,
|
|
171
|
+
ArtifactusePanelToggle,
|
|
172
|
+
provideArtifactuse
|
|
173
|
+
} from 'artifactuse/vue2';
|
|
174
|
+
import 'artifactuse/styles';
|
|
175
|
+
|
|
176
|
+
export default {
|
|
177
|
+
components: {
|
|
178
|
+
ArtifactuseAgentMessage,
|
|
179
|
+
ArtifactusePanel,
|
|
180
|
+
ArtifactusePanelToggle,
|
|
181
|
+
},
|
|
182
|
+
setup() {
|
|
183
|
+
provideArtifactuse({
|
|
184
|
+
theme: 'dark',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// ... your setup code
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
</script>
|
|
191
|
+
|
|
192
|
+
<style>
|
|
193
|
+
html, body {
|
|
194
|
+
margin: 0;
|
|
195
|
+
padding: 0;
|
|
196
|
+
height: 100%;
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#app {
|
|
201
|
+
height: 100%;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.app-container {
|
|
205
|
+
display: flex;
|
|
206
|
+
height: 100%;
|
|
207
|
+
overflow: hidden;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.chat {
|
|
211
|
+
flex: 1;
|
|
212
|
+
padding: 20px;
|
|
213
|
+
min-width: 0;
|
|
214
|
+
overflow-y: auto;
|
|
215
|
+
}
|
|
216
|
+
</style>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Vue 2.6 + @vue/composition-api
|
|
220
|
+
|
|
221
|
+
If you're using Vue 2.6 with `@vue/composition-api` or `@nuxtjs/composition-api`, add this alias to your build config:
|
|
222
|
+
|
|
223
|
+
**Nuxt 2:**
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
// nuxt.config.js
|
|
227
|
+
export default {
|
|
228
|
+
build: {
|
|
229
|
+
extend(config) {
|
|
230
|
+
config.resolve.alias['vue'] = '@vue/composition-api';
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Webpack:**
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
// webpack.config.js
|
|
240
|
+
module.exports = {
|
|
241
|
+
resolve: {
|
|
242
|
+
alias: {
|
|
243
|
+
'vue': '@vue/composition-api'
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Vue CLI:**
|
|
250
|
+
|
|
251
|
+
```js
|
|
252
|
+
// vue.config.js
|
|
253
|
+
module.exports = {
|
|
254
|
+
configureWebpack: {
|
|
255
|
+
resolve: {
|
|
256
|
+
alias: {
|
|
257
|
+
'vue': '@vue/composition-api'
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
> **Note:** Vue 2.7+ has the Composition API built-in and works without any alias configuration.
|
|
265
|
+
|
|
266
|
+
## Quick Start (React / Next.js)
|
|
267
|
+
|
|
268
|
+
```jsx
|
|
269
|
+
import { useState } from 'react';
|
|
270
|
+
import {
|
|
271
|
+
ArtifactuseProvider,
|
|
272
|
+
ArtifactuseAgentMessage,
|
|
273
|
+
ArtifactusePanel,
|
|
274
|
+
ArtifactusePanelToggle
|
|
275
|
+
} from 'artifactuse/react';
|
|
276
|
+
import 'artifactuse/styles';
|
|
277
|
+
import './styles.css';
|
|
278
|
+
|
|
279
|
+
function App() {
|
|
280
|
+
return (
|
|
281
|
+
<ArtifactuseProvider config={{ theme: 'dark' }}>
|
|
282
|
+
<Chat />
|
|
283
|
+
</ArtifactuseProvider>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function Chat() {
|
|
288
|
+
const [messages, setMessages] = useState([]);
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<div className="app-container">
|
|
292
|
+
<div className="chat">
|
|
293
|
+
{messages.map((msg, index) => (
|
|
294
|
+
<ArtifactuseAgentMessage
|
|
295
|
+
key={msg.id}
|
|
296
|
+
content={msg.content}
|
|
297
|
+
messageId={msg.id}
|
|
298
|
+
isLastMessage={index === messages.length - 1}
|
|
299
|
+
onFormSubmit={handleFormSubmit}
|
|
300
|
+
onSocialCopy={handleSocialCopy}
|
|
301
|
+
/>
|
|
302
|
+
))}
|
|
303
|
+
|
|
304
|
+
<ArtifactusePanelToggle />
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<ArtifactusePanel onAIRequest={handleAIRequest} />
|
|
308
|
+
</div>
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```css
|
|
314
|
+
/* styles.css */
|
|
315
|
+
html, body, #root {
|
|
316
|
+
margin: 0;
|
|
317
|
+
padding: 0;
|
|
318
|
+
height: 100%;
|
|
319
|
+
overflow: hidden;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.app-container {
|
|
323
|
+
display: flex;
|
|
324
|
+
height: 100%;
|
|
325
|
+
overflow: hidden;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.chat {
|
|
329
|
+
flex: 1;
|
|
330
|
+
padding: 20px;
|
|
331
|
+
min-width: 0;
|
|
332
|
+
overflow-y: auto;
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Quick Start (Svelte / SvelteKit)
|
|
337
|
+
|
|
338
|
+
```svelte
|
|
339
|
+
<!-- +layout.svelte -->
|
|
340
|
+
<script>
|
|
341
|
+
import { setArtifactuseContext } from 'artifactuse/svelte';
|
|
342
|
+
import 'artifactuse/styles';
|
|
343
|
+
|
|
344
|
+
setArtifactuseContext({ theme: 'dark' });
|
|
345
|
+
</script>
|
|
346
|
+
|
|
347
|
+
<slot />
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
```svelte
|
|
351
|
+
<!-- +page.svelte -->
|
|
352
|
+
<script>
|
|
353
|
+
import {
|
|
354
|
+
ArtifactuseAgentMessage,
|
|
355
|
+
ArtifactusePanel,
|
|
356
|
+
ArtifactusePanelToggle
|
|
357
|
+
} from 'artifactuse/svelte';
|
|
358
|
+
|
|
359
|
+
let messages = [];
|
|
360
|
+
|
|
361
|
+
function handleFormSubmit(event) {
|
|
362
|
+
const { formId, values } = event.detail;
|
|
363
|
+
console.log('Form submitted:', formId, values);
|
|
364
|
+
}
|
|
365
|
+
</script>
|
|
366
|
+
|
|
367
|
+
<div class="app-container">
|
|
368
|
+
<div class="chat">
|
|
369
|
+
{#each messages as msg, index (msg.id)}
|
|
370
|
+
<ArtifactuseAgentMessage
|
|
371
|
+
content={msg.content}
|
|
372
|
+
messageId={msg.id}
|
|
373
|
+
isLastMessage={index === messages.length - 1}
|
|
374
|
+
on:form-submit={handleFormSubmit}
|
|
375
|
+
/>
|
|
376
|
+
{/each}
|
|
377
|
+
|
|
378
|
+
<ArtifactusePanelToggle />
|
|
379
|
+
</div>
|
|
380
|
+
|
|
381
|
+
<ArtifactusePanel on:ai-request={handleAIRequest} />
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
<style>
|
|
385
|
+
:global(html), :global(body) {
|
|
386
|
+
margin: 0;
|
|
387
|
+
padding: 0;
|
|
388
|
+
height: 100%;
|
|
389
|
+
overflow: hidden;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.app-container {
|
|
393
|
+
display: flex;
|
|
394
|
+
height: 100%;
|
|
395
|
+
overflow: hidden;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.chat {
|
|
399
|
+
flex: 1;
|
|
400
|
+
padding: 20px;
|
|
401
|
+
min-width: 0;
|
|
402
|
+
overflow-y: auto;
|
|
403
|
+
}
|
|
404
|
+
</style>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Artifacts
|
|
408
|
+
|
|
409
|
+
### What are Artifacts?
|
|
410
|
+
|
|
411
|
+
Artifacts are structured content blocks detected in AI responses. They can be:
|
|
412
|
+
|
|
413
|
+
- **Explicit** - JSON blocks with `type` field (forms, social previews)
|
|
414
|
+
- **Implicit** - Auto-detected from content (code blocks, images, videos)
|
|
415
|
+
|
|
416
|
+
### Panel Artifacts
|
|
417
|
+
|
|
418
|
+
Panel artifacts open in a side panel with preview, code view, and editing capabilities.
|
|
419
|
+
|
|
420
|
+
- **Code** - JavaScript, TypeScript, Python, HTML, CSS, React, Vue, Svelte
|
|
421
|
+
- **HTML/React/Vue** - Live preview with code editing
|
|
422
|
+
- **Mermaid** - Diagrams with live preview
|
|
423
|
+
- **SVG** - SVG graphics with live preview and editing
|
|
424
|
+
- **Diff / Patch** - Code diffs with side-by-side or unified view
|
|
425
|
+
- **Canvas / Whiteboard** - Interactive drawing canvas and whiteboard
|
|
426
|
+
- **Video Editor** - Timeline-based video editing interface
|
|
427
|
+
- **Forms (Panel)** - Complex forms with wizard variant, file uploads, or 4+ fields
|
|
428
|
+
|
|
429
|
+
### Inline Artifacts
|
|
430
|
+
|
|
431
|
+
Inline artifacts render directly within the message.
|
|
432
|
+
|
|
433
|
+
#### Forms (Inline)
|
|
434
|
+
|
|
435
|
+
Simple forms render inline. Set `display: "inline"` or use buttons variant with few simple fields.
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"type": "form",
|
|
440
|
+
"variant": "fields",
|
|
441
|
+
"display": "inline",
|
|
442
|
+
"title": "Contact Us",
|
|
443
|
+
"data": {
|
|
444
|
+
"fields": [
|
|
445
|
+
{ "name": "name", "type": "text", "label": "Name", "required": true },
|
|
446
|
+
{ "name": "email", "type": "email", "label": "Email" }
|
|
447
|
+
]
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**Variants:** `fields`, `wizard`, `buttons`
|
|
453
|
+
|
|
454
|
+
**Form Collapse Behavior:** Inline forms automatically collapse after user interaction (submit, cancel, or custom button click) to keep the chat clean. After page refresh, only the last message's forms remain active.
|
|
455
|
+
|
|
456
|
+
#### Social Previews
|
|
457
|
+
|
|
458
|
+
Platform-accurate social media post previews:
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"type": "social",
|
|
463
|
+
"platform": "twitter",
|
|
464
|
+
"data": {
|
|
465
|
+
"author": {
|
|
466
|
+
"name": "Acme Corp",
|
|
467
|
+
"handle": "@acmecorp",
|
|
468
|
+
"verified": true
|
|
469
|
+
},
|
|
470
|
+
"content": {
|
|
471
|
+
"text": "Excited to announce our new product! ๐",
|
|
472
|
+
"media": [{ "type": "image", "url": "https://..." }]
|
|
473
|
+
},
|
|
474
|
+
"engagement": {
|
|
475
|
+
"likes": 1200,
|
|
476
|
+
"retweets": 340
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Platforms:** Twitter/X, LinkedIn, Instagram, Facebook, Threads, TikTok, YouTube
|
|
483
|
+
|
|
484
|
+
#### Media & Embeds
|
|
485
|
+
|
|
486
|
+
| Type | Supported |
|
|
487
|
+
|------|-----------|
|
|
488
|
+
| **Images** | jpg, jpeg, png, gif, webp, svg, bmp, ico, avif |
|
|
489
|
+
| **Videos** | YouTube, Vimeo, Loom, Wistia, Dailymotion, MP4, WebM, MOV |
|
|
490
|
+
| **Audio** | Spotify, SoundCloud, Apple Music, MP3, WAV, OGG |
|
|
491
|
+
| **Maps** | Google Maps, OpenStreetMap |
|
|
492
|
+
| **Documents** | PDF, Google Docs/Sheets/Slides, Microsoft Office |
|
|
493
|
+
| **Code Platforms** | CodePen, CodeSandbox, JSFiddle, Replit, StackBlitz |
|
|
494
|
+
| **Design & 3D** | Figma, Sketchfab |
|
|
495
|
+
| **Interactive** | Typeform, Calendly, Airtable, Miro, Notion |
|
|
496
|
+
| **Data Viz** | Flourish, Datawrapper, Tableau Public |
|
|
497
|
+
|
|
498
|
+
## Composable / Hooks
|
|
499
|
+
|
|
500
|
+
```js
|
|
501
|
+
// Vue 3
|
|
502
|
+
import { useArtifactuse } from 'artifactuse/vue';
|
|
503
|
+
|
|
504
|
+
// Vue 2
|
|
505
|
+
import { useArtifactuse } from 'artifactuse/vue2';
|
|
506
|
+
|
|
507
|
+
// React
|
|
508
|
+
import { useArtifactuse } from 'artifactuse/react';
|
|
509
|
+
|
|
510
|
+
// Svelte
|
|
511
|
+
import { getArtifactuseContext } from 'artifactuse/svelte';
|
|
512
|
+
|
|
513
|
+
const {
|
|
514
|
+
state, // Reactive state
|
|
515
|
+
activeArtifact, // Currently open artifact
|
|
516
|
+
artifactCount, // Number of artifacts
|
|
517
|
+
hasArtifacts, // Boolean
|
|
518
|
+
|
|
519
|
+
// Panel state
|
|
520
|
+
panelTypes, // List of registered panel types
|
|
521
|
+
activePanelUrl, // URL for active artifact's panel
|
|
522
|
+
|
|
523
|
+
processMessage, // Process AI content
|
|
524
|
+
openArtifact, // Open artifact in panel
|
|
525
|
+
closePanel, // Close panel
|
|
526
|
+
togglePanel, // Toggle panel visibility
|
|
527
|
+
toggleFullscreen, // Toggle fullscreen mode
|
|
528
|
+
setViewMode, // Set 'preview' | 'code' | 'split'
|
|
529
|
+
getPanelUrl, // Get panel URL for artifact
|
|
530
|
+
|
|
531
|
+
// Panel management
|
|
532
|
+
hasPanel, // Check if panel exists for artifact
|
|
533
|
+
registerPanel, // Register panel (string or string[])
|
|
534
|
+
unregisterPanel, // Disable panel (string or string[])
|
|
535
|
+
getPanelTypes, // Get all panel types
|
|
536
|
+
|
|
537
|
+
// Theme
|
|
538
|
+
getTheme, // Get current theme
|
|
539
|
+
setTheme, // Set theme
|
|
540
|
+
|
|
541
|
+
on, // Subscribe to events
|
|
542
|
+
off, // Unsubscribe
|
|
543
|
+
} = useArtifactuse();
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
## Configuration
|
|
547
|
+
|
|
548
|
+
```js
|
|
549
|
+
provideArtifactuse({
|
|
550
|
+
// CDN URL for panel artifacts
|
|
551
|
+
// Defaults to https://cdn.artifactuse.com
|
|
552
|
+
// Set this only if self-hosting panels
|
|
553
|
+
cdnUrl: 'https://cdn.artifactuse.com',
|
|
554
|
+
|
|
555
|
+
// Theme: 'dark' | 'light' | 'auto'
|
|
556
|
+
theme: 'auto',
|
|
557
|
+
|
|
558
|
+
// Custom colors - hex or RGB format both work
|
|
559
|
+
colors: {
|
|
560
|
+
primary: '#6366f1', // hex format
|
|
561
|
+
background: '#111827',
|
|
562
|
+
surface: '31, 41, 55', // RGB format also works
|
|
563
|
+
text: '#f3f4f6',
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
// Show "Powered by Artifactuse" branding in panel footer
|
|
567
|
+
// Set to false to hide (requires paid license)
|
|
568
|
+
branding: true,
|
|
569
|
+
|
|
570
|
+
// Enable/disable processors
|
|
571
|
+
processors: {
|
|
572
|
+
codeBlocks: true,
|
|
573
|
+
images: true,
|
|
574
|
+
videos: true,
|
|
575
|
+
audio: true,
|
|
576
|
+
maps: true,
|
|
577
|
+
social: true,
|
|
578
|
+
documents: true,
|
|
579
|
+
tables: true,
|
|
580
|
+
math: true,
|
|
581
|
+
},
|
|
582
|
+
|
|
583
|
+
// Code extraction settings
|
|
584
|
+
codeExtraction: {
|
|
585
|
+
minLines: 3,
|
|
586
|
+
minLength: 50,
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
## Panels
|
|
592
|
+
|
|
593
|
+
The SDK supports configurable panels that can be added, overridden, or disabled without updating the SDK.
|
|
594
|
+
|
|
595
|
+
```js
|
|
596
|
+
provideArtifactuse({
|
|
597
|
+
panels: {
|
|
598
|
+
// Add new panel type
|
|
599
|
+
'chart': 'chart-panel',
|
|
600
|
+
|
|
601
|
+
// Use a different CDN for specific panel
|
|
602
|
+
'video': 'https://my-video-cdn.com/editor-panel',
|
|
603
|
+
|
|
604
|
+
// Disable a built-in panel
|
|
605
|
+
'canvas': null,
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// Runtime registration with aliases
|
|
610
|
+
const { registerPanel, unregisterPanel } = useArtifactuse();
|
|
611
|
+
|
|
612
|
+
registerPanel(['python', 'py'], 'code-panel');
|
|
613
|
+
registerPanel(['typescript', 'ts', 'tsx'], 'code-panel');
|
|
614
|
+
unregisterPanel(['canvas', 'whiteboard', 'drawing']);
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
For full documentation on panel configuration, runtime management, and examples, see **[PANELS.md](./PANELS.md)**.
|
|
618
|
+
|
|
619
|
+
## Events
|
|
620
|
+
|
|
621
|
+
```js
|
|
622
|
+
const { on } = useArtifactuse();
|
|
623
|
+
|
|
624
|
+
// AI assistance requested from panel
|
|
625
|
+
on('ai:request', async ({ prompt, context, requestId }) => {
|
|
626
|
+
const response = await yourAI.chat(prompt);
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// Save requested
|
|
630
|
+
on('save:request', async ({ artifactId, data }) => {
|
|
631
|
+
await saveToCloud(artifactId, data);
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
// Export completed
|
|
635
|
+
on('export:complete', ({ artifactId, blob, filename }) => {
|
|
636
|
+
// Download or upload the exported file
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// Form events
|
|
640
|
+
on('form:submit', ({ formId, action, values }) => {
|
|
641
|
+
console.log('Form submitted:', values);
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
on('form:cancel', ({ formId }) => {
|
|
645
|
+
console.log('Form cancelled');
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
on('form:button-click', ({ formId, action, buttonName, values }) => {
|
|
649
|
+
console.log('Custom button clicked:', action, buttonName);
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
// Social events
|
|
653
|
+
on('social:copy', ({ platform, text }) => {
|
|
654
|
+
console.log('Copied from:', platform);
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
// Media events
|
|
658
|
+
on('media:open', ({ type, src, alt, caption }) => {
|
|
659
|
+
console.log('Media opened:', type, src);
|
|
660
|
+
});
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
## Framework Support
|
|
664
|
+
|
|
665
|
+
| Framework | Import Path | Status |
|
|
666
|
+
|-----------|-------------|--------|
|
|
667
|
+
| Vue 3 | `artifactuse/vue` | โ
|
|
|
668
|
+
| Vue 2.7+ | `artifactuse/vue2` | โ
|
|
|
669
|
+
| Vue 2.6 | `artifactuse/vue2` | โ
(requires alias) |
|
|
670
|
+
| Nuxt 3 | `artifactuse/vue` | โ
|
|
|
671
|
+
| Nuxt 2 | `artifactuse/vue2` | โ
|
|
|
672
|
+
| React 18+ | `artifactuse/react` | โ
|
|
|
673
|
+
| Next.js | `artifactuse/react` | โ
|
|
|
674
|
+
| Svelte 4/5 | `artifactuse/svelte` | โ
|
|
|
675
|
+
| SvelteKit | `artifactuse/svelte` | โ
|
|
|
676
|
+
|
|
677
|
+
## Theming
|
|
678
|
+
|
|
679
|
+
```js
|
|
680
|
+
const { setTheme } = useArtifactuse();
|
|
681
|
+
|
|
682
|
+
setTheme('dark');
|
|
683
|
+
setTheme('light');
|
|
684
|
+
setTheme('auto'); // Follow system preference
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
Or use CSS variables:
|
|
688
|
+
|
|
689
|
+
```css
|
|
690
|
+
:root {
|
|
691
|
+
--artifactuse-primary: 99, 102, 241;
|
|
692
|
+
--artifactuse-background: 17, 24, 39;
|
|
693
|
+
--artifactuse-surface: 31, 41, 55;
|
|
694
|
+
--artifactuse-text: 243, 244, 246;
|
|
695
|
+
}
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
### Modular CSS Imports
|
|
699
|
+
|
|
700
|
+
Import all styles:
|
|
701
|
+
|
|
702
|
+
```js
|
|
703
|
+
import 'artifactuse/styles';
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
Or import only what you need:
|
|
707
|
+
|
|
708
|
+
```js
|
|
709
|
+
// Base (required)
|
|
710
|
+
import 'artifactuse/styles/base/variables.css';
|
|
711
|
+
import 'artifactuse/styles/base/reset.css';
|
|
712
|
+
|
|
713
|
+
// Components (pick what you use)
|
|
714
|
+
import 'artifactuse/styles/components/message.css';
|
|
715
|
+
import 'artifactuse/styles/components/panel.css';
|
|
716
|
+
import 'artifactuse/styles/components/card.css';
|
|
717
|
+
import 'artifactuse/styles/components/viewer.css';
|
|
718
|
+
import 'artifactuse/styles/components/form.css';
|
|
719
|
+
import 'artifactuse/styles/components/social.css';
|
|
720
|
+
import 'artifactuse/styles/components/toggle.css';
|
|
721
|
+
|
|
722
|
+
// Processors (pick what you use)
|
|
723
|
+
import 'artifactuse/styles/processors/image.css';
|
|
724
|
+
import 'artifactuse/styles/processors/video.css';
|
|
725
|
+
import 'artifactuse/styles/processors/audio.css';
|
|
726
|
+
import 'artifactuse/styles/processors/code.css';
|
|
727
|
+
import 'artifactuse/styles/processors/table.css';
|
|
728
|
+
import 'artifactuse/styles/processors/math.css';
|
|
729
|
+
import 'artifactuse/styles/processors/embed.css';
|
|
730
|
+
|
|
731
|
+
// Utilities
|
|
732
|
+
import 'artifactuse/styles/utilities/animations.css';
|
|
733
|
+
import 'artifactuse/styles/utilities/responsive.css';
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
## Development
|
|
737
|
+
|
|
738
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
|
|
739
|
+
|
|
740
|
+
### Architecture
|
|
741
|
+
|
|
742
|
+
Artifactuse uses a modular processor pipeline:
|
|
743
|
+
|
|
744
|
+
```
|
|
745
|
+
AI Content โ Markdown Parser โ Processors โ Rendered HTML
|
|
746
|
+
โ
|
|
747
|
+
Detector โ Artifacts
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
**Key modules:**
|
|
751
|
+
|
|
752
|
+
- `src/core/processors/` - Content processors (images, videos, audio, social, etc.)
|
|
753
|
+
- `src/core/detector.js` - Artifact detection and creation
|
|
754
|
+
- `src/core/state.js` - Reactive state management
|
|
755
|
+
- `src/styles/` - Modular CSS (base, components, processors, utilities)
|
|
756
|
+
- `src/vue/`, `src/vue2/`, `src/react/`, `src/svelte/` - Framework components
|
|
757
|
+
|
|
758
|
+
## Browser Support
|
|
759
|
+
|
|
760
|
+
- Chrome 80+
|
|
761
|
+
- Firefox 75+
|
|
762
|
+
- Safari 14+
|
|
763
|
+
- Edge 80+
|
|
764
|
+
|
|
765
|
+
## License
|
|
766
|
+
|
|
767
|
+
MIT ยฉ [Artifactuse](https://artifactuse.com). Crafted with โค๏ธ by the [BoostGPT Team](https://boostgpt.co).
|
|
768
|
+
|
|
769
|
+
---
|
|
770
|
+
|
|
771
|
+
**[Documentation](https://artifactuse.com/docs)** ยท **[Examples](https://artifactuse.com/docs/examples)** ยท **[Contributing](./CONTRIBUTING.md)**
|