jbilcke-hf HF staff commited on
Commit
7fd8bde
·
1 Parent(s): 3e3029e

upgrade libs

Browse files
package-lock.json CHANGED
@@ -8,8 +8,8 @@
8
  "name": "@jbilcke-hf/ai-stories-factory",
9
  "version": "0.0.0",
10
  "dependencies": {
11
- "@aitube/clap": "0.0.10",
12
- "@aitube/client": "0.0.15",
13
  "@radix-ui/react-accordion": "^1.1.2",
14
  "@radix-ui/react-avatar": "^1.0.4",
15
  "@radix-ui/react-checkbox": "^1.0.4",
@@ -65,9 +65,9 @@
65
  }
66
  },
67
  "node_modules/@aitube/clap": {
68
- "version": "0.0.10",
69
- "resolved": "https://registry.npmjs.org/@aitube/clap/-/clap-0.0.10.tgz",
70
- "integrity": "sha512-pj855yWhUJ0QTJIaxMJhg0PwC3JaHsScJ5rQ8iqog7zDBWNNJR9MPBtFDYRuIs3vmUsGVxHwSlIBz5I1VjMF8w==",
71
  "dependencies": {
72
  "pure-uuid": "^1.8.1",
73
  "yaml": "^2.4.1"
@@ -77,14 +77,14 @@
77
  }
78
  },
79
  "node_modules/@aitube/client": {
80
- "version": "0.0.15",
81
- "resolved": "https://registry.npmjs.org/@aitube/client/-/client-0.0.15.tgz",
82
- "integrity": "sha512-lGmdsBqjNVStBxZSH+Iig/nOyPdSpqpqU6M0OvOBMTwR4rohSvIQ7TnFJGvoc4WEFciNoCc6Vg6Q5W99ovG+fg==",
83
  "dependencies": {
84
  "query-string": "^9.0.0"
85
  },
86
  "peerDependencies": {
87
- "@aitube/clap": "0.0.10"
88
  }
89
  },
90
  "node_modules/@alloc/quick-lru": {
@@ -3742,9 +3742,9 @@
3742
  "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
3743
  },
3744
  "node_modules/electron-to-chromium": {
3745
- "version": "1.4.756",
3746
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.756.tgz",
3747
- "integrity": "sha512-RJKZ9+vEBMeiPAvKNWyZjuYyUqMndcP1f335oHqn3BEQbs2NFtVrnK5+6Xg5wSM9TknNNpWghGDUCKGYF+xWXw=="
3748
  },
3749
  "node_modules/emoji-regex": {
3750
  "version": "9.2.2",
@@ -3752,9 +3752,9 @@
3752
  "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
3753
  },
3754
  "node_modules/enhanced-resolve": {
3755
- "version": "5.16.0",
3756
- "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.0.tgz",
3757
- "integrity": "sha512-O+QWCviPNSSLAD9Ucn8Awv+poAkqn3T1XY5/N7kR7rQO9yfSGWkYZDwpJ+iKF7B8rxaQKWngSqACpgzeapSyoA==",
3758
  "dependencies": {
3759
  "graceful-fs": "^4.2.4",
3760
  "tapable": "^2.2.0"
@@ -4596,9 +4596,9 @@
4596
  }
4597
  },
4598
  "node_modules/get-tsconfig": {
4599
- "version": "4.7.3",
4600
- "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.3.tgz",
4601
- "integrity": "sha512-ZvkrzoUA0PQZM6fy6+/Hce561s+faD1rsNwhnO5FelNjyy7EMGJ3Rz1AQ8GYDWjhRs/7dBLOEJvhK8MiEJOAFg==",
4602
  "dependencies": {
4603
  "resolve-pkg-maps": "^1.0.0"
4604
  },
@@ -6380,9 +6380,9 @@
6380
  }
6381
  },
