@lingjingai/scriptctl 0.61.2 → 0.61.3

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.
@@ -0,0 +1,4 @@
1
+ # 0.61.3
2
+
3
+ - Refresh the screenplay document indexes after every mutation, including in-memory review sessions. Repeated moves preserve action identity without duplicating actions or deleting unrelated ones; reads and subsequent edits see the current document.
4
+ - Stage scene and episode writes in a detached copy. Rejected writes leave both the document and its indexes unchanged.
package/dist/bin.js CHANGED
@@ -4207,6 +4207,7 @@ function newId(prefix, taken) {
4207
4207
  return id;
4208
4208
  }
4209
4209
  function save(doc2) {
4210
+ Object.assign(doc2, parse(doc2.raw, doc2.path));
4210
4211
  if (!doc2.path) {
4211
4212
  step("save", "skipped: document is not bound to a file");
4212
4213
  return;
@@ -4940,6 +4941,13 @@ function preview(raw) {
4940
4941
  return clip(String(raw.content ?? ""), 40);
4941
4942
  }
4942
4943
  function write(doc2, addr, text2, opts = {}) {
4944
+ const draft = parse(structuredClone(doc2.raw));
4945
+ const result = writeDraft(draft, addr, text2, opts);
4946
+ doc2.raw = draft.raw;
4947
+ save(doc2);
4948
+ return result;
4949
+ }
4950
+ function writeDraft(doc2, addr, text2, opts) {
4943
4951
  if (addr === "+" || Number(addr) === doc2.episodes.length + 1) {
4944
4952
  const raw = { scenes: [] };
4945
4953
  if (doc2.version === 4)