Julian Bilcke
		
	commited on
		
		
					Commit 
							
							·
						
						61bb967
	
1
								Parent(s):
							
							7edb17c
								
protect the api
Browse files- src/app/interface/bottom-bar/index.tsx +10 -1
 - src/app/interface/panel/index.tsx +5 -0
 - src/app/main.tsx +1 -1
 - src/app/store/index.ts +1 -0
 
    	
        src/app/interface/bottom-bar/index.tsx
    CHANGED
    
    | 
         @@ -17,7 +17,16 @@ export function BottomBar() { 
     | 
|
| 17 | 
         | 
| 18 | 
         
             
              const allStatus = Object.values(panelGenerationStatus)
         
     | 
| 19 | 
         
             
              const remainingImages = allStatus.reduce((acc, s) => (acc + (s ? 1 : 0)), 0)
         
     | 
| 20 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 21 | 
         
             
              const handleShare = async () => {
         
     | 
| 22 | 
         
             
                const dataUrl = await pageToImage()
         
     | 
| 23 | 
         
             
                // console.log("dataUrl:", dataUrl)
         
     | 
| 
         | 
|
| 17 | 
         | 
| 18 | 
         
             
              const allStatus = Object.values(panelGenerationStatus)
         
     | 
| 19 | 
         
             
              const remainingImages = allStatus.reduce((acc, s) => (acc + (s ? 1 : 0)), 0)
         
     | 
| 20 | 
         
            +
              
         
     | 
| 21 | 
         
            +
              /*
         
     | 
| 22 | 
         
            +
              const handleUpscale = () => {
         
     | 
| 23 | 
         
            +
                startTransition(() => {
         
     | 
| 24 | 
         
            +
                  we are blocked here, because we don't know the render id
         
     | 
| 25 | 
         
            +
                  also  we will have to store a state about the 
         
     | 
| 26 | 
         
            +
                })
         
     | 
| 27 | 
         
            +
              }
         
     | 
| 28 | 
         
            +
              */
         
     | 
| 29 | 
         
            +
             
     | 
| 30 | 
         
             
              const handleShare = async () => {
         
     | 
| 31 | 
         
             
                const dataUrl = await pageToImage()
         
     | 
| 32 | 
         
             
                // console.log("dataUrl:", dataUrl)
         
     | 
    	
        src/app/interface/panel/index.tsx
    CHANGED
    
    | 
         @@ -35,6 +35,8 @@ export function Panel({ 
     | 
|
| 35 | 
         
             
              const panels = useStore(state => state.panels)
         
     | 
| 36 | 
         
             
              const prompt = panels[panel] || ""
         
     | 
| 37 | 
         | 
| 
         | 
|
| 
         | 
|
| 38 | 
         
             
              const captions = useStore(state => state.captions)
         
     | 
| 39 | 
         
             
              const caption = captions[panel] || ""
         
     | 
| 40 | 
         | 
| 
         @@ -61,6 +63,8 @@ export function Panel({ 
     | 
|
| 61 | 
         | 
| 62 | 
         
             
                // important: update the status, and clear the scene
         
     | 
| 63 | 
         
             
                setGeneratingImages(panel, true)
         
     | 
| 
         | 
|
| 
         | 
|
| 64 | 
         
             
                setRendered(getInitialRenderedScene())
         
     | 
| 65 | 
         | 
| 66 | 
         
             
                setTimeout(() => {
         
     | 
| 
         @@ -79,6 +83,7 @@ export function Panel({ 
     | 
|
| 79 | 
         
             
                  if (newRendered) {
         
     | 
| 80 | 
         
             
                    // console.log("newRendered:", newRendered)
         
     | 
| 81 | 
         
             
                    setRendered(renderedRef.current = newRendered)
         
     | 
| 
         | 
|
| 82 | 
         | 
| 83 | 
         
             
                    // but we are still loading!
         
     | 
| 84 | 
         
             
                  } else {
         
     | 
| 
         | 
|
| 35 | 
         
             
              const panels = useStore(state => state.panels)
         
     | 
| 36 | 
         
             
              const prompt = panels[panel] || ""
         
     | 
| 37 | 
         | 
| 38 | 
         
            +
              const setRenderedIds = useStore(state => state.setRenderedIds)
         
     | 
| 39 | 
         
            +
             
     | 
| 40 | 
         
             
              const captions = useStore(state => state.captions)
         
     | 
| 41 | 
         
             
              const caption = captions[panel] || ""
         
     | 
| 42 | 
         | 
| 
         | 
|
| 63 | 
         | 
| 64 | 
         
             
                // important: update the status, and clear the scene
         
     | 
| 65 | 
         
             
                setGeneratingImages(panel, true)
         
     | 
| 66 | 
         
            +
             
     | 
| 67 | 
         
            +
                // just to empty it
         
     | 
| 68 | 
         
             
                setRendered(getInitialRenderedScene())
         
     | 
| 69 | 
         | 
| 70 | 
         
             
                setTimeout(() => {
         
     | 
| 
         | 
|
| 83 | 
         
             
                  if (newRendered) {
         
     | 
| 84 | 
         
             
                    // console.log("newRendered:", newRendered)
         
     | 
| 85 | 
         
             
                    setRendered(renderedRef.current = newRendered)
         
     | 
| 86 | 
         
            +
                    // addRenderedScene(newRendered)
         
     | 
| 87 | 
         | 
| 88 | 
         
             
                    // but we are still loading!
         
     | 
| 89 | 
         
             
                  } else {
         
     | 
    	
        src/app/main.tsx
    CHANGED
    
    | 
         @@ -122,7 +122,7 @@ export default function Main() { 
     | 
|
| 122 | 
         
             
                    fonts.actionman.className
         
     | 
| 123 | 
         
             
                  )}>
         
     | 
| 124 | 
         
             
                    <div className={cn(
         
     | 
| 125 | 
         
            -
                      `text-center text-xl text-stone- 
     | 
| 126 | 
         
             
                      isGeneratingStory ? ``: `scale-0 opacity-0`,
         
     | 
| 127 | 
         
             
                      `transition-all duration-300 ease-in-out`,
         
     | 
| 128 | 
         
             
                    )}>
         
     | 
| 
         | 
|
| 122 | 
         
             
                    fonts.actionman.className
         
     | 
| 123 | 
         
             
                  )}>
         
     | 
| 124 | 
         
             
                    <div className={cn(
         
     | 
| 125 | 
         
            +
                      `text-center text-xl text-stone-700 w-[70%]`,
         
     | 
| 126 | 
         
             
                      isGeneratingStory ? ``: `scale-0 opacity-0`,
         
     | 
| 127 | 
         
             
                      `transition-all duration-300 ease-in-out`,
         
     | 
| 128 | 
         
             
                    )}>
         
     | 
    	
        src/app/store/index.ts
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ import { FontName } from "@/lib/fonts" 
     | 
|
| 6 | 
         
             
            import { Preset, PresetName, defaultPreset, getPreset, getRandomPreset } from "@/app/engine/presets"
         
     | 
| 7 | 
         
             
            import { LayoutName, defaultLayout, getRandomLayoutName, getRandomLayoutNames } from "../layouts"
         
     | 
| 8 | 
         
             
            import html2canvas from "html2canvas"
         
     | 
| 
         | 
|
| 9 | 
         | 
| 10 | 
         
             
            export const useStore = create<{
         
     | 
| 11 | 
         
             
              prompt: string
         
     | 
| 
         | 
|
| 6 | 
         
             
            import { Preset, PresetName, defaultPreset, getPreset, getRandomPreset } from "@/app/engine/presets"
         
     | 
| 7 | 
         
             
            import { LayoutName, defaultLayout, getRandomLayoutName, getRandomLayoutNames } from "../layouts"
         
     | 
| 8 | 
         
             
            import html2canvas from "html2canvas"
         
     | 
| 9 | 
         
            +
            import { RenderedScene } from "@/types"
         
     | 
| 10 | 
         | 
| 11 | 
         
             
            export const useStore = create<{
         
     | 
| 12 | 
         
             
              prompt: string
         
     |