artifactuse 0.2.6 → 0.3.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.
@@ -6866,6 +6866,10 @@ const DEFAULT_CONFIG = {
6866
6866
  // Can be overridden per-artifact via openFile/openCode options or per-component via props
6867
6867
  externalPreview: false,
6868
6868
 
6869
+ // Show console panel footer for runtime logs/errors from HTML artifacts
6870
+ // When false, footer UI is hidden but console:log events still emit
6871
+ consolePanel: true,
6872
+
6869
6873
  // Enable multi-tab mode (open multiple artifacts as tabs)
6870
6874
  multiTab: false,
6871
6875
 
@@ -7646,6 +7650,10 @@ function createArtifactuse(userConfig = {}) {
7646
7650
  }
7647
7651
  emit('edit:save', data);
7648
7652
  });
7653
+ bridge.on('console:log', (data) => {
7654
+ const artifactId = state.getState().activeArtifactId;
7655
+ emit('console:log', { artifactId, ...data });
7656
+ });
7649
7657
 
7650
7658
  /**
7651
7659
  * Apply theme to document
@@ -27657,6 +27665,30 @@ var JSZip = /*@__PURE__*/getDefaultExportFromCjs(libExports);
27657
27665
  //
27658
27666
  //
27659
27667
  //
27668
+ //
27669
+ //
27670
+ //
27671
+ //
27672
+ //
27673
+ //
27674
+ //
27675
+ //
27676
+ //
27677
+ //
27678
+ //
27679
+ //
27680
+ //
27681
+ //
27682
+ //
27683
+ //
27684
+ //
27685
+ //
27686
+ //
27687
+ //
27688
+ //
27689
+ //
27690
+ //
27691
+ //
27660
27692
 
27661
27693
 
