artifactuse 0.1.24 → 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 +26 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/{index-CdjLieSe.js → index-Bzk5VnG1.js} +461 -454
- package/dist/index.js +1 -1
- package/dist/react/index.js +150 -145
- package/dist/svelte/index.d.ts +6 -0
- package/dist/svelte/index.js +396 -391
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +8 -2
- package/dist/vue2/composables.d.ts +4 -0
- package/dist/vue2/index.js +26 -1
- 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
|
|
@@ -758,6 +759,31 @@ openCode(pythonCode, 'python', { title: 'My Script', tabs: ['code', 'edit'] });
|
|
|
758
759
|
|
|
759
760
|
> **Note:** If the language has no registered panel, it falls back to `txt` (plain text) in the code panel.
|
|
760
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
|
+
|
|
761
787
|
### clearArtifacts
|
|
762
788
|
|
|
763
789
|
Removes all artifacts and closes the panel:
|
package/dist/core/index.d.ts
CHANGED