Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/sveltekit-demo/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"baseColor": "slate"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils",
"ui": "$lib/components/ui",
"hooks": "$lib/hooks",
"lib": "$lib"
"components": "#lib/components",
"utils": "#lib/utils",
"ui": "#lib/components/ui",
"hooks": "#lib/hooks",
"lib": "#lib"
},
"typescript": true,
"registry": "https://shadcn-svelte.com/registry"
Expand Down
3,710 changes: 1,516 additions & 2,194 deletions examples/sveltekit-demo/package-lock.json

Large diffs are not rendered by default.

48 changes: 26 additions & 22 deletions examples/sveltekit-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"private": true,
"version": "1.0.0",
"type": "module",
"imports": {
"#lib": "./src/lib/index.js",
"#lib/*": "./src/lib/*"
},
"scripts": {
"app:dev": "vite dev",
"dev": "pnpm pull:manifest && pnpm app:dev",
"build": "pnpm pull:manifest && pnpm app:build",
"dev": "npm run pull:manifest && npm run app:dev",
"build": "npm run pull:manifest && npm run app:build",
"app:build": "vite build",
"preview": "vite preview",
"prepare": "svelte-kit sync || echo ''",
Expand All @@ -17,35 +21,35 @@
"push:content": "uniform sync push"
},
"dependencies": {
"@uniformdev/canvas": "20.48.1-alpha.28",
"@uniformdev/canvas-svelte": "20.48.1-alpha.28",
"@uniformdev/canvas-sveltekit": "20.48.1-alpha.28",
"@uniformdev/context": "20.48.1-alpha.28",
"@uniformdev/context-edge": "20.48.1-alpha.28",
"@uniformdev/context-edge-sveltekit": "20.48.1-alpha.28",
"@uniformdev/context-svelte": "20.48.1-alpha.28",
"@uniformdev/insights": "20.48.1-alpha.28",
"@uniformdev/canvas": "20.89.0",
"@uniformdev/canvas-svelte": "20.89.0",
"@uniformdev/canvas-sveltekit": "20.89.0",
"@uniformdev/context": "20.89.0",
"@uniformdev/context-edge": "20.89.0",
"@uniformdev/context-edge-sveltekit": "20.89.0",
"@uniformdev/context-svelte": "20.89.0",
"@uniformdev/insights": "20.89.0",
"@vercel/functions": "^3.4.0",
"cookie": "1.0.1",
"immer": "10.1.3"
"cookie": "1.1.1",
"immer": "10.2.0"
},
"devDependencies": {
"@lucide/svelte": "^0.563.1",
"@sveltejs/adapter-auto": "^7.0.0",
"@sveltejs/adapter-vercel": "^6.3.1",
"@sveltejs/kit": "^2.49.1",
"@sveltejs/vite-plugin-svelte": "^6.2.1",
"@sveltejs/adapter-auto": "8.0.0",
"@sveltejs/adapter-vercel": "7.0.3",
"@sveltejs/kit": "3.1.0",
"@sveltejs/vite-plugin-svelte": "7.3.1",
"@tailwindcss/vite": "4.2.1",
"@types/node": "^25.3.0",
"@tailwindcss/postcss": "^4.1.9",
"@uniformdev/cli": "20.48.1-alpha.28",
"@uniformdev/cli": "20.89.0",
"clsx": "^2.1.1",
"svelte": "^5.45.6",
"svelte-check": "^4.3.4",
"svelte": "5.57.3",
"svelte-check": "4.7.7",
"tailwind-merge": "^3.4.0",
"tailwind-variants": "^3.2.2",
"tailwindcss": "^4.1.9",
"tw-animate-css": "1.4.0",
"typescript": "^5.9.3",
"vite": "^7.2.6"
"typescript": "6.0.3",
"vite": "8.3.5"
}
}
5 changes: 0 additions & 5 deletions examples/sveltekit-demo/postcss.config.js