27662
27694
  var script$1 = defineComponent({
@@ -27680,6 +27712,10 @@ var script$1 = defineComponent({
27680
27712
  type: Boolean,
27681
27713
  default: undefined,
27682
27714
  },
27715
+ consolePanel: {
27716
+ type: Boolean,
27717
+ default: undefined,
27718
+ },
27683
27719
  },
27684
27720
 
27685
27721
  setup(props, { emit }) {
@@ -27724,6 +27760,13 @@ var script$1 = defineComponent({
27724
27760
  const savedArtifactsLoading = ref(false);
27725
27761
  const updatedArtifactName = ref('');
27726
27762
 
27763
+ // Console state
27764
+ const consoleEntries = ref([]);
27765
+ const consoleExpanded = ref(false);
27766
+ const consoleEntriesEl = ref(null);
27767
+ const consoleFilter = ref(new Set(['log', 'warn', 'error', 'info']));
27768
+ let unsubConsole = null;
27769
+
27727
27770
  // Panel/split resize state — prop > global config > default
27728
27771
  const panelWidth = ref(
27729
27772
  Math.min(Math.max(props.panelWidth ?? instance.config?.panelWidth ?? 65, 25), 75)
@@ -27792,6 +27835,27 @@ var script$1 = defineComponent({
27792
27835
  return instance.config?.externalPreview ?? false;
27793
27836
  });
27794
27837
 
27838
+ const consoleErrorCount = computed(() => {
27839
+ return consoleEntries.value.filter(e => e.type === 'error').length;
27840
+ });
27841
+ const consoleWarnCount = computed(() => {
27842
+ return consoleEntries.value.filter(e => e.type === 'warn').length;
27843
+ });
27844
+ const consoleInfoCount = computed(() => consoleEntries.value.filter(e => e.type === 'info').length);
27845
+ const consoleLogCount = computed(() => consoleEntries.value.filter(e => e.type === 'log').length);
27846
+ const filteredConsoleEntries = computed(() => consoleEntries.value.filter(e => consoleFilter.value.has(e.type)));
27847
+
27848
+ function toggleConsoleFilter(type) {
27849
+ const next = new Set(consoleFilter.value);
27850
+ if (next.has(type)) next.delete(type);
27851
+ else next.add(type);
27852
+ consoleFilter.value = next;
27853
+ }
27854
+
27855
+ const showConsolePanel = computed(() => {
27856
+ return (props.consolePanel ?? instance.config?.consolePanel) !== false && consoleEntries.value.length > 0;
27857
+ });
27858
+
27795
27859
  // Multi-tab computed
27796
27860
  const isMultiTab = computed(() => instance.config?.multiTab === true);
27797
27861
 
@@ -28418,16 +28482,32 @@ var script$1 = defineComponent({
28418
28482
  }
28419
28483
  });
28420
28484
 
28485
+ // Clear console when artifact changes
28486
+ watch(() => activeArtifact.value?.id, () => {
28487
+ consoleEntries.value = [];
28488
+ consoleExpanded.value = false;
28489
+ });
28490
+
28421
28491
  onMounted(() => {
28422
28492
  instance.on('ai:request', (data) => emit('ai-request', data));
28423
28493
  instance.on('save:request', (data) => emit('save', data));
28424
28494
  instance.on('export:complete', (data) => emit('export', data));
28425
-
28495
+
28426
28496
  document.addEventListener('click', handleClickOutside);
28427
-
28497
+
28428
28498
  if (state.isPanelOpen && activeArtifact.value) {
28429
28499
  updateCodeView();
28430
28500
  }
28501
+
28502
+ unsubConsole = instance.on('console:log', ({ entry }) => {
28503
+ consoleEntries.value = [...consoleEntries.value, entry].slice(-500);
28504
+ if (entry.type === 'error') consoleExpanded.value = true;
28505
+ nextTick(() => {
28506
+ if (consoleEntriesEl.value && consoleExpanded.value) {
28507
+ consoleEntriesEl.value.scrollTop = consoleEntriesEl.value.scrollHeight;
28508
+ }
28509
+ });
28510
+ });
28431
28511
  });
28432
28512
 
28433
28513
  onUnmounted(() => {
@@ -28437,6 +28517,7 @@ var script$1 = defineComponent({
28437
28517
  document.removeEventListener('click', handleClickOutside);
28438
28518
  clearTimeout(streamEndTimer);
28439
28519
  clearTimeout(iframeLoadTimer);
28520
+ if (unsubConsole) unsubConsole();
28440
28521
  });
28441
28522
 
28442
28523
  return {
@@ -28489,6 +28570,17 @@ var script$1 = defineComponent({
28489
28570
  currentNonInlineIndex,
28490
28571
  showBranding,
28491
28572
  showExternalPreview,
28573
+ consoleEntries,
28574
+ consoleExpanded,
28575
+ consoleEntriesEl,
28576
+ consoleErrorCount,
28577
+ consoleWarnCount,
28578
+ consoleInfoCount,
28579
+ consoleLogCount,
28580
+ consoleFilter,
28581
+ filteredConsoleEntries,
28582
+ toggleConsoleFilter,
28583
+ showConsolePanel,
28492
28584
  effectivePanelWidth,
28493
28585
  panelClasses,
28494
28586
  forceEmptyView,
@@ -30076,6 +30168,281 @@ var __vue_render__$1 = function () {
30076
30168
  ]
30077
30169
  ),
30078
30170
  _vm._v(" "),
30171
+ _vm.showConsolePanel
30172
+ ? _c(
30173
+ "div",
30174
+ {
30175
+ class: [
30176
+ "artifactuse-panel__console",
30177
+ {
30178
+ "artifactuse-panel__console--expanded":
30179
+ _vm.consoleExpanded,
30180
+ },
30181
+ ],
30182
+ },
30183
+ [
30184
+ _c(
30185
+ "div",
30186
+ {
30187
+ staticClass:
30188
+ "artifactuse-panel__console-header",
30189
+ on: {
30190
+ click: function ($event) {
30191
+ _vm.consoleExpanded = !_vm.consoleExpanded;
30192
+ },
30193
+ },
30194
+ },
30195
+ [
30196
+ _c(
30197
+ "svg",
30198
+ {
30199
+ staticClass:
30200
+ "artifactuse-panel__console-chevron",
30201
+ attrs: {
30202
+ viewBox: "0 0 24 24",
30203
+ fill: "none",
30204
+ stroke: "currentColor",
30205
+ "stroke-width": "2",
30206
+ },
30207
+ },
30208
+ [
30209
+ _c("polyline", {
30210
+ attrs: { points: "18 15 12 9 6 15" },
30211
+ }),
30212
+ ]
30213
+ ),
30214
+ _vm._v(" "),
30215
+ _c("span", [_vm._v("Console")]),
30216
+ _vm._v(" "),
30217
+ _c(
30218
+ "div",
30219
+ {
30220
+ staticClass:
30221
+ "artifactuse-panel__console-filters",
30222
+ on: {
30223
+ click: function ($event) {
30224
+ $event.stopPropagation();
30225
+ },
30226
+ },
30227
+ },
30228
+ [
30229
+ _vm.consoleErrorCount > 0
30230
+ ? _c(
30231
+ "button",
30232
+ {
30233
+ class: [
30234
+ "artifactuse-panel__console-filter",
30235
+ "artifactuse-panel__console-filter--error",
30236
+ {
30237
+ "artifactuse-panel__console-filter--inactive":
30238
+ !_vm.consoleFilter.has(
30239
+ "error"
30240
+ ),
30241
+ },
30242
+ ],
30243
+ on: {
30244
+ click: function ($event) {
30245
+ return _vm.toggleConsoleFilter(
30246
+ "error"
30247
+ )
30248
+ },
30249
+ },
30250
+ },
30251
+ [
30252
+ _vm._v(
30253
+ _vm._s(_vm.consoleErrorCount) +
30254
+ " error" +
30255
+ _vm._s(
30256
+ _vm.consoleErrorCount !== 1
30257
+ ? "s"
30258
+ : ""
30259
+ )
30260
+ ),
30261
+ ]
30262
+ )
30263
+ : _vm._e(),
30264
+ _vm._v(" "),
30265
+ _vm.consoleWarnCount > 0
30266
+ ? _c(
30267
+ "button",
30268
+ {
30269
+ class: [
30270
+ "artifactuse-panel__console-filter",
30271
+ "artifactuse-panel__console-filter--warn",
30272
+ {
30273
+ "artifactuse-panel__console-filter--inactive":
30274
+ !_vm.consoleFilter.has(
30275
+ "warn"
30276
+ ),
30277
+ },
30278
+ ],
30279
+ on: {
30280
+ click: function ($event) {
30281
+ return _vm.toggleConsoleFilter(
30282
+ "warn"
30283
+ )
30284
+ },
30285
+ },
30286
+ },
30287
+ [
30288
+ _vm._v(
30289
+ _vm._s(_vm.consoleWarnCount) +
30290
+ " warn"
30291
+ ),
30292
+ ]
30293
+ )
30294
+ : _vm._e(),
30295
+ _vm._v(" "),
30296
+ _vm.consoleInfoCount > 0
30297
+ ? _c(
30298
+ "button",
30299
+ {
30300
+ class: [
30301
+ "artifactuse-panel__console-filter",
30302
+ "artifactuse-panel__console-filter--info",
30303
+ {
30304
+ "artifactuse-panel__console-filter--inactive":
30305
+ !_vm.consoleFilter.has(
30306
+ "info"
30307
+ ),
30308
+ },
30309
+ ],
30310
+ on: {
30311
+ click: function ($event) {
30312
+ return _vm.toggleConsoleFilter(
30313
+ "info"
30314
+ )
30315
+ },
30316
+ },
30317
+ },
30318
+ [
30319
+ _vm._v(
30320
+ _vm._s(_vm.consoleInfoCount) +
30321
+ " info"
30322
+ ),
30323
+ ]
30324
+ )
30325
+ : _vm._e(),
30326
+ _vm._v(" "),
30327
+ _vm.consoleLogCount > 0
30328
+ ? _c(
30329
+ "button",
30330
+ {
30331
+ class: [
30332
+ "artifactuse-panel__console-filter",
30333
+ "artifactuse-panel__console-filter--log",
30334
+ {
30335
+ "artifactuse-panel__console-filter--inactive":
30336
+ !_vm.consoleFilter.has(
30337
+ "log"
30338
+ ),
30339
+ },
30340
+ ],
30341
+ on: {
30342
+ click: function ($event) {
30343
+ return _vm.toggleConsoleFilter(
30344
+ "log"
30345
+ )
30346
+ },
30347
+ },
30348
+ },
30349
+ [
30350
+ _vm._v(
30351
+ _vm._s(_vm.consoleLogCount) +
30352
+ " log"
30353
+ ),
30354
+ ]
30355
+ )
30356
+ : _vm._e(),
30357
+ ]
30358
+ ),
30359
+ _vm._v(" "),
30360
+ _c(
30361
+ "button",
30362
+ {
30363
+ staticClass:
30364
+ "artifactuse-panel__console-clear",
30365
+ on: {
30366
+ click: function ($event) {
30367
+ $event.stopPropagation();
30368
+ _vm.consoleEntries = [];
30369
+ },
30370
+ },
30371
+ },
30372
+ [_vm._v("Clear")]
30373
+ ),
30374
+ ]
30375
+ ),
30376
+ _vm._v(" "),
30377
+ _vm.consoleExpanded
30378
+ ? _c(
30379
+ "div",
30380
+ {
30381
+ ref: "consoleEntriesEl",
30382
+ staticClass:
30383
+ "artifactuse-panel__console-entries",
30384
+ },
30385
+ _vm._l(
30386
+ _vm.filteredConsoleEntries,
30387
+ function (entry, i) {
30388
+ return _c(
30389
+ "div",
30390
+ {
30391
+ key: i,
30392
+ class:
30393
+ "artifactuse-panel__console-entry artifactuse-panel__console-entry--" +
30394
+ entry.type,
30395
+ },
30396
+ [
30397
+ _c(
30398
+ "span",
30399
+ {
30400
+ staticClass:
30401
+ "artifactuse-panel__console-type",
30402
+ },
30403
+ [
30404
+ _vm._v(
30405
+ "[" + _vm._s(entry.type) + "]"
30406
+ ),
30407
+ ]
30408
+ ),
30409
+ _vm._v(" "),
30410
+ _c(
30411
+ "span",
30412
+ {
30413
+ staticClass:
30414
+ "artifactuse-panel__console-content",
30415
+ },
30416
+ [_vm._v(_vm._s(entry.content))]
30417
+ ),
30418
+ _vm._v(" "),
30419
+ _c(
30420
+ "span",
30421
+ {
30422
+ staticClass:
30423
+ "artifactuse-panel__console-timestamp",
30424
+ },
30425
+ [
30426
+ _vm._v(
30427
+ _vm._s(
30428
+ new Date(
30429
+ entry.timestamp
30430
+ ).toLocaleTimeString()
30431
+ )
30432
+ ),
30433
+ ]
30434
+ ),
30435
+ ]
30436
+ )
30437
+ }
30438
+ ),
30439
+ 0
30440
+ )
30441
+ : _vm._e(),
30442
+ ]
30443
+ )
30444
+ : _vm._e(),
30445
+ _vm._v(" "),
30079
30446
  _c(
30080
30447
  "footer",
30081
30448
  { staticClass: "artifactuse-panel__footer" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artifactuse",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "The Artifact SDK for AI Agents - Turn AI outputs into interactive experiences",
6
6
  "author": "Artifactuse",