@tdacorp/hyle-sdk 0.8.1 → 0.9.0

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.
package/dist/react.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps } from './types-BoyBWF2F.js';
4
- export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-BoyBWF2F.js';
3
+ import { H as HyleComponents, P as PageBaseProps } from './types-C1eCQ2As.js';
4
+ export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-C1eCQ2As.js';
5
5
  import { Root } from 'hast';
6
- import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.js';
6
+ import { f as ResolvedArticle, h as ResolvedList } from './types-CHxH5E0S.js';
7
7
 
8
8
  interface HastContentProps {
9
9
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -95,35 +95,6 @@ declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
95
95
  */
96
96
  declare function sanitizeHast(tree: unknown, title?: string): Root;
97
97
 
98
- interface ArticlePageProps extends PageBaseProps {
99
- article: ResolvedArticle;
100
- }
101
- declare function ArticlePage({ article, ...base }: ArticlePageProps): ReactElement;
102
- interface ListPageProps extends PageBaseProps {
103
- list: ResolvedList;
104
- /** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
105
- olderHref?: string;
106
- /** Page description under the title. */
107
- description?: string;
108
- }
109
- declare function ListPage({ list, olderHref, description, ...base }: ListPageProps): ReactElement;
110
- declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
111
- interface NotFoundProps extends PageBaseProps {
112
- /** The path that was not found, shown to the visitor. */
113
- path?: string;
114
- /** Where "Go to home" goes. */
115
- homeHref?: string;
116
- }
117
- declare function NotFound({ path, homeHref, ...base }: NotFoundProps): ReactElement;
118
- /** The fail-safe state `hylePage` renders when hyle cannot be reached. It takes no error: nothing internal can reach the markup. */
119
- declare function Unavailable(base: PageBaseProps): ReactElement;
120
- interface RedirectingProps extends PageBaseProps {
121
- from?: string;
122
- to: string;
123
- }
124
- /** For a client-side explanation of a move. The Next adapter redirects on the server and never renders this. */
125
- declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
126
-
127
98
  /**
128
99
  * Chrome strings for en, fr and es. The fr and es copy is a draft carried over from the design kit and has not been
129
100
  * reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
@@ -154,6 +125,8 @@ declare const en: {
154
125
  emptyBody: string;
155
126
  docs: string;
156
127
  menu: string;
128
+ closeMenu: string;
129
+ updated: string;
157
130
  nfKind: string;
158
131
  nfTitle: string;
159
132
  nfBody: string;
@@ -174,4 +147,34 @@ type Strings = typeof en;
174
147
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
175
148
  declare function stringsFor(locale: string | undefined): Strings;
176
149
 
150
+ interface ArticlePageProps extends PageBaseProps {
151
+ article: ResolvedArticle;
152
+ }
153
+ declare function ArticlePage({ article, ...base }: ArticlePageProps): ReactElement;
154
+ interface ListPageProps extends PageBaseProps {
155
+ list: ResolvedList;
156
+ /** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
157
+ olderHref?: string;
158
+ /** Page description under the title. */
159
+ description?: string;
160
+ }
161
+ declare function ListPage({ list, olderHref, description, ...base }: ListPageProps): ReactElement;
162
+ interface NotFoundProps extends PageBaseProps {
163
+ /** The path that was not found, shown to the visitor. */
164
+ path?: string;
165
+ /** Where "Go to home" goes. */
166
+ homeHref?: string;
167
+ }
168
+ declare function NotFound({ path, homeHref, ...base }: NotFoundProps): ReactElement;
169
+ /** The fail-safe state `hylePage` renders when hyle cannot be reached. It takes no error: nothing internal can reach the markup. */
170
+ declare function Unavailable(base: PageBaseProps): ReactElement;
171
+ interface RedirectingProps extends PageBaseProps {
172
+ from?: string;
173
+ to: string;
174
+ }
175
+ /** For a client-side explanation of a move. The Next adapter redirects on the server and never renders this. */
176
+ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
177
+
178
+ declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
179
+
177
180
  export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
package/dist/react.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  sanitizeHast,
14
14
  scopeId,
15
15
  stringsFor
