@tdacorp/hyle-sdk 0.24.0 → 0.26.1

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 (46) hide show
  1. package/README.md +7 -5
  2. package/dist/{embed-B7T--kTT.d.cts → brand-CwXvdSkk.d.ts} +14 -2
  3. package/dist/{embed-DavTgSU4.d.ts → brand-IuZSB9UX.d.cts} +14 -2
  4. package/dist/check-routes-bin.js +10 -5
  5. package/dist/{chunk-4REU4HJI.js → chunk-3UQGU62T.js} +22 -5
  6. package/dist/{chunk-SY2FMIRZ.js → chunk-IDBQSMWT.js} +1 -1
  7. package/dist/{chunk-5TKJH2XC.js → chunk-NUQQ6VHH.js} +267 -43
  8. package/dist/{chunk-Y3BACEWA.js → chunk-T4EZAQFU.js} +129 -3
  9. package/dist/chunk-VAR2B7S6.js +82 -0
  10. package/dist/{chunk-U74B7AUG.js → chunk-ZWKAEWEW.js} +22 -74
  11. package/dist/{client-BErei7cE.d.ts → client-B2zi_BGq.d.ts} +11 -4
  12. package/dist/{client-DrB2vcTi.d.cts → client-DBZTvcCh.d.cts} +11 -4
  13. package/dist/comments.cjs +25 -1
  14. package/dist/comments.js +4 -2
  15. package/dist/html.cjs +129 -3
  16. package/dist/html.js +1 -1
  17. package/dist/index.cjs +22 -5
  18. package/dist/index.d.cts +4 -4
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +1 -1
  21. package/dist/next.cjs +674 -211
  22. package/dist/next.d.cts +44 -18
  23. package/dist/next.d.ts +44 -18
  24. package/dist/next.js +241 -135
  25. package/dist/react.cjs +401 -46
  26. package/dist/react.d.cts +114 -4
  27. package/dist/react.d.ts +114 -4
  28. package/dist/react.js +14 -4
  29. package/dist/reactions.cjs +25 -1
  30. package/dist/reactions.js +4 -2
  31. package/dist/{resolve-03IVloXU.d.cts → resolve-0nGnsIHo.d.cts} +1 -1
  32. package/dist/{resolve-BseM68oy.d.ts → resolve-CguSaZLa.d.ts} +1 -1
  33. package/dist/{revalidation-callback-BQl77tQR.d.cts → revalidation-callback-FT9ik1dh.d.cts} +11 -0
  34. package/dist/{revalidation-callback-BQl77tQR.d.ts → revalidation-callback-FT9ik1dh.d.ts} +11 -0
  35. package/dist/share-client.cjs +498 -0
  36. package/dist/share-client.d.cts +99 -0
  37. package/dist/share-client.d.ts +99 -0
  38. package/dist/share-client.js +390 -0
  39. package/dist/styles.css +176 -1
  40. package/dist/{types-Dx-fEiZd.d.cts → types-CdaIzSjg.d.cts} +10 -3
  41. package/dist/{types-Dx-fEiZd.d.ts → types-CdaIzSjg.d.ts} +10 -3
  42. package/dist/use-cache.cjs +10 -5
  43. package/dist/use-cache.d.cts +3 -3
  44. package/dist/use-cache.d.ts +3 -3
  45. package/dist/use-cache.js +2 -2
  46. package/package.json +1 -1
package/dist/next.d.cts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ReactElement } from 'react';
2
- import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-B7T--kTT.cjs';
3
- export { c as HyleCommentsFallback } from './embed-B7T--kTT.cjs';
4
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-03IVloXU.cjs';
5
- export { f as fetchResolver, w as workspaceTags } from './resolve-03IVloXU.cjs';
2
+ import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, S as ShareHost, b as EmbedHeading } from './brand-IuZSB9UX.cjs';
3
+ export { c as HyleCommentsFallback } from './brand-IuZSB9UX.cjs';
4
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-0nGnsIHo.cjs';
5
+ export { f as fetchResolver, w as workspaceTags } from './resolve-0nGnsIHo.cjs';
6
6
  import { MetadataRoute, ResolvingMetadata, Metadata } from 'next';
