@hywax/cms 0.0.1 → 0.0.3

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.
Files changed (47) hide show
  1. package/.nuxt/cms/button-clear.ts +5 -0
  2. package/.nuxt/cms/index.ts +2 -0
  3. package/.nuxt/cms/prose/index.ts +1 -0
  4. package/.nuxt/cms/prose/uplora-image.ts +5 -0
  5. package/.nuxt/cms/uplora-image.ts +8 -0
  6. package/.nuxt/cms.css +1 -0
  7. package/cli/commands/make/component.mjs +75 -0
  8. package/cli/commands/make/index.mjs +12 -0
  9. package/cli/index.mjs +15 -0
  10. package/cli/package.json +13 -0
  11. package/cli/templates.mjs +101 -0
  12. package/cli/utils.mjs +31 -0
  13. package/dist/module.d.mts +26 -0
  14. package/dist/module.json +1 -1
  15. package/dist/module.mjs +185 -4
  16. package/dist/runtime/components/ButtonClear.vue +35 -0
  17. package/dist/runtime/components/ButtonClear.vue.d.ts +35 -0
  18. package/dist/runtime/components/UploraImage.vue +108 -0
  19. package/dist/runtime/components/UploraImage.vue.d.ts +34 -0
  20. package/dist/runtime/components/prose/UploraImage.vue +23 -0
  21. package/dist/runtime/components/prose/UploraImage.vue.d.ts +13 -0
  22. package/dist/runtime/composables/useApi.d.ts +14 -0
  23. package/dist/runtime/composables/useApi.js +16 -0
  24. package/dist/runtime/composables/useSeoStats.d.ts +12 -0
  25. package/dist/runtime/composables/useSeoStats.js +44 -0
  26. package/dist/runtime/index.css +1 -0
  27. package/dist/runtime/plugins/api.d.ts +6 -0
  28. package/dist/runtime/plugins/api.js +26 -0
  29. package/dist/runtime/types/app.config.d.ts +6 -0
  30. package/dist/runtime/types/image.d.ts +48 -0
  31. package/dist/runtime/types/image.js +0 -0
  32. package/dist/runtime/types/index.d.ts +5 -0
  33. package/dist/runtime/types/index.js +5 -0
  34. package/dist/runtime/types/seo.d.ts +4 -0
  35. package/dist/runtime/types/seo.js +0 -0
  36. package/dist/runtime/types/tv.d.ts +53 -0
  37. package/dist/runtime/types/tv.js +0 -0
  38. package/dist/runtime/types/utils.d.ts +3 -0
  39. package/dist/runtime/types/utils.js +1 -0
  40. package/dist/runtime/utils/image.d.ts +30 -0
  41. package/dist/runtime/utils/image.js +81 -0
  42. package/dist/runtime/utils/index.d.ts +1 -0
  43. package/dist/runtime/utils/index.js +1 -0
  44. package/dist/runtime/utils/tv.d.ts +1 -0
  45. package/dist/runtime/utils/tv.js +4 -0
  46. package/dist/types.d.mts +2 -0
  47. package/package.json +43 -4
