Skip to content

Commit

Permalink
fix env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasfha committed Jan 24, 2024
1 parent bb80a43 commit 12a9930
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/src/docs/components/cldimage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ By enabling Strict Transformations, you restrict the ability to generate transfo
approval through the Cloudinary dashboard.

> Note: This disables [optimization](#optimization) and [responsive sizing](/guides/responsive-images)
only allowing [named transformations](#transformations) to be applied. The width and height are not applied to the URL,
only allowing [named transformations](#transformations-depreacted) to be applied. The width and height are not applied to the URL,
but are still included on the image tag rendered to the DOM.

**Examples**
Expand Down
6 changes: 3 additions & 3 deletions docs/src/docs/components/clduploadbutton/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ order: 3
<script>
import Callout from '$lib/components/Callout.svelte'
importCldUploadButton } from 'svelte-cloudinary'
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET, PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET } from '$env/static/public';
let info
let infoSecure
</script>
Expand All @@ -26,7 +26,7 @@ class="cldbutton"
info = result?.info;
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
/>

<p><strong>URL:</strong> { info?.secure_url || 'Upload to see example result.' }</p>
Expand All @@ -51,7 +51,7 @@ class="cldbutton"
infoSecure = result?.info;
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET}
/>

<p><strong>URL:</strong> { infoSecure?.secure_url || 'Upload to see example result.' }</p>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/components/clduploadbutton/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 1
<script>
import Callout from '$lib/components/Callout.svelte'
importCldUploadButton } from 'svelte-cloudinary'
import { env } from '$env/dynamic/public';
import {PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET } from '$env/static/public';
let info
</script>

Expand All @@ -33,7 +33,7 @@ class="cldbutton"
info = result?.info
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
/>
<p>URL: { info?.secure_url }</p>

Expand Down
8 changes: 4 additions & 4 deletions docs/src/docs/components/clduploadwidget/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 3
import Callout from '$lib/components/Callout.svelte'
importCldUploadWidget } from 'svelte-cloudinary'
import ImageGrid from '$lib/components/ImageGrid.svelte';
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET, PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET } from '$env/static/public';
let info
let infoSecure
let infoSecure2
Expand All @@ -24,7 +24,7 @@ order: 3
info = result?.info
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
>
<button on:click|preventDefault={open} class="cldbutton">
Unsigned Upload
Expand All @@ -39,7 +39,7 @@ uploadPreset="svelte-cloudinary-unsigned"
```
<li>

<CldUploadWidget uploadPreset={env.PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET} let:open let:isLoading
<CldUploadWidget uploadPreset={PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET} let:open let:isLoading
signatureEndpoint="/api/sign-cloudinary-params"
onUpload={(result, widget) => {
infoSecure = result?.info
Expand All @@ -57,7 +57,7 @@ signatureEndpoint="/api/sign-cloudinary-params"
```
</li>
<li>
<CldUploadWidget uploadPreset={env.PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET} let:open let:isLoading options={{sources: ['local']}}
<CldUploadWidget uploadPreset={PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET} let:open let:isLoading options={{sources: ['local']}}
signatureEndpoint="/api/sign-cloudinary-params"
onUpload={(result, widget) => {
infoSecure2 = result?.info
Expand Down
3 changes: 0 additions & 3 deletions docs/src/docs/components/clduploadwidget/signed-uploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ order: 4
import CodeBlock from '$lib/components/CodeBlock.svelte'
import Callout from '$lib/components/Callout.svelte'
importCldUploadWidget } from 'svelte-cloudinary'
import { env } from '$env/dynamic/public';
let infoUpload
let infoUploadSecure

</script>
# Signing CldUploadWidget Uploads
Expand Down
6 changes: 3 additions & 3 deletions docs/src/docs/components/clduploadwidget/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 1
<script>
import Callout from '$lib/components/Callout.svelte'
importCldUploadWidget } from 'svelte-cloudinary'
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET, PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET } from '$env/static/public';
import Video from '$lib/components/Video.svelte'
let infoUpload
let infoUploadSecure
Expand Down Expand Up @@ -57,7 +57,7 @@ Use the following to generate an unsigned upload widget:
infoUpload = result?.info
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
>
<button on:click|preventDefault={open} class="cldbutton">
Unsigned Upload
Expand Down Expand Up @@ -118,7 +118,7 @@ To use the above, create a Node-based API route, add the snippet, and use that e
See a full example of an API endpoint used with the Svelte Cloudinary docs: https://github.com/cloudinary-community/svelte-cloudinary/blob/main/docs/src/routes/api/sign-cloudinary-params/+server.ts

<div class="mt-6">
<CldUploadWidget uploadPreset={env.PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET} let:open let:isLoading
<CldUploadWidget uploadPreset={PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET} let:open let:isLoading
signatureEndpoint="/api/sign-cloudinary-params"
onUpload={(result, widget) => {
infoUploadSecure = result?.info
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/guides/uploading-images-and-videos.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 9

import Callout from '$lib/components/Callout.svelte'
importCldUploadButton, CldImage } from 'svelte-cloudinary'
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET } from '$env/static/public';

let resource

