zudoku 0.3.0-dev.95 → 0.3.0-dev.96

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 (48) hide show
  1. package/dist/app/demo.d.ts +1 -1
  2. package/dist/app/demo.js +43 -24
  3. package/dist/app/demo.js.map +1 -1
  4. package/dist/app/main.js +1 -0
  5. package/dist/app/main.js.map +1 -1
  6. package/dist/app/standalone.d.ts +1 -1
  7. package/dist/app/standalone.js +37 -26
  8. package/dist/app/standalone.js.map +1 -1
  9. package/dist/config/validators/validate.d.ts +6 -0
  10. package/dist/config/validators/validate.js +1 -0
  11. package/dist/config/validators/validate.js.map +1 -1
  12. package/dist/lib/components/Bootstrap.d.ts +3 -3
  13. package/dist/lib/components/Bootstrap.js.map +1 -1
  14. package/dist/lib/components/Layout.js +1 -1
  15. package/dist/lib/components/Layout.js.map +1 -1
  16. package/dist/lib/components/index.d.ts +1 -1
  17. package/dist/lib/util/joinPath.js +1 -1
  18. package/dist/lib/util/joinPath.js.map +1 -1
  19. package/dist/vite/plugin-api.js +2 -7
  20. package/dist/vite/plugin-api.js.map +1 -1
  21. package/dist/vite/plugin-component.d.ts +2 -2
  22. package/dist/vite/plugin-component.js +4 -3
  23. package/dist/vite/plugin-component.js.map +1 -1
  24. package/dist/vite/plugin.js +2 -2
  25. package/dist/vite/plugin.js.map +1 -1
  26. package/lib/{MdxPage-3-PenZs2.js → MdxPage-oN3huD58.js} +2 -2
  27. package/lib/{MdxPage-3-PenZs2.js.map → MdxPage-oN3huD58.js.map} +1 -1
  28. package/lib/{OperationList-BAZX1Gla.js → OperationList-Ctj0ihBN.js} +2 -2
  29. package/lib/{OperationList-BAZX1Gla.js.map → OperationList-Ctj0ihBN.js.map} +1 -1
  30. package/lib/{Route-Cq7WBHPC.js → Route-DAF15JAU.js} +2 -2
  31. package/lib/{Route-Cq7WBHPC.js.map → Route-DAF15JAU.js.map} +1 -1
  32. package/lib/{index-DGb_offs.js → index-CtKkHGcd.js} +4 -4
  33. package/lib/{index-DGb_offs.js.map → index-CtKkHGcd.js.map} +1 -1
  34. package/lib/{joinPath-VeNuJa7y.js → joinPath-B7kNnUX4.js} +2 -2
  35. package/lib/{joinPath-VeNuJa7y.js.map → joinPath-B7kNnUX4.js.map} +1 -1
  36. package/lib/{utils-D3g3xyZM.js → utils-Bh4upQ0e.js} +2 -2
  37. package/lib/{utils-D3g3xyZM.js.map → utils-Bh4upQ0e.js.map} +1 -1
  38. package/lib/zudoku.components.js +3 -2
  39. package/lib/zudoku.components.js.map +1 -1
  40. package/lib/zudoku.plugin-markdown.js +1 -1
  41. package/lib/zudoku.plugin-openapi.js +2 -2
  42. package/package.json +2 -2
  43. package/src/app/demo.tsx +51 -36
  44. package/src/app/main.tsx +1 -0
  45. package/src/app/standalone.tsx +40 -39
  46. package/src/lib/components/Bootstrap.tsx +3 -2
  47. package/src/lib/components/Layout.tsx +3 -0
  48. package/src/lib/util/joinPath.tsx +1 -1
