@tdacorp/hyle-sdk 0.9.0 → 0.12.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/README.md +111 -2
- package/bin/hyle-sdk-engage-keygen.mjs +3 -0
- package/dist/check-routes-bin.js +5 -1
- package/dist/{chunk-54JF4E53.js → chunk-N7ZQUAGM.js} +45 -2
- package/dist/chunk-R5EMI4HQ.js +61 -0
- package/dist/{chunk-XKR74Y5G.js → chunk-S7PCCEHP.js} +1 -1
- package/dist/{chunk-6LW33475.js → chunk-ZQFYH4FX.js} +538 -50
- package/dist/comments.cjs +1048 -0
- package/dist/comments.d.cts +152 -0
- package/dist/comments.d.ts +152 -0
- package/dist/comments.js +1025 -0
- package/dist/{types-BPPZrYOZ.d.cts → embed-DL5QIZRJ.d.ts} +44 -3
- package/dist/{types-C1eCQ2As.d.ts → embed-jCaSI31t.d.cts} +44 -3
- package/dist/engage-keygen-bin.js +67 -0
- package/dist/index.cjs +26 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +5 -1
- package/dist/mermaid-diagram.js +9 -54
- package/dist/next.cjs +1010 -78
- package/dist/next.d.cts +163 -6
- package/dist/next.d.ts +163 -6
- package/dist/next.js +442 -14
- package/dist/react.cjs +340 -49
- package/dist/react.d.cts +112 -7
- package/dist/react.d.ts +112 -7
- package/dist/react.js +7 -1
- package/dist/{resolve-Dpb6Orsj.d.ts → resolve-DvmuBlpO.d.ts} +1 -1
- package/dist/{resolve-D2rnnho9.d.cts → resolve-f6IJ6SL9.d.cts} +1 -1
- package/dist/styles.css +117 -0
- package/dist/{types-CHxH5E0S.d.cts → types-5D6ZD0Wi.d.cts} +59 -1
- package/dist/{types-CHxH5E0S.d.ts → types-5D6ZD0Wi.d.ts} +59 -1
- package/dist/use-cache.cjs +5 -1
- package/dist/use-cache.d.cts +2 -2
- package/dist/use-cache.d.ts +2 -2
- package/dist/use-cache.js +2 -2
- package/package.json +4 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementType, ReactNode, ComponentType } from 'react';
|
|
2
|
-
import { L as ListItem } from './types-
|
|
1
|
+
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
+
import { L as ListItem, h as ResolvedArticle } from './types-5D6ZD0Wi.js';
|
|
3
3
|
|
|
4
4
|
type CalloutKind = "note" | "tip" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
|
@@ -90,5 +90,46 @@ interface PageBaseProps {
|
|
|
90
90
|
*/
|
|
91
91
|
toHref?: ((sitePath: string, locale: string) => string) | undefined;
|
|
92
92
|
}
|
|
93
|
+
/** Reader comments and likes under an article (ADR 0017). Pass it only when the workspace has engagement on and the host mounted `createEngagementRoute`. */
|
|
94
|
+
interface EngagementConfig {
|
|
95
|
+
/** The host route that answers the calls. Default "/api/hyle/engage". */
|
|
96
|
+
endpoint?: string | undefined;
|
|
97
|
+
/** Where the "Sign in" button goes (the host's own sign-in). Without it a signed-out visitor sees the prompt but no button. */
|
|
98
|
+
signInHref?: string | undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Embeds: parts of a hyle site inside a page the host owns. Pure markup, server safe, no "use client". Unlike the pages they have
|
|
103
|
+
* no frame, no `<title>`, no `<link>`, no `<meta>`, no JSON-LD, no table of contents and no pager: the host page keeps its own
|
|
104
|
+
* metadata, and every embed links back to the canonical URL on the mount.
|
|
105
|
+
*/
|
|
106
|
+
type EmbedHeading = 2 | 3 | 4;
|
|
107
|
+
interface HyleListViewProps extends PageBaseProps {
|
|
108
|
+
readonly items: readonly ListItem[];
|
|
109
|
+
/** Default "list". "grid" lays the items out as cards. */
|
|
110
|
+
readonly layout?: "list" | "grid" | undefined;
|
|
111
|
+
/** An optional heading above the list. */
|
|
112
|
+
readonly title?: string | undefined;
|
|
113
|
+
/** The heading's level, so it nests under the host page's own headings. Default 2. */
|
|
114
|
+
readonly headingLevel?: EmbedHeading | undefined;
|
|
115
|
+
/** Where "View all" goes (a URL in the host's space); omit to hide it. */
|
|
116
|
+
readonly moreHref?: string | undefined;
|
|
117
|
+
}
|
|
118
|
+
/** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping and no pagination. */
|
|
119
|
+
declare function HyleListView({ items, layout, title, headingLevel, moreHref, ...base }: HyleListViewProps): ReactElement | null;
|
|
120
|
+
interface HyleArticleViewProps extends PageBaseProps {
|
|
121
|
+
readonly article: ResolvedArticle;
|
|
122
|
+
/**
|
|
123
|
+
* The title's level. Default 2: a host page normally has its own h1, and body headings are h2 and below, so nest the embed
|
|
124
|
+
* under a section heading of your own and raise this to match.
|
|
125
|
+
*/
|
|
126
|
+
readonly headingLevel?: EmbedHeading | undefined;
|
|
127
|
+
}
|
|
128
|
+
/** The article's title, date, description and body, then a visible link to the canonical page. */
|
|
129
|
+
declare function HyleArticleView({ article, headingLevel, ...base }: HyleArticleViewProps): ReactElement;
|
|
130
|
+
/** The placeholder to give `<Suspense fallback>` around `HyleComments`: the labelled section and skeleton rows, no data. */
|
|
131
|
+
declare function HyleCommentsFallback({ locale }: {
|
|
132
|
+
locale?: string | undefined;
|
|
133
|
+
}): ReactElement;
|
|
93
134
|
|
|
94
|
-
export type
|
|
135
|
+
export { type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type LinkProps as L, type MermaidProps as M, type PageBaseProps as P, type HyleSlots as a, type EmbedHeading as b, HyleCommentsFallback as c, type CalloutProps as d, type CodeBlockProps as e, HyleArticleView as f, type HyleArticleViewProps as g, HyleListView as h, type HyleListViewProps as i, type ListItemProps as j };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementType, ReactNode, ComponentType } from 'react';
|
|
2
|
-
import { L as ListItem } from './types-
|
|
1
|
+
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
+
import { L as ListItem, h as ResolvedArticle } from './types-5D6ZD0Wi.cjs';
|
|
3
3
|
|
|
4
4
|
type CalloutKind = "note" | "tip" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
|
@@ -90,5 +90,46 @@ interface PageBaseProps {
|
|
|
90
90
|
*/
|
|
91
91
|
toHref?: ((sitePath: string, locale: string) => string) | undefined;
|
|
92
92
|
}
|
|
93
|
+
/** Reader comments and likes under an article (ADR 0017). Pass it only when the workspace has engagement on and the host mounted `createEngagementRoute`. */
|
|
94
|
+
interface EngagementConfig {
|
|
95
|
+
/** The host route that answers the calls. Default "/api/hyle/engage". */
|
|
96
|
+
endpoint?: string | undefined;
|
|
97
|
+
/** Where the "Sign in" button goes (the host's own sign-in). Without it a signed-out visitor sees the prompt but no button. */
|
|
98
|
+
signInHref?: string | undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Embeds: parts of a hyle site inside a page the host owns. Pure markup, server safe, no "use client". Unlike the pages they have
|
|
103
|
+
* no frame, no `<title>`, no `<link>`, no `<meta>`, no JSON-LD, no table of contents and no pager: the host page keeps its own
|
|
104
|
+
* metadata, and every embed links back to the canonical URL on the mount.
|
|
105
|
+
*/
|
|
106
|
+
type EmbedHeading = 2 | 3 | 4;
|
|
107
|
+
interface HyleListViewProps extends PageBaseProps {
|
|
108
|
+
readonly items: readonly ListItem[];
|
|
109
|
+
/** Default "list". "grid" lays the items out as cards. */
|
|
110
|
+
readonly layout?: "list" | "grid" | undefined;
|
|
111
|
+
/** An optional heading above the list. */
|
|
112
|
+
readonly title?: string | undefined;
|
|
113
|
+
/** The heading's level, so it nests under the host page's own headings. Default 2. */
|
|
114
|
+
readonly headingLevel?: EmbedHeading | undefined;
|
|
115
|
+
/** Where "View all" goes (a URL in the host's space); omit to hide it. */
|
|
116
|
+
readonly moreHref?: string | undefined;
|
|
117
|
+
}
|
|
118
|
+
/** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping and no pagination. */
|
|
119
|
+
declare function HyleListView({ items, layout, title, headingLevel, moreHref, ...base }: HyleListViewProps): ReactElement | null;
|
|
120
|
+
interface HyleArticleViewProps extends PageBaseProps {
|
|
121
|
+
readonly article: ResolvedArticle;
|
|
122
|
+
/**
|
|
123
|
+
* The title's level. Default 2: a host page normally has its own h1, and body headings are h2 and below, so nest the embed
|
|
124
|
+
* under a section heading of your own and raise this to match.
|
|
125
|
+
*/
|
|
126
|
+
readonly headingLevel?: EmbedHeading | undefined;
|
|
127
|
+
}
|
|
128
|
+
/** The article's title, date, description and body, then a visible link to the canonical page. */
|
|
129
|
+
declare function HyleArticleView({ article, headingLevel, ...base }: HyleArticleViewProps): ReactElement;
|
|
130
|
+
/** The placeholder to give `<Suspense fallback>` around `HyleComments`: the labelled section and skeleton rows, no data. */
|
|
131
|
+
declare function HyleCommentsFallback({ locale }: {
|
|
132
|
+
locale?: string | undefined;
|
|
133
|
+
}): ReactElement;
|
|
93
134
|
|
|
94
|
-
export type
|
|
135
|
+
export { type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type LinkProps as L, type MermaidProps as M, type PageBaseProps as P, type HyleSlots as a, type EmbedHeading as b, HyleCommentsFallback as c, type CalloutProps as d, type CodeBlockProps as e, HyleArticleView as f, type HyleArticleViewProps as g, HyleListView as h, type HyleListViewProps as i, type ListItemProps as j };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/engage-keygen.ts
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import { closeSync, openSync, writeSync } from "fs";
|
|
4
|
+
|
|
5
|
+
// src/engage-keys.ts
|
|
6
|
+
import { createPrivateKey, createPublicKey, generateKeyPairSync, randomUUID, sign } from "crypto";
|
|
7
|
+
var PKCS8_ED25519 = Buffer.from("302e020100300506032b657004220420", "hex");
|
|
8
|
+
function generateEngagementKeyPair() {
|
|
9
|
+
const jwk = generateKeyPairSync("ed25519").privateKey.export({ format: "jwk" });
|
|
10
|
+
return { publicKey: String(jwk.x), privateKey: String(jwk.d) };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/engage-keygen.ts
|
|
14
|
+
var KEYGEN_USAGE = `usage:
|
|
15
|
+
hyle-sdk-engage-keygen --out <env-file> write HYLE_ENGAGE_SIGNING_KEY=<private key> to a new file (mode 0600), print only the public key
|
|
16
|
+
hyle-sdk-engage-keygen --stdout print both keys to the terminal (the private key lands in your scrollback)`;
|
|
17
|
+
var nodeIo = {
|
|
18
|
+
stdout: (t) => void console.log(t),
|
|
19
|
+
stderr: (t) => void console.error(t),
|
|
20
|
+
writeNew: (path, content) => {
|
|
21
|
+
const fd = openSync(path, "wx", 384);
|
|
22
|
+
try {
|
|
23
|
+
writeSync(fd, content);
|
|
24
|
+
} finally {
|
|
25
|
+
closeSync(fd);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
gitIgnored: (path) => {
|
|
29
|
+
const r = spawnSync("git", ["check-ignore", "-q", "--", path], { stdio: "ignore" });
|
|
30
|
+
return r.status === 0 ? true : r.status === 1 ? false : void 0;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function keygen(argv, io = nodeIo) {
|
|
34
|
+
const outAt = argv.indexOf("--out");
|
|
35
|
+
const out = outAt >= 0 ? argv[outAt + 1] : void 0;
|
|
36
|
+
const toStdout = argv.length === 1 && argv[0] === "--stdout";
|
|
37
|
+
const toFile = argv.length === 2 && outAt === 0 && out !== void 0 && !out.startsWith("--");
|
|
38
|
+
if (!toStdout && !toFile) {
|
|
39
|
+
io.stderr(KEYGEN_USAGE);
|
|
40
|
+
return 2;
|
|
41
|
+
}
|
|
42
|
+
const { publicKey, privateKey } = generateEngagementKeyPair();
|
|
43
|
+
if (toStdout) {
|
|
44
|
+
io.stdout(`Public key (register it in hyle, workspace engagement settings):
|
|
45
|
+
${publicKey}
|
|
46
|
+
`);
|
|
47
|
+
io.stdout(`Private key (set it as the HYLE_ENGAGE_SIGNING_KEY environment variable; never commit it, never share it):
|
|
48
|
+
${privateKey}`);
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
io.writeNew(out, `HYLE_ENGAGE_SIGNING_KEY=${privateKey}
|
|
53
|
+
`);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
io.stderr(`could not write ${out}: ${error.code ?? "error"} (no key was printed)`);
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
io.stdout(`Public key (register it in hyle, workspace engagement settings):
|
|
59
|
+
${publicKey}
|
|
60
|
+
`);
|
|
61
|
+
io.stdout(`Private key written to ${out} (mode 0600). Load it as HYLE_ENGAGE_SIGNING_KEY; never commit it.`);
|
|
62
|
+
if (io.gitIgnored(out) === false) io.stderr(`warning: ${out} is not ignored by git. Add it to .gitignore before you commit anything.`);
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/engage-keygen-bin.ts
|
|
67
|
+
process.exitCode = keygen(process.argv.slice(2));
|
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,9 @@ __export(src_exports, {
|
|
|
27
27
|
checkRoutes: () => checkRoutes,
|
|
28
28
|
createHyleClient: () => createHyleClient,
|
|
29
29
|
createRevalidationCallbackRoute: () => createRevalidationCallbackRoute,
|
|
30
|
+
engagementPublicKey: () => engagementPublicKey,
|
|
30
31
|
formatReport: () => formatReport,
|
|
32
|
+
generateEngagementKeyPair: () => generateEngagementKeyPair,
|
|
31
33
|
hostRoutesFromManifests: () => hostRoutesFromManifests,
|
|
32
34
|
isValidCacheTag: () => isValidCacheTag,
|
|
33
35
|
listPublicationPaths: () => listPublicationPaths,
|
|
@@ -139,7 +141,11 @@ function createHyleClient(options) {
|
|
|
139
141
|
if (opts.limit !== void 0) query.set("limit", String(opts.limit));
|
|
140
142
|
const reply = await get("/cp1/read/resolve", query, opts.init);
|
|
141
143
|
const data = reply.parsed?.data;
|
|
142
|
-
if (data && data.cp === 1 && typeof data.kind === "string" && KINDS.has(data.kind))
|
|
144
|
+
if (data && data.cp === 1 && typeof data.kind === "string" && KINDS.has(data.kind)) {
|
|
145
|
+
const resolved = data;
|
|
146
|
+
if (resolved.kind === "article" && resolved.content.format === "html" && opts.format !== "html") throw failure(reply);
|
|
147
|
+
return resolved;
|
|
148
|
+
}
|
|
143
149
|
throw failure(reply);
|
|
144
150
|
}
|
|
145
151
|
async function mounts(opts = {}) {
|
|
@@ -559,6 +565,23 @@ var printable = (text) => {
|
|
|
559
565
|
const clean = text.replace(/\u001b(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007\u001b]*(?:\u0007|\u001b\\)?|.)?/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
|
|
560
566
|
return clean.length > MAX_PRINTED ? `${clean.slice(0, MAX_PRINTED)}...` : clean;
|
|
561
567
|
};
|
|
568
|
+
|
|
569
|
+
// src/engage-keys.ts
|
|
570
|
+
var import_node_crypto2 = require("crypto");
|
|
571
|
+
var KEY_B64URL = /^[A-Za-z0-9_-]{43}$/;
|
|
572
|
+
var PKCS8_ED25519 = Buffer.from("302e020100300506032b657004220420", "hex");
|
|
573
|
+
function generateEngagementKeyPair() {
|
|
574
|
+
const jwk = (0, import_node_crypto2.generateKeyPairSync)("ed25519").privateKey.export({ format: "jwk" });
|
|
575
|
+
return { publicKey: String(jwk.x), privateKey: String(jwk.d) };
|
|
576
|
+
}
|
|
577
|
+
function engagementSigningKey(seed) {
|
|
578
|
+
const bytes = KEY_B64URL.test(seed) ? Buffer.from(seed, "base64url") : void 0;
|
|
579
|
+
if (bytes?.length !== 32) throw new TypeError("the engagement signing key must be a 32-byte Ed25519 seed, base64url (43 characters)");
|
|
580
|
+
return (0, import_node_crypto2.createPrivateKey)({ key: Buffer.concat([PKCS8_ED25519, bytes]), format: "der", type: "pkcs8" });
|
|
581
|
+
}
|
|
582
|
+
function engagementPublicKey(seed) {
|
|
583
|
+
return String((0, import_node_crypto2.createPublicKey)(engagementSigningKey(seed)).export({ format: "jwk" }).x);
|
|
584
|
+
}
|
|
562
585
|
// Annotate the CommonJS export names for ESM import in node:
|
|
563
586
|
0 && (module.exports = {
|
|
564
587
|
CACHE_TAG_PATTERN,
|
|
@@ -568,7 +591,9 @@ var printable = (text) => {
|
|
|
568
591
|
checkRoutes,
|
|
569
592
|
createHyleClient,
|
|
570
593
|
createRevalidationCallbackRoute,
|
|
594
|
+
engagementPublicKey,
|
|
571
595
|
formatReport,
|
|
596
|
+
generateEngagementKeyPair,
|
|
572
597
|
hostRoutesFromManifests,
|
|
573
598
|
isValidCacheTag,
|
|
574
599
|
listPublicationPaths,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Resolved, M as MountsResult } from './types-
|
|
2
|
-
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem,
|
|
1
|
+
import { R as Resolved, M as MountsResult } from './types-5D6ZD0Wi.cjs';
|
|
2
|
+
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-5D6ZD0Wi.cjs';
|
|
3
3
|
export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.cjs';
|
|
4
4
|
|
|
5
5
|
/** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
|
|
@@ -274,4 +274,12 @@ declare function reservedFor(hostRoutes: readonly string[], options?: {
|
|
|
274
274
|
/** The human report. */
|
|
275
275
|
declare function formatReport(report: RouteCheckReport): string;
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
/** Fresh pair for `hyle-sdk-engage-keygen`. Nothing is logged here. */
|
|
278
|
+
declare function generateEngagementKeyPair(): {
|
|
279
|
+
readonly publicKey: string;
|
|
280
|
+
readonly privateKey: string;
|
|
281
|
+
};
|
|
282
|
+
/** The public half to register in hyle, from the private seed. */
|
|
283
|
+
declare function engagementPublicKey(seed: string): string;
|
|
284
|
+
|
|
285
|
+
export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, engagementPublicKey, formatReport, generateEngagementKeyPair, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Resolved, M as MountsResult } from './types-
|
|
2
|
-
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem,
|
|
1
|
+
import { R as Resolved, M as MountsResult } from './types-5D6ZD0Wi.js';
|
|
2
|
+
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-5D6ZD0Wi.js';
|
|
3
3
|
export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.js';
|
|
4
4
|
|
|
5
5
|
/** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
|
|
@@ -274,4 +274,12 @@ declare function reservedFor(hostRoutes: readonly string[], options?: {
|
|
|
274
274
|
/** The human report. */
|
|
275
275
|
declare function formatReport(report: RouteCheckReport): string;
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
/** Fresh pair for `hyle-sdk-engage-keygen`. Nothing is logged here. */
|
|
278
|
+
declare function generateEngagementKeyPair(): {
|
|
279
|
+
readonly publicKey: string;
|
|
280
|
+
readonly privateKey: string;
|
|
281
|
+
};
|
|
282
|
+
/** The public half to register in hyle, from the private seed. */
|
|
283
|
+
declare function engagementPublicKey(seed: string): string;
|
|
284
|
+
|
|
285
|
+
export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, engagementPublicKey, formatReport, generateEngagementKeyPair, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
checkRoutes,
|
|
7
7
|
createHyleClient,
|
|
8
8
|
createRevalidationCallbackRoute,
|
|
9
|
+
engagementPublicKey,
|
|
9
10
|
formatReport,
|
|
11
|
+
generateEngagementKeyPair,
|
|
10
12
|
hostRoutesFromManifests,
|
|
11
13
|
isValidCacheTag,
|
|
12
14
|
listPublicationPaths,
|
|
@@ -16,7 +18,7 @@ import {
|
|
|
16
18
|
routeMatches,
|
|
17
19
|
syncHostReserved,
|
|
18
20
|
verifyHyleSignature
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-N7ZQUAGM.js";
|
|
20
22
|
import "./chunk-67IOIAVW.js";
|
|
21
23
|
export {
|
|
22
24
|
CACHE_TAG_PATTERN,
|
|
@@ -26,7 +28,9 @@ export {
|
|
|
26
28
|
checkRoutes,
|
|
27
29
|
createHyleClient,
|
|
28
30
|
createRevalidationCallbackRoute,
|
|
31
|
+
engagementPublicKey,
|
|
29
32
|
formatReport,
|
|
33
|
+
generateEngagementKeyPair,
|
|
30
34
|
hostRoutesFromManifests,
|
|
31
35
|
isValidCacheTag,
|
|
32
36
|
listPublicationPaths,
|
package/dist/mermaid-diagram.js
CHANGED
|
@@ -1,64 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
MAX_MERMAID_SOURCE,
|
|
4
|
+
RENDER_TIMEOUT_MS,
|
|
5
|
+
nextMermaidId,
|
|
6
|
+
pickMermaidTheme,
|
|
7
|
+
stripMermaidConfig,
|
|
8
|
+
whenNearViewport,
|
|
9
|
+
withTimeout
|
|
10
|
+
} from "./chunk-R5EMI4HQ.js";
|
|
2
11
|
import {
|
|
3
12
|
VIEWER_LABELS_EN
|
|
4
13
|
} from "./chunk-BUJFMR3M.js";
|
|
5
14
|
|
|
6
15
|
// src/react/mermaid-diagram.tsx
|
|
7
16
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
8
|
-
|
|
9
|
-
// src/react/mermaid-config.ts
|
|
10
|
-
var MAX_MERMAID_SOURCE = 2e4;
|
|
11
|
-
function luminance(css) {
|
|
12
|
-
const m = /^(rgba?)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/.exec(css.trim());
|
|
13
|
-
if (!m) return void 0;
|
|
14
|
-
const parts = (m[2] ?? m[3] ?? "").split(/[\s,/]+/).filter(Boolean).map(Number);
|
|
15
|
-
const [r, g, b] = parts.map((v) => m[3] ? v : v / 255);
|
|
16
|
-
const alpha = parts[3] ?? 1;
|
|
17
|
-
if (r === void 0 || g === void 0 || b === void 0 || [r, g, b, alpha].some(Number.isNaN) || alpha < 0.5) return void 0;
|
|
18
|
-
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
19
|
-
}
|
|
20
|
-
function pickMermaidTheme(background, prefersDark) {
|
|
21
|
-
const l = luminance(background);
|
|
22
|
-
return (l === void 0 ? prefersDark : l < 0.5) ? "dark" : "default";
|
|
23
|
-
}
|
|
24
|
-
var RENDER_TIMEOUT_MS = 1e4;
|
|
25
|
-
var NEAR_VIEWPORT_MARGIN = "200px";
|
|
26
|
-
var FRONTMATTER = /^\s*-{3}[^\S\n]*\n[\s\S]*?\n-{3}[^\S\n]*(?:\n|$)/;
|
|
27
|
-
var DIRECTIVE = /%%\{(?:(?!\}%%)[\s\S])*(?:\}%%)?/g;
|
|
28
|
-
function stripMermaidConfig(source) {
|
|
29
|
-
let text = source.replace(/\r\n?/g, "\n");
|
|
30
|
-
for (let previous = ""; previous !== text; ) {
|
|
31
|
-
previous = text;
|
|
32
|
-
text = text.replace(FRONTMATTER, "").replace(DIRECTIVE, "");
|
|
33
|
-
}
|
|
34
|
-
return text;
|
|
35
|
-
}
|
|
36
|
-
var counter = 0;
|
|
37
|
-
var nextMermaidId = () => `hyle-mermaid-${++counter}`;
|
|
38
|
-
function withTimeout(promise, ms) {
|
|
39
|
-
let timer;
|
|
40
|
-
const timeout = new Promise((_, reject) => {
|
|
41
|
-
timer = setTimeout(() => reject(new Error("timeout")), ms);
|
|
42
|
-
});
|
|
43
|
-
return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
|
|
44
|
-
}
|
|
45
|
-
function whenNearViewport(el, onNear, Observer = globalThis.IntersectionObserver) {
|
|
46
|
-
if (!Observer) {
|
|
47
|
-
onNear();
|
|
48
|
-
return () => {
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const observer = new Observer((entries) => {
|
|
52
|
-
if (entries.some((e) => e.isIntersecting)) {
|
|
53
|
-
observer.disconnect();
|
|
54
|
-
onNear();
|
|
55
|
-
}
|
|
56
|
-
}, { rootMargin: NEAR_VIEWPORT_MARGIN });
|
|
57
|
-
observer.observe(el);
|
|
58
|
-
return () => observer.disconnect();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/react/mermaid-diagram.tsx
|
|
62
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
63
18
|
var queue = Promise.resolve();
|
|
64
19
|
async function renderSvg(id, source, theme) {
|