Skip to content

Commit 1347c5e

Browse files
authored
Merge pull request #19 from cloudinary-community/beta-fix-types
2 parents cc425a0 + 0359711 commit 1347c5e

File tree

10 files changed

+69
-40
lines changed

10 files changed

+69
-40
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

svelte-cloudinary/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
"svelte-preprocess": "^5.0.3",
5454
"tslib": "^2.4.1",
5555
"typescript": "^5.0.0",
56+
"unpic": "3.6.1",
5657
"vite": "^4.3.0",
5758
"vitest": "^0.25.3"
5859
},
59-
"svelte": "./dist/index.js",
6060
"types": "./dist/index.d.ts",
6161
"type": "module",
6262
"dependencies": {

svelte-cloudinary/src/index.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

svelte-cloudinary/src/lib/components/CldImage.svelte

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
<script lang="ts" context="module">
2-
// This types still comes wrong
3-
// import type { ImageProps } from '@unpic/svelte'
4-
// But this is the same used by the @unpic/svelte package
5-
import type { UnpicImageProps } from '@unpic/core';
6-
import type { HTMLImgAttributes } from 'svelte/elements';
7-
type ImageProps = UnpicImageProps<HTMLImgAttributes, string | null>;
8-
import type { ImageOptions } from '@cloudinary-util/url-loader';
9-
export type CldImageProps = ImageOptions &
10-
ImageProps & {
11-
layout: ImageProps['layout'];
12-
};
13-
</script>
14-
151
<script lang="ts">
2+
import type { CldImageProps } from './CldImageTypes.ts'
3+
// This unused import is a hack to get around a bug in svelte2tsx
4+
import type { UrlTransformer, ImageCdn } from "unpic";
5+
import type { ImageOptions } from '@cloudinary-util/url-loader';
166
import { getTransformations } from '@cloudinary-util/util';
177
import { transformationPlugins } from '@cloudinary-util/url-loader';
188
import { Image } from '@unpic/svelte';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This types still comes wrong
2+
// import type { ImageProps } from '@unpic/svelte'
3+
// But this is the same used by the @unpic/svelte package
4+
import type { UnpicImageProps } from '@unpic/core';
5+
import type { HTMLImgAttributes } from 'svelte/elements';
6+
type ImageProps = UnpicImageProps<HTMLImgAttributes, string | null>;
7+
import type { ImageOptions } from '@cloudinary-util/url-loader';
8+
export type CldImageProps = ImageOptions &
9+
ImageProps & {
10+
layout: ImageProps['layout'];
11+
};

svelte-cloudinary/src/lib/components/CldOgImage.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { getCldImageUrl } from '$lib/helpers/getCldImageUrl.js';
33
import type { ImageOptions } from '@cloudinary-util/url-loader';
4-
import type { CldImageProps } from './CldImage.svelte';
4+
import type { CldImageProps } from './CldImageTypes.ts';
55
import { OG_IMAGE_WIDTH, OG_IMAGE_WIDTH_RESIZE, OG_IMAGE_HEIGHT } from '$lib/constants/sizes.js';
66
77
const TWITTER_CARD = 'summary_large_image';

svelte-cloudinary/src/lib/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

svelte-cloudinary/src/lib/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Reexport your entry components here
2+
import CldImage from './components/CldImage.svelte'
3+
export { CldImage }
4+
export type { CldImageProps } from "./components/CldImageTypes.ts";
5+
6+
import CldOgImage from './components/CldOgImage.svelte'
7+
export { CldOgImage }
8+
9+
import CldUploadWidget from './components/CldUploadWidget.svelte'
10+
export { CldUploadWidget}
11+
12+
import CldUploadButton from './components/CldUploadButton.svelte'
13+
export { CldUploadButton}
14+
15+
export { getCldImageUrl } from '$lib/helpers/getCldImageUrl.js';
16+
export type { GetCldImageUrl, GetCldImageUrlOptions, GetCldImageUrlConfig, GetCldImageUrlAnalytics } from '$lib/helpers/getCldImageUrl.ts';
17+
18+
export { getCldOgImageUrl } from '$lib/helpers/getCldOgImageUrl.js';
19+
export type { GetCldOgImageUrl } from '$lib/helpers/getCldOgImageUrl.ts';
20+
21+
export type { CloudinaryVideoPlayer, CloudinaryVideoPlayerOptions, CloudinaryVideoPlayerOptionsColors, CloudinaryVideoPlayerOptionsLogo } from '../types/player.ts';
22+

svelte-cloudinary/src/routes/+page.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
</script>
44

55
<CldImage
6-
width="1200"
7-
height="1200"
6+
width={1200}
7+
height={1200}
88
src="images/woman-headphones"
99
crop="thumb"
1010
removeBackground
@@ -20,7 +20,6 @@
2020
src="images/woman-headphones"
2121
sizes="50vw"
2222
crop="thumb"
23-
layout="constrained"
2423
tint="40:253f8c"
2524
gravity="faces"
2625
underlay="images/city-skyline"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface CloudinaryVideoPlayer {
2+
on: Function;
3+
}
4+
export interface CloudinaryVideoPlayerOptions {
5+
autoplayMode?: string;
6+
cloud_name?: string;
7+
colors?: CloudinaryVideoPlayerOptionsColors;
8+
controls?: boolean;
9+
fontFace?: string;
10+
loop?: boolean;
11+
muted?: boolean;
12+
publicId: string;
13+
secure?: boolean;
14+
transformation?: Array<object> | object;
15+
}
16+
export interface CloudinaryVideoPlayerOptionsColors {
17+
accent?: string;
18+
base?: string;
19+
text?: string;
20+
}
21+
export interface CloudinaryVideoPlayerOptionsLogo {
22+
logoImageUrl?: string;
23+
logoOnclickUrl?: string;
24+
showLogo?: boolean;
25+
}

0 commit comments

Comments
 (0)