This file was deleted.

6 changes: 1 addition & 5 deletions examples/sveltekit-demo/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import type { UniformPreviewData } from '@uniformdev/canvas-sveltekit';

// See https://svelte.dev/docs/kit/types#app.d.ts
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
interface Locals {
uniformPreview?: UniformPreviewData;
}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
Expand Down
16 changes: 16 additions & 0 deletions examples/sveltekit-demo/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineEnvVars } from '@sveltejs/kit/env';

/**
* Accepts a missing value so the demo can boot before Uniform credentials are set.
*/
function optionalString(value: string | undefined): string | undefined {
return value;
}

export const variables = defineEnvVars({
UNIFORM_API_KEY: { schema: optionalString },
UNIFORM_PROJECT_ID: { schema: optionalString },
UNIFORM_PREVIEW_SECRET: { schema: optionalString },
PUBLIC_UNIFORM_INSIGHTS_API_KEY: { public: true, static: true },
PUBLIC_UNIFORM_INSIGHTS_PROJECT_ID: { public: true, static: true },
});
5 changes: 4 additions & 1 deletion examples/sveltekit-demo/src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { sequence } from "@sveltejs/kit/hooks";
import { createUniformHandle } from "@uniformdev/canvas-sveltekit";

import { UNIFORM_PREVIEW_SECRET } from "$app/env/private";

