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.
- package/README.md +48 -3
- package/dist/core/index.d.ts +1 -0
- package/dist/{index-BR2-i8NP.js → index-Bzk5VnG1.js} +1411 -1368
- package/dist/index.js +1 -1
- package/dist/react/index.js +151 -146
- package/dist/svelte/index.d.ts +6 -0
- package/dist/svelte/index.js +397 -392
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +9 -3
- package/dist/vue2/composables.d.ts +4 -0
- package/dist/vue2/index.js +72 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -531,6 +531,7 @@ const {
|
|
|
531
531
|
// Programmatic API
|
|
532
532
|
openFile, // Open file in panel (auto-detect language from extension)
|
|
533
533
|
openCode, // Open code in panel (explicit language)
|
|
534
|
+
updateFile, // Update existing artifact's code and refresh panel
|
|
534
535
|
clearArtifacts, // Clear all artifacts
|
|
535
536
|
|
|
536
537
|
// Panel management
|
|
@@ -594,17 +595,36 @@ provideArtifactuse({
|
|
|
594
595
|
// Code Editor (Optional) — CodeMirror 6 for the edit tab
|
|
595
596
|
// Requires: @codemirror/state, @codemirror/view, @codemirror/commands,
|
|
596
597
|
// @codemirror/language, @codemirror/autocomplete
|
|
597
|
-
// Optional:
|
|
598
|
+
// Optional: language packages and @lezer/highlight (for syntax highlighting)
|
|
598
599
|
editor: {
|
|
599
600
|
modules: {
|
|
601
|
+
// Required
|
|
600
602
|
state: cmState, // @codemirror/state
|
|
601
603
|
view: cmView, // @codemirror/view
|
|
602
604
|
commands: cmCommands, // @codemirror/commands
|
|
603
605
|
language: cmLanguage, // @codemirror/language
|
|
604
606
|
autocomplete: cmAutocomplete, // @codemirror/autocomplete
|
|
605
|
-
|
|
607
|
+
// Syntax highlighting (optional)
|
|
608
|
+
lezerHighlight: lezerHighlight, // @lezer/highlight
|
|
609
|
+
// Language packages (all optional — add only what you need)
|
|
610
|
+
langJavascript: cmLangJavascript, // @codemirror/lang-javascript (js/jsx/ts/tsx)
|
|
606
611
|
langPython: cmLangPython, // @codemirror/lang-python
|
|
607
|
-
|
|
612
|
+
langHtml: cmLangHtml, // @codemirror/lang-html
|
|
613
|
+
langCss: cmLangCss, // @codemirror/lang-css
|
|
614
|
+
langJson: cmLangJson, // @codemirror/lang-json
|
|
615
|
+
langMarkdown: cmLangMarkdown, // @codemirror/lang-markdown
|
|
616
|
+
langXml: cmLangXml, // @codemirror/lang-xml
|
|
617
|
+
langYaml: cmLangYaml, // @codemirror/lang-yaml
|
|
618
|
+
langSql: cmLangSql, // @codemirror/lang-sql
|
|
619
|
+
langJava: cmLangJava, // @codemirror/lang-java
|
|
620
|
+
langCpp: cmLangCpp, // @codemirror/lang-cpp (c/c++)
|
|
621
|
+
langGo: cmLangGo, // @codemirror/lang-go
|
|
622
|
+
langRust: cmLangRust, // @codemirror/lang-rust
|
|
623
|
+
langPhp: cmLangPhp, // @codemirror/lang-php
|
|
624
|
+
langVue: cmLangVue, // @codemirror/lang-vue
|
|
625
|
+
langAngular: cmLangAngular, // @codemirror/lang-angular
|
|
626
|
+
langLess: cmLangLess, // @codemirror/lang-less
|
|
627
|
+
langSass: cmLangSass, // @codemirror/lang-sass (sass/scss)
|
|
608
628
|
},
|
|
609
629
|
theme: 'dark', // 'dark' | 'light' | 'auto'
|
|
610
630
|
},
|
|
@@ -739,6 +759,31 @@ openCode(pythonCode, 'python', { title: 'My Script', tabs: ['code', 'edit'] });
|
|
|
739
759
|
|
|
740
760
|
> **Note:** If the language has no registered panel, it falls back to `txt` (plain text) in the code panel.
|
|
741
761
|
|
|
762
|
+
### updateFile
|
|
763
|
+
|
|
764
|
+
Updates an existing artifact's code in place and refreshes the panel (no duplicate tabs):
|
|
765
|
+
|
|
766
|
+
```js
|
|
767
|
+
const { openFile, updateFile } = useArtifactuse();
|
|
768
|
+
|
|
769
|
+
// First open — returns artifact reference
|
|
770
|
+
const artifact = openFile('app.html', code, { panelUrl: '...' });
|
|
771
|
+
|
|
772
|
+
// Later — update in place, refreshes iframe
|
|
773
|
+
updateFile(artifact, newCode);
|
|
774
|
+
updateFile(artifact.id, newCode, { panelUrl: newUrl });
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
| Parameter | Type | Required | Description |
|
|
778
|
+
|-----------|------|----------|-------------|
|
|
779
|
+
| `artifact` | `object\|string` | Yes | Artifact object (from `openFile`) or artifact ID string |
|
|
780
|
+
| `code` | `string` | Yes | New code content |
|
|
781
|
+
| `options.title` | `string` | No | Update display title |
|
|
782
|
+
| `options.tabs` | `string[]` | No | Update visible tabs |
|
|
783
|
+
| `options.panelUrl` | `string` | No | Update custom iframe URL |
|
|
784
|
+
|
|
785
|
+
> **Note:** `updateFile` triggers the `artifact:updated` event with `{ artifactId, artifact }`.
|
|
786
|
+
|
|
742
787
|
### clearArtifacts
|
|
743
788
|
|
|
744
789
|
Removes all artifacts and closes the panel:
|
package/dist/core/index.d.ts
CHANGED