@uniformdev/canvas-sveltekit 20.48.1-alpha.27 → 20.48.1-alpha.33.sha-eb3f272086

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.
@@ -1,4 +1,5 @@
1
- import type { Handle, RequestEvent } from '@sveltejs/kit';
1
+ import type { RequestEvent } from '@sveltejs/kit';
2
+ import type { Handle } from '@sveltejs/kit/hooks';
2
3
  import type { UniformPreviewData } from '../models.js';
3
4
  /**
4
5
  * Options for creating the Uniform handle hook.
@@ -1,4 +1,4 @@
1
- import { error, json } from '@sveltejs/kit';
1
+ import { error } from '@sveltejs/kit';
2
2
  /**
3
3
  * Creates a SvelteKit request handler for on-demand ISR revalidation.
4
4
  *
@@ -41,7 +41,7 @@ export function createRevalidateHandler(options) {
41
41
  // Note: On Vercel, actual ISR revalidation happens automatically
42
42
  // This endpoint is primarily for logging/tracking purposes
43
43
  // or for custom cache invalidation logic
44
- return json({
44
+ return Response.json({
45
45
  revalidated: true,
46
46
  paths,
47
47
  timestamp: Date.now(),
@@ -1,4 +1,4 @@
1
- import { error, json } from '@sveltejs/kit';
1
+ import { error } from '@sveltejs/kit';
2
2
  import { generateHash } from '@uniformdev/canvas';
3
3
  /**
4
4
  * Creates a SvelteKit POST request handler for preview mode.
@@ -39,6 +39,6 @@ export function createPreviewHandlerPost(options) {
39
39
  error(401, 'Not authorized');
40
40
  }
41
41
  await enhance?.(composition, { event });
42
- return json({ composition });
42
+ return Response.json({ composition });
43
43
  };
44
44
  }
@@ -1,14 +1,5 @@
1
1
  import type { ServerLoadEvent } from '@sveltejs/kit';
2
- import { type RootComponentInstance } from '@uniformdev/canvas';
3
- import type { CreateUniformLoadOptions } from './types.js';
4
- /**
5
- * Result type for the load function.
6
- */
7
- export type UniformLoadResult = {
8
- data: RootComponentInstance;
9
- matchedRoute: string;
10
- dynamicInputs: Record<string, string>;
11
- };
2
+ import type { CreateUniformLoadOptions, UniformLoadFoundResult, UniformLoadResult } from './types.js';
12
3
  /**
13
4
  * Creates a SvelteKit load function that fetches compositions from the Uniform Route API.
14
5
  *
@@ -21,13 +12,13 @@ export type UniformLoadResult = {
21
12
  * });
22
13
  *
23
14
  * @example
24
- * // With custom options
15
+ * // With handleNotFound to allow non-Uniform routes to pass through
25
16
  * export const load = createUniformLoad({
26
- * param: 'slug',
27
- * silent: true,
28
- * requestOptions: {
29
- * skipEnhance: false,
30
- * },
17
+ * param: 'path',
18
+ * handleNotFound: () => ({ data: null, matchedRoute: null, dynamicInputs: null }),
31
19
  * });
32
20
  */
33
- export declare function createUniformLoad(options?: CreateUniformLoadOptions): (event: ServerLoadEvent) => Promise<UniformLoadResult>;
21
+ export declare function createUniformLoad(options: CreateUniformLoadOptions & {
22
+ handleNotFound: NonNullable<CreateUniformLoadOptions['handleNotFound']>;
23
+ }): (event: ServerLoadEvent) => Promise<UniformLoadResult>;
24
+ export declare function createUniformLoad(options?: Omit<CreateUniformLoadOptions, 'handleNotFound'>): (event: ServerLoadEvent) => Promise<UniformLoadFoundResult>;
@@ -4,27 +4,6 @@ import { getTargetVariableExpandedUrl } from '@uniformdev/redirect';
4
4
  import { resolvePathFromParams } from '../helpers/resolvePathFromParams.js';
5
5
  import { getPreviewData } from '../preview/previewCookie.js';
6
6
  import { createRouteFetcher } from './createRouteFetcher.js';
