@clarify-labs/renderer 0.9.2 → 0.9.4

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 (49) hide show
  1. package/output/{ClarifyShell-DdYRgrfY.cjs → ClarifyShell-7r92MZg9.cjs} +134 -75
  2. package/output/ClarifyShell-7r92MZg9.cjs.map +1 -0
  3. package/output/{ClarifyShell-C38EkErX.js → ClarifyShell-D2P0iZ_m.js} +128 -75
  4. package/output/ClarifyShell-D2P0iZ_m.js.map +1 -0
  5. package/output/{OpenApiOperation-CP_fxT_F.cjs → OpenApiOperation-CyyPlZL6.cjs} +389 -135
  6. package/output/OpenApiOperation-CyyPlZL6.cjs.map +1 -0
  7. package/output/{OpenApiOperation-DIFaYAe5.js → OpenApiOperation-Dhlz3JSx.js} +391 -137
  8. package/output/OpenApiOperation-Dhlz3JSx.js.map +1 -0
  9. package/output/{PageActions-B08cDCzq.cjs → PageActions-CTn2XkPg.cjs} +16 -31
  10. package/output/PageActions-CTn2XkPg.cjs.map +1 -0
  11. package/output/{PageActions-tmnpzi23.js → PageActions-D0PA8Zv5.js} +11 -26
  12. package/output/PageActions-D0PA8Zv5.js.map +1 -0
  13. package/output/app/ContentDiagnostic.d.ts +9 -0
  14. package/output/app/ErrorBoundary.d.ts +0 -2
  15. package/output/app/RenderErrorPanel.d.ts +20 -0
  16. package/output/client.cjs +3 -3
  17. package/output/client.js +3 -3
  18. package/output/components/Tabs.d.ts +16 -0
  19. package/output/components/index.d.ts +1 -0
  20. package/output/core/context.d.ts +1 -0
  21. package/output/core/i18n.d.ts +1 -1
  22. package/output/core/types.d.ts +1 -0
  23. package/output/index.cjs +43 -4
  24. package/output/index.cjs.map +1 -1
  25. package/output/index.d.ts +5 -3
  26. package/output/index.js +42 -5
  27. package/output/index.js.map +1 -1
  28. package/output/openapi/components/EndpointSections.d.ts +2 -0
  29. package/output/openapi/components/ExamplePanels.d.ts +2 -0
  30. package/output/openapi/components/OpenApiOperation.d.ts +6 -0
  31. package/output/openapi/components/SchemaProperties.d.ts +3 -0
  32. package/output/openapi/entry.d.ts +5 -0
  33. package/output/openapi/index.d.ts +2 -2
  34. package/output/preview.cjs +2 -2
  35. package/output/preview.js +2 -2
  36. package/output/{render-6gHfrR9h.js → render-CwSsfrs7.js} +2 -2
  37. package/output/{render-6gHfrR9h.js.map → render-CwSsfrs7.js.map} +1 -1
  38. package/output/{render-Bvf5ZMZb.cjs → render-DXDSIfZ8.cjs} +2 -2
  39. package/output/{render-Bvf5ZMZb.cjs.map → render-DXDSIfZ8.cjs.map} +1 -1
  40. package/output/renderer.css +47 -1
  41. package/output/server.cjs +2 -2
  42. package/output/server.js +2 -2
  43. package/package.json +1 -1
  44. package/output/ClarifyShell-C38EkErX.js.map +0 -1
  45. package/output/ClarifyShell-DdYRgrfY.cjs.map +0 -1
  46. package/output/OpenApiOperation-CP_fxT_F.cjs.map +0 -1
  47. package/output/OpenApiOperation-DIFaYAe5.js.map +0 -1
  48. package/output/PageActions-B08cDCzq.cjs.map +0 -1
  49. package/output/PageActions-tmnpzi23.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { A as LocaleContext, C as themeCookieName, D as copyTextToClipboard, M as useConfig, N as useLocale, O as useBuiltInText, T as localizeHref, _ as getStoredLocalePreference, a as safeDecodeURIComponent, d as isSameRoutePath, f as normalizeRoutePath, g as useTheme, h as ThemeProvider, i as Navigation, j as OpenApisContext, k as ConfigContext, o as SectionProvider, p as resolveLocalizedText, r as Header, t as PageActionsProvider, w as isExternalHref, x as storeLocalePreference } from "./PageActions-tmnpzi23.js";