Expand All @@ -26,7 +26,7 @@ class="cldbutton"
resource = result?.info;
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
/>
{#if resource?.resource_type === 'image'}
<CldImage width={resource.width} height={resource.height} src={resource?.public_id} alt="Uploaded Asset" />
Expand Down
4 changes: 2 additions & 2 deletions svelte-cloudinary/src/lib/cloudinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export async function pollForProcessingImage(options: PollForProcessingImageOpti

export function checkCloudinaryCloudName(cloudName: string) {
if (!cloudName) {
throw new Error("[Svelte-cloudinary] A Cloudinary Cloud name is required, please make sure VITE_PUBLIC_CLOUDINARY_CLOUD_NAME is set and configured in your environment");
throw new Error("[Svelte-cloudinary] A Cloudinary Cloud name is required, please make sure PUBLIC_CLOUDINARY_CLOUD_NAME is set and configured in your environment");
}
}
}
8 changes: 4 additions & 4 deletions svelte-cloudinary/src/lib/components/CldUploadWidget.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { triggerOnIdle, loadCloudinary } from '$lib/util.js';
import { checkCloudinaryCloudName } from '$lib/cloudinary.js';
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_CLOUD_NAME, PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET, PUBLIC_CLOUDINARY_API_KEY } from '$env/static/public';
import type {
CloudinaryUploadWidgetResults,
CloudinaryUploadWidgetInstanceMethods,
Expand Down Expand Up @@ -44,7 +44,7 @@
// Validation
const cloudName =
env.PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
checkCloudinaryCloudName(cloudName);
// State
Expand All @@ -53,9 +53,9 @@
cloudName,
uploadPreset:
uploadPreset ||
env.PUBLIC_CLOUDINARY_UPLOAD_PRESET ||
PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET ||
import.meta.env.PUBLIC_CLOUDINARY_UPLOAD_PRESET,
apiKey: env.PUBLIC_CLOUDINARY_API_KEY || import.meta.env.VITE_PUBLIC_CLOUDINARY_API_KEY,
apiKey:PUBLIC_CLOUDINARY_API_KEY || import.meta.env.VITE_PUBLIC_CLOUDINARY_API_KEY,
...options
};
Expand Down
4 changes: 2 additions & 2 deletions svelte-cloudinary/src/lib/components/CldVideoPlayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import { checkCloudinaryCloudName } from '$lib/cloudinary.js';
import { onMount } from 'svelte';
import { getCldVideoUrl, type GetCldImageUrlOptions, type GetCldVideoUrlOptions, getCldImageUrl } from '$lib/index.js';
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_CLOUD_NAME } from '$env/static/public';
const idRef = Math.ceil(Math.random() * 100000);
type $$Props = CldVideoPlayerProps;
Expand Down Expand Up @@ -169,7 +169,7 @@
// Validation
const cloudName =
env.PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
checkCloudinaryCloudName(cloudName);
// Parse the value passed to 'autoplay';
Expand Down
6 changes: 3 additions & 3 deletions svelte-cloudinary/src/lib/helpers/getCldImageUrl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { constructCloudinaryUrl } from '@cloudinary-util/url-loader';
import { checkCloudinaryCloudName } from '../cloudinary.js';
import type { ImageOptions, ConfigOptions, AnalyticsOptions } from '@cloudinary-util/url-loader';
import { env } from '$env/dynamic/public';
// import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_CLOUD_NAME } from '$env/static/public';

import {
SVELTE_CLOUDINARY_ANALYTICS_ID,
Expand All @@ -26,8 +27,7 @@ export function getCldImageUrl(
config?: ConfigOptions,
analytics?: AnalyticsOptions
) {

const cloudName = env.PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
const cloudName = PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
// Validation
checkCloudinaryCloudName(cloudName);

Expand Down
4 changes: 2 additions & 2 deletions svelte-cloudinary/src/lib/helpers/getCldVideoUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SVELTE_VERSION
} from '$lib/constants/analytics.js';
import { checkCloudinaryCloudName } from "../cloudinary.js";
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_CLOUD_NAME } from '$env/static/public';

/**
* getCldVideoUrl
Expand All @@ -18,7 +18,7 @@ export interface GetCldVideoUrlConfig extends ConfigOptions {};
export interface GetCldVideoUrlAnalytics extends AnalyticsOptions {};

export function getCldVideoUrl(options: GetCldVideoUrlOptions, config?: GetCldVideoUrlConfig, analytics?: GetCldVideoUrlAnalytics) {
const cloudName = env.PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
const cloudName = PUBLIC_CLOUDINARY_CLOUD_NAME || import.meta.env.VITE_PUBLIC_CLOUDINARY_CLOUD_NAME;
checkCloudinaryCloudName(cloudName);
return constructCloudinaryUrl({
options: {
Expand Down
6 changes: 3 additions & 3 deletions svelte-cloudinary/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { tick } from 'svelte';
import { env } from '$env/dynamic/public';
import { PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET, PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET } from '$env/static/public';
import CldImage from '$lib/components/CldImage.svelte';
import CldUploadButton from '$lib/components/CldUploadButton.svelte';
Expand Down Expand Up @@ -164,7 +164,7 @@
infoUpload = result?.info
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
>
Unsigned Upload
</CldUploadButton>
Expand All @@ -178,7 +178,7 @@
infoUploadSecure = result?.info
widget.close();
}}
uploadPreset={env.PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET}
uploadPreset={PUBLIC_CLOUDINARY_SIGNED_UPLOAD_PRESET}
signatureEndpoint="/api"
>
Signed Upload
Expand Down

0 comments on commit 12a9930

Please sign in to comment.