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 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:
@@ -70,6 +70,7 @@ export function createArtifactuse(userConfig?: {}): {
70
70
  lineCount: number;
71
71
  createdAt: string;
72
72
  };
73
+ updateFile: (artifactOrId: any, code: any, options?: {}) => any;
73
74
  closePanel: () => void;
74
75
  togglePanel: () => void;
75
76
  toggleFullscreen: () => void;