@tdacorp/hyle-sdk 0.14.1 → 0.21.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.
Files changed (86) hide show
  1. package/README.md +171 -32
  2. package/dist/check-routes-bin.js +48 -21
  3. package/dist/chunk-56Y24XBV.js +840 -0
  4. package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
  5. package/dist/chunk-HJX57NLI.js +1105 -0
  6. package/dist/chunk-K5VDLROQ.js +145 -0
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-U74B7AUG.js +398 -0
  9. package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
  10. package/dist/client-41fU6OY2.d.cts +201 -0
  11. package/dist/client-LwzHwqpM.d.ts +201 -0
  12. package/dist/code-copy.cjs +72 -0
  13. package/dist/code-copy.d.cts +15 -0
  14. package/dist/code-copy.d.ts +15 -0
  15. package/dist/code-copy.js +48 -0
  16. package/dist/comments.cjs +733 -278
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +414 -330
  20. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-XY3CG75U.js} +107 -46
  21. package/dist/{embed-B76zRRPa.d.cts → embed-BUFRQboD.d.ts} +10 -5
  22. package/dist/{embed-SqOBGI-E.d.ts → embed-CYt-q13P.d.cts} +10 -5
  23. package/dist/fragment-alias.cjs +51 -0
  24. package/dist/fragment-alias.d.cts +7 -0
  25. package/dist/fragment-alias.d.ts +7 -0
  26. package/dist/fragment-alias.js +27 -0
  27. package/dist/html.cjs +881 -0
  28. package/dist/html.d.cts +20 -0
  29. package/dist/html.d.ts +20 -0
  30. package/dist/html.js +45 -0
  31. package/dist/index.cjs +181 -14
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +11 -1
  35. package/dist/labels-CrA-iqTN.d.cts +46 -0
  36. package/dist/labels-CrA-iqTN.d.ts +46 -0
  37. package/dist/mermaid-diagram.cjs +453 -148
  38. package/dist/mermaid-diagram.d.cts +25 -42
  39. package/dist/mermaid-diagram.d.ts +25 -42
  40. package/dist/mermaid-diagram.js +205 -50
  41. package/dist/mermaid-image.cjs +1456 -0
  42. package/dist/mermaid-image.d.cts +30 -0
  43. package/dist/mermaid-image.d.ts +30 -0
  44. package/dist/mermaid-image.js +93 -0
  45. package/dist/next.cjs +1709 -1134
  46. package/dist/next.d.cts +67 -14
  47. package/dist/next.d.ts +67 -14
  48. package/dist/next.js +950 -794
  49. package/dist/print-coordinator.cjs +157 -0
  50. package/dist/print-coordinator.d.cts +27 -0
  51. package/dist/print-coordinator.d.ts +27 -0
  52. package/dist/print-coordinator.js +83 -0
  53. package/dist/react.cjs +677 -264
  54. package/dist/react.d.cts +161 -31
  55. package/dist/react.d.ts +161 -31
  56. package/dist/react.js +23 -3
  57. package/dist/reactions.cjs +653 -0
  58. package/dist/reactions.d.cts +27 -0
  59. package/dist/reactions.d.ts +27 -0
  60. package/dist/reactions.js +364 -0
  61. package/dist/{resolve-DC2ccfwA.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-DKLVftk_.d.cts → resolve-eI1muCKL.d.cts} +2 -2
  63. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  64. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  65. package/dist/sanitize-ijiWjEm9.d.cts +23 -0
  66. package/dist/sanitize-ijiWjEm9.d.ts +23 -0
  67. package/dist/styles.css +107 -47
  68. package/dist/toc-spy.cjs +59 -0
  69. package/dist/toc-spy.d.cts +15 -0
  70. package/dist/toc-spy.d.ts +15 -0
  71. package/dist/toc-spy.js +35 -0
  72. package/dist/{types-ByodIyEv.d.cts → types-3F0wqD-o.d.cts} +44 -4
  73. package/dist/{types-ByodIyEv.d.ts → types-3F0wqD-o.d.ts} +44 -4
  74. package/dist/use-cache.cjs +37 -11
  75. package/dist/use-cache.d.cts +12 -5
  76. package/dist/use-cache.d.ts +12 -5
  77. package/dist/use-cache.js +7 -7
  78. package/dist/youtube-facade.cjs +50 -0
  79. package/dist/youtube-facade.d.cts +17 -0
  80. package/dist/youtube-facade.d.ts +17 -0
  81. package/dist/youtube-facade.js +26 -0
  82. package/package.json +16 -3
  83. package/dist/chunk-4V4VKB3O.js +0 -1471
  84. package/dist/chunk-R5EMI4HQ.js +0 -61
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
@@ -0,0 +1,201 @@
1
+ import { i as Resolved, e as MountsResult } from './types-3F0wqD-o.cjs';
2
+
3
+ /** docs/cp1-spec.md section 5.3.3: `hyle.push/1`, the whole-post delivery of a path in push mode (ADR 0025). */
4
+ declare const MAX_PUSH_BODY_BYTES: number;
5
+ interface PushPost {
6
+ readonly publication_id: string;
7
+ readonly document_id: string;
8
+ readonly version: number;
9
+ readonly slug: string;
10
+ readonly canonical_path: string;
11
+ readonly locale: string;
12
+ readonly title: string;
13
+ readonly description: string | null;
14
+ /** The author's source. Never render it with raw HTML enabled: use `html`, or a Markdown renderer with raw HTML off. */
15
+ readonly markdown: string;
16
+ /** Sanitized HTML, the same output as `format=html` on the read surface. */
17
+ readonly html: string;
18
+ readonly tags: readonly string[];
19
+ readonly kicker: string | null;
20
+ readonly status_label: string | null;
21
+ readonly author_name: string | null;
22
+ readonly author_url: string | null;
23
+ readonly published_at: string;
24
+ readonly updated_at: string;
25
+ readonly word_count: number;
26
+ }
27
+ type PushEventType = "post.published" | "post.updated" | "post.unpublished" | "post.deleted" | "post.moved" | "section.moved";
28
+ interface PushEvent {
29
+ readonly schema: "hyle.push/1";
30
+ readonly type: PushEventType;
31
+ /** The delivery id: a retry carries the same one. */
32
+ readonly event_id: string;
33
+ readonly occurred_at: string;
34
+ readonly seq: number;
35
+ readonly workspace_id: string;
36
+ readonly section: {
37
+ readonly id: string;
38
+ readonly site_path: string;
39
+ };
40
+ readonly publication_id?: string;
41
+ readonly document_id?: string;
42
+ /** post.moved and section.moved: where it used to live. */
43
+ readonly previous_path?: string;
44
+ /** On post.published, post.updated and post.moved. */
45
+ readonly post?: PushPost;
46
+ }
47
+ /**
48
+ * The host's record of the highest seq applied per post. The key is opaque (`{section id}:{publication id}`, built by
49
+ * this module): per section, because a move to another path sends `post.moved` to the new section and `post.deleted` to
50
+ * the one it left under the SAME seq, and a store keyed by publication alone would drop the second. KEEP the seq after
51
+ * a post is deleted: it is what stops a late, older event from bringing the post back.
52
+ */
53
+ interface PushStore {
54
+ getSeq(key: string): Promise<number | undefined> | number | undefined;
55
+ setSeq(key: string, seq: number): Promise<void> | void;
56
+ }
57
+ interface PushRouteOptions {
58
+ /** Current secret first, previous secret(s) after, for rotation (docs/cp1-spec.md section 5.2). */
59
+ readonly secret: string | readonly string[];
60
+ /** Write the event however the site wants. Throwing answers 500 so hyle retries; the seq is recorded only after it returns. */
61
+ readonly onEvent: (event: PushEvent) => Promise<void> | void;
62
+ readonly store: PushStore;
63
+ readonly toleranceSeconds?: number;
64
+ /** Injectable for tests. */
65
+ readonly now?: () => number;
66
+ }
67
+ interface PushRoute {
68
+ readonly POST: (req: Request) => Promise<Response>;
69
+ }
70
+ /**
71
+ * The receiving route for a push path: verifies the signature (the scheme of every hyle webhook), parses `hyle.push/1`,
72
+ * applies an event only when its seq is higher than the last applied for that post in that section (webhooks arrive out of
73
+ * order and are retried), and hands it to `onEvent`. `section.moved` has no publication and is always handed over:
74
+ * the site resyncs. Answers 200 for an ignored or already-applied event, so hyle never retries those.
75
+ */
76
+ declare function createPushRoute(options: PushRouteOptions): PushRoute;
77
+ interface PushPage {
78
+ readonly section: {
79
+ readonly id: string;
80
+ readonly site_path: string;
81
+ };
82
+ /** First page only: webhook events with a seq at or below this are already in the resync. */
83
+ readonly as_of_seq?: number;
84
+ readonly posts: readonly PushPost[];
85
+ /** Posts hyle could not ship (unrenderable, or media slipped in). They are live: keep the local copy, do not sweep it. */
86
+ readonly skipped?: readonly {
87
+ readonly publication_id: string;
88
+ readonly slug: string;
89
+ readonly reason: string;
90
+ }[];
91
+ readonly next_cursor: string | null;
92
+ readonly complete: boolean;
93
+ }
94
+ interface ResyncOptions {
95
+ /** The slug of the push section. */
96
+ readonly section: string;
97
+ /** Upsert one post. */
98
+ readonly onPost: (post: PushPost) => Promise<void> | void;
99
+ /** When given, each resynced post's seq is raised to as_of_seq so an older webhook cannot undo the import. */
100
+ readonly store?: PushStore;
101
+ }
102
+ interface ResyncResult {
103
+ readonly asOfSeq: number;
104
+ /** Every publication_id returned. */
105
+ readonly publicationIds: readonly string[];
106
+ /** Live posts hyle could not ship: neither upserted nor to be swept. */
107
+ readonly skipped: readonly {
108
+ readonly publication_id: string;
109
+ readonly slug: string;
110
+ readonly reason: string;
111
+ }[];
112
+ }
113
+ /**
114
+ * The local rows a finished resync may delete: not returned (nor skipped) AND last written at or before `asOfSeq`. A row
115
+ * with a higher seq was published by a webhook while the walk ran, so the walk could not have seen it. Pass the site's
116
+ * own rows with the seq it stored for each (`resyncPath` raises every resynced row to asOfSeq).
117
+ */
118
+ declare function staleAfterResync(result: ResyncResult, local: readonly {
119
+ readonly publicationId: string;
120
+ readonly seq: number;
121
+ }[]): string[];
122
+ /** Walks `GET /cp1/read/sections/{section}/posts` to its last page (`complete: true`), upserting through `onPost`. */
123
+ declare function resyncPath(client: HyleClient, options: ResyncOptions): Promise<ResyncResult>;
124
+
125
+ /** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
126
+ type HyleRequestInit = Omit<RequestInit, "method" | "body"> & {
127
+ readonly next?: {
128
+ readonly revalidate?: number | false;
129
+ readonly tags?: readonly string[];
130
+ };
131
+ };
132
+ /**
133
+ * Auth headers for ONE request, for an identity-issued machine token (hyle ADR 0027): a DPoP proof is bound to the request's
134
+ * method and URL, so the host builds it per call, typically `(req) => identityServiceClient.headersFor(token, req)`. The SDK
135
+ * takes no identity dependency; it only sets the headers returned (and the `CP-Workspace` header from `workspaceId`).
136
+ */
137
+ type HyleAuth = (req: {
138
+ readonly method: string;
139
+ readonly url: string;
140
+ }) => Promise<Record<string, string>>;
141
+ /** Either a target credential, or a `HyleAuth` for one workspace. Server-side only: neither is ever put in a URL. */
142
+ type HyleCredential = {
143
+ readonly token: string;
144
+ readonly auth?: never;
145
+ readonly workspaceId?: never;
146
+ } | {
147
+ readonly auth: HyleAuth; /** The workspace to read, sent as `CP-Workspace`. */
148
+ readonly workspaceId: string;
149
+ readonly token?: never;
150
+ };
151
+ type HyleClientOptions = HyleCredential & {
152
+ /** hyle's origin, for example https://hyle.tdacorp.in. */
153
+ readonly baseUrl: string;
154
+ /** Injectable for tests; defaults to the global fetch. */
155
+ readonly fetch?: typeof fetch;
156
+ /** Abort a request after this many milliseconds. Default 10000. */
157
+ readonly timeoutMs?: number;
158
+ /** Refuse a response body larger than this many bytes. Default 5 MiB. */
159
+ readonly maxResponseBytes?: number;
160
+ /** Allow a plain http baseUrl on a non-loopback host (tests, private networks). Default false: the token would travel unencrypted. */
161
+ readonly allowInsecureHttp?: boolean;
162
+ };
163
+ interface ResolveOptions {
164
+ /** The site path as a visitor sees it, including the workspace's path prefix. Sent as a query parameter, so it is encoded once. */
165
+ readonly path: string;
166
+ readonly locale?: string;
167
+ readonly format?: "hast" | "html" | "md";
168
+ /** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
169
+ readonly nav?: "tree";
170
+ readonly cursor?: string;
171
+ readonly limit?: number;
172
+ /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
173
+ readonly init?: HyleRequestInit;
174
+ }
175
+ interface MountsOptions {
176
+ /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
177
+ readonly init?: HyleRequestInit;
178
+ }
179
+ interface AssetOptions {
180
+ /** Only these request headers are sent upstream: a browser's own cache validators and byte range. Everything else is dropped. */
181
+ readonly headers?: {
182
+ readonly range?: string | null;
183
+ readonly "if-range"?: string | null;
184
+ readonly "if-none-match"?: string | null;
185
+ };
186
+ /** Abort after this many milliseconds, body included. Default: the client's `timeoutMs`. */
187
+ readonly timeoutMs?: number;
188
+ }
189
+ declare function createHyleClient(options: HyleClientOptions): {
190
+ resolve: (opts: ResolveOptions) => Promise<Resolved>;
191
+ mounts: (opts?: MountsOptions) => Promise<MountsResult>;
192
+ pushPosts: (opts: {
193
+ readonly section: string;
194
+ readonly cursor?: string;
195
+ readonly init?: HyleRequestInit;
196
+ }) => Promise<PushPage>;
197
+ asset: (file: string, opts?: AssetOptions) => Promise<Response>;
198
+ };
199
+ type HyleClient = ReturnType<typeof createHyleClient>;
200
+
201
+ export { type AssetOptions as A, type HyleAuth as H, MAX_PUSH_BODY_BYTES as M, type PushEvent as P, type ResolveOptions as R, type HyleClient as a, type HyleClientOptions as b, type HyleCredential as c, type HyleRequestInit as d, type MountsOptions as e, type PushEventType as f, type PushPage as g, type PushPost as h, type PushRoute as i, type PushRouteOptions as j, type PushStore as k, type ResyncOptions as l, type ResyncResult as m, createHyleClient as n, createPushRoute as o, resyncPath as r, staleAfterResync as s };
@@ -0,0 +1,201 @@
1
+ import { i as Resolved, e as MountsResult } from './types-3F0wqD-o.js';
2
+
3
+ /** docs/cp1-spec.md section 5.3.3: `hyle.push/1`, the whole-post delivery of a path in push mode (ADR 0025). */
4
+ declare const MAX_PUSH_BODY_BYTES: number;
5
+ interface PushPost {
6
+ readonly publication_id: string;
7
+ readonly document_id: string;
8
+ readonly version: number;
9
+ readonly slug: string;
10
+ readonly canonical_path: string;
11
+ readonly locale: string;
12
+ readonly title: string;
13
+ readonly description: string | null;
14
+ /** The author's source. Never render it with raw HTML enabled: use `html`, or a Markdown renderer with raw HTML off. */
15
+ readonly markdown: string;
16
+ /** Sanitized HTML, the same output as `format=html` on the read surface. */
17
+ readonly html: string;
18
+ readonly tags: readonly string[];
19
+ readonly kicker: string | null;
20
+ readonly status_label: string | null;
21
+ readonly author_name: string | null;
22
+ readonly author_url: string | null;
23
+ readonly published_at: string;
24
+ readonly updated_at: string;
25
+ readonly word_count: number;
26
+ }
27
+ type PushEventType = "post.published" | "post.updated" | "post.unpublished" | "post.deleted" | "post.moved" | "section.moved";
28
+ interface PushEvent {
29
+ readonly schema: "hyle.push/1";
30
+ readonly type: PushEventType;
31
+ /** The delivery id: a retry carries the same one. */
32
+ readonly event_id: string;
33
+ readonly occurred_at: string;
34
+ readonly seq: number;
35
+ readonly workspace_id: string;
36
+ readonly section: {
37
+ readonly id: string;
38
+ readonly site_path: string;
39
+ };
40
+ readonly publication_id?: string;
41
+ readonly document_id?: string;
42
+ /** post.moved and section.moved: where it used to live. */
43
+ readonly previous_path?: string;
44
+ /** On post.published, post.updated and post.moved. */
45
+ readonly post?: PushPost;
46
+ }
47
+ /**
48
+ * The host's record of the highest seq applied per post. The key is opaque (`{section id}:{publication id}`, built by
49
+ * this module): per section, because a move to another path sends `post.moved` to the new section and `post.deleted` to
50
+ * the one it left under the SAME seq, and a store keyed by publication alone would drop the second. KEEP the seq after
51
+ * a post is deleted: it is what stops a late, older event from bringing the post back.
52
+ */
53
+ interface PushStore {
54
+ getSeq(key: string): Promise<number | undefined> | number | undefined;
55
+ setSeq(key: string, seq: number): Promise<void> | void;
56
+ }
57
+ interface PushRouteOptions {
58
+ /** Current secret first, previous secret(s) after, for rotation (docs/cp1-spec.md section 5.2). */
59
+ readonly secret: string | readonly string[];
60
+ /** Write the event however the site wants. Throwing answers 500 so hyle retries; the seq is recorded only after it returns. */
61
+ readonly onEvent: (event: PushEvent) => Promise<void> | void;
62
+ readonly store: PushStore;
63
+ readonly toleranceSeconds?: number;
64
+ /** Injectable for tests. */
65
+ readonly now?: () => number;
66
+ }
67
+ interface PushRoute {
68
+ readonly POST: (req: Request) => Promise<Response>;
69
+ }
70
+ /**
71
+ * The receiving route for a push path: verifies the signature (the scheme of every hyle webhook), parses `hyle.push/1`,
72
+ * applies an event only when its seq is higher than the last applied for that post in that section (webhooks arrive out of
73
+ * order and are retried), and hands it to `onEvent`. `section.moved` has no publication and is always handed over:
74
+ * the site resyncs. Answers 200 for an ignored or already-applied event, so hyle never retries those.
75
+ */
76
+ declare function createPushRoute(options: PushRouteOptions): PushRoute;
77
+ interface PushPage {
78
+ readonly section: {
79
+ readonly id: string;
80
+ readonly site_path: string;
81
+ };
82
+ /** First page only: webhook events with a seq at or below this are already in the resync. */
83
+ readonly as_of_seq?: number;
84
+ readonly posts: readonly PushPost[];
85
+ /** Posts hyle could not ship (unrenderable, or media slipped in). They are live: keep the local copy, do not sweep it. */
86
+ readonly skipped?: readonly {
87
+ readonly publication_id: string;
88
+ readonly slug: string;
89
+ readonly reason: string;
90
+ }[];
91
+ readonly next_cursor: string | null;
92
+ readonly complete: boolean;
93
+ }
94
+ interface ResyncOptions {
95
+ /** The slug of the push section. */
96
+ readonly section: string;
97
+ /** Upsert one post. */
98
+ readonly onPost: (post: PushPost) => Promise<void> | void;
99
+ /** When given, each resynced post's seq is raised to as_of_seq so an older webhook cannot undo the import. */
100
+ readonly store?: PushStore;
101
+ }
102
+ interface ResyncResult {
103
+ readonly asOfSeq: number;
104
+ /** Every publication_id returned. */
105
+ readonly publicationIds: readonly string[];
106
+ /** Live posts hyle could not ship: neither upserted nor to be swept. */
107
+ readonly skipped: readonly {
108
+ readonly publication_id: string;
109
+ readonly slug: string;
110
+ readonly reason: string;
111
+ }[];
112
+ }
113
+ /**
114
+ * The local rows a finished resync may delete: not returned (nor skipped) AND last written at or before `asOfSeq`. A row
115
+ * with a higher seq was published by a webhook while the walk ran, so the walk could not have seen it. Pass the site's
116
+ * own rows with the seq it stored for each (`resyncPath` raises every resynced row to asOfSeq).
117
+ */
118
+ declare function staleAfterResync(result: ResyncResult, local: readonly {
119
+ readonly publicationId: string;
120
+ readonly seq: number;
121
+ }[]): string[];
122
+ /** Walks `GET /cp1/read/sections/{section}/posts` to its last page (`complete: true`), upserting through `onPost`. */
123
+ declare function resyncPath(client: HyleClient, options: ResyncOptions): Promise<ResyncResult>;
124
+
125
+ /** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
126
+ type HyleRequestInit = Omit<RequestInit, "method" | "body"> & {
127
+ readonly next?: {
128
+ readonly revalidate?: number | false;
129
+ readonly tags?: readonly string[];
130
+ };
131
+ };
132
+ /**
133
+ * Auth headers for ONE request, for an identity-issued machine token (hyle ADR 0027): a DPoP proof is bound to the request's
134
+ * method and URL, so the host builds it per call, typically `(req) => identityServiceClient.headersFor(token, req)`. The SDK
135
+ * takes no identity dependency; it only sets the headers returned (and the `CP-Workspace` header from `workspaceId`).
136
+ */
137
+ type HyleAuth = (req: {
138
+ readonly method: string;
139
+ readonly url: string;
140
+ }) => Promise<Record<string, string>>;
141
+ /** Either a target credential, or a `HyleAuth` for one workspace. Server-side only: neither is ever put in a URL. */
142
+ type HyleCredential = {
143
+ readonly token: string;
144
+ readonly auth?: never;
145
+ readonly workspaceId?: never;
146
+ } | {
147
+ readonly auth: HyleAuth; /** The workspace to read, sent as `CP-Workspace`. */
148
+ readonly workspaceId: string;
149
+ readonly token?: never;
150
+ };
151
+ type HyleClientOptions = HyleCredential & {
152
+ /** hyle's origin, for example https://hyle.tdacorp.in. */
153
+ readonly baseUrl: string;
154
+ /** Injectable for tests; defaults to the global fetch. */
155
+ readonly fetch?: typeof fetch;
156
+ /** Abort a request after this many milliseconds. Default 10000. */
157
+ readonly timeoutMs?: number;
158
+ /** Refuse a response body larger than this many bytes. Default 5 MiB. */
159
+ readonly maxResponseBytes?: number;
160
+ /** Allow a plain http baseUrl on a non-loopback host (tests, private networks). Default false: the token would travel unencrypted. */
161
+ readonly allowInsecureHttp?: boolean;
162
+ };
163
+ interface ResolveOptions {
164
+ /** The site path as a visitor sees it, including the workspace's path prefix. Sent as a query parameter, so it is encoded once. */
165
+ readonly path: string;
166
+ readonly locale?: string;
167
+ readonly format?: "hast" | "html" | "md";
168
+ /** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
169
+ readonly nav?: "tree";
170
+ readonly cursor?: string;
171
+ readonly limit?: number;
172
+ /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
173
+ readonly init?: HyleRequestInit;
174
+ }
175
+ interface MountsOptions {
176
+ /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
177
+ readonly init?: HyleRequestInit;
178
+ }
179
+ interface AssetOptions {
180
+ /** Only these request headers are sent upstream: a browser's own cache validators and byte range. Everything else is dropped. */
181
+ readonly headers?: {
182
+ readonly range?: string | null;
183
+ readonly "if-range"?: string | null;
184
+ readonly "if-none-match"?: string | null;
185
+ };
186
+ /** Abort after this many milliseconds, body included. Default: the client's `timeoutMs`. */
187
+ readonly timeoutMs?: number;
188
+ }
189
+ declare function createHyleClient(options: HyleClientOptions): {
190
+ resolve: (opts: ResolveOptions) => Promise<Resolved>;
191
+ mounts: (opts?: MountsOptions) => Promise<MountsResult>;
192
+ pushPosts: (opts: {
193
+ readonly section: string;
194
+ readonly cursor?: string;
195
+ readonly init?: HyleRequestInit;
196
+ }) => Promise<PushPage>;
197
+ asset: (file: string, opts?: AssetOptions) => Promise<Response>;
198
+ };
199
+ type HyleClient = ReturnType<typeof createHyleClient>;
200
+
201
+ export { type AssetOptions as A, type HyleAuth as H, MAX_PUSH_BODY_BYTES as M, type PushEvent as P, type ResolveOptions as R, type HyleClient as a, type HyleClientOptions as b, type HyleCredential as c, type HyleRequestInit as d, type MountsOptions as e, type PushEventType as f, type PushPage as g, type PushPost as h, type PushRoute as i, type PushRouteOptions as j, type PushStore as k, type ResyncOptions as l, type ResyncResult as m, createHyleClient as n, createPushRoute as o, resyncPath as r, staleAfterResync as s };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/react/code-copy.tsx
22
+ var code_copy_exports = {};
23
+ __export(code_copy_exports, {
24
+ CodeCopy: () => CodeCopy
25
+ });
26
+ module.exports = __toCommonJS(code_copy_exports);
27
+ var import_react = require("react");
28
+ var RESET_MS = 1500;
29
+ function CodeCopy({ rootId, copyLabel, copiedLabel, blockedLabel }) {
30
+ (0, import_react.useEffect)(() => {
31
+ const root = document.getElementById(rootId);
32
+ if (!root) return;
33
+ const timers = /* @__PURE__ */ new Map();
34
+ const show = (button, state) => {
35
+ const label = state === "copied" ? copiedLabel : state === "blocked" ? blockedLabel : "";
36
+ if (state) button.dataset.state = state;
37
+ else delete button.dataset.state;
38
+ button.setAttribute("aria-label", label || copyLabel);
39
+ const status = button.parentElement?.querySelector("[role='status']");
40
+ if (status) status.textContent = label;
41
+ };
42
+ const onClick = (event) => {
43
+ const button = event.target instanceof Element ? event.target.closest(".hyle-codeblock > header > button") : null;
44
+ const figure = button?.closest("figure");
45
+ if (!button || !figure) return;
46
+ const code = figure.querySelector("pre")?.textContent ?? "";
47
+ const done = (state) => {
48
+ window.clearTimeout(timers.get(button));
49
+ show(button, state);
50
+ timers.set(button, window.setTimeout(() => show(button, void 0), RESET_MS));
51
+ };
52
+ const write = navigator.clipboard?.writeText(code) ?? Promise.reject(new Error("no clipboard"));
53
+ write.then(
54
+ () => {
55
+ done("copied");
56
+ figure.dispatchEvent(new CustomEvent("hyle:code-copied", { bubbles: true, detail: { language: figure.querySelector(".lang")?.textContent ?? void 0 } }));
57
+ },
58
+ () => done("blocked")
59
+ );
60
+ };
61
+ root.addEventListener("click", onClick);
62
+ return () => {
63
+ root.removeEventListener("click", onClick);
64
+ for (const timer of timers.values()) window.clearTimeout(timer);
65
+ };
66
+ }, [rootId, copyLabel, copiedLabel, blockedLabel]);
67
+ return null;
68
+ }
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ CodeCopy
72
+ });
@@ -0,0 +1,15 @@
1
+ interface CodeCopyProps {
2
+ /** The `id` of the body whose code blocks this island serves. */
3
+ rootId: string;
4
+ copyLabel: string;
5
+ copiedLabel: string;
6
+ blockedLabel: string;
7
+ }
8
+ /**
9
+ * One delegated click listener for every `figure.hyle-codeblock` copy button under `rootId`: writes the block's code to the
10
+ * clipboard, then shows and announces "copied" or "blocked" for a moment. A successful copy also dispatches a bubbling
11
+ * `hyle:code-copied` event on the figure, for a host that counts copies. Renders nothing; the buttons are server HTML.
12
+ */
13
+ declare function CodeCopy({ rootId, copyLabel, copiedLabel, blockedLabel }: CodeCopyProps): null;
14
+
15
+ export { CodeCopy, type CodeCopyProps };
@@ -0,0 +1,15 @@
1
+ interface CodeCopyProps {
2
+ /** The `id` of the body whose code blocks this island serves. */
3
+ rootId: string;
4
+ copyLabel: string;
5
+ copiedLabel: string;
6
+ blockedLabel: string;
7
+ }
8
+ /**
9
+ * One delegated click listener for every `figure.hyle-codeblock` copy button under `rootId`: writes the block's code to the
10
+ * clipboard, then shows and announces "copied" or "blocked" for a moment. A successful copy also dispatches a bubbling
11
+ * `hyle:code-copied` event on the figure, for a host that counts copies. Renders nothing; the buttons are server HTML.
12
+ */
13
+ declare function CodeCopy({ rootId, copyLabel, copiedLabel, blockedLabel }: CodeCopyProps): null;
14
+
15
+ export { CodeCopy, type CodeCopyProps };
@@ -0,0 +1,48 @@
1
+ "use client";
2
+
3
+ // src/react/code-copy.tsx
4
+ import { useEffect } from "react";
5
+ var RESET_MS = 1500;
6
+ function CodeCopy({ rootId, copyLabel, copiedLabel, blockedLabel }) {
7
+ useEffect(() => {
8
+ const root = document.getElementById(rootId);
9
+ if (!root) return;
10
+ const timers = /* @__PURE__ */ new Map();
11
+ const show = (button, state) => {
12
+ const label = state === "copied" ? copiedLabel : state === "blocked" ? blockedLabel : "";
13
+ if (state) button.dataset.state = state;
14
+ else delete button.dataset.state;
15
+ button.setAttribute("aria-label", label || copyLabel);
16
+ const status = button.parentElement?.querySelector("[role='status']");
17
+ if (status) status.textContent = label;
18
+ };
19
+ const onClick = (event) => {
20
+ const button = event.target instanceof Element ? event.target.closest(".hyle-codeblock > header > button") : null;
21
+ const figure = button?.closest("figure");
22
+ if (!button || !figure) return;
23
+ const code = figure.querySelector("pre")?.textContent ?? "";
24
+ const done = (state) => {
25
+ window.clearTimeout(timers.get(button));
26
+ show(button, state);
27
+ timers.set(button, window.setTimeout(() => show(button, void 0), RESET_MS));
28
+ };
29
+ const write = navigator.clipboard?.writeText(code) ?? Promise.reject(new Error("no clipboard"));
30
+ write.then(
31
+ () => {
32
+ done("copied");
33
+ figure.dispatchEvent(new CustomEvent("hyle:code-copied", { bubbles: true, detail: { language: figure.querySelector(".lang")?.textContent ?? void 0 } }));
34
+ },
35
+ () => done("blocked")
36
+ );
37
+ };
38
+ root.addEventListener("click", onClick);
39
+ return () => {
40
+ root.removeEventListener("click", onClick);
41
+ for (const timer of timers.values()) window.clearTimeout(timer);
42
+ };
43
+ }, [rootId, copyLabel, copiedLabel, blockedLabel]);
44
+ return null;
45
+ }
46
+ export {
47
+ CodeCopy
48
+ };