7
- import { R as RevalidationCallbackOptions, b as RevalidationCallbackRoute } from './revalidation-callback-BQl77tQR.cjs';
8
- import { c as HyleCredential } from './client-DrB2vcTi.cjs';
7
+ import { R as RevalidationCallbackOptions, b as RevalidationCallbackRoute } from './revalidation-callback-FT9ik1dh.cjs';
8
+ import { c as HyleCredential } from './client-DBZTvcCh.cjs';
9
9
  import { NextRequest, NextResponse } from 'next/server';
10
- import './types-Dx-fEiZd.cjs';
10
+ import './types-CdaIzSjg.cjs';
11
11
 
12
12
  type RouteParams = Record<string, string | string[] | undefined>;
13
13
  interface CommonOptions {
@@ -222,6 +222,16 @@ interface RevalidateRouteOptions {
222
222
  readonly secrets: readonly (string | undefined)[];
223
223
  /** Comment notifications, see `RevalidationCallbackOptions.onCommentEvent`. */
224
224
  readonly onCommentEvent?: RevalidationCallbackOptions["onCommentEvent"];
225
+ /**
226
+ * Tell search engines (IndexNow) about the addresses a publish changed. Submits only in production and only with a key.
227
+ * The origin is this option's alone, never the payload's, and must be a bare https origin (else logged and off).
228
+ * `localePrefix` is the host's, as in `hylePage` (docs/cp1-spec.md section 5.3.5).
229
+ */
230
+ readonly indexNow?: {
231
+ readonly origin: string;
232
+ readonly key: string | undefined;
233
+ readonly localePrefix?: (locale: string) => string;
234
+ };
225
235
  /** Environment to read the site switch from. Default process.env. */
226
236
  readonly env?: Readonly<Record<string, string | undefined>>;
227
237
  }
@@ -247,6 +257,8 @@ type HyleRootConfig = Omit<Extract<HyleNextOptions, {
247
257
  * (a given `list` or `jsonLd` replaces the config's whole value). Lets one mount carry its own `titleTemplate`, `ogImage`, `jsonLd`, `list` or `siteOrigin`.
248
258
  */
249
259
  readonly mountOptions?: Readonly<Record<string, Partial<Pick<CommonOptions, "titleTemplate" | "list" | "ogImage" | "jsonLd" | "siteOrigin">>>>;
260
+ /** The host's logo and name in a protected share's bar (`chrome.brand` is the slot alternative). Only protected shares read it. */
261
+ readonly host?: ShareHost;
250
262
  };
251
263
  type Configs = HyleRootConfig | readonly HyleRootConfig[];
252
264
  /** How long a mounts copy that could not be refreshed may still be used. Past this a transient failure is rethrown. */
@@ -546,10 +558,11 @@ declare function hylePreviewPage(options: HylePreviewPageOptions): (props: PageP
546
558
  declare const hyleProtectedMetadata: Metadata;
547
559
  /**
548
560
  * `export const { POST } = createProtectedUnlockRoute()` in `app/hyle-protected/unlock/route.ts` (ADR 0040). The password form
549
- * posts `slug` and `password` here; the route sets the password in the share's HttpOnly cookie (scoped to `/<slug>` and to the asset route, so no other request of the host carries it) and sends the visitor to `/<slug>`,
550
- * where the page checks it with hyle. It never calls hyle, so a view is one open. Only a same-origin POST with a form body of at
551
- * most 1 KiB is read. The cookie is set only for a password of the right shape, and the redirect target is built from the
552
- * validated slug alone.
561
+ * posts `slug`, `password` and the optional `docSlug` here; the Lock button posts `slug` and `lock=1`. A password sets the share's
562
+ * HttpOnly cookie (scoped to `/<slug>` and the asset route, so no other request of the host carries it) and sends the visitor to
563
+ * the share, where the page checks it with hyle. `lock=1` clears that cookie on both paths and sends the visitor to the gate with
564
+ * `?locked=1`. It never calls hyle, so a view is one open. Only a same-origin POST with a form body of at most 1 KiB is read, and
565
+ * the redirect is built from the validated slugs alone.
553
566
  */
554
567
  declare function createProtectedUnlockRoute(): {
555
568
  POST: (req: Request) => Promise<Response>;
@@ -561,17 +574,30 @@ declare function createProtectedUnlockRoute(): {
561
574
  * `const share = hyleProtectedProxy(configs); export async function proxy(req) { return (await share(req)) ?? NextResponse.next(); }`.
562
575
  * A path under a live share slug is REWRITTEN to `/hyle-protected/view/<path>` (the visitor's URL does not change); every other
563
576
  * request returns undefined, so the host's ordinary pages stay cached. A proxy has no fetch cache, so it keeps ONE read of hyle's
564
- * mounts per config in memory for 30 seconds (shared by concurrent requests, the last good copy used when a refresh fails) and
565
- * matches every path against it locally: random paths never cost a call to hyle. The page behind the rewrite checks again through
566
- * the usual mounts cache. A mounts read that fails with no copy counts as "not a share" for those 30 seconds rather than erroring
567
- * every request of the host.
577
+ * mounts per config in memory and matches every path against it locally: random paths never cost a call to hyle. It is
578
+ * stale-while-revalidate: after 30 seconds the copy it has is still used at once and ONE refresh runs in the background (a failed
579
+ * refresh keeps the copy, within the 15 minutes `hyleRootPage` also allows), so a slow hyle delays no request. Only with no copy
580
+ * at all (a cold start) does a request wait, for `lookupTimeoutMs` (default 1500) at most, then it passes through as not a share;
581
+ * the read goes on and the next request finds its result. The page behind the rewrite checks again through the usual mounts cache.
582
+ * A mounts read that fails with no copy counts as "not a share" for those 30 seconds rather than erroring every request of the host.
568
583
  */
569
- declare function hyleProtectedProxy(options: Configs): (req: NextRequest) => Promise<NextResponse | undefined>;
570
- /** The page of `app/hyle-protected/view/[[...path]]/page.tsx` (see `hyleProtectedProxy`): the share under the path, else `notFound()`. */
571
- declare function hyleProtectedPage(options: Configs): (props: {
584
+ declare function hyleProtectedProxy(options: Configs, { lookupTimeoutMs }?: {
585
+ readonly lookupTimeoutMs?: number;
586
+ }): (req: NextRequest) => Promise<NextResponse | undefined>;
587
+ /**
588
+ * The page of `app/hyle-protected/view/[[...path]]/page.tsx` (see `hyleProtectedProxy`): the share under the path, else `notFound()`.
589
+ * The visitor's address goes to hyle with every read: by default the first `x-forwarded-for` hop, else `x-real-ip`; pass `clientIp`
590
+ * to read it from where your platform puts it (the first hop is only the visitor's when your edge overwrites that header).
591
+ */
592
+ declare function hyleProtectedPage(options: Configs, { clientIp }?: {
593
+ readonly clientIp?: (headers: Headers) => string | undefined;
594
+ }): (props: {
572
595
  readonly params: Promise<{
573
596
  readonly path?: string[];
574
597
  }>;
598
+ readonly searchParams?: Promise<{
599
+ readonly locked?: string | string[];
600
+ }>;
575
601
  }) => Promise<ReactElement>;
576
602
 
577
603
  export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, type HylePreviewPageOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createProtectedUnlockRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hylePreviewMetadata, hylePreviewPage, hyleProtectedMetadata, hyleProtectedPage, hyleProtectedProxy, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };
package/dist/next.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ReactElement } from 'react';
2
- import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-DavTgSU4.js';
3
- export { c as HyleCommentsFallback } from './embed-DavTgSU4.js';
4
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-BseM68oy.js';
5
- export { f as fetchResolver, w as workspaceTags } from './resolve-BseM68oy.js';
2
+ import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, S as ShareHost, b as EmbedHeading } from './brand-CwXvdSkk.js';
3
+ export { c as HyleCommentsFallback } from './brand-CwXvdSkk.js';
4
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-CguSaZLa.js';
5
+ export { f as fetchResolver, w as workspaceTags } from './resolve-CguSaZLa.js';
6
6
  import { MetadataRoute, ResolvingMetadata, Metadata } from 'next';
7
- import { R as RevalidationCallbackOptions, b as RevalidationCallbackRoute } from './revalidation-callback-BQl77tQR.js';
8
- import { c as HyleCredential } from './client-BErei7cE.js';
7
+ import { R as RevalidationCallbackOptions, b as RevalidationCallbackRoute } from './revalidation-callback-FT9ik1dh.js';
8
+ import { c as HyleCredential } from './client-B2zi_BGq.js';
9
9
  import { NextRequest, NextResponse } from 'next/server';
10
- import './types-Dx-fEiZd.js';
10
+ import './types-CdaIzSjg.js';
11
11
 
12
12
  type RouteParams = Record<string, string | string[] | undefined>;
13
13
  interface CommonOptions {
@@ -222,6 +222,16 @@ interface RevalidateRouteOptions {
222
222
  readonly secrets: readonly (string | undefined)[];
223
223
  /** Comment notifications, see `RevalidationCallbackOptions.onCommentEvent`. */
224
224
  readonly onCommentEvent?: RevalidationCallbackOptions["onCommentEvent"];
225
+ /**
226
+ * Tell search engines (IndexNow) about the addresses a publish changed. Submits only in production and only with a key.
227
+ * The origin is this option's alone, never the payload's, and must be a bare https origin (else logged and off).
228
+ * `localePrefix` is the host's, as in `hylePage` (docs/cp1-spec.md section 5.3.5).
229
+ */
230
+ readonly indexNow?: {
231
+ readonly origin: string;
232
+ readonly key: string | undefined;
233
+ readonly localePrefix?: (locale: string) => string;
234
+ };
225
235
  /** Environment to read the site switch from. Default process.env. */
226
236
  readonly env?: Readonly<Record<string, string | undefined>>;
227
237
  }
@@ -247,6 +257,8 @@ type HyleRootConfig = Omit<Extract<HyleNextOptions, {
247
257
  * (a given `list` or `jsonLd` replaces the config's whole value). Lets one mount carry its own `titleTemplate`, `ogImage`, `jsonLd`, `list` or `siteOrigin`.
248
258
  */
249
259
  readonly mountOptions?: Readonly<Record<string, Partial<Pick<CommonOptions, "titleTemplate" | "list" | "ogImage" | "jsonLd" | "siteOrigin">>>>;
260
+ /** The host's logo and name in a protected share's bar (`chrome.brand` is the slot alternative). Only protected shares read it. */
261
+ readonly host?: ShareHost;
250
262
  };
251
263
  type Configs = HyleRootConfig | readonly HyleRootConfig[];
252
264
  /** How long a mounts copy that could not be refreshed may still be used. Past this a transient failure is rethrown. */
@@ -546,10 +558,11 @@ declare function hylePreviewPage(options: HylePreviewPageOptions): (props: PageP
546
558
  declare const hyleProtectedMetadata: Metadata;
547
559
  /**
548
560
  * `export const { POST } = createProtectedUnlockRoute()` in `app/hyle-protected/unlock/route.ts` (ADR 0040). The password form
549
- * posts `slug` and `password` here; the route sets the password in the share's HttpOnly cookie (scoped to `/<slug>` and to the asset route, so no other request of the host carries it) and sends the visitor to `/<slug>`,
550
- * where the page checks it with hyle. It never calls hyle, so a view is one open. Only a same-origin POST with a form body of at
551
- * most 1 KiB is read. The cookie is set only for a password of the right shape, and the redirect target is built from the
552
- * validated slug alone.
561
+ * posts `slug`, `password` and the optional `docSlug` here; the Lock button posts `slug` and `lock=1`. A password sets the share's
562
+ * HttpOnly cookie (scoped to `/<slug>` and the asset route, so no other request of the host carries it) and sends the visitor to
563
+ * the share, where the page checks it with hyle. `lock=1` clears that cookie on both paths and sends the visitor to the gate with
564
+ * `?locked=1`. It never calls hyle, so a view is one open. Only a same-origin POST with a form body of at most 1 KiB is read, and
565
+ * the redirect is built from the validated slugs alone.
553
566
  */
554
567
  declare function createProtectedUnlockRoute(): {
555
568
  POST: (req: Request) => Promise<Response>;
@@ -561,17 +574,30 @@ declare function createProtectedUnlockRoute(): {
561
574
  * `const share = hyleProtectedProxy(configs); export async function proxy(req) { return (await share(req)) ?? NextResponse.next(); }`.
562
575
  * A path under a live share slug is REWRITTEN to `/hyle-protected/view/<path>` (the visitor's URL does not change); every other
563
576
  * request returns undefined, so the host's ordinary pages stay cached. A proxy has no fetch cache, so it keeps ONE read of hyle's
564
- * mounts per config in memory for 30 seconds (shared by concurrent requests, the last good copy used when a refresh fails) and
565
- * matches every path against it locally: random paths never cost a call to hyle. The page behind the rewrite checks again through
566
- * the usual mounts cache. A mounts read that fails with no copy counts as "not a share" for those 30 seconds rather than erroring
567
- * every request of the host.
577
+ * mounts per config in memory and matches every path against it locally: random paths never cost a call to hyle. It is
578
+ * stale-while-revalidate: after 30 seconds the copy it has is still used at once and ONE refresh runs in the background (a failed
579
+ * refresh keeps the copy, within the 15 minutes `hyleRootPage` also allows), so a slow hyle delays no request. Only with no copy
580
+ * at all (a cold start) does a request wait, for `lookupTimeoutMs` (default 1500) at most, then it passes through as not a share;
581
+ * the read goes on and the next request finds its result. The page behind the rewrite checks again through the usual mounts cache.
582
+ * A mounts read that fails with no copy counts as "not a share" for those 30 seconds rather than erroring every request of the host.
568
583
  */
569
- declare function hyleProtectedProxy(options: Configs): (req: NextRequest) => Promise<NextResponse | undefined>;
570
- /** The page of `app/hyle-protected/view/[[...path]]/page.tsx` (see `hyleProtectedProxy`): the share under the path, else `notFound()`. */
571
- declare function hyleProtectedPage(options: Configs): (props: {
584
+ declare function hyleProtectedProxy(options: Configs, { lookupTimeoutMs }?: {
585
+ readonly lookupTimeoutMs?: number;
586
+ }): (req: NextRequest) => Promise<NextResponse | undefined>;
587
+ /**
588
+ * The page of `app/hyle-protected/view/[[...path]]/page.tsx` (see `hyleProtectedProxy`): the share under the path, else `notFound()`.
589
+ * The visitor's address goes to hyle with every read: by default the first `x-forwarded-for` hop, else `x-real-ip`; pass `clientIp`
590
+ * to read it from where your platform puts it (the first hop is only the visitor's when your edge overwrites that header).
591
+ */
592
+ declare function hyleProtectedPage(options: Configs, { clientIp }?: {
593
+ readonly clientIp?: (headers: Headers) => string | undefined;
594
+ }): (props: {
572
595
  readonly params: Promise<{
573
596
  readonly path?: string[];
574
597
  }>;
598
+ readonly searchParams?: Promise<{
599
+ readonly locked?: string | string[];
600
+ }>;
575
601
  }) => Promise<ReactElement>;
576
602
 
577
603
  export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, type HylePreviewPageOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createProtectedUnlockRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hylePreviewMetadata, hylePreviewPage, hyleProtectedMetadata, hyleProtectedPage, hyleProtectedProxy, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };