Skip to content

Commit

Permalink
tentative fix for sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke-hf committed Jul 27, 2024
1 parent 99e9cb6 commit c5df71e
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 369 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install dependencies
run: npm ci
- name: Install dependencies (with optional dependencies)
run: npm ci --include=optional

- name: Install Playwright
run: npm install @playwright/test@${{ env.PLAYWRIGHT_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN ffmpeg -version
# Copy the current directory contents into the container at /app setting the owner to the user
COPY --chown=user . /app

RUN npm ci
RUN npm ci --include=optional

RUN npm run build:ci

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ If you find that Clapper is working with a more recent (stable) version of Node,
### Installing and running the app

```bash
npm i
npm i --include=optional
npm run dev
```

`--include=optional` is to make sure optional dependencies are installed (pre-build native modules compatible with your system)

### Making sure everything is working properly

There are no tests yet (I will create a ticket for that),
Expand Down
4 changes: 4 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module.exports = {
packagerConfig: {
name: "Clapper",
asar: true,
asarUnpack: [
"**/node_modules/sharp/**/*",
"**/node_modules/@img/**/*"
],
icon: "./public/images/logos/CL.png",
osxSign: {},

Expand Down
398 changes: 194 additions & 204 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@aitube/broadway": "0.1.2",
"@aitube/clap": "0.1.2",
"@aitube/clapper-services": "0.1.2-2",
"@aitube/clapper-services": "0.1.2-4",
"@aitube/engine": "0.1.2",
"@aitube/timeline": "0.1.2-0",
"@fal-ai/serverless-client": "^0.13.0",
Expand Down Expand Up @@ -163,5 +163,25 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.5.0",
"vitest": "^2.0.2"
},
"optionalDependencies": {
"@img/sharp-win32-ia32": "0.33.4",
"@img/sharp-win32-x64": "0.33.4",
"@img/sharp-darwin-arm64": "0.33.4",
"@img/sharp-darwin-x64": "0.33.4",
"@img/sharp-linux-arm": "0.33.4",
"@img/sharp-linux-arm64": "0.33.4",
"@img/sharp-linux-x64": "0.33.4",
"@img/sharp-linuxmusl-x64": "0.33.4",
"@img/sharp-linuxmusl-arm64": "0.33.4",
"@img/sharp-libvips-win32-x64": "1.0.2",
"@img/sharp-libvips-win32-ia32": "1.0.2",
"@img/sharp-libvips-linux-arm": "1.0.2",
"@img/sharp-libvips-linux-x64": "1.0.2",
"@img/sharp-libvips-linux-arm64": "1.0.2",
"@img/sharp-libvips-linuxmusl-x64": "1.0.2",
"@img/sharp-libvips-linuxmusl-arm64": "1.0.2",
"@img/sharp-libvips-darwin-x64": "1.0.2",
"@img/sharp-libvips-darwin-arm64": "1.0.2"
}
}
1 change: 1 addition & 0 deletions src/components/assistant/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function ChatView() {
placeholder="Ask something (a red car, etc)"
value={draft}
onChange={(e) => setDraft(e.target.value)}
className="rounded-none border-t border-none"
onKeyDown={({ key }) => {
if (key === 'Enter') {
handleSubmit()
Expand Down
11 changes: 9 additions & 2 deletions src/components/forms/FormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { cn, getValidNumber, isValidNumber } from '@/lib/utils'
import { Input } from '../ui/input'

import { FormField } from './FormField'
import { useTheme } from '@/services'

export function FormInput<T>(
{
Expand All @@ -24,7 +25,7 @@ export function FormInput<T>(
disabled,
onChange,
type,
// ...props
...props
}: {
label?: ReactNode
className?: string
Expand All @@ -36,10 +37,12 @@ export function FormInput<T>(
disabled?: boolean
onChange?: (newValue: T) => void
type?: HTMLInputTypeAttribute
props?: any
}
// & Omit<ComponentProps<typeof Input>, "value" | "defaultValue" | "placeholder" | "type" | "className" | "disabled" | "onChange">
// & ComponentProps<typeof Input>
) {
const theme = useTheme()
const isNumberInput =
typeof defaultValue === 'number' || typeof value === 'number'

Expand Down Expand Up @@ -100,9 +103,13 @@ export function FormInput<T>(
// {...props}
type={inputType}
value={`${value || defaultValue}`}

// since we are controlling the element with value=*, we should not use defaultValue=*
// defaultValue={`${defaultValue || ""}`}

style={{
borderRadius: theme.formInputRadius || '8px',
}}
{...props}
/>
</FormField>
)
Expand Down
7 changes: 6 additions & 1 deletion src/components/forms/FormLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export function FormLabel({
className?: string
}) {
return (
<label className={cn(`font-mono text-xs text-white/70`, className)}>
<label
className={cn(`font-mono text-xs text-white/80`, className)}
style={{
textShadow: '#000000 0px 0 1px',
}}
>
{children}
</label>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/FormSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function FormSection({
className
)}
>
<h2 className="pb-2 text-xl font-normal text-white/45">{label}</h2>
<h2 className="pb-2 text-xl font-normal text-white/60">{label}</h2>
<div className={cn('flex w-full', 'flex-col space-y-4')}>{children}</div>
</div>
)
Expand Down
8 changes: 8 additions & 0 deletions src/components/forms/FormSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SelectTrigger,
SelectValue,
} from '../ui/select'
import { useTheme } from '@/services'

export function FormSelect<T>({
label,
Expand All @@ -18,6 +19,7 @@ export function FormSelect<T>({
defaultItemLabel,
items = [],
onSelect,
props,
}: {
label?: string
className?: string
Expand All @@ -32,7 +34,9 @@ export function FormSelect<T>({
value: T
}[]
onSelect?: (value?: T) => void
props?: any
}) {
const theme = useTheme()
return (
<FormField
label={
Expand All @@ -54,6 +58,10 @@ export function FormSelect<T>({
onSelect(selectedItem?.value)
}}
defaultValue={selectedItemId}
style={{
borderRadius: theme.formInputRadius || '8px',
}}
{...props}
>
<SelectTrigger className={cn(`w-full`, `font-mono text-xs font-light`)}>
<SelectValue placeholder={selectedItemLabel} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Switch = React.forwardRef<
>
<SwitchPrimitives.Thumb
className={cn(
'pointer-events-none block h-5 w-5 rounded-full bg-white/80 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 dark:bg-neutral-950/60'
'pointer-events-none block h-5 w-5 rounded-full bg-white/40 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 dark:bg-neutral-950/40'
)}
/>
</SwitchPrimitives.Root>
Expand Down
8 changes: 7 additions & 1 deletion src/lib/utils/decodeOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ export async function decodeOutput(input: any): Promise<string> {
? urlOrBase64
: await fetchContentToBase64(urlOrBase64)

if (base64Url.startsWith('data:image/')) {
if (
base64Url.startsWith('data:image/')
) {

if (base64Url.startsWith('data:image/jpeg') || base64Url.startsWith('data:image/jpg')) {
return base64Url
}
// this step is important since some providers store data as PNG,
// which is a unreasonable since a few frames quickly add up to 10 Mb,
// we can't afford to have a 20 Gb .clap file
Expand Down
Loading

0 comments on commit c5df71e

Please sign in to comment.