1 Commits

Author SHA1 Message Date
dependabot[bot]
c0cf4377a2 Bump tar from 6.1.14 to 6.2.1
Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.14 to 6.2.1.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/isaacs/node-tar/compare/v6.1.14...v6.2.1)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 08:46:42 +00:00
3 changed files with 6 additions and 46 deletions

View File

@@ -191,11 +191,6 @@ export type Plugin<P extends PluginTypeHelper = PluginTypeHelperDefault> = {
StableDiffusionStyle[] | undefined
>;
/** If you want to provide a list of resolutions in pixels to choose from, you can return them via this function and they will be presented as a slider in the UI */
getStableDiffusionAllowedResolutions?: (
model?: ID
) => MaybePromise<{ width: number; height: number }[] | undefined>;
/** Determines the default count passed to `createStableDiffusionImages` */
getStableDiffusionDefaultCount?: () => number | undefined;

View File

@@ -1,8 +1,5 @@
import * as ReactQuery from "@tanstack/react-query";
import { Generation } from "~/Generation";
import { Size } from "~/Geometry";
import { Plugin } from "~/Plugin";
import { Theme } from "~/Theme";
export type Ratio = Size & { label?: string };
@@ -154,30 +151,8 @@ export namespace Ratios {
{ width: 4, height: 1 },
] as const;
const gcd = (a: number, b: number): number => (b ? gcd(b, a % b) : a);
const simplifyAspectRatio = (width: number, height: number) => {
const divisor = gcd(width, height);
return { width: width / divisor, height: height / divisor } as Ratio;
};
export const usePluginResolutions = (model?: ID) => {
const getStableDiffusionAllowedResolutions = Plugin.use(
({ getStableDiffusionAllowedResolutions }) =>
getStableDiffusionAllowedResolutions
);
return ReactQuery.useQuery({
enabled: !!getStableDiffusionAllowedResolutions,
queryKey: ["Generation.Image.Ratio.PluginResolutions.use"],
queryFn: async () =>
(await getStableDiffusionAllowedResolutions?.(model)) ?? [],
});
};
export const use = (id?: ID, fullControl = false) => {
const { input } = Generation.Image.Input.use(id);
const { data: pluginResolutions } = usePluginResolutions(input?.model);
const bounds = Generation.Image.Size.Bounds.use(id);
const ratios = useMemo(() => {
if (!input?.width || !input?.height || !bounds) return [];
@@ -193,19 +168,9 @@ export namespace Ratios {
};
};
const ratios = pluginResolutions
? pluginResolutions.map(({ width, height }) => ({
...simplifyAspectRatio(width, height),
input: {
width,
height,
},
}))
: (fullControl ? presets : presets.slice(0, -2))
.map(sizing)
.filter(
({ input }) => input.width * input.height <= bounds.area.max
);
const ratios = (fullControl ? presets : presets.slice(0, -2))
.map(sizing)
.filter(({ input }) => input.width * input.height <= bounds.area.max);
const flipped = ratios.map(({ width, height, input }) => ({
width: height,

View File

@@ -7531,8 +7531,8 @@ __metadata:
linkType: hard
"tar@npm:^6.1.11, tar@npm:^6.1.2":
version: 6.1.14
resolution: "tar@npm:6.1.14"
version: 6.2.1
resolution: "tar@npm:6.2.1"
dependencies:
chownr: ^2.0.0
fs-minipass: ^2.0.0
@@ -7540,7 +7540,7 @@ __metadata:
minizlib: ^2.1.1
mkdirp: ^1.0.3
yallist: ^4.0.0
checksum: a1be0815a9bdc97dfca7c6c2d71d1b836f8ba9314684e2c412832f0f59cc226d4c13da303d6bc30925e82f634cc793f40da79ae72f3e96fb87c23d0f4efd5207
checksum: f1322768c9741a25356c11373bce918483f40fa9a25c69c59410c8a1247632487edef5fe76c5f12ac51a6356d2f1829e96d2bc34098668a2fc34d76050ac2b6c
languageName: node
linkType: hard