artifactuse 0.1.23 → 0.1.25

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.
@@ -100,6 +100,7 @@ export function provideArtifactuse(config?: {
100
100
  lineCount: number;
101
101
  createdAt: string;
102
102
  };
103
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
103
104
  closePanel: () => void;
104
105
  togglePanel: () => void;
105
106
  toggleFullscreen: () => void;
@@ -216,6 +217,7 @@ export function provideArtifactuse(config?: {
216
217
  lineCount: number;
217
218
  createdAt: string;
218
219
  };
220
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
219
221
  closePanel: () => void;
220
222
  togglePanel: () => void;
221
223
  toggleFullscreen: () => void;
@@ -310,6 +312,7 @@ export function createArtifactuseComposable(config?: {}): {
310
312
  lineCount: number;
311
313
  createdAt: string;
312
314
  };
315
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
313
316
  closePanel: () => void;
314
317
  togglePanel: () => void;
315
318
  toggleFullscreen: () => void;
@@ -426,6 +429,7 @@ export function createArtifactuseComposable(config?: {}): {
426
429
  lineCount: number;
427
430
  createdAt: string;
428
431
  };
432
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
429
433
  closePanel: () => void;
430
434
  togglePanel: () => void;
431
435
  toggleFullscreen: () => void;
package/dist/vue/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ref as M, computed as b, createElementBlock as s, openBlock as a, normalizeClass as N, createElementVNode as e, toDisplayString as n, withModifiers as he, onMounted as we, watch as fe, Fragment as R, createCommentVNode as d, renderList as ue, createTextVNode as K, h as le, normalizeStyle as $e, createStaticVNode as Pt, createBlock as ke, resolveDynamicComponent as Bt, nextTick as ge, onUnmounted as Oe, Teleport as Et, createVNode as Ae, Transition as Me, withCtx as Le, withKeys as St, onBeforeUnmount as zt, unref as y, withDirectives as Qe, vShow as Ge, reactive as et, provide as It, inject as Ft } from "vue";
2
- import { g as Te, f as tt, a as Re, b as qe, n as Vt, i as Rt, D as qt, c as at } from "../index-BR2-i8NP.js";
2
+ import { g as Te, f as tt, a as Re, b as qe, n as Vt, i as Rt, D as qt, c as at } from "../index-Bzk5VnG1.js";
3
3
  import { J as Ot } from "../jszip.min-CdmYyw5L.js";
4
4
  const Ut = { class: "artifactuse-card__icon" }, Dt = ["innerHTML"], jt = { class: "artifactuse-card__content" }, Nt = { class: "artifactuse-card__title" }, Jt = { class: "artifactuse-card__meta" }, Xt = { class: "artifactuse-card__type" }, Zt = { class: "artifactuse-card__size" }, Wt = { class: "artifactuse-card__actions" }, Kt = ["title"], Yt = {
5
5
  key: 0,
@@ -1782,7 +1782,11 @@ const Ut = { class: "artifactuse-card__icon" }, Dt = ["innerHTML"], jt = { class
1782
1782
  const x = b(() => {
1783
1783
  var i;
1784
1784
  return ((i = $.editor) == null ? void 0 : i.isAvailable()) || !1;
1785
- }), V = M(65), D = M(50), re = b(() => l.value ? Te(l.value.language) : ""), z = b(() => l.value ? `<svg viewBox="0 0 24 24" fill="currentColor">${Re(l.value.language)}</svg>` : ""), G = b(() => l.value ? m(l.value) : null);
1785
+ }), V = M(65), D = M(50), re = b(() => l.value ? Te(l.value.language) : ""), z = b(() => l.value ? `<svg viewBox="0 0 24 24" fill="currentColor">${Re(l.value.language)}</svg>` : ""), G = b(() => {
1786
+ if (!l.value) return null;
1787
+ let i = m(l.value);
1788
+ return i && l.value._refreshToken && (i += (i.includes("?") ? "&" : "?") + "_t=" + l.value._refreshToken), i;
1789
+ });
1786
1790
  b(() => !l.value || !k.artifacts.length ? -1 : k.artifacts.findIndex((i) => i.id === l.value.id));
1787
1791
  const v = b(() => l.value ? Vt(l.value.language || "plaintext") : "plaintext"), B = b(() => k.artifacts.filter((i) => !i.isInline)), W = b(() => l.value ? B.value.findIndex((i) => i.id === l.value.id) : -1), se = b(() => {
1788
1792
  var i;
@@ -1840,7 +1844,7 @@ const Ut = { class: "artifactuse-card__icon" }, Dt = ["innerHTML"], jt = { class
1840
1844
  function je() {
1841
1845
  !x.value || !I.value || !l.value || (Pe(), de = $.editor.create(I.value, {
1842
1846
  code: l.value.code || "",
1843
- language: l.value.language || "plaintext",
1847
+ language: l.value.editorLanguage || l.value.language || "plaintext",
1844
1848
  sdkTheme: $.getTheme()
1845
1849
  }));
1846
1850
  }
@@ -3118,6 +3122,7 @@ function it(H = {}) {
3118
3122
  openArtifact: u.openArtifact,
3119
3123
  openFile: u.openFile,
3120
3124
  openCode: u.openCode,
3125
+ updateFile: u.updateFile,
3121
3126
  closePanel: u.closePanel,
3122
3127
  togglePanel: u.togglePanel,
3123
3128
  toggleFullscreen: u.toggleFullscreen,
@@ -3179,6 +3184,7 @@ function En(H = {}) {
3179
3184
  openArtifact: u.openArtifact,
3180
3185
  openFile: u.openFile,
3181
3186
  openCode: u.openCode,
3187
+ updateFile: u.updateFile,
3182
3188
  closePanel: u.closePanel,
3183
3189
  togglePanel: u.togglePanel,
3184
3190
  toggleFullscreen: u.toggleFullscreen,
@@ -100,6 +100,7 @@ export function provideArtifactuse(config?: {
100
100
  lineCount: number;
101
101
  createdAt: string;
102
102
  };
103
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
103
104
  closePanel: () => void;
104
105
  togglePanel: () => void;
105
106
  toggleFullscreen: () => void;
@@ -216,6 +217,7 @@ export function provideArtifactuse(config?: {
216
217
  lineCount: number;
217
218
  createdAt: string;
218
219
  };
220
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
219
221
  closePanel: () => void;
220
222
  togglePanel: () => void;
221
223
  toggleFullscreen: () => void;
@@ -310,6 +312,7 @@ export function createArtifactuseComposable(config?: {}): {
310
312
  lineCount: number;
311
313
  createdAt: string;
312
314
  };
315
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
313
316
  closePanel: () => void;
314
317
  togglePanel: () => void;
315
318
  toggleFullscreen: () => void;
@@ -426,6 +429,7 @@ export function createArtifactuseComposable(config?: {}): {
426
429
  lineCount: number;
427
430
  createdAt: string;
428
431
  };
432
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
429
433
  closePanel: () => void;
430
434
  togglePanel: () => void;
431
435
  toggleFullscreen: () => void;
@@ -2051,19 +2051,54 @@ function createEditorManager(editorConfig = {}) {
2051
2051
  ]);
2052
2052
  }
2053
2053
 
2054
+ /**
2055
+ * Language → CodeMirror module mapping
2056
+ * Each entry: { mod: module key in config.editor.modules, fn: factory function name, opts?: options }
2057
+ */
2058
+ const LANG_MAP = {
2059
+ 'javascript': { mod: 'langJavascript', fn: 'javascript' },
2060
+ 'js': { mod: 'langJavascript', fn: 'javascript' },
2061
+ 'jsx': { mod: 'langJavascript', fn: 'javascript', opts: { jsx: true } },
2062
+ 'typescript': { mod: 'langJavascript', fn: 'javascript', opts: { typescript: true } },
2063
+ 'ts': { mod: 'langJavascript', fn: 'javascript', opts: { typescript: true } },
2064
+ 'tsx': { mod: 'langJavascript', fn: 'javascript', opts: { jsx: true, typescript: true } },
2065
+ 'python': { mod: 'langPython', fn: 'python' },
2066
+ 'py': { mod: 'langPython', fn: 'python' },
2067
+ 'html': { mod: 'langHtml', fn: 'html' },
2068
+ 'htm': { mod: 'langHtml', fn: 'html' },
2069
+ 'css': { mod: 'langCss', fn: 'css' },
2070
+ 'json': { mod: 'langJson', fn: 'json' },
2071
+ 'markdown': { mod: 'langMarkdown', fn: 'markdown' },
2072
+ 'md': { mod: 'langMarkdown', fn: 'markdown' },
2073
+ 'xml': { mod: 'langXml', fn: 'xml' },
2074
+ 'yaml': { mod: 'langYaml', fn: 'yaml' },
2075
+ 'yml': { mod: 'langYaml', fn: 'yaml' },
2076
+ 'sql': { mod: 'langSql', fn: 'sql' },
2077
+ 'java': { mod: 'langJava', fn: 'java' },
2078
+ 'cpp': { mod: 'langCpp', fn: 'cpp' },
2079
+ 'c': { mod: 'langCpp', fn: 'cpp' },
2080
+ 'c++': { mod: 'langCpp', fn: 'cpp' },
2081
+ 'go': { mod: 'langGo', fn: 'go' },
2082
+ 'golang': { mod: 'langGo', fn: 'go' },
2083
+ 'rust': { mod: 'langRust', fn: 'rust' },
2084
+ 'rs': { mod: 'langRust', fn: 'rust' },
2085
+ 'php': { mod: 'langPhp', fn: 'php' },
2086
+ 'vue': { mod: 'langVue', fn: 'vue' },
2087
+ 'angular': { mod: 'langAngular', fn: 'angular' },
2088
+ 'less': { mod: 'langLess', fn: 'less' },
2089
+ 'sass': { mod: 'langSass', fn: 'sass', opts: { indented: true } },
2090
+ 'scss': { mod: 'langSass', fn: 'sass' },
2091
+ };
2092
+
2054
2093
  /**
2055
2094
  * Resolve language extension from language string
2056
2095
  */
2057
2096
  function getLanguageExtension(lang) {
2058
- const normalized = lang?.toLowerCase();
2059
- if ((normalized === 'javascript' || normalized === 'js' || normalized === 'jsx' || normalized === 'tsx' || normalized === 'typescript' || normalized === 'ts') && modules.langJavascript) {
2060
- return modules.langJavascript.javascript();
2061
- }
2062
- if ((normalized === 'python' || normalized === 'py') && modules.langPython) {
2063
- return modules.langPython.python();
2064
- }
2065
- // No language extension — plain text
2066
- return [];
2097
+ const entry = LANG_MAP[lang?.toLowerCase()];
2098
+ if (!entry) return [];
2099
+ const mod = modules[entry.mod];
2100
+ if (!mod || typeof mod[entry.fn] !== 'function') return [];
2101
+ return entry.opts ? mod[entry.fn](entry.opts) : mod[entry.fn]();
2067
2102
  }
2068
2103
 
2069
2104
  /**
@@ -6820,6 +6855,7 @@ function createArtifactuse(userConfig = {}) {
6820
6855
  const artifact = createArtifact(code, resolvedLang, msgId, 0);
6821
6856
  artifact.title = options.title || artifact.title;
6822
6857
  artifact.isInline = false;
6858
+ artifact.editorLanguage = language;
6823
6859
  if (options.tabs) artifact.tabs = options.tabs;
6824
6860
  if (options.panelUrl) artifact.panelUrl = options.panelUrl;
6825
6861
  state.addArtifact(artifact);
@@ -6829,6 +6865,24 @@ function createArtifactuse(userConfig = {}) {
6829
6865
  return artifact;
6830
6866
  }
6831
6867
 
6868
+ /**
6869
+ * Update an existing artifact's code and refresh the panel
6870
+ */
6871
+ function updateFile(artifactOrId, code, options = {}) {
6872
+ const id = typeof artifactOrId === 'string' ? artifactOrId : artifactOrId?.id;
6873
+ const existing = state.getArtifact(id);
6874
+ if (!existing) return null;
6875
+
6876
+ const updates = { ...existing, code, _refreshToken: Date.now() };
6877
+ if (options.title !== undefined) updates.title = options.title;
6878
+ if (options.tabs !== undefined) updates.tabs = options.tabs;
6879
+ if (options.panelUrl !== undefined) updates.panelUrl = options.panelUrl;
6880
+
6881
+ state.addArtifact(updates);
6882
+ emit('artifact:updated', { artifactId: id, artifact: state.getArtifact(id) });
6883
+ return state.getArtifact(id);
6884
+ }
6885
+
6832
6886
  /**
6833
6887
  * Close panel
6834
6888
  */
@@ -7059,6 +7113,7 @@ function createArtifactuse(userConfig = {}) {
7059
7113
  openArtifact,
7060
7114
  openFile,
7061
7115
  openCode,
7116
+ updateFile,
7062
7117
  closePanel,
7063
7118
  togglePanel,
7064
7119
  toggleFullscreen,
@@ -7242,6 +7297,7 @@ function provideArtifactuse(config = {}) {
7242
7297
  openArtifact: instance.openArtifact,
7243
7298
  openFile: instance.openFile,
7244
7299
  openCode: instance.openCode,
7300
+ updateFile: instance.updateFile,
7245
7301
  closePanel: instance.closePanel,
7246
7302
  togglePanel: instance.togglePanel,
7247
7303
  toggleFullscreen: instance.toggleFullscreen,
@@ -7362,6 +7418,7 @@ function createArtifactuseComposable(config = {}) {
7362
7418
  openArtifact: instance.openArtifact,
7363
7419
  openFile: instance.openFile,
7364
7420
  openCode: instance.openCode,
7421
+ updateFile: instance.updateFile,
7365
7422
  closePanel: instance.closePanel,
7366
7423
  togglePanel: instance.togglePanel,
7367
7424
  toggleFullscreen: instance.toggleFullscreen,
@@ -26984,7 +27041,11 @@ var script$1 = defineComponent({
26984
27041
 
26985
27042
  const panelUrl = computed(() => {
26986
27043
  if (!activeArtifact.value) return null;
26987
- return getPanelUrl(activeArtifact.value);
27044
+ var url = getPanelUrl(activeArtifact.value);
27045
+ if (url && activeArtifact.value._refreshToken) {
27046
+ url += (url.includes('?') ? '&' : '?') + '_t=' + activeArtifact.value._refreshToken;
27047
+ }
27048
+ return url;
26988
27049
  });
26989
27050
 
26990
27051
  const normalizedLanguage = computed(() => {
@@ -27093,7 +27154,7 @@ var script$1 = defineComponent({
27093
27154
  destroyEditor();
27094
27155
  editorInstance = instance.editor.create(editorContainerRef.value, {
27095
27156
  code: activeArtifact.value.code || '',
27096
- language: activeArtifact.value.language || 'plaintext',
27157
+ language: activeArtifact.value.editorLanguage || activeArtifact.value.language || 'plaintext',
27097
27158
  sdkTheme: instance.getTheme(),
27098
27159
  });
27099
27160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artifactuse",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "type": "module",
5
5
  "description": "The Artifact SDK for AI Agents - Turn AI outputs into interactive experiences",
6
6
  "author": "Artifactuse",