@uniformdev/canvas-sveltekit 20.48.1-alpha.27 → 20.48.1-alpha.28

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,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) {
@@ -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.28+77388717bf",
4
4
  "description": "SvelteKit SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "scripts": {
@@ -48,12 +48,12 @@
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.28+77388717bf",
52
+ "@uniformdev/canvas-svelte": "20.48.1-alpha.28+77388717bf",
53
+ "@uniformdev/context": "20.48.1-alpha.28+77388717bf",
54
+ "@uniformdev/project-map": "20.48.1-alpha.28+77388717bf",
55
+ "@uniformdev/redirect": "20.48.1-alpha.28+77388717bf",
56
+ "@uniformdev/richtext": "20.48.1-alpha.28+77388717bf",
57
57
  "colorette": "2.0.20",
58
58
  "uuid": "^13.0.0"
59
59
  },
@@ -63,7 +63,7 @@
63
63
  "@sveltejs/kit": "^2.49.1",
64
64
  "@sveltejs/package": "^2.5.7",
65
65
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
66
- "@uniformdev/context-edge": "20.48.1-alpha.27+63ada9fa57",
66
+ "@uniformdev/context-edge": "20.48.1-alpha.28+77388717bf",
67
67
  "publint": "^0.3.15",
68
68
  "svelte": "^5.45.6",
69
69
  "svelte-check": "^4.3.4",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "63ada9fa5718447c1000a9d9d1ad8acf3f1609c6"
82
+ "gitHead": "77388717bfa6e82a2443accdfc896c8e137b2185"
83
83
  }