7
- /**
8
- * Creates a SvelteKit load function that fetches compositions from the Uniform Route API.
9
- *
10
- * @example
11
- * // In +page.server.ts
12
- * import { createUniformLoad } from '@uniformdev/canvas-sveltekit/route';
13
- *
14
- * export const load = createUniformLoad({
15
- * param: 'path', // matches [...path] route param
16
- * });
17
- *
18
- * @example
19
- * // With custom options
20
- * export const load = createUniformLoad({
21
- * param: 'slug',
22
- * silent: true,
23
- * requestOptions: {
24
- * skipEnhance: false,
25
- * },
26
- * });
27
- */
28
7
  export function createUniformLoad(options) {
29
8
  const defaultHandleRedirect = (requestUrl, matched, event) => {
30
9
  if (matched.redirect.targetStatusCode > 400) {
@@ -32,7 +11,10 @@ export function createUniformLoad(options) {
32
11
  }
33
12
  const absoluteUrl = `${event.url.protocol}//${event.url.host}${requestUrl}`;
34
13
  const destination = getTargetVariableExpandedUrl(absoluteUrl, matched.redirect);
35
- redirect(matched.redirect.targetStatusCode, destination);
14
+ // Redirect targets can leave the site. Kit 3 rejects those unless external is set.
15
+ redirect(matched.redirect.targetStatusCode, destination, {
16
+ external: true,
17
+ });
36
18
  };
37
19
  const defaultHandleNotFound = () => {
38
20
  error(404, 'Not Found');
@@ -1,4 +1,4 @@
1
1
  export { createRouteFetcher } from './createRouteFetcher.js';
2
2
  export { createUniformEntries, type UniformEntry } from './createUniformEntries.js';
3
- export { createUniformLoad, type UniformLoadResult } from './createUniformLoad.js';
3
+ export { createUniformLoad } from './createUniformLoad.js';
4
4
  export type * from './types.js';
@@ -35,14 +35,27 @@ export type RouteHandlerOptions<TContext, TResult, TSuccessResult> = {
35
35
  /** Override handling of a not found route response */
36
36
  handleNotFound?: HandleRouteNotFoundFunction<TContext, TResult>;
37
37
  };
38
- /**
39
- * Options for creating a SvelteKit load function.
40
- */
41
- export type CreateUniformLoadOptions = RouteHandlerOptions<ServerLoadEvent, never, {
38
+ /** Result returned when a route is successfully resolved from Uniform. */
39
+ export type UniformLoadFoundResult = {
42
40
  data: RootComponentInstance;
43
41
  matchedRoute: string;
44
42
  dynamicInputs: Record<string, string>;
45
- }> & {
43
+ };
44
+ /** Result returned when a route is not found in Uniform. */
45
+ export type UniformLoadNotFoundResult = {
46
+ data: null;
47
+ matchedRoute: null;
48
+ dynamicInputs: null;
49
+ };
50
+ /**
51
+ * Result type for the load function.
52
+ * Check `data` to discriminate between a found and not-found result.
53
+ */
54
+ export type UniformLoadResult = UniformLoadFoundResult | UniformLoadNotFoundResult;
55
+ /**
56
+ * Options for creating a SvelteKit load function.
57
+ */
58
+ export type CreateUniformLoadOptions = RouteHandlerOptions<ServerLoadEvent, UniformLoadNotFoundResult, UniformLoadFoundResult> & {
46
59
  /** Name of the route parameter containing the path segments (default: 'path') */
47
60
  param?: string;
48
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-sveltekit",
3
- "version": "20.48.1-alpha.27+63ada9fa57",
3
+ "version": "20.48.1-alpha.33.sha-eb3f272086",
4
4
  "description": "SvelteKit SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "scripts": {
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "peerDependencies": {
41
- "@sveltejs/kit": "^2.0.0",
41
+ "@sveltejs/kit": "^3.0.0",
42
42
  "@uniformdev/context-edge": ">=20.0.0",
43
- "svelte": "^5.0.0"
43
+ "svelte": "^5.57.1"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@uniformdev/context-edge": {
@@ -48,27 +48,27 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@uniformdev/canvas": "20.48.1-alpha.27+63ada9fa57",
52
- "@uniformdev/canvas-svelte": "20.48.1-alpha.27+63ada9fa57",
53
- "@uniformdev/context": "20.48.1-alpha.27+63ada9fa57",
54
- "@uniformdev/project-map": "20.48.1-alpha.27+63ada9fa57",
55
- "@uniformdev/redirect": "20.48.1-alpha.27+63ada9fa57",
56
- "@uniformdev/richtext": "20.48.1-alpha.27+63ada9fa57",
51
+ "@uniformdev/canvas": "20.48.1-alpha.33.sha-eb3f272086",
52
+ "@uniformdev/canvas-svelte": "20.48.1-alpha.33.sha-eb3f272086",
53
+ "@uniformdev/context": "20.48.1-alpha.33.sha-eb3f272086",
54
+ "@uniformdev/project-map": "20.48.1-alpha.33.sha-eb3f272086",
55
+ "@uniformdev/redirect": "20.48.1-alpha.33.sha-eb3f272086",
56
+ "@uniformdev/richtext": "20.48.1-alpha.33.sha-eb3f272086",
57
57
  "colorette": "2.0.20",
58
58
  "uuid": "^13.0.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@sveltejs/adapter-auto": "^7.0.0",
62
- "@sveltejs/adapter-vercel": "^5.7.2",
63
- "@sveltejs/kit": "^2.49.1",
64
- "@sveltejs/package": "^2.5.7",
65
- "@sveltejs/vite-plugin-svelte": "^6.2.1",
66
- "@uniformdev/context-edge": "20.48.1-alpha.27+63ada9fa57",
61
+ "@sveltejs/adapter-auto": "^8.0.0",
62
+ "@sveltejs/adapter-vercel": "^7.0.1",
63
+ "@sveltejs/kit": "^3.1.0",
64
+ "@sveltejs/package": "^3.0.1",
65
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
66
+ "@uniformdev/context-edge": "20.48.1-alpha.33.sha-eb3f272086",
67
67
  "publint": "^0.3.15",
68
- "svelte": "^5.45.6",
69
- "svelte-check": "^4.3.4",
70
- "typescript": "^5.9.3",
71
- "vite": "^7.2.6"
68
+ "svelte": "^5.57.3",
69
+ "svelte-check": "^4.7.7",
70
+ "typescript": "6.0.3",
71
+ "vite": "^8.3.5"
72
72
  },
73
73
  "keywords": [
74
74
  "svelte",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "63ada9fa5718447c1000a9d9d1ad8acf3f1609c6"
82
+ "gitHead": "eb3f2720868747479af048c5aa8fb28df7b01936"
83
83
  }