1
+ import { A as OpenApisContext, C as isExternalHref, D as useBuiltInText, E as copyTextToClipboard, M as useConfigOptional, N as useLocale, O as ConfigContext, S as themeCookieName, a as SectionProvider, b as storeLocalePreference, d as normalizeRoutePath, f as resolveLocalizedText, g as getStoredLocalePreference, h as useTheme, i as Navigation, j as useConfig, k as LocaleContext, m as ThemeProvider, r as Header, t as PageActionsProvider, u as isSameRoutePath, w as localizeHref } from "./PageActions-D0PA8Zv5.js";
2
2
  import clsx from "clsx";
3
3
  import { Component, Suspense, createContext, lazy, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { Link, Route, Routes, useLocation, useNavigate } from "react-router-dom";
@@ -108,6 +108,15 @@ function LazySlotComponent(props) {
108
108
  return /* @__PURE__ */ jsx(Component, {});
109
109
  }
110
110
  //#endregion
111
+ //#region source/utils/hash.ts
112
+ function safeDecodeURIComponent(value) {
113
+ try {
114
+ return decodeURIComponent(value);
115
+ } catch {
116
+ return value;
117
+ }
118
+ }
119
+ //#endregion
111
120
  //#region source/assets/clarify.svg?url
112
121
  var clarify_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='279px'%20height='200px'%20viewBox='0%200%20279%20200'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eclarify%3c/title%3e%3cg%20id='页面-1'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='clarify'%20transform='translate(-0,%200.0054)'%3e%3cpath%20d='M44.867217,0.0054376148%20C130.715579,1.00591567%20200,70.9091172%20200,156.994562%20L199.986321,155.127494%20C199.384888,180.009127%20179.026368,199.994562%20154,199.994562%20L46,199.994562%20C20.5949015,199.994562%200,179.399661%200,153.994562%20L0,45.9945624%20C0,21.0975659%2019.7793434,0.820282524%2044.4815926,0.0191499894%20Z'%20fill='%2300D492'%3e%3c/path%3e%3cpath%20d='M123.867217,0.0054376148%20C209.715579,1.00591567%20279,70.9091172%20279,156.994562%20L278.986321,155.127494%20C278.384888,180.009127%20258.026368,199.994562%20233,199.994562%20L125,199.994562%20C99.5949015,199.994562%2079,179.399661%2079,153.994562%20L79,45.9945624%20C79,21.0975659%2098.7793434,0.820282524%20123.481593,0.0191499894%20Z'%20id='clarify-right'%20fill-opacity='0.6'%20fill='%2300F6C9'%20transform='translate(179,%20100)%20rotate(-90)%20translate(-179,%20-100)'%3e%3c/path%3e%3cpath%20d='M199.979267,154.416906%20L199.984438,155.157125%20L199.962366,155.872459%20C198.977251,180.406837%20178.776104,199.994562%20154,199.994562%20L124.372438,199.994125%20L124.249053,199.994081%20C99.6939678,199.603921%2079.8122712,179.973634%2079.01915,155.518407%20L79.0054376,155.132783%20C79.5830823,105.566626%20103.129768,61.5221348%20139.498462,33.1463428%20C175.69419,61.3871018%20199.186123,105.143863%20199.979267,154.416906%20Z'%20id='形状结合'%20fill='%2300F692'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e";
113
122
  //#endregion
@@ -135,22 +144,27 @@ function BuiltWithClarify() {
135
144
  });
136
145
  }
137
146
  //#endregion
