@vishu1301/script-writing 1.5.5 → 1.5.8

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
@@ -330,4 +330,22 @@ declare const scene_types: {
330
330
  name: string;
331
331
  }[];
332
332
 
333
- export { type Block, type BlockType, CATEGORIES, type Camera, type ElementCategory, ScreenplayEditorView, type ScriptBreakdown, ScriptBreakdownSceneView, type Shot, type ShotBreakdown, ShotBreakdownView, type ShotPart, type Tag, type TimeOfDay, aperture_options, blockStyles, blockTypes, camera_angles, camera_movements, camera_supports, convertBlocksToSbx, fps_options, handleSaveAsPdf, handleSyncWithCloud, icons, lens_options, scene_types, shot_types, timeOfDayOptions, useScreenplayEditor, useScriptBreakdownScene, useShotBreakdownScene, uuid, vfx_types };
333
+ declare function SceneScriptView({ blocks, isLoading, sceneNumber, title, }: {
334
+ blocks: Block[];
335
+ isLoading?: boolean;
336
+ sceneNumber?: string;
337
+ title?: string;
338
+ }): react_jsx_runtime.JSX.Element;
339
+
340
+ interface UseSceneScriptOptions {
341
+ scene_url: string;
342
+ fetchOptions?: RequestInit;
343
+ }
344
+ declare function useSceneScript(options: UseSceneScriptOptions): {
345
+ blocks: Block[];
346
+ isLoading: boolean;
347
+ error: string | null;
348
+ sceneContent: string | null;
349
+ };
350
+
351
+ export { type Block, type BlockType, CATEGORIES, type Camera, type ElementCategory, SceneScriptView, ScreenplayEditorView, type ScriptBreakdown, ScriptBreakdownSceneView, type Shot, type ShotBreakdown, ShotBreakdownView, type ShotPart, type Tag, type TimeOfDay, aperture_options, blockStyles, blockTypes, camera_angles, camera_movements, camera_supports, convertBlocksToSbx, fps_options, handleSaveAsPdf, handleSyncWithCloud, icons, lens_options, scene_types, shot_types, timeOfDayOptions, useSceneScript, useScreenplayEditor, useScriptBreakdownScene, useShotBreakdownScene, uuid, vfx_types };
package/dist/index.d.ts CHANGED
@@ -330,4 +330,22 @@ declare const scene_types: {
330
330
  name: string;
331
331
  }[];
332
332
 
333
- export { type Block, type BlockType, CATEGORIES, type Camera, type ElementCategory, ScreenplayEditorView, type ScriptBreakdown, ScriptBreakdownSceneView, type Shot, type ShotBreakdown, ShotBreakdownView, type ShotPart, type Tag, type TimeOfDay, aperture_options, blockStyles, blockTypes, camera_angles, camera_movements, camera_supports, convertBlocksToSbx, fps_options, handleSaveAsPdf, handleSyncWithCloud, icons, lens_options, scene_types, shot_types, timeOfDayOptions, useScreenplayEditor, useScriptBreakdownScene, useShotBreakdownScene, uuid, vfx_types };
333
+ declare function SceneScriptView({ blocks, isLoading, sceneNumber, title, }: {
334
+ blocks: Block[];
335
+ isLoading?: boolean;
336
+ sceneNumber?: string;
337
+ title?: string;
338
+ }): react_jsx_runtime.JSX.Element;
339
+
340
+ interface UseSceneScriptOptions {
341
+ scene_url: string;
342
+ fetchOptions?: RequestInit;
343
+ }
344
+ declare function useSceneScript(options: UseSceneScriptOptions): {
345
+ blocks: Block[];
346
+ isLoading: boolean;
347
+ error: string | null;
348
+ sceneContent: string | null;
349
+ };
350
+
351
+ export { type Block, type BlockType, CATEGORIES, type Camera, type ElementCategory, SceneScriptView, ScreenplayEditorView, type ScriptBreakdown, ScriptBreakdownSceneView, type Shot, type ShotBreakdown, ShotBreakdownView, type ShotPart, type Tag, type TimeOfDay, aperture_options, blockStyles, blockTypes, camera_angles, camera_movements, camera_supports, convertBlocksToSbx, fps_options, handleSaveAsPdf, handleSyncWithCloud, icons, lens_options, scene_types, shot_types, timeOfDayOptions, useSceneScript, useScreenplayEditor, useScriptBreakdownScene, useShotBreakdownScene, uuid, vfx_types };
package/dist/index.js CHANGED
@@ -6259,7 +6259,180 @@ function useShotBreakdownScene(options) {
6259
6259
  menuRef
6260
6260
  };
6261
6261
  }
