@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.d.cts CHANGED
@@ -120,7 +120,15 @@ declare function ScriptBreakdownSceneView({ blocks, characters, isLoading, scene
120
120
  isSummarizing?: boolean;
121
121
  }): react_jsx_runtime.JSX.Element;
122
122
 
123
- declare function useScriptBreakdownScene(scene_url: string, fetchOptions?: RequestInit, onAISummarize?: (scene: any) => void, onTagAdded?: (tag: Tag) => void, onTagRemoved?: (tagId: string) => void, preLoadedTags?: Tag[]): {
123
+ interface UseScriptBreakdownSceneOptions {
124
+ scene_url: string;
125
+ fetchOptions?: RequestInit;
126
+ onAISummarize?: (scene: any) => void;
127
+ onTagAdded?: (tag: Tag) => void;
128
+ onTagRemoved?: (tagId: string) => void;
129
+ preLoadedTags?: Tag[];
130
+ }
131
+ declare function useScriptBreakdownScene(options: UseScriptBreakdownSceneOptions): {
124
132
  scene: any;
125
133
  blocks: Block[];
126
134
  characters: string[];
package/dist/index.d.ts CHANGED
@@ -120,7 +120,15 @@ declare function ScriptBreakdownSceneView({ blocks, characters, isLoading, scene
120
120
  isSummarizing?: boolean;
121
121
  }): react_jsx_runtime.JSX.Element;
122
122
 
123
- declare function useScriptBreakdownScene(scene_url: string, fetchOptions?: RequestInit, onAISummarize?: (scene: any) => void, onTagAdded?: (tag: Tag) => void, onTagRemoved?: (tagId: string) => void, preLoadedTags?: Tag[]): {
123
+ interface UseScriptBreakdownSceneOptions {
124
+ scene_url: string;
125
+ fetchOptions?: RequestInit;
126
+ onAISummarize?: (scene: any) => void;
127
+ onTagAdded?: (tag: Tag) => void;
128
+ onTagRemoved?: (tagId: string) => void;
129
+ preLoadedTags?: Tag[];
130
+ }
131
+ declare function useScriptBreakdownScene(options: UseScriptBreakdownSceneOptions): {
124
132
  scene: any;
125
133
  blocks: Block[];
126
134
  characters: string[];
package/dist/index.js CHANGED
@@ -2279,8 +2279,8 @@ function ScriptBreakdownSceneView({
2279
2279
  ] })
2280
2280
  ] }) });
2281
2281
  }
2282
- function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAdded, onTagRemoved, preLoadedTags) {
2283
- const [tags, setTags] = useState(preLoadedTags || []);
2282
+ function useScriptBreakdownScene(options) {
2283
+ const [tags, setTags] = useState(options.preLoadedTags || []);
2284
2284
  const [selectionMenu, setSelectionMenu] = useState(null);
2285
2285
  const autoTaggedSceneRef = useRef(null);
2286
2286
  const [scene, setScene] = useState(null);
@@ -2295,7 +2295,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2295
2295
  setIsLoading(true);
2296
2296
  const fetchScene = async () => {
2297
2297
  try {
2298
- const response = await fetch(scene_url, fetchOptions);
2298
+ const response = await fetch(options.scene_url, options.fetchOptions);
2299
2299
  if (response.ok) {
2300
2300
  const text = await response.text();
2301
2301
  setScene({ content: text });
@@ -2352,8 +2352,9 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2352
2352
  return [...new Set(chars)];
2353
2353
  }, [blocks]);
2354
2354
  const handleAISummarize = async () => {
2355
+ var _a;
2355
2356
  setIsSummarizing(true);
2356
- const res = await (onAISummarize == null ? void 0 : onAISummarize(scene.content));
2357
+ const res = await ((_a = options.onAISummarize) == null ? void 0 : _a.call(options, scene.content));
2357
2358
  if (res.ok) {
2358
2359
  const data = await res.json();
2359
2360
  setIsSummarizing(false);
@@ -2415,11 +2416,15 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2415
2416
  setSubLocations((prev) => prev.filter((loc) => loc !== subLocation));
2416
2417
  }, []);
2417
2418
  useEffect(() => {
2418
- setTags([]);
2419
2419
  setSubLocations([]);
2420
2420
  setSceneBrief("");
2421
2421
  autoTaggedSceneRef.current = null;
2422
- }, [scene_url]);
2422
+ }, [options.scene_url]);
2423
+ useEffect(() => {
2424
+ if (options.preLoadedTags && options.preLoadedTags.length > 0) {
2425
+ setTags(options.preLoadedTags);
2426
+ }
2427
+ }, []);
2423
2428
  const clearSelection = useCallback(() => {
2424
2429
  var _a;
2425
2430
  setSelectionMenu(null);
@@ -2507,6 +2512,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2507
2512
  }
2508
2513
  };
2509
2514
  const addTag = async (categoryId) => {
2515
+ var _a;
2510
2516
  if (!selectionMenu) return;
2511
2517
  const newTag = {
2512
2518
  id: uuid(),
@@ -2524,13 +2530,14 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2524
2530
  });
2525
2531
  clearSelection();
2526
2532
  try {
2527
- await (onTagAdded == null ? void 0 : onTagAdded(newTag));
2533
+ await ((_a = options.onTagAdded) == null ? void 0 : _a.call(options, newTag));
2528
2534
  } catch (error2) {
2529
2535
  console.error("Failed to add tag:", error2);
2530
2536
  setTags((prev) => prev.filter((t) => t.id !== newTag.id));
2531
2537
  }
2532
2538
  };
2533
2539
  const removeTag = async (e, id) => {
2540
+ var _a;
2534
2541
  e.stopPropagation();
2535
2542
  e.preventDefault();
2536
2543
  const tagToRemove = tags.find((t) => t.id === id);
@@ -2538,7 +2545,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
2538
2545
  setTags((prev) => prev.filter((t) => t.id !== id));
2539
2546
  clearSelection();
2540
2547
  try {
2541
- await (onTagRemoved == null ? void 0 : onTagRemoved(id));
2548
+ await ((_a = options.onTagRemoved) == null ? void 0 : _a.call(options, id));
2542
2549
  } catch (error2) {
2543
2550
  console.error("Failed to remove tag:", error2);
2544
2551
  setTags((prev) => [...prev, tagToRemove]);