6382
  "node_modules/react-icons": {
6383
- "version": "5.2.0",
6384
- "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.0.tgz",
6385
- "integrity": "sha512-n52Y7Eb4MgQZHsSZOhSXv1zs2668/hBYKfSRIvKh42yExjyhZu0d1IK2CLLZ3BZB1oo13lDfwx2vOh2z9FTV6Q==",
6386
  "peerDependencies": {
6387
  "react": "*"
6388
  }
 
8
  "name": "@jbilcke-hf/ai-stories-factory",
9
  "version": "0.0.0",
10
  "dependencies": {
11
+ "@aitube/clap": "0.0.14",
12
+ "@aitube/client": "0.0.17",
13
  "@radix-ui/react-accordion": "^1.1.2",
14
  "@radix-ui/react-avatar": "^1.0.4",
15
  "@radix-ui/react-checkbox": "^1.0.4",
 
65
  }
66
  },
67
  "node_modules/@aitube/clap": {
68
+ "version": "0.0.14",
69
+ "resolved": "https://registry.npmjs.org/@aitube/clap/-/clap-0.0.14.tgz",
70
+ "integrity": "sha512-i4mq3YFecWVOTS/p5QaSQ0VJfurKXlyRc8FJMqKI6P/7rpf4vE4IL+jBKa4HPsYeNt85/KOt3MJKEFVtgiWGfQ==",
71
  "dependencies": {
72
  "pure-uuid": "^1.8.1",
73
  "yaml": "^2.4.1"
 
77
  }
78
  },
79
  "node_modules/@aitube/client": {
80
+ "version": "0.0.17",
81
+ "resolved": "https://registry.npmjs.org/@aitube/client/-/client-0.0.17.tgz",
82
+ "integrity": "sha512-waRA1k2pqKI7uOXUnBs6y056JY2h7LO+kzKDcHBiNSAyC0ZvSvP7VqTia2fxpF99rik6HgmC3N0AslObP4T6Zw==",
83
  "dependencies": {
84
  "query-string": "^9.0.0"
85
  },
86
  "peerDependencies": {
87
+ "@aitube/clap": "0.0.14"
88
  }
89
  },
90
  "node_modules/@alloc/quick-lru": {
 
3742
  "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
3743
  },
3744
  "node_modules/electron-to-chromium": {
3745
+ "version": "1.4.757",
3746
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.757.tgz",
3747
+ "integrity": "sha512-jftDaCknYSSt/+KKeXzH3LX5E2CvRLm75P3Hj+J/dv3CL0qUYcOt13d5FN1NiL5IJbbhzHrb3BomeG2tkSlZmw=="
3748
  },
3749
  "node_modules/emoji-regex": {
3750
  "version": "9.2.2",
 
3752
  "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
3753
  },
3754
  "node_modules/enhanced-resolve": {
3755
+ "version": "5.16.1",
3756
+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.1.tgz",
3757
+ "integrity": "sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw==",
3758
  "dependencies": {
3759
  "graceful-fs": "^4.2.4",
3760
  "tapable": "^2.2.0"
 
4596
  }
4597
  },
4598
  "node_modules/get-tsconfig": {
4599
+ "version": "4.7.4",
4600
+ "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.4.tgz",
4601
+ "integrity": "sha512-ofbkKj+0pjXjhejr007J/fLf+sW+8H7K5GCm+msC8q3IpvgjobpyPqSRFemNyIMxklC0zeJpi7VDFna19FacvQ==",
4602
  "dependencies": {
4603
  "resolve-pkg-maps": "^1.0.0"
4604
  },
 
6380
  }
6381
  },
6382
  "node_modules/react-icons": {
6383
+ "version": "5.2.1",
6384
+ "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz",
6385
+ "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==",
6386
  "peerDependencies": {
6387
  "react": "*"
6388
  }
package.json CHANGED
@@ -9,8 +9,8 @@
9
  "lint": "next lint"
10
  },