6262
+ function SceneScriptView({
6263
+ blocks,
6264
+ isLoading = false,
6265
+ sceneNumber,
6266
+ title
6267
+ }) {
6268
+ const COURIER_STACK = "'Courier Prime', 'Courier', monospace";
6269
+ useEffect(() => {
6270
+ const fontId = "google-font-courier-prime";
6271
+ const styleId = "screenplay-editor-force-v4";
6272
+ if (!document.getElementById(fontId)) {
6273
+ const link = document.createElement("link");
6274
+ link.id = fontId;
6275
+ link.rel = "stylesheet";
6276
+ link.href = "https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&display=swap";
6277
+ document.head.appendChild(link);
6278
+ }
6279
+ if (!document.getElementById(styleId)) {
6280
+ const style = document.createElement("style");
6281
+ style.id = styleId;
6282
+ style.textContent = `
6283
+ [data-scene-script-view] *,
6284
+ [data-scene-script-view] div,
6285
+ [data-scene-script-view] span {
6286
+ font-family: ${COURIER_STACK} !important;
6287
+ -webkit-font-smoothing: antialiased;
6288
+ }
6289
+ `;
6290
+ document.head.appendChild(style);
6291
+ }
6292
+ }, [COURIER_STACK]);
6293
+ if (isLoading) {
6294
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-32 gap-4", children: [
6295
+ /* @__PURE__ */ jsx(Loader2, { className: "w-8 h-8 animate-spin text-zinc-400" }),
6296
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-zinc-500 animate-pulse", children: "Loading script..." })
6297
+ ] });
6298
+ }
6299
+ return /* @__PURE__ */ jsx(
6300
+ "div",
6301
+ {
6302
+ className: "relative bg-[#fdfdfc] shadow-[0_10px_30px_rgba(0,0,0,0.04),0_1px_8px_rgba(0,0,0,0.02)] border border-zinc-100 rounded-sm md:rounded-md flex flex-col w-full max-w-[210mm] min-h-auto shrink-0 pb-24",
6303
+ style: {
6304
+ fontFamily: COURIER_STACK,
6305
+ paddingLeft: "1.5in",
6306
+ paddingRight: "1in",
6307
+ paddingTop: "1in",
6308
+ paddingBottom: "1in",
6309
+ lineHeight: "1.2"
6310
+ },
6311
+ "data-scene-script-view": "true",
6312
+ children: blocks.map((block) => /* @__PURE__ */ jsx(
6313
+ "div",
6314
+ {
6315
+ className: `relative break-words w-full px-4 py-2 ${blockStyles[block.type].className}`,
6316
+ style: __spreadProps(__spreadValues({}, blockStyles[block.type].inputStyle), {
6317
+ minHeight: "1.5rem"
6318
+ }),
6319
+ children: block.type === "SCENE_HEADING" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6320
+ block.sceneNumber && /* @__PURE__ */ jsx("span", { className: "absolute -left-16 text-zinc-400 font-bold select-none", children: block.sceneNumber }),
6321
+ block.sceneType && /* @__PURE__ */ jsx("span", { className: "font-bold", children: block.sceneType }),
6322
+ /* @__PURE__ */ jsx("span", { className: "font-bold", children: block.text }),
6323
+ block.timeOfDay && /* @__PURE__ */ jsxs(Fragment, { children: [
6324
+ /* @__PURE__ */ jsx("span", { className: "text-zinc-400", children: "-" }),
6325
+ /* @__PURE__ */ jsx("span", { className: "font-bold", children: block.timeOfDay })
6326
+ ] })
6327
+ ] }) : block.text
6328
+ },
6329
+ block.id
6330
+ ))
6331
+ }
6332
+ );
6333
+ }
6334
+ function useSceneScript(options) {
6335
+ const [sceneContent, setSceneContent] = useState(null);
6336
+ const [isLoading, setIsLoading] = useState(true);
6337
+ const [error, setError] = useState(null);
6338
+ useEffect(() => {
6339
+ let isMounted = true;
6340
+ setIsLoading(true);
6341
+ setError(null);
6342
+ const fetchScene = async () => {
6343
+ try {
6344
+ const response = await fetch(options.scene_url, options.fetchOptions);
6345
+ if (response.ok) {
6346
+ const text = await response.text();
6347
+ if (isMounted) {
6348
+ setSceneContent(text);
6349
+ }
6350
+ } else {
6351
+ if (isMounted) {
6352
+ setError(`Failed to fetch scene: ${response.statusText}`);
6353
+ }
6354
+ }
6355
+ } catch (err) {
6356
+ if (isMounted) {
6357
+ setError(err instanceof Error ? err.message : "An unknown error occurred");
6358
+ }
6359
+ } finally {
6360
+ if (isMounted) {
6361
+ setIsLoading(false);
6362
+ }
6363
+ }
6364
+ };
6365
+ fetchScene();
6366
+ return () => {
6367
+ isMounted = false;
6368
+ };
6369
+ }, [options.scene_url]);
6370
+ const blocks = useMemo(() => {
6371
+ if (!sceneContent) return [];
6372
+ const parser = new DOMParser();
6373
+ const doc = parser.parseFromString(sceneContent, "text/html");
6374
+ const divs = Array.from(doc.querySelectorAll("div"));
6375
+ const parsedBlocks = [];
6376
+ const typeMap = {
6377
+ divtype0: "SCENE_HEADING",
6378
+ divtype2: "ACTION",
6379
+ divtype3: "CHARACTER",
6380
+ divtype4: "PARENTHETICAL",
6381
+ divtype5: "DIALOGUE",
6382
+ divtype6: "TRANSITION"
6383
+ };
6384
+ divs.forEach((div) => {
6385
+ var _a;
6386
+ const divText = ((_a = div.textContent) == null ? void 0 : _a.trim()) || "";
6387
+ if (!divText && !div.classList.contains("divtype0")) return;
6388
+ let type = "ACTION";
6389
+ for (const className of Array.from(div.classList)) {
6390
+ if (typeMap[className]) {
6391
+ type = typeMap[className];
6392
+ break;
6393
+ }
6394
+ }
6395
+ const idAttr = div.getAttribute("id");
6396
+ const blockId = idAttr && idAttr.startsWith("par") ? idAttr.substring(3) : idAttr || uuid();
6397
+ let sceneNumber;
6398
+ let sceneType;
6399
+ let timeOfDay;
6400
+ let blockText = divText;
6401
+ if (type === "SCENE_HEADING") {
6402
+ const typeMatch = blockText.match(/^(INT\.?\/EXT\.?|INT\.?|EXT\.?|I\/E)\s+/i);
6403
+ if (typeMatch) {
6404
+ const matchedType = typeMatch[1].toUpperCase();
6405
+ if (matchedType.includes("INT") && matchedType.includes("EXT")) sceneType = "INT/EXT.";
6406
+ else if (matchedType.includes("EXT")) sceneType = "EXT.";
6407
+ else sceneType = "INT.";
6408
+ blockText = blockText.substring(typeMatch[0].length).trim();
6409
+ }
6410
+ const timeMatch = blockText.match(/\s+-\s+(DAY|NIGHT|MORNING|EVENING|AFTERNOON|LATER|MOMENTS LATER|CONTINUOUS)$/i);
6411
+ if (timeMatch) {
6412
+ timeOfDay = timeMatch[1].toUpperCase();
6413
+ blockText = blockText.substring(0, timeMatch.index).trim();
6414
+ }
6415
+ blockText = blockText.replace(/^-+\s*|\s*-+$/g, "").trim();
6416
+ }
6417
+ parsedBlocks.push({
6418
+ id: blockId,
6419
+ type,
6420
+ text: blockText,
6421
+ sceneNumber,
6422
+ sceneType,
6423
+ timeOfDay
6424
+ });
6425
+ });
6426
+ return parsedBlocks;
6427
+ }, [sceneContent]);
6428
+ return {
6429
+ blocks,
6430
+ isLoading,
6431
+ error,
6432
+ sceneContent
6433
+ };
6434
+ }
6262
6435
 
6263
- export { CATEGORIES, ScreenplayEditorView, ScriptBreakdownSceneView, ShotBreakdownView, aperture_options, blockStyles, blockTypes, camera_angles, camera_movements, camera_supports, convertBlocksToSbx, fps_options, handleSaveAsPdf, handleSyncWithCloud, icons, lens_options, scene_types, shot_types, timeOfDayOptions, useScreenplayEditor, useScriptBreakdownScene, useShotBreakdownScene, uuid, vfx_types };
6436
+ export { CATEGORIES, SceneScriptView, ScreenplayEditorView, ScriptBreakdownSceneView, ShotBreakdownView, aperture_options, blockStyles, blockTypes, camera_angles, camera_movements, camera_supports, convertBlocksToSbx, fps_options, handleSaveAsPdf, handleSyncWithCloud, icons, lens_options, scene_types, shot_types, timeOfDayOptions, useSceneScript, useScreenplayEditor, useScriptBreakdownScene, useShotBreakdownScene, uuid, vfx_types };
6264
6437
  //# sourceMappingURL=index.js.map
6265
6438
  //# sourceMappingURL=index.js.map