16
- } from "./chunk-LGW2KP4X.js";
16
+ } from "./chunk-6LW33475.js";
17
17
  import "./chunk-67IOIAVW.js";
18
18
  export {
19
19
  ArticlePage,
@@ -1,7 +1,7 @@
1
- import { R as Resolved } from './types-CwBCPh6K.js';
1
+ import { R as Resolved } from './types-CHxH5E0S.cjs';
2
2
 
3
3
  /** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
4
- type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string) => Promise<Resolved>;
4
+ type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree") => Promise<Resolved>;
5
5
  interface FetchResolverOptions {
6
6
  readonly baseUrl: string;
7
7
  readonly token: string;
@@ -1,7 +1,7 @@
1
- import { R as Resolved } from './types-CwBCPh6K.cjs';
1
+ import { R as Resolved } from './types-CHxH5E0S.js';
2
2
 
3
3
  /** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
4
- type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string) => Promise<Resolved>;
4
+ type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree") => Promise<Resolved>;
5
5
  interface FetchResolverOptions {
6
6
  readonly baseUrl: string;
7
7
  readonly token: string;
package/dist/styles.css CHANGED
@@ -185,38 +185,49 @@
185
185
  .hyle-docs{display:grid;grid-template-columns:minmax(0,1fr);gap:24px 48px}
186
186
  .hyle-docs>*{min-width:0}
187
187
  .hyle-docs-main>*{max-width:var(--h-measure)}
188
- .hyle-nav-d{display:none}
189
- .hyle-nav-m{border:var(--h-border-width) solid var(--h-border);border-radius:var(--h-radius);background:var(--h-surface)}
190
- .hyle-nav-m>summary{display:flex;align-items:center;gap:8px;height:44px;padding:0 16px;cursor:pointer;font-size:14px;font-weight:600;list-style:none}
191
- .hyle-nav-m>summary::-webkit-details-marker{display:none}
192
- .hyle-nav-m>summary .cur{color:var(--h-text-muted);font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
193
- .hyle-nav-m>summary .hyle-chev{margin-left:auto}
194
- .hyle-nav-m[open]>summary .hyle-chev{transform:rotate(180deg)}
195
- .hyle-nav-m[open]>summary{border-bottom:1px solid var(--h-hairline)}
196
- .hyle-nav-m .hyle-tree{padding:12px}
197
- .hyle-side-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:12px}
198
- .hyle-side-head b{font-size:15px;font-weight:600}
188
+ .hyle-docs-main>.hyle-docs-end{display:block;height:1px}
189
+ .hyle-updated{display:flex;align-items:center;gap:8px;margin-top:16px;font-size:14px;color:var(--h-text-muted)}
190
+
191
+ /* sidebar: a popover drawer in a narrow mount (top layer, so a container's containment cannot trap it), a sticky column in a wide one */
192
+ .hyle-nav-bar{display:flex;align-items:center;gap:8px;width:100%;height:44px;padding:0 16px;border:var(--h-border-width) solid var(--h-border);border-radius:var(--h-radius);background:var(--h-surface);color:var(--h-text);font:600 14px/1 var(--h-font-sans);text-align:left;cursor:pointer}
193
+ .hyle-nav-bar .cur{min-width:0;overflow:hidden;color:var(--h-text-muted);font-weight:400;text-overflow:ellipsis;white-space:nowrap}
194
+ .hyle-nav-bar .hyle-chev{margin-left:auto}
195
+ .hyle-nav-d{color:var(--h-text);font-family:var(--h-font-sans);font-size:var(--h-font-size);line-height:var(--h-line-height)}
196
+ .hyle-nav-d:popover-open{display:block;position:fixed;inset:0 auto 0 0;width:min(320px,86vw);max-width:none;height:100dvh;max-height:none;margin:0;padding:16px;overflow:auto;overscroll-behavior:contain;border:0;border-right:var(--h-border-width) solid var(--h-border);border-radius:0;background:var(--h-surface);color:var(--h-text);box-shadow:var(--h-shadow)}
197
+ .hyle-nav-d::backdrop{background:rgb(0 0 0/.5)}
198
+ html:has(.hyle-nav-d:popover-open){overflow:hidden}
199
+ .hyle-nav-x{display:inline-grid;place-items:center;flex:none;width:32px;height:32px;margin-left:auto;padding:0;border:var(--h-border-width) solid var(--h-border);border-radius:var(--h-radius);background:transparent;color:var(--h-text);cursor:pointer}
200
+ .hyle-nav-x:hover{background:var(--h-surface-2)}
201
+ .hyle-side-head{display:flex;align-items:center;gap:8px;margin-bottom:12px}
202
+ .hyle-side-head b{min-width:0;font-size:15px;font-weight:600;overflow-wrap:anywhere}
199
203
  .hyle-side-slot{margin-bottom:12px}
204
+ @supports not selector(:popover-open){.hyle-nav-d{display:block;margin-bottom:0}.hyle-nav-bar,.hyle-nav-x{display:none}}
205
+
206
+ /* tree: the summary toggles (chevron), the link inside it navigates; the page's own group and its ancestors start open */
200
207
  .hyle-tree{font-size:14px;line-height:1.4}
201
208
  .hyle-tree ul{display:block}
202
- .hyle-tree details{margin-top:12px}
203
- .hyle-tree summary{display:flex;align-items:center;gap:8px;min-height:32px;padding:0 12px;margin-left:-12px;cursor:pointer;font-weight:600;color:var(--h-text);list-style:none;border-radius:min(var(--h-radius),6px)}
209
+ .hyle-tree li+li{margin-top:2px}
210
+ .hyle-tree ul ul{margin:2px 0 0 14px;padding-left:8px;border-left:1px solid var(--h-hairline)}
211
+ .hyle-tree summary{display:flex;align-items:center;list-style:none;cursor:pointer;border-radius:min(var(--h-radius),6px)}
204
212
  .hyle-tree summary::-webkit-details-marker{display:none}
205
- .hyle-tree summary .hyle-ic{width:14px;height:14px;color:var(--h-text-faint)}
206
- .hyle-tree details[open]>summary .hyle-ic{transform:rotate(90deg)}
207
213
  .hyle-tree summary:hover{background:var(--h-surface-2)}
208
- .hyle-tree ul ul{margin-left:0;padding-left:12px;border-left:1px solid var(--h-hairline);margin-top:4px}
209
- .hyle-tree li a{display:flex;align-items:center;min-height:32px;padding:4px 12px;margin-left:-12px;border-radius:min(var(--h-radius),6px);color:var(--h-text-muted);text-decoration:none}
210
- .hyle-tree li a:hover{background:var(--h-surface-2);color:var(--h-text)}
211
- .hyle-tree li a[aria-current="page"]{background:var(--h-surface-2);color:var(--h-text);font-weight:600}
214
+ .hyle-tree summary .hyle-ic{flex:none;box-sizing:content-box;width:14px;height:14px;padding:9px;color:var(--h-text-faint)}
215
+ .hyle-tree details[open]>summary .hyle-ic{transform:rotate(90deg)}
216
+ .hyle-tree a{display:flex;align-items:center;flex:1;min-width:0;min-height:32px;padding:4px 12px;border-radius:min(var(--h-radius),6px);color:var(--h-text-muted);text-decoration:none;overflow-wrap:anywhere}
217
+ .hyle-tree summary a{padding-left:0}
218
+ .hyle-tree li>a{padding-left:32px}
219
+ .hyle-tree a:hover{color:var(--h-text)}
220
+ .hyle-tree li>a:hover{background:var(--h-surface-2)}
221
+ .hyle-tree a[aria-current="page"]{color:var(--h-text);font-weight:600}
222
+ .hyle-tree li>a[aria-current="page"],.hyle-tree summary:has(>a[aria-current="page"]){background:var(--h-surface-2);box-shadow:inset 2px 0 0 var(--h-accent)}
212
223
  .hyle-tree li a .hyle-badge{margin-left:auto;height:20px;font-size:11px}
213
224
  .hyle-docs-main .hyle-crumbs{margin-bottom:16px}
214
225
  .hyle-docs-main .hyle-title{font-size:calc(var(--h-h1-size) * .9)}
215
226
  .hyle-docs .hyle-banner{margin-bottom:24px}
216
227
  @container hyle (min-width:760px){
217
228
  .hyle-docs{grid-template-columns:var(--h-nav-width) minmax(0,1fr)}
218
- .hyle-nav-m{display:none}
219
- .hyle-nav-d{display:block;position:sticky;top:calc(var(--h-sticky-top) + 24px);align-self:start;max-height:calc(100vh - var(--h-sticky-top) - 48px);overflow:auto;padding-right:16px}
229
+ .hyle-nav-bar,.hyle-nav-x{display:none}
230
+ .hyle-nav-d{display:block;position:sticky;inset:auto;top:calc(var(--h-sticky-top) + 24px);align-self:start;width:auto;height:auto;max-height:calc(100vh - var(--h-sticky-top) - 48px);margin:0;padding:0 16px 0 0;overflow:auto;border:0;background:transparent}
220
231
  }
221
232
  @container hyle (min-width:1100px){
222
233
  .hyle-docs{grid-template-columns:var(--h-nav-width) minmax(0,1fr) var(--h-toc-width)}
@@ -1,5 +1,5 @@
1
1
  import { ElementType, ReactNode, ComponentType } from 'react';
2
- import { L as ListItem } from './types-CwBCPh6K.cjs';
2
+ import { L as ListItem } from './types-CHxH5E0S.cjs';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "warning" | "caution";
5
5
  interface LinkProps {
@@ -1,5 +1,5 @@
1
1
  import { ElementType, ReactNode, ComponentType } from 'react';
2
- import { L as ListItem } from './types-CwBCPh6K.js';
2
+ import { L as ListItem } from './types-CHxH5E0S.js';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "warning" | "caution";
5
5
  interface LinkProps {
@@ -16,6 +16,18 @@ interface NavItem {
16
16
  readonly title: string;
17
17
  readonly canonical_path: string;
18
18
  }
19
+ /** One page of the section's navigation tree; `children` are its effective children in sibling order. */
20
+ interface NavNode extends NavItem {
21
+ readonly children: readonly NavNode[];
22
+ }
23
+ /**
24
+ * The whole section's navigation for the article's locale (hidden pages excluded, their children promoted).
25
+ * `truncated` (with empty `items`) means the section is too large to send as one tree.
26
+ */
27
+ interface NavTree {
28
+ readonly truncated: boolean;
29
+ readonly items: readonly NavNode[];
30
+ }
19
31
  interface Breadcrumb {
20
32
  readonly title: string;
21
33
  readonly canonical_path: string;
@@ -59,6 +71,8 @@ interface ResolvedArticle {
59
71
  readonly children: readonly NavItem[];
60
72
  readonly prev: NavItem | null;
61
73
  readonly next: NavItem | null;
74
+ /** Present only when requested with `nav: "tree"` (the docs layout does); absent from every other response. */
75
+ readonly nav?: NavTree;
62
76
  readonly alternates: readonly Alternate[];
63
77
  readonly fallback?: Fallback;
64
78
  readonly cache: CacheInfo;
@@ -121,4 +135,4 @@ interface Mounts {
121
135
  }
122
136
  type MountsResult = Mounts | ResolvedDisabled;
123
137
 
124
- export type { Alternate as A, Breadcrumb as B, CacheInfo as C, Fallback as F, ListItem as L, MountsResult as M, NavItem as N, Resolved as R, TocEntry as T, ArticleContent as a, Mount as b, Mounts as c, ResolvedArticle as d, ResolvedDisabled as e, ResolvedList as f, ResolvedNotFound as g, ResolvedRedirect as h };
138
+ export type { Alternate as A, Breadcrumb as B, CacheInfo as C, Fallback as F, ListItem as L, MountsResult as M, NavItem as N, Resolved as R, TocEntry as T, ArticleContent as a, Mount as b, Mounts as c, NavNode as d, NavTree as e, ResolvedArticle as f, ResolvedDisabled as g, ResolvedList as h, ResolvedNotFound as i, ResolvedRedirect as j };
@@ -16,6 +16,18 @@ interface NavItem {
16
16
  readonly title: string;
17
17
  readonly canonical_path: string;
18
18
  }
19
+ /** One page of the section's navigation tree; `children` are its effective children in sibling order. */
20
+ interface NavNode extends NavItem {
21
+ readonly children: readonly NavNode[];
22
+ }
23
+ /**
24
+ * The whole section's navigation for the article's locale (hidden pages excluded, their children promoted).
25
+ * `truncated` (with empty `items`) means the section is too large to send as one tree.
26
+ */
27
+ interface NavTree {
28
+ readonly truncated: boolean;
29
+ readonly items: readonly NavNode[];
30
+ }
19
31
  interface Breadcrumb {
20
32
  readonly title: string;
21
33
  readonly canonical_path: string;
@@ -59,6 +71,8 @@ interface ResolvedArticle {
59
71
  readonly children: readonly NavItem[];
60
72
  readonly prev: NavItem | null;
61
73
  readonly next: NavItem | null;
74
+ /** Present only when requested with `nav: "tree"` (the docs layout does); absent from every other response. */
75
+ readonly nav?: NavTree;
62
76
  readonly alternates: readonly Alternate[];
63
77
  readonly fallback?: Fallback;
64
78
  readonly cache: CacheInfo;
@@ -121,4 +135,4 @@ interface Mounts {
121
135
  }
122
136
  type MountsResult = Mounts | ResolvedDisabled;
123
137
 
124
- export type { Alternate as A, Breadcrumb as B, CacheInfo as C, Fallback as F, ListItem as L, MountsResult as M, NavItem as N, Resolved as R, TocEntry as T, ArticleContent as a, Mount as b, Mounts as c, ResolvedArticle as d, ResolvedDisabled as e, ResolvedList as f, ResolvedNotFound as g, ResolvedRedirect as h };
138
+ export type { Alternate as A, Breadcrumb as B, CacheInfo as C, Fallback as F, ListItem as L, MountsResult as M, NavItem as N, Resolved as R, TocEntry as T, ArticleContent as a, Mount as b, Mounts as c, NavNode as d, NavTree as e, ResolvedArticle as f, ResolvedDisabled as g, ResolvedList as h, ResolvedNotFound as i, ResolvedRedirect as j };
@@ -117,6 +117,7 @@ function createHyleClient(options) {
117
117
  const query = new URLSearchParams({ path: opts.path });
118
118
  if (opts.locale !== void 0) query.set("locale", opts.locale);
119
119
  if (opts.format !== void 0) query.set("format", opts.format);
120
+ if (opts.nav !== void 0) query.set("nav", opts.nav);
120
121
  if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
121
122
  if (opts.limit !== void 0) query.set("limit", String(opts.limit));
122
123
  const reply = await get("/cp1/read/resolve", query, opts.init);
@@ -157,11 +158,11 @@ var MAX_TAGS = 128;
157
158
  var DISABLED_REVALIDATE = 30;
158
159
  var tokens = /* @__PURE__ */ new Map();
159
160
  var keyOf = (baseUrl, workspaceId) => `${baseUrl}\0${workspaceId}`;
160
- async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor, revalidate) {
161
+ async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor, nav, revalidate) {
161
162
  "use cache";
162
163
  const token = tokens.get(keyOf(baseUrl, workspaceId));
163
164
  if (!token) throw new Error("hyle: unknown cache configuration");
164
- const result = await createHyleClient({ baseUrl, token }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {} });
165
+ const result = await createHyleClient({ baseUrl, token }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {}, ...nav === "tree" ? { nav: "tree" } : {} });
165
166
  if (result.kind !== "disabled") (0, import_cache.cacheTag)(...result.cache.tags.filter(isValidCacheTag).slice(0, MAX_TAGS));
166
167
  (0, import_cache.cacheLife)({ stale: 30, revalidate: result.kind === "disabled" ? Math.min(revalidate, DISABLED_REVALIDATE) : revalidate });
167
168
  return result;
@@ -169,7 +170,7 @@ async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor,
169
170
  function cachedResolver(options) {
170
171
  tokens.set(keyOf(options.baseUrl, options.workspaceId), options.token);
171
172
  const revalidate = options.revalidate ?? DEFAULT_REVALIDATE;
172
- return (path, locale, limit, cursor) => resolveCached(options.baseUrl, options.workspaceId, path, locale ?? "", limit ?? 0, cursor ?? "", revalidate);
173
+ return (path, locale, limit, cursor, nav) => resolveCached(options.baseUrl, options.workspaceId, path, locale ?? "", limit ?? 0, cursor ?? "", nav ?? "", revalidate);
173
174
  }
174
175
  // Annotate the CommonJS export names for ESM import in node:
175
176
  0 && (module.exports = {
@@ -1,5 +1,5 @@
1
- import { H as HyleResolver } from './resolve-36-Ng1H0.cjs';
2
- import './types-CwBCPh6K.cjs';
1
+ import { H as HyleResolver } from './resolve-D2rnnho9.cjs';
2
+ import './types-CHxH5E0S.cjs';
3
3
 
4
4
  /**
5
5
  * The exact caching strategy: a `'use cache'` function that fetches, then tags its own entry with the tags the response
@@ -1,5 +1,5 @@
1
- import { H as HyleResolver } from './resolve-1rQntRBh.js';
2
- import './types-CwBCPh6K.js';
1
+ import { H as HyleResolver } from './resolve-Dpb6Orsj.js';
2
+ import './types-CHxH5E0S.js';
3
3
 
4
4
  /**
5
5
  * The exact caching strategy: a `'use cache'` function that fetches, then tags its own entry with the tags the response
package/dist/use-cache.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  DEFAULT_REVALIDATE
3
- } from "./chunk-N4QYPO7S.js";
3
+ } from "./chunk-XKR74Y5G.js";
4
4
  import {
5
5
  createHyleClient,
6
6
  isValidCacheTag
7
- } from "./chunk-EBNIKRQH.js";
7
+ } from "./chunk-54JF4E53.js";
8
8
  import "./chunk-67IOIAVW.js";
9
9
 
10
10
  // src/next/use-cache.ts
@@ -13,11 +13,11 @@ var MAX_TAGS = 128;
13
13
  var DISABLED_REVALIDATE = 30;
14
14
  var tokens = /* @__PURE__ */ new Map();
15
15
  var keyOf = (baseUrl, workspaceId) => `${baseUrl}\0${workspaceId}`;
16
- async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor, revalidate) {
16
+ async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor, nav, revalidate) {
17
17
  "use cache";
18
18
  const token = tokens.get(keyOf(baseUrl, workspaceId));
19
19
  if (!token) throw new Error("hyle: unknown cache configuration");
20
- const result = await createHyleClient({ baseUrl, token }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {} });
20
+ const result = await createHyleClient({ baseUrl, token }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {}, ...nav === "tree" ? { nav: "tree" } : {} });
21
21
  if (result.kind !== "disabled") cacheTag(...result.cache.tags.filter(isValidCacheTag).slice(0, MAX_TAGS));
22
22
  cacheLife({ stale: 30, revalidate: result.kind === "disabled" ? Math.min(revalidate, DISABLED_REVALIDATE) : revalidate });
23
23
  return result;
@@ -25,7 +25,7 @@ async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor,
25
25
  function cachedResolver(options) {
26
26
  tokens.set(keyOf(options.baseUrl, options.workspaceId), options.token);
27
27
  const revalidate = options.revalidate ?? DEFAULT_REVALIDATE;
28
- return (path, locale, limit, cursor) => resolveCached(options.baseUrl, options.workspaceId, path, locale ?? "", limit ?? 0, cursor ?? "", revalidate);
28
+ return (path, locale, limit, cursor, nav) => resolveCached(options.baseUrl, options.workspaceId, path, locale ?? "", limit ?? 0, cursor ?? "", nav ?? "", revalidate);
29
29
  }
30
30
  export {
31
31
  cachedResolver
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdacorp/hyle-sdk",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "hyle SDK: a typed client for hyle's resolve endpoint, a hast renderer for React, and a Next.js catch-all page with tag-based revalidation.",
5
5
  "license": "MIT",
6
6
  "repository": {