/**
* Uniform handle hook - parses preview cookies and attaches to locals
* Uniform handle hook - verifies the signed preview cookie and attaches it to locals
*/
const uniformHandle = createUniformHandle({
secret: () => UNIFORM_PREVIEW_SECRET,
onPreview: (event, previewData) => {
// Optional: Log when preview mode is active
if (previewData.isUniformContextualEditing) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sveltekit-demo/src/lib/components/footer.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { categories } from "$lib/data/products";
import { categories } from "#lib/data/products.js";
</script>

<footer class="bg-foreground text-primary-foreground">
Expand Down
2 changes: 1 addition & 1 deletion examples/sveltekit-demo/src/lib/components/header.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { categories } from "$lib/data/products";
import { categories } from "#lib/data/products.js";

interface Props {
darkHero?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { Category } from "$lib/data/products";
import type { Category } from "#lib/data/products.js";

interface Props {
headline: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Product } from "$lib/data/products";
import { formatPrice } from "$lib/data/products";
import type { Product } from "#lib/data/products.js";
import { formatPrice } from "#lib/data/products.js";

interface Props {
product: Product;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Product } from "$lib/data/products";
import { formatPrice } from "$lib/data/products";
import type { Product } from "#lib/data/products.js";
import { formatPrice } from "#lib/data/products.js";

interface Props {
headline: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Product } from "$lib/data/products";
import { formatPrice } from "$lib/data/products";
import type { Product } from "#lib/data/products.js";
import { formatPrice } from "#lib/data/products.js";

interface Props {
eyebrow: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" module>
import { cn, type WithElementRef } from "$lib/utils.js";
import { cn, type WithElementRef } from "#lib/utils.js";
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
import { type VariantProps, tv } from "tailwind-variants";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<script lang="ts">
import type { ComponentProps } from "@uniformdev/canvas-svelte";
import type { LinkParamValue, AssetParamValue } from "@uniformdev/canvas";
import { linkHref, assetUrl, checkbox } from "$lib/uniform/paramHelpers";
import { linkHref, assetUrl, checkbox } from "#lib/uniform/paramHelpers.js";

import HeroVideo from "$lib/components/hero/hero-video.svelte";
import HeroAurora from "$lib/components/hero/hero-aurora.svelte";
import HeroVideo from "#lib/components/hero/hero-video.svelte";
import HeroAurora from "#lib/components/hero/hero-aurora.svelte";

interface Props extends ComponentProps<{
media?: AssetParamValue;
Expand Down
1 change: 1 addition & 0 deletions examples/sveltekit-demo/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// place files you want to import through the `#lib` alias in this folder.
4 changes: 2 additions & 2 deletions examples/sveltekit-demo/src/lib/pages/category-page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
getProductsByCategory,
getCategoryBySlug,
formatPrice
} from "$lib/data/products";
} from "#lib/data/products.js";

let { category } = $props<{ category: string }>();
let { category }: { category: string } = $props();

const currentCategory = $derived(getCategoryBySlug(category));
const categoryProducts = $derived(getProductsByCategory(category));
Expand Down
4 changes: 2 additions & 2 deletions examples/sveltekit-demo/src/lib/pages/product-page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
getProductsByCategory,
getCategoryBySlug,
formatPrice
} from "$lib/data/products";
} from "#lib/data/products.js";

let { category, productId } = $props<{ category: string; productId: string }>();
let { category, productId }: { category: string; productId: string } = $props();

const product = $derived(getProductById(productId));
const currentCategory = $derived(getCategoryBySlug(category));
Expand Down
2 changes: 1 addition & 1 deletion examples/sveltekit-demo/src/lib/uniform/componentMap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentMap } from '@uniformdev/canvas-svelte';
import { Page, Hero } from '$lib/components/uniform/index.js';
import { Page, Hero } from '#lib/components/uniform/index.js';

/**
* Maps Uniform component types to Svelte components.
Expand Down
16 changes: 8 additions & 8 deletions examples/sveltekit-demo/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import "../app.css";
import { page } from "$app/stores";
import { page } from "$app/state";
import { onMount } from "svelte";
import Header from "$lib/components/header.svelte";
import Footer from "$lib/components/footer.svelte";
import { dev } from "$app/environment";
import Header from "#lib/components/header.svelte";
import Footer from "#lib/components/footer.svelte";
import { dev } from "$app/env";
import {
PUBLIC_UNIFORM_INSIGHTS_API_KEY,
PUBLIC_UNIFORM_INSIGHTS_PROJECT_ID,
} from "$env/static/public";
} from "$app/env/public";
import {
Context,
CookieTransitionDataStore,
Expand All @@ -19,8 +19,8 @@
import type { ManifestV2 } from "@uniformdev/context";
import { enableUniformInsights } from "@uniformdev/insights";

import manifestJson from "$lib/uniform/contextManifest.json";
import { tealiumData } from "$lib/tealium-mock";
import manifestJson from "#lib/uniform/contextManifest.json";
import { tealiumData } from "#lib/tealium-mock.js";

let { children } = $props();

Expand Down Expand Up @@ -73,7 +73,7 @@
});

// Only use dark hero mode on homepage
const isHomepage = $derived($page.url.pathname === "/");
const isHomepage = $derived(page.url.pathname === "/");
</script>

<UniformContext {context} outputType={dev ? "standard" : "edge"}>
Expand Down
8 changes: 4 additions & 4 deletions examples/sveltekit-demo/src/routes/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { error } from "@sveltejs/kit";
import { RouteClient } from "@uniformdev/canvas";
import { env } from "$env/dynamic/private";
import { UNIFORM_API_KEY, UNIFORM_PROJECT_ID } from "$app/env/private";
import type { PageServerLoad } from "./$types";

function hasUniformCredentials(): boolean {
return Boolean(env.UNIFORM_API_KEY && env.UNIFORM_PROJECT_ID);
return Boolean(UNIFORM_API_KEY && UNIFORM_PROJECT_ID);
}

// ISR on Vercel - pages revalidate every 60 seconds
Expand All @@ -27,8 +27,8 @@ export const load: PageServerLoad = async (event) => {
);

const client = new RouteClient({
apiKey: env.UNIFORM_API_KEY,
projectId: env.UNIFORM_PROJECT_ID,
apiKey: UNIFORM_API_KEY,
projectId: UNIFORM_PROJECT_ID,
});

const uniformLoad = createUniformLoad({
Expand Down
16 changes: 8 additions & 8 deletions examples/sveltekit-demo/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import { categories, products } from "$lib/data/products";
import homeContent from "$lib/data/home-content.json";
import ProductSpotlights from "$lib/components/sections/product-spotlights.svelte";
import CategoryShowcase from "$lib/components/sections/category-showcase.svelte";
import FeaturedProduct from "$lib/components/sections/featured-product.svelte";
import ProductGrid from "$lib/components/sections/product-grid.svelte";
import Newsletter from "$lib/components/sections/newsletter.svelte";
import { categories, products } from "#lib/data/products.js";
import homeContent from "#lib/data/home-content.json";
import ProductSpotlights from "#lib/components/sections/product-spotlights.svelte";
import CategoryShowcase from "#lib/components/sections/category-showcase.svelte";
import FeaturedProduct from "#lib/components/sections/featured-product.svelte";
import ProductGrid from "#lib/components/sections/product-grid.svelte";
import Newsletter from "#lib/components/sections/newsletter.svelte";

import { UniformComposition, UniformSlot } from "@uniformdev/canvas-svelte";
import { componentMap } from "$lib/uniform/componentMap.js";
import { componentMap } from "#lib/uniform/componentMap.js";
const featuredSpotlightProduct =
products[homeContent.productSpotlights.featuredProductIndex];
const gridSpotlightProducts =
Expand Down
2 changes: 1 addition & 1 deletion examples/sveltekit-demo/src/routes/playground/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { UniformComposition, UniformSlot } from '@uniformdev/canvas-svelte';
import { componentMap } from '$lib/uniform/componentMap.js';
import { componentMap } from '#lib/uniform/componentMap.js';
import { EMPTY_COMPOSITION } from '@uniformdev/canvas';
</script>

Expand Down
4 changes: 2 additions & 2 deletions examples/sveltekit-demo/src/routes/preview/+server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createPreviewHandler } from '@uniformdev/canvas-sveltekit/preview';
import { env } from '$env/dynamic/private';
import { UNIFORM_PREVIEW_SECRET } from '$app/env/private';

const handlers = createPreviewHandler({
secret: () => env.UNIFORM_PREVIEW_SECRET ?? '',
secret: () => UNIFORM_PREVIEW_SECRET ?? '',
playgroundPath: '/playground',
resolveFullPath: ({ path, slug }) => {
return path || slug || '/';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script lang="ts">
import { page } from '$app/stores';
import { Button } from "$lib/components/ui/button";
import { page } from '$app/state';
import { Button } from "#lib/components/ui/button/index.js";
import {
categories,
products,
getCategoryBySlug,
getProductsByCategory,
formatPrice
} from "$lib/data/products";
} from "#lib/data/products.js";

let categorySlug = $derived($page.params.category);
let categorySlug = $derived(page.params.category ?? '');
let category = $derived(getCategoryBySlug(categorySlug));
let categoryProducts = $derived(getProductsByCategory(categorySlug));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<script lang="ts">
import { page } from '$app/stores';
import { Button } from "$lib/components/ui/button";
import { page } from '$app/state';
import { Button } from "#lib/components/ui/button/index.js";
import { getUniformContext } from '@uniformdev/context-svelte';
import {
getProductById,
getCategoryBySlug,
getProductsByCategory,
formatPrice,
type Product
} from "$lib/data/products";
} from "#lib/data/products.js";

// Get Uniform context for tracking events
const { context } = getUniformContext({ throwOnMissingProvider: false }) ?? {};

let productId = $derived($page.params.product ?? '');
let categorySlug = $derived($page.params.category ?? '');
let productId = $derived(page.params.product ?? '');
let categorySlug = $derived(page.params.category ?? '');

let product = $derived(getProductById(productId));
let category = $derived(getCategoryBySlug(categorySlug));
Expand Down
Loading