@@ -6,7 +6,7 @@ const u = (t, e) => Object.entries(t).flatMap(([a, r]) => {
6
6
  return {
7
7
  path: s.at(-1) === "index" ? s.slice(0, -1).join("/") : o,
8
8
  lazy: async () => {
9
- const { MdxPage: i } = await import("./MdxPage-3-PenZs2.js"), { default: p, ...c } = await r();
9
+ const { MdxPage: i } = await import("./MdxPage-oN3huD58.js"), { default: p, ...c } = await r();
10
10
  return {
11
11
  element: /* @__PURE__ */ m.jsx(
12
12
  i,
@@ -1,11 +1,11 @@
1
1
  import "./jsx-runtime-B6kdoens.js";
2
- import { o as l } from "./index-DGb_offs.js";
2
+ import { o as l } from "./index-CtKkHGcd.js";
3
3
  import "./urql-DrBfkb92.js";
4
4
  import "./ZudokuContext-BIZ8zHbZ.js";
5
5
  import "zudoku/openapi-worker";
6
6
  import "./Combination-D-9IH0zy.js";
7
7
  import "./Markdown-B_Gax7at.js";
8
- import "./joinPath-VeNuJa7y.js";
8
+ import "./joinPath-B7kNnUX4.js";
9
9
  import "./router-BiRCp01d.js";
10
10
  import "./index-7kcHaXD6.js";
11
11
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.95",
3
+ "version": "0.3.0-dev.96",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -185,7 +185,7 @@
185
185
  "scripts": {
186
186
  "build": "tsc --project tsconfig.json",
187
187
  "build:vite": "vite build && pnpm run hack:fix-worker-paths lib",
188
- "build:standalone:vite": "vite build --config vite.standalone.config.ts",
188
+ "build:standalone:vite": "vite build --mode standalone --config vite.standalone.config.ts",
189
189
  "build:standalone:html": "cp ./src/app/standalone.html ./standalone/standalone.html && cp ./src/app/demo.html ./standalone/demo.html && cp ./src/app/demo-cdn.html ./standalone/index.html",
190
190
  "hack:fix-worker-paths": "node ./scripts/hack-worker.mjs",
191
191
  "clean": "tsc --build --clean",
package/src/app/demo.tsx CHANGED
@@ -1,46 +1,61 @@
1
- import { StrictMode } from "react";
2
- import { createRoot } from "react-dom/client";
3
-
4
- // Styles
5
- import "./main.css";
6
-
7
- // Logger
8
1
  import logger from "loglevel";
2
+ import { createRoot } from "react-dom/client";
3
+ import { createBrowserRouter } from "react-router-dom";
4
+ import { Bootstrap } from "zudoku/components";
5
+ import type { ZudokuConfig } from "../config/validators/validate.js";
6
+ import { openApiPlugin } from "../lib/plugins/openapi/index.js";
9
7
  import "../lib/util/logInit.js";
8
+ import "./main.css";
9
+ import { getRoutesByConfig } from "./main.js";
10
10
 
11
- // Base React Component
12
- import { DevPortal } from "../lib/components/DevPortal.js";
11
+ const apiUrl = new URL(window.location.href).searchParams.get("api-url");
13
12
 
14
- // Plugins
15
- import { openApiPlugin } from "../lib/plugins/openapi/index.js";
13
+ if (!apiUrl) {
14
+ throw new Error(
15
+ "No API URL in query parameters. Please provide an API URL using the `api-url` query parameter.",
16
+ );
17
+ }
16
18
 
17
- const apiUrl = new URL(window.location.href).searchParams.get("api-url");
18
19
  logger.info(`API URL: ${apiUrl}`);
19
20
 
21
+ const root = document.getElementById("root");
22
+
23
+ if (!root) {
24
+ throw new Error("No div found with id root");
25
+ }
26
+
20
27
  // IMPORTANT: This component must not contain tailwind classes
21
28
  // This directory is not processed by the tailwind plugin
22
29
 
23
- createRoot(document.getElementById("root")!).render(
24
- <StrictMode>
25
- <DevPortal
26
- page={{
27
- logo: {
28
- src: {
29
- light: "https://cdn.zudoku.dev/logos/icon.svg",
30
- dark: "https://cdn.zudoku.dev/logos/icon.svg",
31
- },
32
- },
33
- pageTitle: "Developer Portal",
34
- }}
35
- topNavigation={[
36
- {
37
- id: "demo",
38
- label: "API Reference",
39
- },
40
- ]}
41
- plugins={[
42
- openApiPlugin({ type: "url", input: apiUrl!, navigationId: "demo" }),
43
- ]}
44
- />
45
- </StrictMode>,
46
- );
30
+ const config = {
31
+ page: {
32
+ logo: {
33
+ src: {
34
+ light: "https://cdn.zudoku.dev/logos/icon.svg",
35
+ dark: "https://cdn.zudoku.dev/logos/icon.svg",
36
+ },
37
+ },
38
+ pageTitle: "Developer Portal",
39
+ },
40
+ topNavigation: [
41
+ {
42
+ id: "/",
43
+ label: "API Reference",
44
+ },
45
+ ],
46
+ plugins: [
47
+ // Using the plugin directly because there's no config file to load in the virtual plugins
48
+ openApiPlugin({
49
+ type: "url",
50
+ input: apiUrl,
51
+ navigationId: "/",
52
+ inMemory: true,
53
+ }),
54
+ ],
55
+ } satisfies ZudokuConfig;
56
+
57
+ const routes = getRoutesByConfig(config);
58
+ const router = createBrowserRouter(routes, {
59
+ basename: "/demo",
60
+ });
61
+ createRoot(root).render(<Bootstrap router={router} />);
package/src/app/main.tsx CHANGED
@@ -49,6 +49,7 @@ export const convertZudokuConfigToOptions = (
49
49
  ...(configuredAuthProvider?.getAuthenticationPlugin
50
50
  ? [configuredAuthProvider.getAuthenticationPlugin()]
51
51
  : []),
52
+ ...(config.plugins ?? []),
52
53
  ],
53
54
  };
54
55
  };
@@ -1,20 +1,14 @@
1
- import { StrictMode } from "react";
2
1
  import { createRoot } from "react-dom/client";
3
-
4
- // Styles
5
- import "./main.css";
6
-
7
- // Logger
8
- import "../lib/util/logInit.js";
9
-
10
- // Base React Component
11
- import { DevPortal } from "../lib/components/DevPortal.js";
12
-
13
- // Plugins
2
+ import { createBrowserRouter } from "react-router-dom";
3
+ import { Bootstrap } from "zudoku/components";
4
+ import type { ZudokuConfig } from "../config/validators/validate.js";
14
5
  import { openApiPlugin } from "../lib/plugins/openapi/index.js";
6
+ import "../lib/util/logInit.js";
7
+ import "./main.css";
8
+ import { getRoutesByConfig } from "./main.js";
15
9
 
16
- const root = document.querySelector("[data-api-url]");
17
- if (!root || root.tagName !== "DIV") {
10
+ const root = document.querySelector("div[data-api-url]");
11
+ if (!root) {
18
12
  throw new Error("No div found with attribute data-api-url");
19
13
  }
20
14
 
@@ -25,28 +19,35 @@ const logoUrl = root.getAttribute("data-logo-url");
25
19
  // IMPORTANT: This component must not contain tailwind classes
26
20
  // This directory is not processed by the tailwind plugin
27
21
 
28
- createRoot(root).render(
29
- <StrictMode>
30
- <DevPortal
31
- page={{
32
- logo: {
33
- src: {
34
- light: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
35
- dark: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
36
- },
37
- },
38
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
39
- pageTitle: pageTitle ?? "Developer Portal",
40
- }}
41
- topNavigation={[
42
- {
43
- id: "demo",
44
- label: "API Reference",
45
- },
46
- ]}
47
- plugins={[
48
- openApiPlugin({ type: "url", input: apiUrl!, navigationId: "/" }),
49
- ]}
50
- />
51
- </StrictMode>,
52
- );
22
+ const config = {
23
+ page: {
24
+ logo: {
25
+ src: {
26
+ light: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
27
+ dark: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
28
+ },
29
+ },
30
+ pageTitle: pageTitle ?? "Developer Portal",
31
+ },
32
+ topNavigation: [
33
+ {
34
+ id: "/",
35
+ label: "API Reference",
36
+ },
37
+ ],
38
+ plugins: [
39
+ // Using the plugin directly because there's no config file to load in the virtual plugins
40
+ openApiPlugin({
41
+ type: "url",
42
+ input: apiUrl!,
43
+ navigationId: "/",
44
+ inMemory: true,
45
+ }),
46
+ ],
47
+ } satisfies ZudokuConfig;
48
+
49
+ const routes = getRoutesByConfig(config);
50
+ const router = createBrowserRouter(routes, {
51
+ basename: "/standalone",
52
+ });
53
+ createRoot(root).render(<Bootstrap router={router} />);
@@ -1,7 +1,8 @@
1
1
  import { type HelmetData, HelmetProvider } from "@zudoku/react-helmet-async";
2
2
  import { StrictMode } from "react";
3
- import { createBrowserRouter, RouterProvider } from "react-router-dom";
3
+ import { type createBrowserRouter, RouterProvider } from "react-router-dom";
4
4
  import {
5
+ type createStaticRouter,
5
6
  type StaticHandlerContext,
6
7
  StaticRouterProvider,
7
8
  } from "react-router-dom/server.js";
@@ -32,7 +33,7 @@ const BootstrapStatic = ({
32
33
  }: {
33
34
  helmetContext: HelmetData["context"];
34
35
  context: StaticHandlerContext;
35
- router: ReturnType<typeof createBrowserRouter>;
36
+ router: ReturnType<typeof createStaticRouter>;
36
37
  }) => (
37
38
  <StrictMode>
38
39
  <HelmetProvider context={helmetContext}>
@@ -31,6 +31,9 @@ export const Layout = ({ children }: { children?: ReactNode }) => {
31
31
 
32
32
  return (
33
33
  <>
34
+ {import.meta.env.MODE === "standalone" && (
35
+ <style>{`:root { --top-nav-height: 0px; }`}</style>
36
+ )}
34
37
  <Helmet titleTemplate={meta?.title}>
35
38
  {meta?.description && (
36
39
  <meta name="description" content={meta.description} />
@@ -7,5 +7,5 @@ export const joinPath = (
7
7
  .join("/")
8
8
  .replace(/(^\/+|\/+$)/g, "");
9
9
 
10
- return cleanPath ? `/${cleanPath}` : "";
10
+ return cleanPath ? `/${cleanPath}` : "/";
11
11
  };