@@ -0,0 +1,108 @@
1
+ <template>
2
+ <figure :class="ui.root({ class: [props.ui?.root, props.class] })">
3
+ <div
4
+ v-if="lqip"
5
+ :class="ui.lqip({ class: props.ui?.lqip })"
6
+ :style="{
7
+ backgroundImage: `url(${lqip})`
8
+ }"
9
+ />
10
+ <picture :class="ui.picture({ class: props.ui?.picture })">
11
+ <template v-if="sources.length">
12
+ <source
13
+ v-for="(source, key) in sources"
14
+ :key="key"
15
+ :srcset="source.srcset"
16
+ :type="source.type"
17
+ >
18
+ </template>
19
+
20
+ <img
21
+ ref="imageRef"
22
+ v-bind="imageAttrs"
23
+ :src="image.img"
24
+ :srcset="image?.srcset"
25
+ :alt="alt"
26
+ :loading="loading"
27
+ :class="ui.img({ class: props.ui?.img })"
28
+ >
29
+ </picture>
30
+ </figure>
31
+ </template>
32
+
33
+ <script>
34
+ import theme from "#build/cms/uplora-image";
35
+ import { computed, onMounted, useAppConfig, useHead, useNuxtApp, useTemplateRef } from "#imports";
36
+ import { buildUploraImage } from "../utils";
37
+ import { tv } from "../utils/tv";
38
+ </script>
39
+
40
+ <script setup>
41
+ const props = defineProps({
42
+ id: { type: String, required: true },
43
+ alt: { type: String, required: true },
44
+ formats: { type: Array, required: false },
45
+ sizes: { type: Array, required: false },
46
+ lqip: { type: String, required: false },
47
+ loading: { type: String, required: false, default: "lazy" },
48
+ preload: { type: [Boolean, Object], required: false },
49
+ nonce: { type: String, required: false },
50
+ imgAttrs: { type: Object, required: false },
51
+ class: { type: null, required: false },
52
+ ui: { type: null, required: false }
53
+ });
54
+ const emit = defineEmits(["load", "error"]);
55
+ const nuxtApp = useNuxtApp();
56
+ const initialLoad = nuxtApp.isHydrating;
57
+ const image = computed(() => buildUploraImage({
58
+ id: props.id,
59
+ formats: props.formats,
60
+ sizes: props.sizes
61
+ }));
62
+ const sources = computed(() => {
63
+ if (image.value.sources.length > 1) {
64
+ return image.value.sources.slice(1);
65
+ }
66
+ return [];
67
+ });
68
+ if (import.meta.server && props.preload) {
69
+ useHead({ link: () => {
70
+ if (!image.value.img) {
71
+ return [];
72
+ }
73
+ const link = {
74
+ rel: "preload",
75
+ as: "image",
76
+ imagesrcset: image.value.srcset,
77
+ nonce: props.nonce,
78
+ ...typeof props.preload !== "boolean" && props.preload?.fetchPriority ? { fetchpriority: props.preload.fetchPriority } : {}
79
+ };
80
+ return [link];
81
+ } });
82
+ }
83
+ const imageRef = useTemplateRef("imageRef");
84
+ const imageAttrs = computed(() => ({
85
+ ...props.imgAttrs || {},
86
+ ...import.meta.server ? { onerror: "this.setAttribute('data-error', 1)" } : {}
87
+ }));
88
+ onMounted(() => {
89
+ if (!imageRef.value) {
90
+ return;
91
+ }
92
+ if (imageRef.value.complete && initialLoad) {
93
+ if (imageRef.value.getAttribute("data-error")) {
94
+ emit("error", new Event("error"));
95
+ } else {
96
+ emit("load", new Event("load"));
97
+ }
98
+ }
99
+ imageRef.value.onload = (event) => {
100
+ emit("load", event);
101
+ };
102
+ imageRef.value.onerror = (event) => {
103
+ emit("error", event);
104
+ };
105
+ });
106
+ const appConfig = useAppConfig();
107
+ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.uploraImage || {} })());
108
+ </script>
@@ -0,0 +1,34 @@
1
+ import type { AppConfig } from '@nuxt/schema';
2
+ import type { ImgHTMLAttributes } from 'vue';
3
+ import type { ComponentConfig, ImageFormat, ImageSize } from '../types';
4
+ import theme from '#build/cms/uplora-image';
5
+ export type UploraImage = ComponentConfig<typeof theme, AppConfig, 'uploraImage'>;
6
+ export interface UploraImageProps {
7
+ id: string;
8
+ alt: string;
9
+ formats?: ImageFormat[];
10
+ sizes?: ImageSize[];
11
+ lqip?: string;
12
+ loading?: 'lazy' | 'eager';
13
+ preload?: boolean | {
14
+ fetchPriority: 'auto' | 'high' | 'low';
15
+ };
16
+ nonce?: string;
17
+ imgAttrs?: ImgHTMLAttributes;
18
+ class?: any;
19
+ ui?: UploraImage['slots'];
20
+ }
21
+ export interface UploraImageEmits {
22
+ load: [Event];
23
+ error: [string | Event];
24
+ }
25
+ declare const _default: import("vue").DefineComponent<UploraImageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
26
+ error: (args_0: string | Event) => any;
27
+ load: (args_0: Event) => any;
28
+ }, string, import("vue").PublicProps, Readonly<UploraImageProps> & Readonly<{
29
+ onError?: ((args_0: string | Event) => any) | undefined;
30
+ onLoad?: ((args_0: Event) => any) | undefined;
31
+ }>, {
32
+ loading: "lazy" | "eager";
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ export default _default;
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <div :class="ui.base({ class: [props.ui?.base, props.class] })">
3
+ ...
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import theme from "#build/cms/prose/uplora-image";
9
+ import { computed, useAppConfig } from "#imports";
10
+ import { tv } from "../../utils/tv";
11
+ </script>
12
+
13
+ <script setup>
14
+ const props = defineProps({
15
+ image: { type: String, required: true },
16
+ alt: { type: String, required: true },
17
+ lqip: { type: String, required: false },
18
+ class: { type: null, required: false },
19
+ ui: { type: null, required: false }
20
+ });
21
+ const appConfig = useAppConfig();
22
+ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.prose?.uploraImage || {} })());
23
+ </script>
@@ -0,0 +1,13 @@
1
+ import type { AppConfig } from '@nuxt/schema';
2
+ import type { ComponentConfig } from '../../types';
3
+ import theme from '#build/cms/prose/uplora-image';
4
+ export type ProseUploraImage = ComponentConfig<typeof theme, AppConfig, 'uploraImage', 'cms.prose'>;
5
+ export interface ProseUploraImageProps {
6
+ image: string;
7
+ alt: string;
8
+ lqip?: string;
9
+ class?: any;
10
+ ui?: ProseUploraImage['slots'];
11
+ }
12
+ declare const _default: import("vue").DefineComponent<ProseUploraImageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProseUploraImageProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import type { AvailableRouterMethod, NitroFetchRequest } from 'nitropack';
2
+ import type { AsyncData, FetchResult, UseFetchOptions } from 'nuxt/app';
3
+ import type { DefaultAsyncDataValue } from 'nuxt/app/defaults';
4
+ import type { FetchError } from 'ofetch';
5
+ import type { Ref } from 'vue';
6
+ type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
7
+ type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
8
+ /**
9
+ * На данный момент нет возможности использовать `useFetch` со своим $fetch,
10
+ * поэтому приходится использовать костыль.
11
+ * https://github.com/nuxt/nuxt/issues/14736
12
+ */
13
+ export declare function useApi<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DefaultAsyncDataValue>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: UseFetchOptions<_ResT, DataT, PickKeys, DefaultT, ReqT, Method>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | DefaultAsyncDataValue>;
14
+ export {};
@@ -0,0 +1,16 @@
1
+ import { useFetch, useNuxtApp } from "#imports";
2
+ import { defu } from "defu";
3
+ export function useApi(request, opts) {
4
+ const $api = useNuxtApp().$api;
5
+ return useFetch(
6
+ request,
7
+ defu(
8
+ {
9
+ $fetch: $api
10
+ },
11
+ {
12
+ ...opts
13
+ }
14
+ )
15
+ );
16
+ }
@@ -0,0 +1,12 @@
1
+ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
2
+ import type { SEO } from '../types';
3
+ interface SEOStats {
4
+ progress: number;
5
+ color: 'error' | 'warning' | 'success';
6
+ }
7
+ interface UseSEOStatsReturn {
8
+ title: ComputedRef<SEOStats>;
9
+ description: ComputedRef<SEOStats>;
10
+ }
11
+ export declare function useSEOStats(options: MaybeRefOrGetter<SEO>): UseSEOStatsReturn;
12
+ export {};
@@ -0,0 +1,44 @@
1
+ import { computed, toValue } from "#imports";
2
+ function computeScore(length, recommendedLength, maxLength) {
3
+ if (length === 0) {
4
+ return 0;
5
+ }
6
+ if (length < recommendedLength) {
7
+ return length / recommendedLength * 100;
8
+ }
9
+ if (length > maxLength) {
10
+ return Math.max(0, 100 - (length - maxLength) / maxLength * 100);
11
+ }
12
+ return 100;
13
+ }
14
+ function computeColor(score) {
15
+ if (score < 30) {
16
+ return "error";
17
+ }
18
+ if (score < 70) {
19
+ return "warning";
20
+ }
21
+ return "success";
22
+ }
23
+ export function useSEOStats(options) {
24
+ const title = computed(() => {
25
+ const value = toValue(options);
26
+ const score = computeScore(value.title.length, 45, 60);
27
+ return {
28
+ progress: Math.round(score),
29
+ color: computeColor(score)
30
+ };
31
+ });
32
+ const description = computed(() => {
33
+ const value = toValue(options);
34
+ const score = computeScore(value.description.length, 130, 160);
35
+ return {
36
+ progress: Math.round(score),
37
+ color: computeColor(score)
38
+ };
39
+ });
40
+ return {
41
+ title,
42
+ description
43
+ };
44
+ }
@@ -0,0 +1 @@
1
+ @import "@nuxt/ui-pro";@import "#build/cms.css";@source "./components";
@@ -0,0 +1,6 @@
1
+ declare const _default: import("#app").Plugin<{
2
+ api: import("nitropack/types").$Fetch<unknown, import("nitropack/types").NitroFetchRequest>;
3
+ }> & import("#app").ObjectPlugin<{
4
+ api: import("nitropack/types").$Fetch<unknown, import("nitropack/types").NitroFetchRequest>;
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import { defineNuxtPlugin, navigateTo, useAppConfig, useToast } from "#imports";
2
+ export default defineNuxtPlugin({
3
+ name: "cms-api",
4
+ async setup() {
5
+ const toast = useToast();
6
+ const appConfig = useAppConfig();
7
+ const api = $fetch.create({
8
+ async onResponseError({ response }) {
9
+ toast.add({
10
+ title: "\u041E\u0448\u0438\u0431\u043A\u0430",
11
+ description: response._data.message ?? "\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A",
12
+ color: "error",
13
+ icon: appConfig.ui.icons.close
14
+ });
15
+ if (response.status === 401) {
16
+ await navigateTo({ name: "index" });
17
+ }
18
+ }
19
+ });
20
+ return {
21
+ provide: {
22
+ api
23
+ }
24
+ };
25
+ }
26
+ });
@@ -0,0 +1,6 @@
1
+ declare module '#build/app.config' {
2
+ import type { AppConfig } from '@nuxt/schema'
3
+
4
+ const _default: AppConfig
5
+ export default _default
6
+ }
@@ -0,0 +1,48 @@
1
+ import type { ImageExtension, ImageMimeType } from '@uplora/formats';
2
+ export type ImageFormat = ImageExtension;
3
+ /**
4
+ * Размер изображения
5
+ */
6
+ export interface ImageSize {
7
+ /**
8
+ * Ширина
9
+ *
10
+ * @example 1024
11
+ */
12
+ width?: number;
13
+ /**
14
+ * Высота
15
+ *
16
+ * @example 1024
17
+ */
18
+ height?: number;
19
+ /**
20
+ * Описание размера
21
+ *
22
+ * @example 2x, 512px
23
+ */
24
+ descriptor: string;
25
+ }
26
+ /**
27
+ * Источник изображения
28
+ */
29
+ export interface ImageSource {
30
+ /**
31
+ * Image URL
32
+ *
33
+ * @example https://uplora.ru/fgu1yd2ncj05iogcooz31u55
34
+ */
35
+ img: string;
36
+ /**
37
+ * Image srcset
38
+ *
39
+ * @example https://uplora.ru/fgu1yd2ncj05iogcooz31u55/-/format/jpg 1x, https://uplora.ru/fgu1yd2ncj05iogcooz31u55/-/format/jpg 2x
40
+ */
41
+ srcset?: string;
42
+ /**
43
+ * Image mime type
44
+ *
45
+ * @example image/jpeg
46
+ */
47
+ type?: ImageMimeType;
48
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ export * from '../components/ButtonClear.vue';
2
+ export * from '../components/UploraImage.vue';
3
+ export * from './image';
4
+ export * from './seo';
5
+ export * from './utils';
@@ -0,0 +1,5 @@
1
+ export * from "../components/ButtonClear.vue";
2
+ export * from "../components/UploraImage.vue";
3
+ export * from "./image.js";
4
+ export * from "./seo.js";
5
+ export * from "./utils.js";
@@ -0,0 +1,4 @@
1
+ export interface SEO {
2
+ title: string;
3
+ description: string;
4
+ }
File without changes
@@ -0,0 +1,53 @@
1
+ import type { ClassValue, TVCompoundVariants, TVDefaultVariants, TVVariants } from 'tailwind-variants';
2
+ /**
3
+ * Defines the AppConfig object based on the tailwind-variants configuration.
4
+ */
5
+ export type TVConfig<T extends Record<string, any>> = {
6
+ [P in keyof T]?: {
7
+ [K in keyof T[P] as K extends 'base' | 'slots' | 'variants' | 'compoundVariants' | 'defaultVariants' ? K : never]?: K extends 'base' ? ClassValue : K extends 'slots' ? {
8
+ [S in keyof T[P]['slots']]?: ClassValue;
9
+ } : K extends 'variants' ? TVVariants<T[P]['slots'], ClassValue, T[P]['variants']> : K extends 'compoundVariants' ? TVCompoundVariants<T[P]['variants'], T[P]['slots'], ClassValue, object, undefined> : K extends 'defaultVariants' ? TVDefaultVariants<T[P]['variants'], T[P]['slots'], object, undefined> : never;
10
+ };
11
+ };
12
+ /**
13
+ * Utility type to flatten intersection types for better IDE hover information.
14
+ * @template T The type to flatten.
15
+ */
16
+ type Id<T> = {} & {
17
+ [P in keyof T]: T[P];
18
+ };
19
+ type ComponentVariants<T extends {
20
+ variants?: Record<string, Record<string, any>>;
21
+ }> = {
22
+ [K in keyof T['variants']]: keyof T['variants'][K];
23
+ };
24
+ type ComponentSlots<T extends {
25
+ slots?: Record<string, any>;
26
+ }> = Id<{
27
+ [K in keyof T['slots']]?: ClassValue;
28
+ }>;
29
+ type GetComponentAppConfig<A, U extends string, K extends string> = A extends Record<U, Record<K, any>> ? A[U][K] : object;
30
+ type ComponentAppConfig<T, A extends Record<string, any>, K extends string, U extends string = 'cms' | 'cms.prose'> = A & (U extends 'cms.prose' ? {
31
+ cms?: {
32
+ prose?: {
33
+ [k in K]?: Partial<T>;
34
+ };
35
+ };
36
+ } : {
37
+ [key in Exclude<U, 'cms.prose'>]?: {
38
+ [k in K]?: Partial<T>;
39
+ };
40
+ });
41
+ /**
42
+ * Defines the configuration shape expected for a component.
43
+ * @template T The component's theme imported from `#build/cms/*`.
44
+ * @template A The base AppConfig type from `@nuxt/schema`.
45
+ * @template K The key identifying the component (e.g., 'badge').
46
+ * @template U The top-level key in AppConfig ('cms' or 'cms.prose').
47
+ */
48
+ export type ComponentConfig<T extends Record<string, any>, A extends Record<string, any>, K extends string, U extends 'cms' | 'cms.prose' = 'cms'> = {
49
+ AppConfig: ComponentAppConfig<T, A, K, U>;
50
+ variants: ComponentVariants<T & GetComponentAppConfig<A, U, K>>;
51
+ slots: ComponentSlots<T>;
52
+ };
53
+ export {};
File without changes
@@ -0,0 +1,3 @@
1
+ import type { AcceptableValue as _AcceptableValue } from 'reka-ui';
2
+ export type AcceptableValue = Exclude<_AcceptableValue, Record<string, any>>;
3
+ export * from './tv';
@@ -0,0 +1 @@
1
+ export * from "./tv.js";
@@ -0,0 +1,30 @@
1
+ import type { Filters } from '@uplora/serializer';
2
+ import type { ImageFormat, ImageSize, ImageSource } from '../types';
3
+ /**
4
+ * Создает функцию для получения URL изображения из Uplora
5
+ */
6
+ export declare function createUploraImageResolver(): (id: string, filters?: Filters) => string;
7
+ export interface BuildUploraImageOptions {
8
+ id: string;
9
+ formats?: ImageFormat[];
10
+ sizes?: ImageSize[];
11
+ }
12
+ export interface BuildUploraImageReturn {
13
+ img: string;
14
+ original: string;
15
+ sources: ImageSource[];
16
+ srcset?: string;
17
+ }
18
+ /**
19
+ * Создает URL изображения из Uplora
20
+ */
21
+ export declare function buildUploraImage(options: BuildUploraImageOptions): BuildUploraImageReturn;
22
+ export interface GenerateImageSizesOptions {
23
+ width: number;
24
+ minWidth?: number;
25
+ step?: number;
26
+ }
27
+ /**
28
+ * Генерирует размеры изображения
29
+ */
30
+ export declare function generateImageSizes(options: GenerateImageSizesOptions): ImageSize[];
@@ -0,0 +1,81 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ import { imagesExtensionsToMimeTypes } from "@uplora/formats";
3
+ import { serialize } from "@uplora/serializer";
4
+ export function createUploraImageResolver() {
5
+ const runtimeConfig = useRuntimeConfig();
6
+ const { fluxorUrl } = runtimeConfig.public.cms;
7
+ return (id, filters) => {
8
+ const serializeFilters = filters ? serialize(filters) : "";
9
+ return `${fluxorUrl}/${id}${serializeFilters ? `/${serializeFilters}` : ""}`;
10
+ };
11
+ }
12
+ export function buildUploraImage(options) {
13
+ const resolver = createUploraImageResolver();
14
+ const original = resolver(options.id);
15
+ const sizes = options.sizes ?? [{ descriptor: "1x" }];
16
+ const sources = [];
17
+ function makeSrcset(format) {
18
+ if (sizes && sizes.length > 1) {
19
+ return sizes.map((size) => `${resolver(options.id, { resize: { width: size.width, height: size.height }, format })} ${size.descriptor}`).join(", ");
20
+ }
21
+ return null;
22
+ }
23
+ if (options.formats) {
24
+ for (const format of options.formats) {
25
+ const srcset = makeSrcset(format);
26
+ sources.push({
27
+ img: resolver(options.id, {
28
+ resize: {
29
+ width: sizes[0]?.width,
30
+ height: sizes[0]?.height
31
+ },
32
+ format
33
+ }),
34
+ ...srcset ? { srcset } : {},
35
+ type: imagesExtensionsToMimeTypes[format]
36
+ });
37
+ }
38
+ } else {
39
+ const srcset = makeSrcset();
40
+ sources.push({
41
+ img: resolver(options.id, {
42
+ resize: {
43
+ width: sizes[0]?.width,
44
+ height: sizes[0]?.height
45
+ }
46
+ }),
47
+ ...srcset ? { srcset } : {}
48
+ });
49
+ }
50
+ return {
51
+ img: original,
52
+ original,
53
+ ...sources.length > 0 ? {
54
+ img: sources[0]?.img,
55
+ srcset: sources[0]?.srcset
56
+ } : {},
57
+ sources
58
+ };
59
+ }
60
+ export function generateImageSizes(options) {
61
+ const { width, minWidth = 640, step = 0.7 } = options;
62
+ const sizes = [];
63
+ let currentWidth = width;
64
+ while (true) {
65
+ const normalizedWidth = Math.round(currentWidth);
66
+ sizes.push({
67
+ width: normalizedWidth,
68
+ descriptor: `${Math.round(normalizedWidth * step)}w`
69
+ });
70
+ currentWidth *= step;
71
+ if (currentWidth < minWidth) {
72
+ const normalizedWidth2 = Math.round(currentWidth);
73
+ sizes.push({
74
+ width: normalizedWidth2,
75
+ descriptor: `${Math.round(normalizedWidth2 * step)}w`
76
+ });
77
+ break;
78
+ }
79
+ }
80
+ return sizes;
81
+ }
@@ -0,0 +1 @@
1
+ export * from './image';
@@ -0,0 +1 @@
1
+ export * from "./image.js";
@@ -0,0 +1 @@
1
+ export declare const tv: import("tailwind-variants").CreateTV;
@@ -0,0 +1,4 @@
1
+ import appConfig from "#build/app.config";
2
+ import { createTV } from "tailwind-variants";
3
+ const appConfigTv = appConfig;
4
+ export const tv = /* @__PURE__ */ createTV(appConfigTv.ui?.tv);
package/dist/types.d.mts CHANGED
@@ -1,3 +1,5 @@
1
1
  export { default } from './module.mjs'
2
2
 
3
3
  export { type ModuleOptions } from './module.mjs'
4
+
5
+ export * from '../dist/runtime/types/index.js'