@clarify-labs/renderer 0.7.0 → 0.7.2

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 (64) hide show
  1. package/output/{OpenApiOperation-ZXToVSFC.cjs → OpenApiOperation-BcyW_ULy.cjs} +186 -140
  2. package/output/OpenApiOperation-BcyW_ULy.cjs.map +1 -0
  3. package/output/{OpenApiOperation-CWSOhUVa.js → OpenApiOperation-tUKf7lZ4.js} +166 -120
  4. package/output/OpenApiOperation-tUKf7lZ4.js.map +1 -0
  5. package/output/{shell-xxhV0p7k.cjs → PageActions-1RDCHcUY.cjs} +280 -308
  6. package/output/PageActions-1RDCHcUY.cjs.map +1 -0
  7. package/output/{shell-CumiARRe.js → PageActions-yoDRjkq8.js} +235 -263
  8. package/output/PageActions-yoDRjkq8.js.map +1 -0
  9. package/output/{ThemeRoot-C_ZdzSMu.js → ThemeRoot-QULrwQf6.js} +407 -53
  10. package/output/ThemeRoot-QULrwQf6.js.map +1 -0
  11. package/output/{ThemeRoot-CEvwrGp5.cjs → ThemeRoot-UWj0iK1X.cjs} +458 -80
  12. package/output/ThemeRoot-UWj0iK1X.cjs.map +1 -0
  13. package/output/app/AppShell.d.ts +3 -2
  14. package/output/app/PageActions.d.ts +12 -0
  15. package/output/app/PageBanner.d.ts +7 -0
  16. package/output/app/SectionProvider.d.ts +1 -0
  17. package/output/client.cjs +14 -7
  18. package/output/client.d.ts +4 -2
  19. package/output/client.js +4 -4
  20. package/output/context.d.ts +1 -1
  21. package/output/core/context.d.ts +5 -5
  22. package/output/core/index.d.ts +1 -1
  23. package/output/core/types.d.ts +70 -61
  24. package/output/index.cjs +56 -28
  25. package/output/index.cjs.map +1 -1
  26. package/output/index.d.ts +7 -5
  27. package/output/index.js +37 -12
  28. package/output/index.js.map +1 -1
  29. package/output/mdx/components.d.ts +2 -0
  30. package/output/mdx/primitives.d.ts +2 -0
  31. package/output/openapi/components/EndpointSections.d.ts +30 -0
  32. package/output/preview.cjs +7 -7
  33. package/output/preview.cjs.map +1 -1
  34. package/output/preview.js +4 -4
  35. package/output/preview.js.map +1 -1
  36. package/output/{render-zHU25Nm9.cjs → render-ByWbJbrA.cjs} +8 -7
  37. package/output/render-ByWbJbrA.cjs.map +1 -0
  38. package/output/{render-CnUd0XwZ.js → render-psutGbsg.js} +6 -5
  39. package/output/render-psutGbsg.js.map +1 -0
  40. package/output/renderer.css +371 -269
  41. package/output/server.cjs +8 -7
  42. package/output/server.cjs.map +1 -1
  43. package/output/server.js +5 -4
  44. package/output/server.js.map +1 -1
  45. package/output/shell/ContentActions.d.ts +0 -1
  46. package/output/shell/Header.d.ts +3 -2
  47. package/output/shell/SiteLogo.d.ts +2 -2
  48. package/output/shell/mobile.d.ts +2 -2
  49. package/output/theme/ThemeEditor.d.ts +53 -17
  50. package/output/theme/ThemeProvider.d.ts +2 -1
  51. package/output/theme/ThemeRoot.d.ts +2 -2
  52. package/output/theme/cookies.d.ts +11 -0
  53. package/output/theme/randomTheme.d.ts +2 -2
  54. package/output/theme/variables.d.ts +58 -20
  55. package/output/utils/href.d.ts +3 -3
  56. package/package.json +1 -1
  57. package/output/OpenApiOperation-CWSOhUVa.js.map +0 -1
  58. package/output/OpenApiOperation-ZXToVSFC.cjs.map +0 -1
  59. package/output/ThemeRoot-CEvwrGp5.cjs.map +0 -1
  60. package/output/ThemeRoot-C_ZdzSMu.js.map +0 -1
  61. package/output/render-CnUd0XwZ.js.map +0 -1
  62. package/output/render-zHU25Nm9.cjs.map +0 -1
  63. package/output/shell-CumiARRe.js.map +0 -1
  64. package/output/shell-xxhV0p7k.cjs.map +0 -1
