@lukoweb/apitogo 0.1.20 → 0.1.22

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.
Files changed (51) hide show
  1. package/dist/cli/cli.js +96 -84
  2. package/dist/declarations/app/main.d.ts +4 -3
  3. package/dist/declarations/config/config.d.ts +1 -0
  4. package/dist/declarations/config/create-plugin.d.ts +2 -2
  5. package/dist/declarations/config/validators/ZudokuConfig.d.ts +2 -3
  6. package/dist/declarations/index.d.ts +7 -3
  7. package/dist/declarations/lib/components/PluginHeads.d.ts +2 -2
  8. package/dist/declarations/lib/components/Zudoku.d.ts +7 -1
  9. package/dist/declarations/lib/components/context/ZudokuContext.d.ts +1 -0
  10. package/dist/declarations/lib/components/context/ZudokuProvider.d.ts +3 -0
  11. package/dist/declarations/lib/components/index.d.ts +5 -0
  12. package/dist/declarations/lib/core/ZudokuContext.d.ts +5 -5
  13. package/dist/declarations/lib/core/plugins.d.ts +13 -13
  14. package/dist/declarations/lib/hooks/index.d.ts +1 -0
  15. package/dist/declarations/lib/hooks/useEvent.d.ts +4 -4
  16. package/dist/declarations/lib/plugins/api-catalog/index.d.ts +2 -2
  17. package/dist/declarations/lib/plugins/api-keys/index.d.ts +2 -2
  18. package/dist/declarations/lib/plugins/markdown/index.d.ts +2 -2
  19. package/dist/declarations/lib/plugins/openapi/index.d.ts +2 -2
  20. package/dist/declarations/lib/plugins/search-inkeep/index.d.ts +2 -2
  21. package/dist/declarations/lib/plugins/search-pagefind/index.d.ts +2 -2
  22. package/dist/declarations/lib/testing/index.d.ts +3 -2
  23. package/dist/declarations/lib/util/invariant.d.ts +6 -4
  24. package/package.json +1 -1
  25. package/src/app/main.tsx +14 -11
  26. package/src/config/config.ts +7 -0
  27. package/src/config/create-plugin.ts +3 -3
  28. package/src/config/validators/BuildSchema.ts +7 -2
  29. package/src/config/validators/ZudokuConfig.ts +2 -3
  30. package/src/index.ts +13 -3
  31. package/src/lib/authentication/providers/clerk.tsx +2 -2
  32. package/src/lib/components/PluginHeads.tsx +2 -2
  33. package/src/lib/components/Zudoku.tsx +13 -8
  34. package/src/lib/components/context/ZudokuContext.ts +15 -5
  35. package/src/lib/components/context/ZudokuProvider.tsx +7 -1
  36. package/src/lib/components/index.ts +9 -1
  37. package/src/lib/core/ZudokuContext.ts +8 -8
  38. package/src/lib/core/plugins.ts +13 -13
  39. package/src/lib/hooks/index.ts +2 -0
  40. package/src/lib/hooks/useEvent.ts +12 -12
  41. package/src/lib/plugins/api-catalog/index.tsx +2 -2
  42. package/src/lib/plugins/api-keys/index.tsx +2 -2
  43. package/src/lib/plugins/markdown/index.tsx +2 -2
  44. package/src/lib/plugins/openapi/Sidecar.tsx +4 -2
  45. package/src/lib/plugins/openapi/index.tsx +6 -3
  46. package/src/lib/plugins/search-inkeep/index.tsx +2 -2
  47. package/src/lib/plugins/search-pagefind/index.tsx +2 -2
  48. package/src/lib/testing/index.tsx +11 -2
  49. package/src/lib/util/invariant.ts +16 -6
  50. package/src/types.d.ts +6 -6
  51. package/src/vite/config.ts +24 -0
@@ -32,10 +32,10 @@ import {
32
32
  isProfileMenuPlugin,
33
33
  needsInitialization,
34
34
  type ProfileNavigationItem,
35
- type ZudokuPlugin,
35
+ type ApitogoPlugin,
36
36
  } from "./plugins.js";
37
37
 
