@vishu1301/script-writing 1.1.9 → 1.2.1

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/dist/index.cjs CHANGED
@@ -2304,8 +2304,8 @@ function ScriptBreakdownSceneView({
2304
2304
  ] })
2305
2305
  ] }) });
2306
2306
  }
2307
- function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAdded, onTagRemoved, preLoadedTags) {
2308
- const [tags, setTags] = react.useState(preLoadedTags || []);
2307
+ function useScriptBreakdownScene(options) {
2308
+ const [tags, setTags] = react.useState(options.preLoadedTags || []);
2309
2309
  const [selectionMenu, setSelectionMenu] = react.useState(null);
2310
2310
  const autoTaggedSceneRef = react.useRef(null);
2311
2311
  const [scene, setScene] = react.useState(null);
@@ -2320,7 +2320,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2320
2320
  setIsLoading(true);
2321
2321
  const fetchScene = async () => {
2322
2322
  try {
2323
- const response = await fetch(scene_url, fetchOptions);
2323
+ const response = await fetch(options.scene_url, options.fetchOptions);
2324
2324
  if (response.ok) {
2325
2325
  const text = await response.text();
2326
2326
  setScene({ content: text });
@@ -2377,8 +2377,9 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2377
2377
  return [...new Set(chars)];
2378
2378
  }, [blocks]);
2379
2379
  const handleAISummarize = async () => {
2380
+ var _a;
2380
2381
  setIsSummarizing(true);
2381
- const res = await (onAISummarize == null ? void 0 : onAISummarize(scene.content));
2382
+ const res = await ((_a = options.onAISummarize) == null ? void 0 : _a.call(options, scene.content));
2382
2383
  if (res.ok) {
2383
2384
  const data = await res.json();
2384
2385
  setIsSummarizing(false);
@@ -2440,11 +2441,15 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2440
2441
  setSubLocations((prev) => prev.filter((loc) => loc !== subLocation));
2441
2442
  }, []);
2442
2443
  react.useEffect(() => {
2443
- setTags([]);
2444
2444
  setSubLocations([]);
2445
2445
  setSceneBrief("");
2446
2446
  autoTaggedSceneRef.current = null;
2447
- }, [scene_url]);
2447
+ }, [options.scene_url]);
2448
+ react.useEffect(() => {
2449
+ if (options.preLoadedTags && options.preLoadedTags.length > 0) {
2450
+ setTags(options.preLoadedTags);
2451
+ }
2452
+ }, []);
2448
2453
  const clearSelection = react.useCallback(() => {
2449
2454
  var _a;
2450
2455
  setSelectionMenu(null);
@@ -2532,6 +2537,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2532
2537
  }
2533
2538
  };
2534
2539
  const addTag = async (categoryId) => {
2540
+ var _a;
2535
2541
  if (!selectionMenu) return;
2536
2542
  const newTag = {
2537
2543
  id: uuid(),
@@ -2549,13 +2555,14 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2549
2555
  });
2550
2556
  clearSelection();
2551
2557
  try {
2552
- await (onTagAdded == null ? void 0 : onTagAdded(newTag));
2558
+ await ((_a = options.onTagAdded) == null ? void 0 : _a.call(options, newTag));
2553
2559
  } catch (error2) {
2554
2560
  console.error("Failed to add tag:", error2);
2555
2561
  setTags((prev) => prev.filter((t) => t.id !== newTag.id));
2556
2562
  }
2557
2563
  };
2558
2564
  const removeTag = async (e, id) => {
2565
+ var _a;
2559
2566
  e.stopPropagation();
2560
2567
  e.preventDefault();
2561
2568
  const tagToRemove = tags.find((t) => t.id === id);
@@ -2563,7 +2570,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2563
2570
  setTags((prev) => prev.filter((t) => t.id !== id));
2564
2571
  clearSelection();
2565
2572
  try {
2566
- await (onTagRemoved == null ? void 0 : onTagRemoved(id));
2573
+ await ((_a = options.onTagRemoved) == null ? void 0 : _a.call(options, id));
2567
2574
  } catch (error2) {
2568
2575
  console.error("Failed to remove tag:", error2);
2569
2576
  setTags((prev) => [...prev, tagToRemove]);