package/output/server.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_shell = require("./shell-xxhV0p7k.cjs");
3
- const require_ThemeRoot = require("./ThemeRoot-CEvwrGp5.cjs");
2
+ const require_PageActions = require("./PageActions-1RDCHcUY.cjs");
3
+ const require_ThemeRoot = require("./ThemeRoot-UWj0iK1X.cjs");
4
4
  let react = require("react");
5
5
  let react_router_dom = require("react-router-dom");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -12,22 +12,23 @@ let react_dom_server = require("react-dom/server");
12
12
  * 返回 `div#root` 内部的 HTML,由 Clarify CLI 组装为完整的 HTML 文档。
13
13
  */
14
14
  function renderToHTML(options) {
15
- const { config, routes, navigation, openApis = {}, footerComponent, url, themeEditor = false } = options;
16
- const location = require_shell.prefixHref(url, config.routePrefix);
15
+ const { config, routes, navigation, openApis = {}, bannerComponent, footerComponent, url, themeEditor = false } = options;
16
+ const location = require_PageActions.prefixHref(url, config.routePrefix);
17
17
  return (0, react_dom_server.renderToString)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.StrictMode, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.StaticRouter, {
18
18
  basename: config.routePrefix,
19
19
  location,
20
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ClarifyConfigContext.Provider, {
20
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.ConfigContext.Provider, {
21
21
  value: config,
22
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.OpenApisContext.Provider, {
22
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.OpenApisContext.Provider, {
23
23
  value: openApis,
24
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ThemeProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ThemeRoot.ThemeRoot, {
24
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.ThemeProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ThemeRoot.ThemeRoot, {
25
25
  theme: config.theme,
26
26
  themeEditor,
27
27
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ThemeRoot.AppShell, {
28
28
  config,
29
29
  routes,
30
30
  navigation: navigation ?? [],
31
+ bannerComponent,
31
32
  footerComponent
32
33
  })
33
34
  }) })
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":[],"sources":["../source/runtime/server.tsx"],"sourcesContent":["import { StrictMode } from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { StaticRouter } from 'react-router-dom'\n\nimport { AppShell } from '../app/AppShell'\nimport { ClarifyConfigContext, OpenApisContext } from '../context'\nimport { ThemeProvider } from '../theme/ThemeProvider'\nimport { ThemeRoot } from '../theme/ThemeRoot'\nimport type { ServerRenderOptions } from '../types'\nimport { prefixHref } from '../utils/href'\n\n/**\n * Clarify 服务端渲染入口。\n * 由 @clarify-labs/cli 在构建时调用,为每条路由生成 React HTML 片段。\n * 返回 `div#root` 内部的 HTML,由 Clarify CLI 组装为完整的 HTML 文档。\n */\nexport function renderToHTML(options: ServerRenderOptions): string {\n const { config, routes, navigation, openApis = {}, footerComponent, url, themeEditor = false } = options\n const location = prefixHref(url, config.routePrefix)\n\n return renderToString(\n <StrictMode>\n <StaticRouter basename={config.routePrefix} location={location}>\n <ClarifyConfigContext.Provider value={config}>\n <OpenApisContext.Provider value={openApis}>\n <ThemeProvider>\n <ThemeRoot theme={config.theme} themeEditor={themeEditor}>\n <AppShell config={config} routes={routes} navigation={navigation ?? []} footerComponent={footerComponent} />\n </ThemeRoot>\n </ThemeProvider>\n </OpenApisContext.Provider>\n </ClarifyConfigContext.Provider>\n </StaticRouter>\n </StrictMode>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,aAAa,SAAsC;CACjE,MAAM,EAAE,QAAQ,QAAQ,YAAY,WAAW,CAAC,GAAG,iBAAiB,KAAK,cAAc,UAAU;CACjG,MAAM,WAAW,cAAA,WAAW,KAAK,OAAO,WAAW;CAEnD,QAAA,GAAA,iBAAA,gBACE,iBAAA,GAAA,kBAAA,KAAC,MAAA,YAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,iBAAA,cAAD;EAAc,UAAU,OAAO;EAAuB;YACpD,iBAAA,GAAA,kBAAA,KAAC,cAAA,qBAAqB,UAAtB;GAA+B,OAAO;aACpC,iBAAA,GAAA,kBAAA,KAAC,cAAA,gBAAgB,UAAjB;IAA0B,OAAO;cAC/B,iBAAA,GAAA,kBAAA,KAAC,cAAA,eAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,kBAAA,WAAD;KAAW,OAAO,OAAO;KAAoB;eAC3C,iBAAA,GAAA,kBAAA,KAAC,kBAAA,UAAD;MAAkB;MAAgB;MAAQ,YAAY,cAAc,CAAC;MAAoB;KAAkB,CAAA;IAClG,CAAA,EACE,CAAA;GACS,CAAA;EACG,CAAA;CACnB,CAAA,EACJ,CAAA,CACd;AACF"}
1
+ {"version":3,"file":"server.cjs","names":[],"sources":["../source/runtime/server.tsx"],"sourcesContent":["import { StrictMode } from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { StaticRouter } from 'react-router-dom'\n\nimport { AppShell } from '../app/AppShell'\nimport { ConfigContext, OpenApisContext } from '../context'\nimport { ThemeProvider } from '../theme/ThemeProvider'\nimport { ThemeRoot } from '../theme/ThemeRoot'\nimport type { ServerRenderOptions } from '../types'\nimport { prefixHref } from '../utils/href'\n\n/**\n * Clarify 服务端渲染入口。\n * 由 @clarify-labs/cli 在构建时调用,为每条路由生成 React HTML 片段。\n * 返回 `div#root` 内部的 HTML,由 Clarify CLI 组装为完整的 HTML 文档。\n */\nexport function renderToHTML(options: ServerRenderOptions): string {\n const { config, routes, navigation, openApis = {}, bannerComponent, footerComponent, url, themeEditor = false } = options\n const location = prefixHref(url, config.routePrefix)\n\n return renderToString(\n <StrictMode>\n <StaticRouter basename={config.routePrefix} location={location}>\n <ConfigContext.Provider value={config}>\n <OpenApisContext.Provider value={openApis}>\n <ThemeProvider>\n <ThemeRoot theme={config.theme} themeEditor={themeEditor}>\n <AppShell config={config} routes={routes} navigation={navigation ?? []} bannerComponent={bannerComponent} footerComponent={footerComponent} />\n </ThemeRoot>\n </ThemeProvider>\n </OpenApisContext.Provider>\n </ConfigContext.Provider>\n </StaticRouter>\n </StrictMode>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,aAAa,SAAsC;CACjE,MAAM,EAAE,QAAQ,QAAQ,YAAY,WAAW,CAAC,GAAG,iBAAiB,iBAAiB,KAAK,cAAc,UAAU;CAClH,MAAM,WAAW,oBAAA,WAAW,KAAK,OAAO,WAAW;CAEnD,QAAA,GAAA,iBAAA,gBACE,iBAAA,GAAA,kBAAA,KAAC,MAAA,YAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,iBAAA,cAAD;EAAc,UAAU,OAAO;EAAuB;YACpD,iBAAA,GAAA,kBAAA,KAAC,oBAAA,cAAc,UAAf;GAAwB,OAAO;aAC7B,iBAAA,GAAA,kBAAA,KAAC,oBAAA,gBAAgB,UAAjB;IAA0B,OAAO;cAC/B,iBAAA,GAAA,kBAAA,KAAC,oBAAA,eAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,kBAAA,WAAD;KAAW,OAAO,OAAO;KAAoB;eAC3C,iBAAA,GAAA,kBAAA,KAAC,kBAAA,UAAD;MAAkB;MAAgB;MAAQ,YAAY,cAAc,CAAC;MAAoB;MAAkC;KAAkB,CAAA;IACpI,CAAA,EACE,CAAA;GACS,CAAA;EACJ,CAAA;CACZ,CAAA,EACJ,CAAA,CACd;AACF"}
package/output/server.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as OpenApisContext, O as ClarifyConfigContext, T as prefixHref, f as ThemeProvider } from "./shell-CumiARRe.js";
2
- import { a as AppShell, t as ThemeRoot } from "./ThemeRoot-C_ZdzSMu.js";
1
+ import { A as OpenApisContext, O as ConfigContext, T as prefixHref, m as ThemeProvider } from "./PageActions-yoDRjkq8.js";
2
+ import { c as AppShell, t as ThemeRoot } from "./ThemeRoot-QULrwQf6.js";
3
3
  import { StrictMode } from "react";
4
4
  import { StaticRouter } from "react-router-dom";
5
5
  import { jsx } from "react/jsx-runtime";
@@ -11,12 +11,12 @@ import { renderToString } from "react-dom/server";
11
11
  * 返回 `div#root` 内部的 HTML,由 Clarify CLI 组装为完整的 HTML 文档。
12
12
  */
13
13
  function renderToHTML(options) {
14
- const { config, routes, navigation, openApis = {}, footerComponent, url, themeEditor = false } = options;
14
+ const { config, routes, navigation, openApis = {}, bannerComponent, footerComponent, url, themeEditor = false } = options;
15
15
  const location = prefixHref(url, config.routePrefix);
16
16
  return renderToString(/* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(StaticRouter, {
17
17
  basename: config.routePrefix,
18
18
  location,
19
- children: /* @__PURE__ */ jsx(ClarifyConfigContext.Provider, {
19
+ children: /* @__PURE__ */ jsx(ConfigContext.Provider, {
20
20
  value: config,
21
21
  children: /* @__PURE__ */ jsx(OpenApisContext.Provider, {
22
22
  value: openApis,
@@ -27,6 +27,7 @@ function renderToHTML(options) {
27
27
  config,
28
28
  routes,
29
29
  navigation: navigation ?? [],
30
+ bannerComponent,
30
31
  footerComponent
31
32
  })
32
33
  }) })
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../source/runtime/server.tsx"],"sourcesContent":["import { StrictMode } from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { StaticRouter } from 'react-router-dom'\n\nimport { AppShell } from '../app/AppShell'\nimport { ClarifyConfigContext, OpenApisContext } from '../context'\nimport { ThemeProvider } from '../theme/ThemeProvider'\nimport { ThemeRoot } from '../theme/ThemeRoot'\nimport type { ServerRenderOptions } from '../types'\nimport { prefixHref } from '../utils/href'\n\n/**\n * Clarify 服务端渲染入口。\n * 由 @clarify-labs/cli 在构建时调用,为每条路由生成 React HTML 片段。\n * 返回 `div#root` 内部的 HTML,由 Clarify CLI 组装为完整的 HTML 文档。\n */\nexport function renderToHTML(options: ServerRenderOptions): string {\n const { config, routes, navigation, openApis = {}, footerComponent, url, themeEditor = false } = options\n const location = prefixHref(url, config.routePrefix)\n\n return renderToString(\n <StrictMode>\n <StaticRouter basename={config.routePrefix} location={location}>\n <ClarifyConfigContext.Provider value={config}>\n <OpenApisContext.Provider value={openApis}>\n <ThemeProvider>\n <ThemeRoot theme={config.theme} themeEditor={themeEditor}>\n <AppShell config={config} routes={routes} navigation={navigation ?? []} footerComponent={footerComponent} />\n </ThemeRoot>\n </ThemeProvider>\n </OpenApisContext.Provider>\n </ClarifyConfigContext.Provider>\n </StaticRouter>\n </StrictMode>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,aAAa,SAAsC;CACjE,MAAM,EAAE,QAAQ,QAAQ,YAAY,WAAW,CAAC,GAAG,iBAAiB,KAAK,cAAc,UAAU;CACjG,MAAM,WAAW,WAAW,KAAK,OAAO,WAAW;CAEnD,OAAO,eACL,oBAAC,YAAD,EAAA,UACE,oBAAC,cAAD;EAAc,UAAU,OAAO;EAAuB;YACpD,oBAAC,qBAAqB,UAAtB;GAA+B,OAAO;aACpC,oBAAC,gBAAgB,UAAjB;IAA0B,OAAO;cAC/B,oBAAC,eAAD,EAAA,UACE,oBAAC,WAAD;KAAW,OAAO,OAAO;KAAoB;eAC3C,oBAAC,UAAD;MAAkB;MAAgB;MAAQ,YAAY,cAAc,CAAC;MAAoB;KAAkB,CAAA;IAClG,CAAA,EACE,CAAA;GACS,CAAA;EACG,CAAA;CACnB,CAAA,EACJ,CAAA,CACd;AACF"}
1
+ {"version":3,"file":"server.js","names":[],"sources":["../source/runtime/server.tsx"],"sourcesContent":["import { StrictMode } from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { StaticRouter } from 'react-router-dom'\n\nimport { AppShell } from '../app/AppShell'\nimport { ConfigContext, OpenApisContext } from '../context'\nimport { ThemeProvider } from '../theme/ThemeProvider'\nimport { ThemeRoot } from '../theme/ThemeRoot'\nimport type { ServerRenderOptions } from '../types'\nimport { prefixHref } from '../utils/href'\n\n/**\n * Clarify 服务端渲染入口。\n * 由 @clarify-labs/cli 在构建时调用,为每条路由生成 React HTML 片段。\n * 返回 `div#root` 内部的 HTML,由 Clarify CLI 组装为完整的 HTML 文档。\n */\nexport function renderToHTML(options: ServerRenderOptions): string {\n const { config, routes, navigation, openApis = {}, bannerComponent, footerComponent, url, themeEditor = false } = options\n const location = prefixHref(url, config.routePrefix)\n\n return renderToString(\n <StrictMode>\n <StaticRouter basename={config.routePrefix} location={location}>\n <ConfigContext.Provider value={config}>\n <OpenApisContext.Provider value={openApis}>\n <ThemeProvider>\n <ThemeRoot theme={config.theme} themeEditor={themeEditor}>\n <AppShell config={config} routes={routes} navigation={navigation ?? []} bannerComponent={bannerComponent} footerComponent={footerComponent} />\n </ThemeRoot>\n </ThemeProvider>\n </OpenApisContext.Provider>\n </ConfigContext.Provider>\n </StaticRouter>\n </StrictMode>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,aAAa,SAAsC;CACjE,MAAM,EAAE,QAAQ,QAAQ,YAAY,WAAW,CAAC,GAAG,iBAAiB,iBAAiB,KAAK,cAAc,UAAU;CAClH,MAAM,WAAW,WAAW,KAAK,OAAO,WAAW;CAEnD,OAAO,eACL,oBAAC,YAAD,EAAA,UACE,oBAAC,cAAD;EAAc,UAAU,OAAO;EAAuB;YACpD,oBAAC,cAAc,UAAf;GAAwB,OAAO;aAC7B,oBAAC,gBAAgB,UAAjB;IAA0B,OAAO;cAC/B,oBAAC,eAAD,EAAA,UACE,oBAAC,WAAD;KAAW,OAAO,OAAO;KAAoB;eAC3C,oBAAC,UAAD;MAAkB;MAAgB;MAAQ,YAAY,cAAc,CAAC;MAAoB;MAAkC;KAAkB,CAAA;IACpI,CAAA,EACE,CAAA;GACS,CAAA;EACJ,CAAA;CACZ,CAAA,EACJ,CAAA,CACd;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { RouteItem } from '../types';
2
2
  type ContentActionsProps = {
3
- hasTabs?: boolean;
4
3
  route?: RouteItem;
5
4
  routePrefix?: string;
6
5
  };
@@ -1,9 +1,10 @@
1
- import { ClarifyConfig, NavigationNode, NavigationTab, RouteItem } from '../types';
1
+ import { Config, NavigationNode, NavigationTab, RouteItem } from '../types';
2
2
  export declare const Header: import('react').ForwardRefExoticComponent<Omit<Omit<import('framer-motion').HTMLMotionProps<"header">, "ref"> & import('react').RefAttributes<HTMLElement>, "ref"> & {
3
- config: ClarifyConfig;
3
+ config: Config;
4
4
  navigation: NavigationNode[];
5
5
  tabs?: NavigationTab[];
6
6
  routes: RouteItem[];
7
7
  currentLocale?: string;
8
8
  currentRoute?: RouteItem;
9
+ banner?: React.ReactNode;
9
10
  } & import('react').RefAttributes<HTMLElement>>;
@@ -1,6 +1,6 @@
1
- import { ClarifyLogoConfig } from '../core/types';
1
+ import { LogoConfig } from '../core/types';
2
2
  export type SiteLogoProps = {
3
- logo?: ClarifyLogoConfig;
3
+ logo?: LogoConfig;
4
4
  className?: string;
5
5
  };
6
6
  export declare function SiteLogo(arg0: SiteLogoProps): import("react").JSX.Element | null;
@@ -1,4 +1,4 @@
1
- import { ClarifyConfig, NavigationNode, NavigationTab, RouteItem } from '../types';
1
+ import { Config, NavigationNode, NavigationTab, RouteItem } from '../types';
2
2
  export declare function useIsInsideMobileNavigation(): boolean;
3
3
  export declare const useMobileNavigationStore: import('zustand').UseBoundStore<import('zustand').StoreApi<{
4
4
  isOpen: boolean;
@@ -7,7 +7,7 @@ export declare const useMobileNavigationStore: import('zustand').UseBoundStore<i
7
7
  toggle: () => void;
8
8
  }>>;
9
9
  export type MobileNavigationProps = {
10
- config: ClarifyConfig;
10
+ config: Config;
11
11
  navigation: NavigationNode[];
12
12
  tabs?: NavigationTab[];
13
13
  routes: RouteItem[];
@@ -1,29 +1,47 @@
1
- import { ClarifyThemeConfig } from '../types';
1
+ import { ThemeConfig } from '../types';
2
2
  import { ThemeVariableTarget } from './variables';
3
3
  export type ThemeEditorProps = {
4
4
  /** The resolved theme to use as the editor's initial value. */
5
- initialTheme?: ClarifyThemeConfig;
5
+ initialTheme?: ThemeConfig;
6
6
  /** Called every time a token changes. */
7
- onChange?: (theme: ClarifyThemeConfig) => void;
7
+ onChange?: (theme: ThemeConfig) => void;
8
8
  /** CSS variable target. Defaults to documentElement and every .clarify-app root. */
9
9
  target?: ThemeVariableTarget;
10
10
  /** Whether the panel is open by default. */
11
11
  defaultOpen?: boolean;
12
12
  className?: string;
13
13
  };
14
- export declare const clarifyThemeEditorPresets: {
14
+ export declare const themeEditorPresets: {
15
15
  default: {
16
16
  preset: "default";
17
17
  tokens: {
18
18
  colors: {
19
19
  primary: string;
20
20
  accent: string;
21
- background: string;
22
- foreground: string;
23
- surface: string;
24
- muted: string;
25
- border: string;
26
- codeBackground: string;
21
+ background: {
22
+ light: string;
23
+ dark: string;
24
+ };
25
+ foreground: {
26
+ light: string;
27
+ dark: string;
28
+ };
29
+ surface: {
30
+ light: string;
31
+ dark: string;
32
+ };
33
+ muted: {
34
+ light: string;
35
+ dark: string;
36
+ };
37
+ border: {
38
+ light: string;
39
+ dark: string;
40
+ };
41
+ codeBackground: {
42
+ light: string;
43
+ dark: string;
44
+ };
27
45
  };
28
46
  radius: {
29
47
  sm: string;
@@ -43,12 +61,30 @@ export declare const clarifyThemeEditorPresets: {
43
61
  colors: {
44
62
  primary: string;
45
63
  accent: string;
46
- background: string;
47
- foreground: string;
48
- surface: string;
49
- muted: string;
50
- border: string;
51
- codeBackground: string;
64
+ background: {
65
+ light: string;
66
+ dark: string;
67
+ };
68
+ foreground: {
69
+ light: string;
70
+ dark: string;
71
+ };
72
+ surface: {
73
+ light: string;
74
+ dark: string;
75
+ };
76
+ muted: {
77
+ light: string;
78
+ dark: string;
79
+ };
80
+ border: {
81
+ light: string;
82
+ dark: string;
83
+ };
84
+ codeBackground: {
85
+ light: string;
86
+ dark: string;
87
+ };
52
88
  };
53
89
  radius: {
54
90
  sm: string;
@@ -63,5 +99,5 @@ export declare const clarifyThemeEditorPresets: {
63
99
  editor: false;
64
100
  };
65
101
  };
66
- export declare function applyClarifyThemeVariables(theme: ClarifyThemeConfig, target?: ThemeVariableTarget): () => void;
102
+ export declare function applyThemeVariables(theme: ThemeConfig, target?: ThemeVariableTarget): () => void;
67
103
  export declare function ThemeEditor(props: ThemeEditorProps): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- export type Theme = 'light' | 'dark' | 'system';
2
+ import { ThemePreference } from './cookies';
3
+ export type Theme = ThemePreference;
3
4
  export type ResolvedTheme = 'light' | 'dark';
4
5
  type ThemeContextValue = {
5
6
  theme: Theme;
@@ -1,8 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import { ClarifyThemeConfig } from '../types';
2
+ import { ThemeConfig } from '../types';
3
3
  type ThemeRootProps = {
4
4
  children: ReactNode;
5
- theme: ClarifyThemeConfig;
5
+ theme: ThemeConfig;
6
6
  themeEditor?: boolean;
7
7
  };
8
8
  export declare function ThemeRoot(props: ThemeRootProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ export type ThemePreference = 'light' | 'dark' | 'system';
2
+ export declare const themeCookieName = "clarify-theme";
3
+ export declare const localeCookieName = "clarify-locale";
4
+ export declare function isThemePreference(value: string | null | undefined): value is ThemePreference;
5
+ export declare function readThemeCookie(): ThemePreference | null;
6
+ export declare function getStoredThemePreference(): ThemePreference;
7
+ export declare function storeThemePreference(theme: ThemePreference): void;
8
+ export declare function readLocaleCookie(): string | null;
9
+ export declare function getStoredLocalePreference(locales?: readonly string[]): string | null;
10
+ export declare function storeLocalePreference(locale: string): void;
11
+ export declare function resolveSharedCookieDomains(hostname?: string): string[];
@@ -1,2 +1,2 @@
1
- import { ClarifyThemeConfig } from '../types';
2
- export declare function createRandomTheme(): ClarifyThemeConfig;
1
+ import { ThemeConfig } from '../types';
2
+ export declare function createRandomTheme(): ThemeConfig;
@@ -1,21 +1,41 @@
1
1
  import { CSSProperties } from 'react';
2
- import { ClarifyThemeColorTokensConfig, ClarifyThemeColorValue, ClarifyThemeConfig } from '../types';
2
+ import { ThemeColorTokensConfig, ThemeColorValue, ThemeConfig } from '../types';
3
+ import { themeCookieName } from './cookies';
3
4
  export type ThemeCssVariables = CSSProperties & Record<`--clarify-theme-${string}`, string>;
4
5
  export type ThemeVariableTarget = HTMLElement | string;
5
- export declare const themeStorageKey = "clarify:theme";
6
- export declare const clarifyThemePresets: {
6
+ export declare const themeStorageKey = "clarify-theme";
7
+ export { themeCookieName };
8
+ export declare const themePresets: {
7
9
  default: {
8
10
  preset: "default";
9
11
  tokens: {
10
12
  colors: {
11
13
  primary: string;
12
14
  accent: string;
13
- background: string;
14
- foreground: string;
15
- surface: string;
16
- muted: string;
17
- border: string;
18
- codeBackground: string;
15
+ background: {
16
+ light: string;
17
+ dark: string;
18
+ };
19
+ foreground: {
20
+ light: string;
21
+ dark: string;
22
+ };
23
+ surface: {
24
+ light: string;
25
+ dark: string;
26
+ };
27
+ muted: {
28
+ light: string;
29
+ dark: string;
30
+ };
31
+ border: {
32
+ light: string;
33
+ dark: string;
34
+ };
35
+ codeBackground: {
36
+ light: string;
37
+ dark: string;
38
+ };
19
39
  };
20
40
  radius: {
21
41
  sm: string;
@@ -35,12 +55,30 @@ export declare const clarifyThemePresets: {
35
55
  colors: {
36
56
  primary: string;
37
57
  accent: string;
38
- background: string;
39
- foreground: string;
40
- surface: string;
41
- muted: string;
42
- border: string;
43
- codeBackground: string;
58
+ background: {
59
+ light: string;
60
+ dark: string;
61
+ };
62
+ foreground: {
63
+ light: string;
64
+ dark: string;
65
+ };
66
+ surface: {
67
+ light: string;
68
+ dark: string;
69
+ };
70
+ muted: {
71
+ light: string;
72
+ dark: string;
73
+ };
74
+ border: {
75
+ light: string;
76
+ dark: string;
77
+ };
78
+ codeBackground: {
79
+ light: string;
80
+ dark: string;
81
+ };
44
82
  };
45
83
  radius: {
46
84
  sm: string;
@@ -55,10 +93,10 @@ export declare const clarifyThemePresets: {
55
93
  editor: false;
56
94
  };
57
95
  };
58
- export declare function cloneTheme(theme: ClarifyThemeConfig): ClarifyThemeConfig;
59
- export declare function resolveThemeColorValue(value: ClarifyThemeColorValue, resolvedTheme?: 'light' | 'dark'): string;
60
- export declare function resolveThemeColors(colors: ClarifyThemeColorTokensConfig, resolvedTheme?: 'light' | 'dark'): Record<keyof ClarifyThemeColorTokensConfig, string>;
61
- export declare function themeToCssVariables(theme: ClarifyThemeConfig, resolvedTheme?: 'light' | 'dark'): ThemeCssVariables;
62
- export declare function themeBootstrapScript(theme?: ClarifyThemeConfig): string;
96
+ export declare function cloneTheme(theme: ThemeConfig): ThemeConfig;
97
+ export declare function resolveThemeColorValue(value: ThemeColorValue, resolvedTheme?: 'light' | 'dark'): string;
98
+ export declare function resolveThemeColors(colors: ThemeColorTokensConfig, resolvedTheme?: 'light' | 'dark'): Record<keyof ThemeColorTokensConfig, string>;
99
+ export declare function themeToCssVariables(theme: ThemeConfig, resolvedTheme?: 'light' | 'dark'): ThemeCssVariables;
100
+ export declare function themeBootstrapScript(theme?: ThemeConfig): string;
63
101
  export declare function resolveThemeVariableTargets(target?: ThemeVariableTarget): HTMLElement[];
64
102
  export declare function applyThemeCssVariables(variables: ThemeCssVariables, targets: HTMLElement[]): () => void;
@@ -1,5 +1,5 @@
1
- import { ClarifyConfig } from '../types';
1
+ import { Config } from '../types';
2
2
  export declare function isExternalHref(href: string): boolean;
3
- export declare function hasLocalePrefix(href: string, config: ClarifyConfig): boolean;
4
- export declare function localizeHref(href: string, config: ClarifyConfig, locale?: string): string;
3
+ export declare function hasLocalePrefix(href: string, config: Config): boolean;
4
+ export declare function localizeHref(href: string, config: Config, locale?: string): string;
5
5
  export declare function prefixHref(href: string, routePrefix?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarify-labs/renderer",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "repository": {