38
- export interface ZudokuEvents {
38
+ export interface ApitogoEvents {
39
39
  location: (event: { from?: Location; to: Location }) => void;
40
40
  auth: (auth: { prev: AuthState; next: AuthState }) => void;
41
41
  }
@@ -108,7 +108,7 @@ export type ZudokuContextOptions = {
108
108
  authentication?: AuthenticationPlugin;
109
109
  navigation?: Navigation;
110
110
  navigationRules?: ResolvedNavigationRule[];
111
- plugins?: ZudokuPlugin[];
111
+ plugins?: ApitogoPlugin[];
112
112
  slots?: Record<string, SlotType>;
113
113
  /**
114
114
  * @deprecated Use `slots` instead
@@ -151,7 +151,7 @@ export class ZudokuContext {
151
151
  public readonly env: Record<string, string | undefined>;
152
152
  public readonly protectedRoutes: ReturnType<typeof normalizeProtectedRoutes>;
153
153
  private readonly plugins: NonNullable<ZudokuContextOptions["plugins"]>;
154
- private readonly emitter = createNanoEvents<ZudokuEvents>();
154
+ private readonly emitter = createNanoEvents<ApitogoEvents>();
155
155
  readonly initialize: Promise<void> | undefined;
156
156
 
157
157
  constructor(
@@ -218,16 +218,16 @@ export class ZudokuContext {
218
218
  return keys.flat();
219
219
  };
220
220
 
221
- addEventListener<E extends keyof ZudokuEvents>(
221
+ addEventListener<E extends keyof ApitogoEvents>(
222
222
  event: E,
223
- callback: ZudokuEvents[E],
223
+ callback: ApitogoEvents[E],
224
224
  ) {
225
225
  return this.emitter.on(event, callback);
226
226
  }
227
227
 
228
- emitEvent = <E extends keyof ZudokuEvents>(
228
+ emitEvent = <E extends keyof ApitogoEvents>(
229
229
  event: E,
230
- ...data: Parameters<ZudokuEvents[E]>
230
+ ...data: Parameters<ApitogoEvents[E]>
231
231
  ) => {
232
232
  return this.emitter.emit(event, ...data);
233
233
  };
@@ -8,12 +8,12 @@ import type { AuthenticationPlugin } from "../authentication/authentication.js";
8
8
  import type { MdxComponentsType } from "../util/MdxComponents.js";
9
9
  import type {
10
10
  ApiIdentity,
11
+ ApitogoEvents,
11
12
  ZudokuContext,
12
- ZudokuEvents,
13
13
  } from "./ZudokuContext.js";
14
14
  export { runPluginTransformConfig } from "./transform-config.js";
15
15
 
16
- export type ZudokuPlugin =
16
+ export type ApitogoPlugin =
17
17
  | CommonPlugin
18
18
  | ProfileMenuPlugin
19
19
  | NavigationPlugin
@@ -89,50 +89,50 @@ export interface CommonPlugin {
89
89
  getMdxComponents?: () => MdxComponentsType;
90
90
  }
91
91
 
92
- export type EventConsumerPlugin<Event extends ZudokuEvents = ZudokuEvents> = {
92
+ export type EventConsumerPlugin<Event extends ApitogoEvents = ApitogoEvents> = {
93
93
  events: { [K in keyof Event]?: Event[K] };
94
94
  };
95
95
 
96
96
  export const isEventConsumerPlugin = (
97
- obj: ZudokuPlugin,
97
+ obj: ApitogoPlugin,
98
98
  ): obj is EventConsumerPlugin =>
99
99
  "events" in obj && typeof obj.events === "object";
100
100
 
101
101
  export const isProfileMenuPlugin = (
102
- obj: ZudokuPlugin,
102
+ obj: ApitogoPlugin,
103
103
  ): obj is ProfileMenuPlugin =>
104
104
  "getProfileMenuItems" in obj && typeof obj.getProfileMenuItems === "function";
105
105
 
106
106
  export const isNavigationPlugin = (
107
- obj: ZudokuPlugin,
107
+ obj: ApitogoPlugin,
108
108
  ): obj is NavigationPlugin =>
109
109
  "getRoutes" in obj && typeof obj.getRoutes === "function";
110
110
 
111
111
  export const isAuthenticationPlugin = (
112
- obj: ZudokuPlugin,
112
+ obj: ApitogoPlugin,
113
113
  ): obj is AuthenticationPlugin =>
114
114
  "signUp" in obj && typeof obj.signUp === "function";
115
115
 
116
116
  export const isSearchPlugin = (
117
- obj: ZudokuPlugin,
117
+ obj: ApitogoPlugin,
118
118
  ): obj is SearchProviderPlugin =>
119
119
  "renderSearch" in obj && typeof obj.renderSearch === "function";
120
120
 
121
- export const needsInitialization = (obj: ZudokuPlugin): obj is CommonPlugin =>
121
+ export const needsInitialization = (obj: ApitogoPlugin): obj is CommonPlugin =>
122
122
  "initialize" in obj && typeof obj.initialize === "function";
123
123
 
124
- export const hasHead = (obj: ZudokuPlugin): obj is CommonPlugin =>
124
+ export const hasHead = (obj: ApitogoPlugin): obj is CommonPlugin =>
125
125
  "getHead" in obj && typeof obj.getHead === "function";
126
126
 
127
- export const isMdxProviderPlugin = (obj: ZudokuPlugin): obj is CommonPlugin =>
127
+ export const isMdxProviderPlugin = (obj: ApitogoPlugin): obj is CommonPlugin =>
128
128
  "getMdxComponents" in obj && typeof obj.getMdxComponents === "function";
129
129
 
130
130
  export const isApiIdentityPlugin = (
131
- obj: ZudokuPlugin,
131
+ obj: ApitogoPlugin,
132
132
  ): obj is ApiIdentityPlugin =>
133
133
  "getIdentities" in obj && typeof obj.getIdentities === "function";
134
134
 
135
135
  export const isTransformConfigPlugin = (
136
- obj: ZudokuPlugin,
136
+ obj: ApitogoPlugin,
137
137
  ): obj is TransformConfigPlugin =>
138
138
  "transformConfig" in obj && typeof obj.transformConfig === "function";
@@ -6,6 +6,8 @@ export {
6
6
  useVerifiedEmail,
7
7
  } from "../authentication/hook.js";
8
8
  export { CACHE_KEYS, useCache } from "../components/cache.js";
9
+ export { useApitogo } from "../components/context/ZudokuContext.js";
10
+ /** @deprecated Use {@link useApitogo} instead. */
9
11
  export { useZudoku } from "../components/context/ZudokuContext.js";
10
12
  export { useExposedProps } from "../util/useExposedProps.js";
11
13
  export { useEvent } from "./useEvent.js";
@@ -1,41 +1,41 @@
1
1
  import { useEffect, useState } from "react";
2
- import { useZudoku } from "../components/context/ZudokuContext.js";
3
- import type { ZudokuEvents } from "../core/ZudokuContext.js";
2
+ import { useApitogo } from "../components/context/ZudokuContext.js";
3
+ import type { ApitogoEvents } from "../core/ZudokuContext.js";
4
4
 
5
- type EventParameters<Event extends keyof ZudokuEvents> = Parameters<
6
- ZudokuEvents[Event]
5
+ type EventParameters<Event extends keyof ApitogoEvents> = Parameters<
6
+ ApitogoEvents[Event]
7
7
  >;
8
8
 
9
9
  /**
10
- * Hook to subscribe to Zudoku events with automatic cleanup
10
+ * Hook to subscribe to APIToGo application events with automatic cleanup
11
11
  * @param event The event to subscribe to
12
12
  * @param callback Optional callback to be called when the event is emitted
13
13
  * @returns The latest event data if no callback is provided, or the callback's return value if it returns something
14
14
  */
15
- export function useEvent<E extends keyof ZudokuEvents>(
15
+ export function useEvent<E extends keyof ApitogoEvents>(
16
16
  event: E,
17
17
  ): EventParameters<E>;
18
- export function useEvent<E extends keyof ZudokuEvents, R>(
18
+ export function useEvent<E extends keyof ApitogoEvents, R>(
19
19
  event: E,
20
20
  callback: (...args: EventParameters<E>) => R,
21
21
  ): R;
22
- export function useEvent<E extends keyof ZudokuEvents, R>(
22
+ export function useEvent<E extends keyof ApitogoEvents, R>(
23
23
  event: E,
24
24
  callback?: (...args: EventParameters<E>) => R,
25
25
  ) {
26
- const zudoku = useZudoku();
26
+ const apitogo = useApitogo();
27
27
  const [latestData, setLatestData] = useState<R | EventParameters<E>>();
28
28
 
29
29
  useEffect(() => {
30
- return zudoku.addEventListener(event, ((...args: EventParameters<E>) => {
30
+ return apitogo.addEventListener(event, ((...args: EventParameters<E>) => {
31
31
  if (callback) {
32
32
  const result = callback(...args);
33
33
  setLatestData(result);
34
34
  } else {
35
35
  setLatestData(args);
36
36
  }
37
- }) as ZudokuEvents[E]);
38
- }, [zudoku, event, callback]);
37
+ }) as ApitogoEvents[E]);
38
+ }, [apitogo, event, callback]);
39
39
 
40
40
  return latestData;
41
41
  }
@@ -1,7 +1,7 @@
1
1
  import { matchPath } from "react-router";
2
2
  import type { NavigationItem } from "../../../config/validators/NavigationSchema.js";
3
3
  import type { AuthState } from "../../authentication/state.js";
4
- import type { ZudokuPlugin } from "../../core/plugins.js";
4
+ import type { ApitogoPlugin } from "../../core/plugins.js";
5
5
  import { joinUrl } from "../../util/joinUrl.js";
6
6
  import { slugify } from "../../util/slugify.js";
7
7
 
@@ -49,7 +49,7 @@ export const apiCatalogPlugin = ({
49
49
  categories?: CatalogCategory[];
50
50
  items: ApiCatalogItem[];
51
51
  filterCatalogItems?: FilterCatalogItemsFn;
52
- }): ZudokuPlugin => {
52
+ }): ApitogoPlugin => {
53
53
  const paths = Object.fromEntries(
54
54
  categories.flatMap((category) =>
55
55
  [undefined, ...category.tags].map((tag) => [
@@ -5,7 +5,7 @@ import type { UseAuthReturn } from "../../authentication/hook.js";
5
5
  import type {
6
6
  ApiIdentityPlugin,
7
7
  ProfileMenuPlugin,
8
- ZudokuPlugin,
8
+ ApitogoPlugin,
9
9
  } from "../../core/plugins.js";
10
10
  import type { ZudokuContext } from "../../core/ZudokuContext.js";
11
11
  import invariant from "../../util/invariant.js";
@@ -203,7 +203,7 @@ export const apiKeyPlugin = ({
203
203
  isZuplo,
204
204
  ...options
205
205
  }: Omit<ApiKeysOptions, "enabled"> &
206
- InternalApiKeyPluginOptions): ZudokuPlugin &
206
+ InternalApiKeyPluginOptions): ApitogoPlugin &
207
207
  ApiIdentityPlugin &
208
208
  ProfileMenuPlugin => {
209
209
  if (isZuplo && !deploymentName) {
@@ -2,7 +2,7 @@ import type { MDXProps } from "mdx/types.js";
2
2
  import type { JSX } from "react";
3
3
  import type { ZudokuDocsConfig } from "../../../config/validators/ZudokuConfig.js";
4
4
  import type { Toc } from "../../../vite/mdx/rehype-extract-toc-with-jsx.js";
5
- import type { ZudokuPlugin } from "../../core/plugins.js";
5
+ import type { ApitogoPlugin } from "../../core/plugins.js";
6
6
 
7
7
  export interface MarkdownPluginOptions extends ZudokuDocsConfig {
8
8
  basePath: string;
@@ -37,7 +37,7 @@ export type MDXImport = {
37
37
 
38
38
  export const markdownPlugin = (
39
39
  options: MarkdownPluginOptions,
40
- ): ZudokuPlugin => ({
40
+ ): ApitogoPlugin => ({
41
41
  getRoutes: () => {
42
42
  return Object.entries(options.fileImports).map(
43
43
  ([routePath, importPromise]) => ({
@@ -1,4 +1,4 @@
1
- import { useZudoku } from "@lukoweb/apitogo/hooks";
1
+ import { useApitogo } from "@lukoweb/apitogo/hooks";
2
2
  import { Badge } from "@lukoweb/apitogo/ui/Badge.js";
3
3
  import {
4
4
  NativeSelect,
@@ -63,7 +63,7 @@ export const Sidecar = ({
63
63
  }) => {
64
64
  const { options } = useOasConfig();
65
65
  const auth = useAuthState();
66
- const context = useZudoku();
66
+ const context = useApitogo();
67
67
 
68
68
  const methodTextColor = methodForColor(operation.method);
69
69
 
@@ -175,8 +175,10 @@ export const Sidecar = ({
175
175
  const showPlayground =
176
176
  isOnScreen &&
177
177
  (operation.extensions["x-explorer-enabled"] === true ||
178
+ operation.extensions["x-apitogo-playground-enabled"] === true ||
178
179
  operation.extensions["x-zudoku-playground-enabled"] === true ||
179
180
  (operation.extensions["x-explorer-enabled"] === undefined &&
181
+ operation.extensions["x-apitogo-playground-enabled"] === undefined &&
180
182
  operation.extensions["x-zudoku-playground-enabled"] === undefined &&
181
183
  !options?.disablePlayground));
182
184
 
@@ -1,7 +1,7 @@
1
1
  import { CirclePlayIcon } from "lucide-react";
2
2
  import { type PropsWithChildren, Suspense, lazy } from "react";
3
3
  import { matchPath } from "react-router";
4
- import type { ZudokuPlugin } from "../../core/plugins.js";
4
+ import type { ApitogoPlugin } from "../../core/plugins.js";
5
5
  import { Button } from "../../ui/Button.js";
6
6
  import { joinUrl } from "../../util/joinUrl.js";
7
7
  import { GraphQLClient } from "./client/GraphQLClient.js";
@@ -52,7 +52,7 @@ export type OpenApiPluginOptions = OasPluginConfig;
52
52
 
53
53
  export const UNTAGGED_PATH = "~endpoints";
54
54
 
55
- export const openApiPlugin = (config: OasPluginConfig): ZudokuPlugin => {
55
+ export const openApiPlugin = (config: OasPluginConfig): ApitogoPlugin => {
56
56
  const basePath = joinUrl(config.path);
57
57
  const client = new GraphQLClient(config);
58
58
 
@@ -148,10 +148,13 @@ export const openApiPlugin = (config: OasPluginConfig): ZudokuPlugin => {
148
148
  const categoryPath = joinUrl(basePath, versionParam, tag.slug);
149
149
 
150
150
  const isCollapsed =
151
+ tag.extensions?.["x-apitogo-collapsed"] ??
151
152
  tag.extensions?.["x-zudoku-collapsed"] ??
152
153
  !config.options?.expandAllTags;
153
154
  const isCollapsible =
154
- tag.extensions?.["x-zudoku-collapsible"] ?? true;
155
+ tag.extensions?.["x-apitogo-collapsible"] ??
156
+ tag.extensions?.["x-zudoku-collapsible"] ??
157
+ true;
155
158
 
156
159
  return [
157
160
  tag.name,
@@ -6,7 +6,7 @@ import type {
6
6
  } from "@inkeep/cxkit-types";
7
7
  import { useEffect, useMemo, useState } from "react";
8
8
  import { ClientOnly } from "../../components/ClientOnly.js";
9
- import type { ZudokuPlugin } from "../../core/plugins.js";
9
+ import type { ApitogoPlugin } from "../../core/plugins.js";
10
10
  import {
11
11
  aiChatSettings,
12
12
  baseSettings,
@@ -86,7 +86,7 @@ const InkeepSearch = ({
86
86
 
87
87
  export const inkeepSearchPlugin = (
88
88
  settings: InkeepBaseSettings,
89
- ): ZudokuPlugin => {
89
+ ): ApitogoPlugin => {
90
90
  return {
91
91
  getHead: () => {
92
92
  return (
@@ -1,6 +1,6 @@
1
1
  import type { ZudokuConfig } from "../../../config/validators/ZudokuConfig.js";
2
2
  import { ClientOnly } from "../../components/ClientOnly.js";
3
- import type { ZudokuPlugin } from "../../core/plugins.js";
3
+ import type { ApitogoPlugin } from "../../core/plugins.js";
4
4
  import { PagefindSearch } from "./PagefindSearch.js";
5
5
 
6
6
  export type PagefindOptions = Extract<
@@ -10,7 +10,7 @@ export type PagefindOptions = Extract<
10
10
 
11
11
  export const pagefindSearchPlugin = (
12
12
  options: PagefindOptions,
13
- ): ZudokuPlugin => {
13
+ ): ApitogoPlugin => {
14
14
  return {
15
15
  renderSearch: ({ isOpen, onClose }) => (
16
16
  <ClientOnly>
@@ -23,7 +23,10 @@ type QueryData = {
23
23
  data: unknown;
24
24
  };
25
25
 
26
- type StaticZudokuProps = ZudokuContextOptions & {
26
+ /**
27
+ * @deprecated Use {@link StaticApitogoProps} instead.
28
+ */
29
+ export type StaticZudokuProps = ZudokuContextOptions & {
27
30
  path: string;
28
31
  queryData?: QueryData[];
29
32
  env?: Record<string, string>;
@@ -31,6 +34,9 @@ type StaticZudokuProps = ZudokuContextOptions & {
31
34
  redirects?: ZudokuRedirect[];
32
35
  };
33
36
 
37
+ /** Prefer this over {@link StaticZudokuProps}. */
38
+ export type StaticApitogoProps = StaticZudokuProps;
39
+
34
40
  const getRoutesByOptions = (options: ZudokuContextOptions) => {
35
41
  return [
36
42
  ...(options.plugins ?? []),
@@ -134,4 +140,7 @@ const StaticZudoku = ({
134
140
  );
135
141
  };
136
142
 
137
- export { StaticZudoku, type StaticZudokuProps, type QueryData };
143
+ /**
144
+ * @deprecated Use {@link StaticApitogo} and {@link StaticApitogoProps} instead.
145
+ */
146
+ export { StaticZudoku, StaticZudoku as StaticApitogo, type QueryData };
@@ -7,7 +7,7 @@ export default function invariant(
7
7
  * the message takes a fair amount of effort to compute
8
8
  */
9
9
  message?: string | (() => string),
10
- options?: ZudokuErrorOptions,
10
+ options?: ApitogoErrorOptions,
11
11
  ): asserts condition {
12
12
  if (condition) {
13
13
  return;
@@ -17,26 +17,36 @@ export default function invariant(
17
17
  const provided: string | undefined =
18
18
  typeof message === "function" ? message() : message;
19
19
 
20
- throw new ZudokuError(provided ?? "Invariant failed", options);
20
+ throw new ApitogoError(provided ?? "Invariant failed", options);
21
21
  }
22
22
 
23
- export type ZudokuErrorOptions = {
23
+ export type ApitogoErrorOptions = {
24
24
  developerHint?: string;
25
25
  title?: string;
26
26
  cause?: Error;
27
27
  };
28
28
 
29
- export class ZudokuError extends Error {
29
+ /**
30
+ * @deprecated Use {@link ApitogoErrorOptions} instead.
31
+ */
32
+ export type ZudokuErrorOptions = ApitogoErrorOptions;
33
+
34
+ export class ApitogoError extends Error {
30
35
  public developerHint: string | undefined;
31
36
  public title: string | undefined;
32
37
 
33
38
  constructor(
34
39
  message: string,
35
- { developerHint, title, cause }: ZudokuErrorOptions = {},
40
+ { developerHint, title, cause }: ApitogoErrorOptions = {},
36
41
  ) {
37
42
  super(message, { cause });
38
- this.name = "ZudokuError";
43
+ this.name = "ApitogoError";
39
44
  this.title = title;
40
45
  this.developerHint = developerHint;
41
46
  }
42
47
  }
48
+
49
+ /**
50
+ * @deprecated Use {@link ApitogoError} instead.
51
+ */
52
+ export const ZudokuError = ApitogoError;
package/src/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare module "virtual:zudoku-docs-plugin" {
2
2
  export const configuredDocsPlugin:
3
- | import("./lib/core/plugins.ts").ZudokuPlugin
3
+ | import("./lib/core/plugins.ts").ApitogoPlugin
4
4
  | undefined;
5
5
  /**
6
6
  * Map of markdown files and imports
@@ -15,25 +15,25 @@ declare module "virtual:zudoku-navigation" {
15
15
  }
16
16
 
17
17
  declare module "virtual:zudoku-api-plugins" {
18
- export const configuredApiPlugins: import("./lib/core/plugins.ts").ZudokuPlugin[];
19
- export const configuredApiCatalogPlugins: import("./lib/core/plugins.ts").ZudokuPlugin[];
18
+ export const configuredApiPlugins: import("./lib/core/plugins.ts").ApitogoPlugin[];
19
+ export const configuredApiCatalogPlugins: import("./lib/core/plugins.ts").ApitogoPlugin[];
20
20
  }
21
21
 
22
22
  declare module "virtual:zudoku-search-plugin" {
23
23
  export const configuredSearchPlugin:
24
- | import("./lib/core/plugins.ts").ZudokuPlugin
24
+ | import("./lib/core/plugins.ts").ApitogoPlugin
25
25
  | undefined;
26
26
  }
27
27
 
28
28
  declare module "virtual:zudoku-api-keys-plugin" {
29
29
  export const configuredApiKeysPlugin:
30
- | import("./lib/core/plugins.ts").ZudokuPlugin
30
+ | import("./lib/core/plugins.ts").ApitogoPlugin
31
31
  | undefined;
32
32
  }
33
33
 
34
34
  declare module "virtual:zudoku-custom-pages-plugin" {
35
35
  export const configuredCustomPagesPlugin:
36
- | import("./lib/core/plugins.ts").ZudokuPlugin
36
+ | import("./lib/core/plugins.ts").ApitogoPlugin
37
37
  | undefined;
38
38
  }
39
39
 
@@ -15,10 +15,22 @@ import { getZudokuRootDir } from "../cli/common/package-json.js";
15
15
  import { loadZudokuConfig } from "../config/loader.js";
16
16
  import { CdnUrlSchema } from "../config/validators/ZudokuConfig.js";
17
17
  import { joinUrl } from "../lib/util/joinUrl.js";
18
+ import { ensurePagefindDevStub } from "./pagefind-dev-stub.js";
18
19
  import { findPackageRoot } from "./package-root.js";
19
20
  import vitePlugin from "./plugin.js";
20
21
  import { getZuploSystemConfigurations } from "./zuplo.js";
21
22
 
23
+ /** Resolved absolute public directory (Vite default: `<root>/public`). */
24
+ const resolveMergedPublicDir = (
25
+ rootDir: string,
26
+ merged: InlineConfig,
27
+ ): string | undefined => {
28
+ if (merged.publicDir === false) return undefined;
29
+ const rel =
30
+ typeof merged.publicDir === "string" ? merged.publicDir : "public";
31
+ return path.resolve(rootDir, rel);
32
+ };
33
+
22
34
  export type ZudokuConfigEnv = ConfigEnv & {
23
35
  mode: "development" | "production";
24
36
  };
@@ -230,5 +242,17 @@ export async function getViteConfig(
230
242
  }
231
243
  }
232
244
 
245
+ // Create pagefind stub before Vite starts. In development, `optimizeDeps.entries` crawls all of
246
+ // `src/lib/**`, which includes PagefindSearch's dev import of `/pagefind/pagefind.js`; esbuild
247
+ // must be able to open that path even when search is not configured. Pagefind users still get
248
+ // the stub until a real index is written (dev index or production prerender).
249
+ const publicDir = resolveMergedPublicDir(dir, mergedViteConfig);
250
+ if (
251
+ publicDir &&
252
+ (configEnv.mode === "development" || config.search?.type === "pagefind")
253
+ ) {
254
+ await ensurePagefindDevStub(publicDir);
255
+ }
256
+
233
257
  return mergedViteConfig;
234
258
  }