138
- //#region source/app/ErrorBoundary.tsx
139
- function PageErrorPanel(props) {
140
- const { title, description, reloadLabel, detailsLabel, pathLabel, typeLabel, messageLabel, stackLabel, componentStackLabel, timestampLabel, copyLabel, copiedLabel, path, error, errorInfo, occurredAt } = props;
141
- const [copiedStack, setCopiedStack] = useState(false);
142
- const stack = error.stack ?? error.message;
143
- const componentStack = errorInfo?.componentStack?.trim();
144
- const stackText = componentStack ? `${stack}\n\n${componentStackLabel}\n${componentStack}` : stack;
145
- const capturedAt = occurredAt ?? (/* @__PURE__ */ new Date()).toISOString();
146
- async function copyStack() {
147
- if (!await copyTextToClipboard(stackText)) return;
148
- setCopiedStack(true);
149
- window.setTimeout(() => setCopiedStack(false), 1600);
150
- }
147
+ //#region source/app/RenderErrorPanel.tsx
148
+ function RenderErrorPanel(props) {
149
+ const { title, description, eyebrowLabel = "Render error", action, metadata = [], detailsLabel, detailsHeaderAction, detailsContent, titleId = "clarify-render-error-title", refreshLabel, onRefresh } = props;
150
+ const t = useBuiltInText();
151
+ const config = useConfigOptional();
152
+ const resolvedRefreshLabel = refreshLabel ?? t("renderError.reload");
153
+ const resolvedVersion = config?.version ?? "0.0.0";
154
+ const resolvedMetadata = [...metadata, {
155
+ label: t("renderError.version"),
156
+ value: resolvedVersion
157
+ }];
158
+ const handleRefresh = () => {
159
+ if (onRefresh) {
160
+ onRefresh();
161
+ return;
162
+ }
163
+ if (typeof window !== "undefined") window.location.reload();
164
+ };
151
165
  return /* @__PURE__ */ jsx("section", {
152
166
  className: "mx-auto flex min-h-(--clarify-error-page-min-height) w-full max-w-4xl flex-col justify-center py-16 text-(--clarify-theme-tokens-colors-foreground)",
153
- "aria-labelledby": "clarify-render-error-title",
167
+ "aria-labelledby": titleId,
154
168
  role: "alert",
155
169
  children: /* @__PURE__ */ jsxs("div", {
156
170
  className: "border-t-2 border-(--clarify-error-accent-text) pt-8",
@@ -160,10 +174,10 @@ function PageErrorPanel(props) {
160
174
  children: [/* @__PURE__ */ jsxs("div", { children: [
161
175
  /* @__PURE__ */ jsx("p", {
162
176
  className: "font-mono text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-error-accent-text)",
163
- children: "Render error"
177
+ children: eyebrowLabel
164
178
  }),
165
179
  /* @__PURE__ */ jsx("h1", {
166
- id: "clarify-render-error-title",
180
+ id: titleId,
167
181
  className: "mt-3 text-3xl/9 font-semibold tracking-tight text-(--clarify-theme-tokens-colors-foreground)",
168
182
  children: title
169
183
  }),
@@ -171,20 +185,22 @@ function PageErrorPanel(props) {
171
185
  className: "mt-4 max-w-2xl text-sm/6 text-(--clarify-theme-tokens-colors-muted)",
172
186
  children: description
173
187
  })
174
- ] }), /* @__PURE__ */ jsx("button", {
175
- type: "button",
176
- className: "inline-flex shrink-0 items-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-theme-tokens-colors-primary) px-4 py-2 text-sm/5 font-semibold text-white shadow-xs transition hover:opacity-90",
177
- onClick: () => window.location.reload(),
178
- children: reloadLabel
188
+ ] }), /* @__PURE__ */ jsxs("div", {
189
+ className: "flex shrink-0 items-center gap-3",
190
+ children: [/* @__PURE__ */ jsx("button", {
191
+ type: "button",
192
+ className: "rounded-(--clarify-theme-tokens-radius-sm) border border-(--clarify-theme-tokens-colors-border) px-3 py-2 text-sm/5 font-semibold text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
193
+ onClick: handleRefresh,
194
+ children: resolvedRefreshLabel
195
+ }), action ? /* @__PURE__ */ jsx("div", {
196
+ className: "shrink-0",
197
+ children: action
198
+ }) : null]
179
199
  })]
180
200
  }),
181
- /* @__PURE__ */ jsx("dl", {
201
+ resolvedMetadata.length > 0 ? /* @__PURE__ */ jsx("dl", {
182
202
  className: "mt-8 grid gap-px overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-border) sm:grid-cols-3",
183
- children: [
184
- [pathLabel, path],
185
- [typeLabel, error.name],
186
- [timestampLabel, capturedAt]
187
- ].map(([label, value]) => /* @__PURE__ */ jsxs("div", {
203
+ children: resolvedMetadata.map(({ label, value }, index) => /* @__PURE__ */ jsxs("div", {
188
204
  className: "min-w-0 bg-(--clarify-theme-tokens-colors-surface) px-4 py-3",
189
205
  children: [/* @__PURE__ */ jsx("dt", {
190
206
  className: "text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
@@ -194,8 +210,8 @@ function PageErrorPanel(props) {
194
210
  title: value,
195
211
  children: value
196
212
  })]
197
- }, label))
198
- }),
213
+ }, `${label}-${index}`))
214
+ }) : null,
199
215
  /* @__PURE__ */ jsxs("div", {
200
216
  className: "mt-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-code-background)",
201
217
  children: [/* @__PURE__ */ jsxs("div", {
@@ -203,59 +219,86 @@ function PageErrorPanel(props) {
203
219
  children: [/* @__PURE__ */ jsx("p", {
204
220
  className: "text-sm/6 font-semibold text-(--clarify-ui-text-strong)",
205
221
  children: detailsLabel
206
- }), /* @__PURE__ */ jsx("button", {
207
- type: "button",
208
- className: "rounded-(--clarify-theme-tokens-radius-sm) px-2 py-1 text-xs/5 font-semibold text-(--clarify-ui-text-soft) ring-1 ring-(--clarify-theme-tokens-colors-border) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
209
- onClick: copyStack,
210
- children: copiedStack ? copiedLabel : copyLabel
211
- })]
212
- }), /* @__PURE__ */ jsxs("div", {
222
+ }), detailsHeaderAction ? /* @__PURE__ */ jsx("div", {
223
+ className: "shrink-0",
224
+ children: detailsHeaderAction
225
+ }) : null]
226
+ }), /* @__PURE__ */ jsx("div", {
213
227
  className: "px-4 py-4 text-xs/5 text-(--clarify-ui-text)",
214
- children: [
215
- /* @__PURE__ */ jsx("p", {
216
- className: "font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
217
- children: messageLabel
218
- }),
219
- /* @__PURE__ */ jsx("p", {
220
- className: "mt-2 wrap-break-word font-mono text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
221
- children: error.message
222
- }),
223
- /* @__PURE__ */ jsx("p", {
224
- className: "mt-6 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
225
- children: stackLabel
226
- }),
227
- /* @__PURE__ */ jsx("pre", {
228
- className: "mt-2 max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono",
229
- children: stack
230
- }),
231
- componentStack ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("p", {
232
- className: "mt-6 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
233
- children: componentStackLabel
234
- }), /* @__PURE__ */ jsx("pre", {
235
- className: "mt-2 max-h-(--clarify-error-component-stack-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono",
236
- children: componentStack
237
- })] }) : null
238
- ]
228
+ children: detailsContent
239
229
  })]
240
230
  })
