@vishu1301/script-writing 1.1.8 → 1.2.0
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 +10 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +10 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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(
|
|
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 :
|
|
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,45 +2416,10 @@ 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]);
|
|
2423
|
-
useEffect(() => {
|
|
2424
|
-
if (blocks.length > 0 && characters.length > 0 && autoTaggedSceneRef.current !== scene) {
|
|
2425
|
-
const autoTags = [];
|
|
2426
|
-
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2427
|
-
const sortedChars = [...characters].sort((a, b) => b.length - a.length);
|
|
2428
|
-
blocks.forEach((block) => {
|
|
2429
|
-
sortedChars.forEach((char) => {
|
|
2430
|
-
const escapedChar = escapeRegExp(char);
|
|
2431
|
-
const regex = new RegExp(`\\b${escapedChar}\\b`, "gi");
|
|
2432
|
-
let match;
|
|
2433
|
-
while ((match = regex.exec(block.text)) !== null) {
|
|
2434
|
-
const isOverlapping = autoTags.some(
|
|
2435
|
-
(t) => t.block_id === block.id && match.index + char.length > t.start_index && match.index < t.end_index
|
|
2436
|
-
);
|
|
2437
|
-
if (!isOverlapping) {
|
|
2438
|
-
autoTags.push({
|
|
2439
|
-
id: uuid(),
|
|
2440
|
-
block_id: block.id,
|
|
2441
|
-
category_id: "CAST",
|
|
2442
|
-
name: block.text.substring(
|
|
2443
|
-
match.index,
|
|
2444
|
-
match.index + char.length
|
|
2445
|
-
),
|
|
2446
|
-
start_index: match.index,
|
|
2447
|
-
end_index: match.index + char.length
|
|
2448
|
-
});
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
2451
|
-
});
|
|
2452
|
-
});
|
|
2453
|
-
setTags(autoTags);
|
|
2454
|
-
autoTaggedSceneRef.current = scene;
|
|
2455
|
-
}
|
|
2456
|
-
}, [blocks, characters, scene]);
|
|
2422
|
+
}, [options.scene_url]);
|
|
2457
2423
|
const clearSelection = useCallback(() => {
|
|
2458
2424
|
var _a;
|
|
2459
2425
|
setSelectionMenu(null);
|
|
@@ -2541,6 +2507,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
|
|
|
2541
2507
|
}
|
|
2542
2508
|
};
|
|
2543
2509
|
const addTag = async (categoryId) => {
|
|
2510
|
+
var _a;
|
|
2544
2511
|
if (!selectionMenu) return;
|
|
2545
2512
|
const newTag = {
|
|
2546
2513
|
id: uuid(),
|
|
@@ -2558,13 +2525,14 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
|
|
|
2558
2525
|
});
|
|
2559
2526
|
clearSelection();
|
|
2560
2527
|
try {
|
|
2561
|
-
await (onTagAdded == null ? void 0 :
|
|
2528
|
+
await ((_a = options.onTagAdded) == null ? void 0 : _a.call(options, newTag));
|
|
2562
2529
|
} catch (error2) {
|
|
2563
2530
|
console.error("Failed to add tag:", error2);
|
|
2564
2531
|
setTags((prev) => prev.filter((t) => t.id !== newTag.id));
|
|
2565
2532
|
}
|
|
2566
2533
|
};
|
|
2567
2534
|
const removeTag = async (e, id) => {
|
|
2535
|
+
var _a;
|
|
2568
2536
|
e.stopPropagation();
|
|
2569
2537
|
e.preventDefault();
|
|
2570
2538
|
const tagToRemove = tags.find((t) => t.id === id);
|
|
@@ -2572,7 +2540,7 @@ function useScriptBreakdownScene(scene_url, fetchOptions, onAISummarize, onTagAd
|
|
|
2572
2540
|
setTags((prev) => prev.filter((t) => t.id !== id));
|
|
2573
2541
|
clearSelection();
|
|
2574
2542
|
try {
|
|
2575
|
-
await (onTagRemoved == null ? void 0 :
|
|
2543
|
+
await ((_a = options.onTagRemoved) == null ? void 0 : _a.call(options, id));
|
|
2576
2544
|
} catch (error2) {
|
|
2577
2545
|
console.error("Failed to remove tag:", error2);
|
|
2578
2546
|
setTags((prev) => [...prev, tagToRemove]);
|