11
  "dependencies": {
12
- "@aitube/clap": "0.0.10",
13
- "@aitube/client": "0.0.15",
14
  "@radix-ui/react-accordion": "^1.1.2",
15
  "@radix-ui/react-avatar": "^1.0.4",
16
  "@radix-ui/react-checkbox": "^1.0.4",
 
9
  "lint": "next lint"
10
  },
11
  "dependencies": {
12
+ "@aitube/clap": "0.0.14",
13
+ "@aitube/client": "0.0.17",
14
  "@radix-ui/react-accordion": "^1.1.2",
15
  "@radix-ui/react-avatar": "^1.0.4",
16
  "@radix-ui/react-checkbox": "^1.0.4",
src/app/main.tsx CHANGED
@@ -2,7 +2,7 @@
2
 
3
  import React, { useEffect, useRef, useTransition } from 'react'
4
  import { IoMdPhonePortrait } from 'react-icons/io'
5
- import { ClapProject } from '@aitube/clap'
6
  import Image from 'next/image'
7
  import { useFilePicker } from 'use-file-picker'
8
  import { DeviceFrameset } from 'react-device-frameset'
@@ -26,7 +26,6 @@ import { fileToBase64 } from '@/lib/base64/fileToBase64'
26
  import { Input } from '@/components/ui/input'
27
  import { Field } from '@/components/form/field'
28
  import { Label } from '@/components/form/label'
29
- import { VideoOrientation } from './types'
30
  import { getParam } from '@/lib/utils/getParam'
31
 
32
  export function Main() {
@@ -319,9 +318,9 @@ export function Main() {
319
 
320
  // note: we are interested in the *current* video orientation,
321
  // not the requested video orientation requested for the next video
322
- const isLandscape = currentVideoOrientation === VideoOrientation.LANDSCAPE
323
- const isPortrait = currentVideoOrientation === VideoOrientation.PORTRAIT
324
- const isSquare = currentVideoOrientation === VideoOrientation.SQUARE
325
 
326
  return (
327
  <div className={cn(
@@ -593,7 +592,7 @@ export function Main() {
593
  >
594
  <div className={cn(
595
  `transition-all duration-200 ease-in-out`,
596
- orientation === VideoOrientation.LANDSCAPE ? `rotate-90` : `rotate-0`
597
  )}>
598
  <IoMdPhonePortrait size={24} />
599
  </div>
 
2
 
3
  import React, { useEffect, useRef, useTransition } from 'react'
4
  import { IoMdPhonePortrait } from 'react-icons/io'
5
+ import { ClapProject, ClapMediaOrientation } from '@aitube/clap'
6
  import Image from 'next/image'
7
  import { useFilePicker } from 'use-file-picker'
8
  import { DeviceFrameset } from 'react-device-frameset'
 
26
  import { Input } from '@/components/ui/input'
27
  import { Field } from '@/components/form/field'
28
  import { Label } from '@/components/form/label'
 
29
  import { getParam } from '@/lib/utils/getParam'
30
 
31
  export function Main() {
 
318
 
319
  // note: we are interested in the *current* video orientation,
320
  // not the requested video orientation requested for the next video
321
+ const isLandscape = currentVideoOrientation === ClapMediaOrientation.LANDSCAPE
322
+ const isPortrait = currentVideoOrientation === ClapMediaOrientation.PORTRAIT
323
+ const isSquare = currentVideoOrientation === ClapMediaOrientation.SQUARE
324
 
325
  return (
326
  <div className={cn(
 
592
  >
593
  <div className={cn(
594
  `transition-all duration-200 ease-in-out`,
595
+ orientation === ClapMediaOrientation.LANDSCAPE ? `rotate-90` : `rotate-0`
596
  )}>
597
  <IoMdPhonePortrait size={24} />
598
  </div>
src/app/server/aitube/createClap.ts CHANGED
@@ -1,25 +1,23 @@
1
  "use server"
2
 
3
- import { ClapProject } from "@aitube/clap"
4
  import { createClap as apiCreateClap } from "@aitube/client"
5
 
6
- import { VideoOrientation } from "../../types"
7
-
8
  import { getToken } from "./getToken"
9
  import { RESOLUTION_LONG, RESOLUTION_SHORT } from "./config"
10
 
11
  export async function createClap({
12
  prompt = "",
13
- orientation = VideoOrientation.PORTRAIT,
14
  }: {
15
  prompt: string
16
- orientation: VideoOrientation
17
  }): Promise<ClapProject> {
18
  const clap: ClapProject = await apiCreateClap({
19
  prompt,
20
 
21
- height: orientation === VideoOrientation.PORTRAIT ? RESOLUTION_LONG : RESOLUTION_SHORT,
22
- width: orientation === VideoOrientation.PORTRAIT ? RESOLUTION_SHORT : RESOLUTION_LONG,
23
 
24
  token: await getToken()
25
  })
 
1
  "use server"
2
 
3
+ import { ClapProject, ClapMediaOrientation } from "@aitube/clap"
4
  import { createClap as apiCreateClap } from "@aitube/client"
5
 
 
 
6
  import { getToken } from "./getToken"
7
  import { RESOLUTION_LONG, RESOLUTION_SHORT } from "./config"
8
 
9
  export async function createClap({
10
  prompt = "",
11
+ orientation = ClapMediaOrientation.PORTRAIT,
12
  }: {
13
  prompt: string
14
+ orientation: ClapMediaOrientation
15
  }): Promise<ClapProject> {
16
  const clap: ClapProject = await apiCreateClap({
17
  prompt,
18
 
19
+ height: orientation === ClapMediaOrientation.PORTRAIT ? RESOLUTION_LONG : RESOLUTION_SHORT,
20
+ width: orientation === ClapMediaOrientation.PORTRAIT ? RESOLUTION_SHORT : RESOLUTION_LONG,
21
 
22
  token: await getToken()
23
  })
src/app/store.ts CHANGED
@@ -1,13 +1,11 @@
1
  "use client"
2
 
3
- import { ClapProject, parseClap, serializeClap } from "@aitube/clap"
4
  import { create } from "zustand"
5
 
6
  import { GlobalStatus, TaskStatus } from "@/types"
7
  import { getVideoOrientation } from "@/lib/utils/getVideoOrientation"
8
- import { parseVideoOrientation } from "@/lib/utils/parseVideoOrientation"
9
 
10
- import { VideoOrientation } from "./types"
11
  import { RESOLUTION_LONG, RESOLUTION_SHORT } from "./server/aitube/config"
12
 
13
  export const useStore = create<{
@@ -18,7 +16,7 @@ export const useStore = create<{
18
 
19
  // the desired orientation for the next video
20
  // but this won't impact the actual orientation of the fake device container
21
- orientation: VideoOrientation
22
 
23
  status: GlobalStatus
24
  parseGenerationStatus: TaskStatus
@@ -32,11 +30,11 @@ export const useStore = create<{
32
 
33
  // orientation of the currently loaded video (which can be different from `orientation`)
34
  // it will impact the actual orientation of the fake device container
35
- currentVideoOrientation: VideoOrientation
36
  progress: number
37
  error: string
38
  toggleOrientation: () => void
39
- setCurrentVideoOrientation: (currentVideoOrientation: VideoOrientation) => void
40
  setMainCharacterImage: (mainCharacterImage: string) => void
41
  setMainCharacterVoice: (mainCharacterVoice: string) => void
42
  setStoryPromptDraft: (storyPromptDraft: string) => void
@@ -62,7 +60,7 @@ export const useStore = create<{
62
  mainCharacterVoice: "",
63
  storyPromptDraft: "Yesterday I was at my favorite pizza place and..",
64
  storyPrompt: "",
65
- orientation: VideoOrientation.PORTRAIT,
66
  status: "idle",
67
  parseGenerationStatus: "idle",
68
  storyGenerationStatus: "idle",
@@ -72,15 +70,15 @@ export const useStore = create<{
72
  videoGenerationStatus: "idle",
73
  currentClap: undefined,
74
  currentVideo: "",
75
- currentVideoOrientation: VideoOrientation.PORTRAIT,
76
  progress: 0,
77
  error: "",
78
  toggleOrientation: () => {
79
  const { orientation: previousOrientation, currentVideoOrientation, currentVideo } = get()
80
  const orientation =
81
- previousOrientation === VideoOrientation.LANDSCAPE
82
- ? VideoOrientation.PORTRAIT
83
- : VideoOrientation.LANDSCAPE
84
 
85
  set({
86
  orientation,
@@ -92,7 +90,7 @@ export const useStore = create<{
92
  : orientation
93
  })
94
  },
95
- setCurrentVideoOrientation: (currentVideoOrientation: VideoOrientation) => { set({ currentVideoOrientation }) },
96
  setMainCharacterImage: (mainCharacterImage: string) => { set({ mainCharacterImage }) },
97
  setMainCharacterVoice: (mainCharacterVoice: string) => { set({ mainCharacterVoice }) },
98
  setStoryPromptDraft: (storyPromptDraft: string) => { set({ storyPromptDraft }) },
@@ -161,8 +159,8 @@ export const useStore = create<{
161
  // let's use the UI settings for now
162
  const { orientation } = get()
163
 
164
- currentClap.meta.height = orientation === VideoOrientation.LANDSCAPE ? RESOLUTION_SHORT : RESOLUTION_LONG
165
- currentClap.meta.width = orientation === VideoOrientation.PORTRAIT ? RESOLUTION_SHORT : RESOLUTION_LONG
166
 
167
  set({
168
  currentClap,
 
1
  "use client"
2
 
3
+ import { ClapProject, parseClap, serializeClap, ClapMediaOrientation } from "@aitube/clap"
4
  import { create } from "zustand"
5
 
6
  import { GlobalStatus, TaskStatus } from "@/types"
7
  import { getVideoOrientation } from "@/lib/utils/getVideoOrientation"
 
8
 
 
9
  import { RESOLUTION_LONG, RESOLUTION_SHORT } from "./server/aitube/config"
10
 
11
  export const useStore = create<{
 
16
 
17
  // the desired orientation for the next video
18
  // but this won't impact the actual orientation of the fake device container
19
+ orientation: ClapMediaOrientation
20
 
21
  status: GlobalStatus
22
  parseGenerationStatus: TaskStatus
 
30
 
31
  // orientation of the currently loaded video (which can be different from `orientation`)
32
  // it will impact the actual orientation of the fake device container
33
+ currentVideoOrientation: ClapMediaOrientation
34
  progress: number
35
  error: string
36
  toggleOrientation: () => void
37
+ setCurrentVideoOrientation: (currentVideoOrientation: ClapMediaOrientation) => void
38
  setMainCharacterImage: (mainCharacterImage: string) => void
39
  setMainCharacterVoice: (mainCharacterVoice: string) => void
40
  setStoryPromptDraft: (storyPromptDraft: string) => void
 
60
  mainCharacterVoice: "",
61
  storyPromptDraft: "Yesterday I was at my favorite pizza place and..",
62
  storyPrompt: "",
63
+ orientation: ClapMediaOrientation.PORTRAIT,
64
  status: "idle",
65
  parseGenerationStatus: "idle",
66
  storyGenerationStatus: "idle",
 
70
  videoGenerationStatus: "idle",
71
  currentClap: undefined,
72
  currentVideo: "",
73
+ currentVideoOrientation: ClapMediaOrientation.PORTRAIT,
74
  progress: 0,
75
  error: "",
76
  toggleOrientation: () => {
77
  const { orientation: previousOrientation, currentVideoOrientation, currentVideo } = get()
78
  const orientation =
79
+ previousOrientation === ClapMediaOrientation.LANDSCAPE
80
+ ? ClapMediaOrientation.PORTRAIT
81
+ : ClapMediaOrientation.LANDSCAPE
82
 
83
  set({
84
  orientation,
 
90
  : orientation
91
  })
92
  },
93
+ setCurrentVideoOrientation: (currentVideoOrientation: ClapMediaOrientation) => { set({ currentVideoOrientation }) },
94
  setMainCharacterImage: (mainCharacterImage: string) => { set({ mainCharacterImage }) },
95
  setMainCharacterVoice: (mainCharacterVoice: string) => { set({ mainCharacterVoice }) },
96
  setStoryPromptDraft: (storyPromptDraft: string) => { set({ storyPromptDraft }) },
 
159
  // let's use the UI settings for now
160
  const { orientation } = get()
161
 
162
+ currentClap.meta.height = orientation === ClapMediaOrientation.LANDSCAPE ? RESOLUTION_SHORT : RESOLUTION_LONG
163
+ currentClap.meta.width = orientation === ClapMediaOrientation.PORTRAIT ? RESOLUTION_SHORT : RESOLUTION_LONG
164
 
165
  set({
166
  currentClap,
src/app/types.ts DELETED
@@ -1,5 +0,0 @@
1
- export enum VideoOrientation {
2
- PORTRAIT = "portrait",
3
- LANDSCAPE = "landscape",
4
- SQUARE = "square"
5
- }
 
 
 
 
 
 
src/lib/utils/getVideoOrientation.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { VideoOrientation } from "@/app/types"
2
 
3
  /**
4
  * Determine the video orientation from a video URL (data-uri or hosted)
@@ -6,14 +6,14 @@ import { VideoOrientation } from "@/app/types"
6
  * @param url
7
  * @returns
8
  */
9
- export async function getVideoOrientation(url: string): Promise<VideoOrientation> {
10
- return new Promise<VideoOrientation>(resolve => {
11
  const video = document.createElement('video')
12
  video.addEventListener( "loadedmetadata", function () {
13
  resolve(
14
- this.videoHeight < this.videoWidth ? VideoOrientation.LANDSCAPE :
15
- this.videoHeight > this.videoWidth ? VideoOrientation.PORTRAIT :
16
- VideoOrientation.SQUARE
17
  )
18
  }, false)
19
  video.src = url
 
1
+ import { ClapMediaOrientation } from "@aitube/clap"
2
 
3
  /**
4
  * Determine the video orientation from a video URL (data-uri or hosted)
 
6
  * @param url
7
  * @returns
8
  */
9
+ export async function getVideoOrientation(url: string): Promise<ClapMediaOrientation> {
10
+ return new Promise<ClapMediaOrientation>(resolve => {
11
  const video = document.createElement('video')
12
  video.addEventListener( "loadedmetadata", function () {
13
  resolve(
14
+ this.videoHeight < this.videoWidth ? ClapMediaOrientation.LANDSCAPE :
15
+ this.videoHeight > this.videoWidth ? ClapMediaOrientation.PORTRAIT :
16
+ ClapMediaOrientation.SQUARE
17
  )
18
  }, false)
19
  video.src = url
src/lib/utils/parseVideoOrientation.ts DELETED
@@ -1,11 +0,0 @@
1
- import { VideoOrientation } from "@/app/types"
2
-
3
- export function parseVideoOrientation(input?: any): VideoOrientation {
4
- const orientation = `${input || ""}`.trim().toLowerCase() || "square"
5
-
6
- return (
7
- (orientation === "vertical" || orientation === "portrait") ? VideoOrientation.PORTRAIT
8
- : (orientation === "horizontal" || orientation === "landscape") ? VideoOrientation.LANDSCAPE
9
- : VideoOrientation.SQUARE
10
- )
11
- }