241
231
  ]
242
232
  })
243
233
  });
244
234
  }
235
+ //#endregion
236
+ //#region source/app/ErrorBoundary.tsx
237
+ function PageErrorPanel(props) {
238
+ const { title, description, reloadLabel, detailsLabel, pathLabel, typeLabel, messageLabel, stackLabel, componentStackLabel, copyLabel, copiedLabel, path, error, errorInfo } = props;
239
+ const [copiedStack, setCopiedStack] = useState(false);
240
+ const stack = error.stack ?? error.message;
241
+ const componentStack = errorInfo?.componentStack?.trim();
242
+ const stackText = componentStack ? `${stack}\n\n${componentStackLabel}\n${componentStack}` : stack;
243
+ async function copyStack() {
244
+ if (!await copyTextToClipboard(stackText)) return;
245
+ setCopiedStack(true);
246
+ window.setTimeout(() => setCopiedStack(false), 1600);
247
+ }
248
+ return /* @__PURE__ */ jsx(RenderErrorPanel, {
249
+ title,
250
+ description,
251
+ refreshLabel: reloadLabel,
252
+ onRefresh: () => window.location.reload(),
253
+ metadata: [[pathLabel, path], [typeLabel, error.name]].map(([label, value]) => ({
254
+ label,
255
+ value: String(value)
256
+ })),
257
+ detailsLabel,
258
+ detailsHeaderAction: /* @__PURE__ */ jsx("button", {
259
+ type: "button",
260
+ className: "rounded-(--clarify-theme-tokens-radius-sm) px-2 py-1 text-xs/5 font-semibold text-(--clarify-ui-text-soft) ring-1 ring-(--clarify-theme-tokens-colors-border) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
261
+ onClick: copyStack,
262
+ children: copiedStack ? copiedLabel : copyLabel
263
+ }),
264
+ detailsContent: /* @__PURE__ */ jsxs(Fragment$1, { children: [
265
+ /* @__PURE__ */ jsx("p", {
266
+ className: "font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
267
+ children: messageLabel
268
+ }),
269
+ /* @__PURE__ */ jsx("p", {
270
+ className: "mt-2 wrap-break-word font-mono text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
271
+ children: error.message
272
+ }),
273
+ /* @__PURE__ */ jsx("p", {
274
+ className: "mt-6 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
275
+ children: stackLabel
276
+ }),
277
+ /* @__PURE__ */ jsx("pre", {
278
+ className: "mt-2 max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono",
279
+ children: stack
280
+ }),
281
+ componentStack ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("p", {
282
+ className: "mt-6 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
283
+ children: componentStackLabel
284
+ }), /* @__PURE__ */ jsx("pre", {
285
+ className: "mt-2 max-h-(--clarify-error-component-stack-max-height) overflow-auto whitespace-pre-wrap wrap-break-word font-mono",
286
+ children: componentStack
287
+ })] }) : null
288
+ ] })
289
+ });
290
+ }
245
291
  var PageErrorBoundary = class extends Component {
246
292
  state = {};
247
293
  static getDerivedStateFromError(error) {
248
- return {
249
- error,
250
- occurredAt: (/* @__PURE__ */ new Date()).toISOString()
251
- };
294
+ return { error };
252
295
  }
253
296
  componentDidCatch(error, errorInfo) {
254
297
  console.error("[clarify] Failed to render page:", error, errorInfo);
255
298
  this.setState({ errorInfo });
256
299
  }
257
300
  render() {
258
- const { error, errorInfo, occurredAt } = this.state;
301
+ const { error, errorInfo } = this.state;
259
302
  if (!error) return this.props.children;
260
303
  return /* @__PURE__ */ jsx(PageErrorPanel, {
261
304
  title: this.props.title,
@@ -267,13 +310,11 @@ var PageErrorBoundary = class extends Component {
267
310
  messageLabel: this.props.messageLabel,
268
311
  stackLabel: this.props.stackLabel,
269
312
  componentStackLabel: this.props.componentStackLabel,
270
- timestampLabel: this.props.timestampLabel,
271
313
  copyLabel: this.props.copyLabel,
272
314
  copiedLabel: this.props.copiedLabel,
273
315
  path: this.props.path,
274
316
  error,
275
- errorInfo,
276
- occurredAt
317
+ errorInfo
277
318
  });
278
319
  }
279
320
  };
@@ -620,11 +661,24 @@ function resolveRouteComponent(route) {
620
661
  function scrollToHash(hash) {
621
662
  if (!hash) return;
622
663
  const targetId = safeDecodeURIComponent(hash.slice(1));
623
- window.requestAnimationFrame(() => {
624
- document.getElementById(targetId)?.scrollIntoView();
664
+ const tryScrollToTarget = (attempt = 0) => {
665
+ const target = document.getElementById(targetId);
666
+ if (!target) {
667
+ if (attempt < 12) window.requestAnimationFrame(() => {
668
+ tryScrollToTarget(attempt + 1);
669
+ });
670
+ return;
671
+ }
672
+ target.scrollIntoView({
673
+ behavior: "smooth",
674
+ block: "start"
675
+ });
625
676
  window.requestAnimationFrame(() => {
626
677
  window.dispatchEvent(new Event("scroll"));
627
678
  });
679
+ };
680
+ window.requestAnimationFrame(() => {
681
+ tryScrollToTarget();
628
682
  });
629
683
  }
630
684
  function explicitLocaleForPath(config, pathname) {
@@ -926,7 +980,6 @@ function AppShell(arg0) {
926
980
  messageLabel: text("renderError.message"),
927
981
  stackLabel: text("renderError.stack"),
928
982
  componentStackLabel: text("renderError.componentStack"),
929
- timestampLabel: text("renderError.timestamp"),
930
983
  copyLabel: text("actions.copy"),
931
984
  copiedLabel: text("actions.copied"),
932
985
  path: pathname,
@@ -2300,6 +2353,6 @@ function ClarifyShell(props) {
2300
2353
  });
2301
2354
  }
2302
2355
  //#endregion
2303
- export { themeBootstrapScript as a, AppShell as c, BuiltWithClarify as d, RuntimeSlot as f, useSlot as h, themeEditorPresets as i, PageFooter as l, SlotProvider as m, ThemeEditor as n, themePresets as o, RuntimeSlotsProvider as p, applyThemeVariables as r, themeStorageKey as s, ClarifyShell as t, PageBanner as u };
2356
+ export { themeBootstrapScript as a, AppShell as c, RenderErrorPanel as d, BuiltWithClarify as f, useSlot as g, SlotProvider as h, themeEditorPresets as i, PageFooter as l, RuntimeSlotsProvider as m, ThemeEditor as n, themePresets as o, RuntimeSlot as p, applyThemeVariables as r, themeStorageKey as s, ClarifyShell as t, PageBanner as u };
2304
2357
 
2305
- //# sourceMappingURL=ClarifyShell-C38EkErX.js.map
2358
+ //# sourceMappingURL=ClarifyShell-D2P0iZ_m.js.map