@tdacorp/hyle-sdk 0.21.0 → 0.23.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 +141 -18
- package/dist/check-routes-bin.js +174 -42
- package/dist/{chunk-56Y24XBV.js → chunk-JHZJOJDC.js} +4 -3
- package/dist/{chunk-K5VDLROQ.js → chunk-SFFBZFEN.js} +34 -1
- package/dist/{chunk-HJX57NLI.js → chunk-UFMKLCXS.js} +246 -225
- package/dist/{chunk-X2TLYM7Y.js → chunk-VUML2UPD.js} +1 -1
- package/dist/chunk-VXARM37R.js +68 -0
- package/dist/{chunk-75JFLML4.js → chunk-YHXE3TGS.js} +94 -12
- package/dist/{client-41fU6OY2.d.cts → client--ighAWaj.d.ts} +13 -1
- package/dist/{client-LwzHwqpM.d.ts → client-DK-S2580.d.cts} +13 -1
- package/dist/code-copy.cjs +4 -2
- package/dist/code-copy.d.cts +5 -2
- package/dist/code-copy.d.ts +5 -2
- package/dist/code-copy.js +5 -3
- package/dist/comments.cjs +14 -6
- package/dist/comments.js +14 -6
- package/dist/docs-enhance.cjs +7 -4
- package/dist/docs-enhance.d.cts +5 -3
- package/dist/docs-enhance.d.ts +5 -3
- package/dist/docs-enhance.js +8 -5
- package/dist/{embed-BUFRQboD.d.ts → embed-XT0x_Jaa.d.cts} +4 -2
- package/dist/{embed-CYt-q13P.d.cts → embed-g7NT1CyB.d.ts} +4 -2
- package/dist/html.cjs +14 -6
- package/dist/html.d.cts +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/html.js +2 -2
- package/dist/index.cjs +85 -12
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +2 -2
- package/dist/mermaid-diagram.cjs +46 -6
- package/dist/mermaid-diagram.js +15 -6
- package/dist/mermaid-image.cjs +4 -1
- package/dist/mermaid-image.js +1 -1
- package/dist/next.cjs +521 -242
- package/dist/next.d.cts +74 -17
- package/dist/next.d.ts +74 -17
- package/dist/next.js +207 -33
- package/dist/print-coordinator.js +1 -1
- package/dist/react.cjs +233 -197
- package/dist/react.d.cts +17 -6
- package/dist/react.d.ts +17 -6
- package/dist/react.js +5 -3
- package/dist/{resolve-BjAK0k_Y.d.ts → resolve-BqC9l5RH.d.ts} +1 -1
- package/dist/{resolve-eI1muCKL.d.cts → resolve-CiZCPysX.d.cts} +1 -1
- package/dist/{sanitize-ijiWjEm9.d.cts → sanitize-BpY_AdZh.d.cts} +1 -1
- package/dist/{sanitize-ijiWjEm9.d.ts → sanitize-BpY_AdZh.d.ts} +1 -1
- package/dist/styles.css +4 -4
- package/dist/toc-spy.cjs +2 -1
- package/dist/toc-spy.js +2 -1
- package/dist/{types-3F0wqD-o.d.cts → types-b9QbmEDd.d.cts} +44 -1
- package/dist/{types-3F0wqD-o.d.ts → types-b9QbmEDd.d.ts} +44 -1
- package/dist/use-cache.cjs +73 -3
- package/dist/use-cache.d.cts +3 -3
- package/dist/use-cache.d.ts +3 -3
- package/dist/use-cache.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-67IOIAVW.js +0 -35
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { k as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-b9QbmEDd.js';
|
|
3
3
|
|
|
4
4
|
type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
|
@@ -160,9 +160,11 @@ interface HyleListViewProps extends PageBaseProps {
|
|
|
160
160
|
readonly moreHref?: string | undefined;
|
|
161
161
|
/** Where "Older posts" goes (built from the list's `next_cursor`); omit to hide it. */
|
|
162
162
|
readonly olderHref?: string | undefined;
|
|
163
|
+
/** The list answer's `theme`, so an embedded list is styled like the workspace's pages. */
|
|
164
|
+
readonly theme?: ThemeRef | undefined;
|
|
163
165
|
}
|
|
164
166
|
/** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping. Pagination is only the optional `olderHref` link. */
|
|
165
|
-
declare function HyleListView({ items, layout, title, headingLevel, moreHref, olderHref, ...base }: HyleListViewProps): ReactElement | null;
|
|
167
|
+
declare function HyleListView({ items, layout, title, headingLevel, moreHref, olderHref, theme, ...base }: HyleListViewProps): ReactElement | null;
|
|
166
168
|
interface HyleArticleViewProps extends PageBaseProps {
|
|
167
169
|
readonly article: ResolvedArticle;
|
|
168
170
|
/**
|
package/dist/html.cjs
CHANGED
|
@@ -29,12 +29,20 @@ var import_hast_util_to_html = require("hast-util-to-html");
|
|
|
29
29
|
// src/asset-path.ts
|
|
30
30
|
var ASSET_ROUTE_PREFIX = "/api/hyle/assets";
|
|
31
31
|
var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
32
|
-
var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg";
|
|
32
|
+
var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg|woff2";
|
|
33
33
|
var ASSET_FILE = new RegExp(`^${UUID}(?:\\.(?:${EXTENSIONS}))?$`);
|
|
34
|
-
var
|
|
34
|
+
var THEME_FONT = new RegExp(`^/assets/${UUID}\\.woff2$`);
|
|
35
|
+
var PREVIEW_TOKEN_SOURCE = "hyle_pv_[A-Za-z0-9_-]{43}";
|
|
36
|
+
var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
37
|
+
var PREVIEW_PARAM = "hyle_preview";
|
|
38
|
+
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
39
|
+
var PROTECTED_PARAM = "hyle_protected";
|
|
40
|
+
var PROTECTED_ID = new RegExp(`^${UUID}$`);
|
|
41
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${UUID}`;
|
|
42
|
+
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
35
43
|
function hostAssetSrc(src) {
|
|
36
|
-
const file = HYLE_ASSET_URL.exec(src)
|
|
37
|
-
return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}` : src;
|
|
44
|
+
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
|
45
|
+
return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}${query}` : src;
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
// src/react/sanitize.ts
|
|
@@ -112,7 +120,7 @@ var ENTITIES = { "<": "<", "&": "&", "<": "<", ">": ">", "&"
|
|
|
112
120
|
function mermaidSource(srcDoc) {
|
|
113
121
|
return MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
|
|
114
122
|
}
|
|
115
|
-
var RENDER_REF =
|
|
123
|
+
var RENDER_REF = new RegExp(`^(/assets/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.svg(?:${PREVIEW_QUERY_SOURCE})?) ([1-9]\\d{0,5}) ([1-9]\\d{0,5})$`);
|
|
116
124
|
var isRenderRef = matches(RENDER_REF);
|
|
117
125
|
var YOUTUBE_WATCH = /^https:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9_-]{11})$/;
|
|
118
126
|
var youtubeId = (href) => typeof href === "string" ? YOUTUBE_WATCH.exec(href)?.[1] : void 0;
|
|
@@ -245,7 +253,7 @@ function sanitizeHast(tree, title, description) {
|
|
|
245
253
|
const [first] = elements;
|
|
246
254
|
const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && collapse(textOf(first)) === collapse(title) ? first : void 0;
|
|
247
255
|
const lead = elements[skip ? 1 : 0];
|
|
248
|
-
const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead))
|
|
256
|
+
const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead)) === collapse(description) && !holdsEmbed(lead) ? lead : void 0;
|
|
249
257
|
const budget = { nodes: 0, text: 0 };
|
|
250
258
|
return { type: "root", children: raw.filter((n) => n !== skip && n !== repeat).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
|
|
251
259
|
}
|
package/dist/html.d.cts
CHANGED
package/dist/html.d.ts
CHANGED
package/dist/html.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -51,9 +51,20 @@ module.exports = __toCommonJS(src_exports);
|
|
|
51
51
|
var ASSET_ROUTE_PREFIX = "/api/hyle/assets";
|
|
52
52
|
var ASSET_RESERVED_PATH = "/api/hyle/*";
|
|
53
53
|
var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
54
|
-
var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg";
|
|
54
|
+
var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg|woff2";
|
|
55
55
|
var ASSET_FILE = new RegExp(`^${UUID}(?:\\.(?:${EXTENSIONS}))?$`);
|
|
56
|
-
var
|
|
56
|
+
var THEME_FONT = new RegExp(`^/assets/${UUID}\\.woff2$`);
|
|
57
|
+
var PREVIEW_TOKEN_SOURCE = "hyle_pv_[A-Za-z0-9_-]{43}";
|
|
58
|
+
var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
59
|
+
var PREVIEW_HEADER = "cp-preview";
|
|
60
|
+
var PREVIEW_PARAM = "hyle_preview";
|
|
61
|
+
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
62
|
+
var PROTECTED_PARAM = "hyle_protected";
|
|
63
|
+
var PROTECTED_HEADER = "cp-protected";
|
|
64
|
+
var PROTECTED_ID = new RegExp(`^${UUID}$`);
|
|
65
|
+
var PROTECTED_PASSWORD = /^[A-Za-z0-9]{16}$/;
|
|
66
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${UUID}`;
|
|
67
|
+
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
57
68
|
|
|
58
69
|
// src/errors.ts
|
|
59
70
|
var Cp1ClientError = class extends Error {
|
|
@@ -71,6 +82,30 @@ var Cp1ClientError = class extends Error {
|
|
|
71
82
|
}
|
|
72
83
|
};
|
|
73
84
|
|
|
85
|
+
// src/preview.ts
|
|
86
|
+
var ASSET_PATH = /^\/assets\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\.[a-z0-9]+)?(?= |$)/i;
|
|
87
|
+
var ASSET_PROPERTIES = ["src", "dataLight", "dataDark"];
|
|
88
|
+
var MAX_DEPTH = 200;
|
|
89
|
+
function mapNode(node, mark, depth) {
|
|
90
|
+
if (typeof node !== "object" || node === null || depth > MAX_DEPTH) return node;
|
|
91
|
+
const { properties, children } = node;
|
|
92
|
+
const marked = properties && Object.fromEntries(ASSET_PROPERTIES.filter((name) => name in properties).map((name) => [name, mark(properties[name])]));
|
|
93
|
+
return {
|
|
94
|
+
...node,
|
|
95
|
+
...properties ? { properties: { ...properties, ...marked } } : {},
|
|
96
|
+
...Array.isArray(children) ? { children: children.map((child) => mapNode(child, mark, depth + 1)) } : {}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function withAssetQuery(article, query) {
|
|
100
|
+
const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${query}`) : value;
|
|
101
|
+
const { publication, content } = article;
|
|
102
|
+
return {
|
|
103
|
+
...article,
|
|
104
|
+
publication: publication.cover ? { ...publication, cover: { path: String(mark(publication.cover.path)) } } : publication,
|
|
105
|
+
content: content.format === "hast" ? { ...content, tree: mapNode(content.tree, mark, 0) } : content
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
74
109
|
// src/client.ts
|
|
75
110
|
var RENDERER_VERSION = "4";
|
|
76
111
|
function applyCredential(headers, credential, method, url) {
|
|
@@ -183,8 +218,31 @@ function createHyleClient(options) {
|
|
|
183
218
|
if (data?.cp === 1 && data.kind === "push_posts" && Array.isArray(data.posts) && typeof data.complete === "boolean") return data;
|
|
184
219
|
throw failure(reply);
|
|
185
220
|
}
|
|
221
|
+
async function preview(token) {
|
|
222
|
+
if (typeof token !== "string" || !PREVIEW_TOKEN.test(token)) return { kind: "notfound" };
|
|
223
|
+
const reply = await get("/cp1/read/_preview", new URLSearchParams(), { headers: { [PREVIEW_HEADER]: token }, cache: "no-store" });
|
|
224
|
+
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
225
|
+
const data = reply.parsed?.data;
|
|
226
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
227
|
+
const article = data?.article;
|
|
228
|
+
if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
229
|
+
return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
|
|
230
|
+
}
|
|
231
|
+
async function protectedPage(pageId, password) {
|
|
232
|
+
if (!PROTECTED_ID.test(pageId) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
|
|
233
|
+
const reply = await get("/cp1/read/_protected", new URLSearchParams(), { headers: { [PROTECTED_HEADER]: `${pageId}.${password}` }, cache: "no-store" });
|
|
234
|
+
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
235
|
+
const data = reply.parsed?.data;
|
|
236
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
237
|
+
const article = data?.article;
|
|
238
|
+
const expires = data?.expires_at;
|
|
239
|
+
if (data?.cp !== 1 || data.kind !== "protected" || typeof expires !== "string" && expires !== null || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
240
|
+
return { kind: "protected", expires_at: expires, article: withAssetQuery(article, `${PROTECTED_PARAM}=${pageId}`) };
|
|
241
|
+
}
|
|
186
242
|
async function asset(file, opts = {}) {
|
|
187
243
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
244
|
+
const { previewToken } = opts;
|
|
245
|
+
if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
|
|
188
246
|
const url = `${base}/cp1/read/assets/${file}`;
|
|
189
247
|
const headers = new Headers();
|
|
190
248
|
const applied = applyCredential(headers, options, "GET", url);
|
|
@@ -193,23 +251,34 @@ function createHyleClient(options) {
|
|
|
193
251
|
const value = opts.headers?.[name];
|
|
194
252
|
if (value) headers.set(name, value);
|
|
195
253
|
}
|
|
254
|
+
const { protectedAccess } = opts;
|
|
255
|
+
if (protectedAccess !== void 0 && !(PROTECTED_ID.test(protectedAccess.pageId) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a page id and password");
|
|
256
|
+
if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
|
|
257
|
+
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, `${protectedAccess.pageId}.${protectedAccess.password}`);
|
|
258
|
+
const uncached = previewToken !== void 0 || protectedAccess !== void 0;
|
|
259
|
+
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
|
|
260
|
+
}
|
|
261
|
+
async function theme(opts = {}) {
|
|
262
|
+
const url = `${base}/cp1/read/theme.css`;
|
|
263
|
+
const headers = new Headers();
|
|
264
|
+
const applied = applyCredential(headers, options, "GET", url);
|
|
265
|
+
if (applied) await applied;
|
|
196
266
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
197
267
|
}
|
|
198
|
-
return { resolve, mounts, pushPosts, asset };
|
|
268
|
+
return { resolve, mounts, pushPosts, preview, protected: protectedPage, asset, theme };
|
|
199
269
|
}
|
|
200
270
|
|
|
201
271
|
// src/host-sync.ts
|
|
202
272
|
var CONTROL_TOKEN_PREFIX = "hyle_tc_";
|
|
203
273
|
var DEFAULT_TIMEOUT_MS2 = 1e4;
|
|
204
274
|
var MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
205
|
-
|
|
206
|
-
async function syncHostReserved(input) {
|
|
275
|
+
async function put(input, path, body, read) {
|
|
207
276
|
checkBaseUrl(input.baseUrl, input.allowInsecureHttp);
|
|
208
277
|
if (input.token !== void 0 && !input.token.startsWith(CONTROL_TOKEN_PREFIX)) {
|
|
209
278
|
throw new TypeError("syncing needs a control credential (hyle_tc_...); a target token is read-only and cannot write");
|
|
210
279
|
}
|
|
211
280
|
const fetchImpl = input.fetch ?? fetch;
|
|
212
|
-
const url = `${input.baseUrl.replace(/\/+$/, "")}${
|
|
281
|
+
const url = `${input.baseUrl.replace(/\/+$/, "")}${path}`;
|
|
213
282
|
const headers = new Headers({ "content-type": "application/json", "idempotency-key": `sync-${crypto.randomUUID()}` });
|
|
214
283
|
await applyCredential(headers, input.auth ? { auth: input.auth, workspaceId: input.workspaceId } : { token: input.token }, "PUT", url);
|
|
215
284
|
headers.set("cp-workspace", input.workspaceId);
|
|
@@ -219,7 +288,7 @@ async function syncHostReserved(input) {
|
|
|
219
288
|
redirect: "error",
|
|
220
289
|
signal: AbortSignal.timeout(input.timeoutMs ?? DEFAULT_TIMEOUT_MS2),
|
|
221
290
|
headers,
|
|
222
|
-
body: JSON.stringify(
|
|
291
|
+
body: JSON.stringify(body)
|
|
223
292
|
});
|
|
224
293
|
const text = await readCapped(res, MAX_RESPONSE_BYTES);
|
|
225
294
|
let parsed;
|
|
@@ -228,14 +297,18 @@ async function syncHostReserved(input) {
|
|
|
228
297
|
} catch {
|
|
229
298
|
parsed = void 0;
|
|
230
299
|
}
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
if (res.ok && data && Array.isArray(data.paths) && typeof data.changed === "boolean" && typeof data.synced_at === "string" && typeof conflicts?.total === "number" && Array.isArray(conflicts.offenders)) {
|
|
234
|
-
return { paths: data.paths, changed: data.changed, syncedAt: data.synced_at, conflicts: { total: conflicts.total, offenders: conflicts.offenders } };
|
|
235
|
-
}
|
|
300
|
+
const result = res.ok && parsed?.data ? read(parsed.data) : void 0;
|
|
301
|
+
if (result !== void 0) return result;
|
|
236
302
|
const err = parsed?.error;
|
|
237
303
|
throw new Cp1ClientError(err?.code ?? "INVALID_RESPONSE", err?.message ?? `Unexpected response from hyle (HTTP ${res.status})`, res.status, err?.request_id ?? "", err?.details);
|
|
238
304
|
}
|
|
305
|
+
function syncHostReserved(input) {
|
|
306
|
+
return put(input, "/cp1/control/workspace/host-reserved-paths", { paths: input.paths, host: input.host, build_id: input.buildId }, (data) => {
|
|
307
|
+
const conflicts = data.conflicts;
|
|
308
|
+
if (!Array.isArray(data.paths) || typeof data.changed !== "boolean" || typeof data.synced_at !== "string" || typeof conflicts?.total !== "number" || !Array.isArray(conflicts.offenders)) return void 0;
|
|
309
|
+
return { paths: data.paths, changed: data.changed, syncedAt: data.synced_at, conflicts: { total: conflicts.total, offenders: conflicts.offenders } };
|
|
310
|
+
});
|
|
311
|
+
}
|
|
239
312
|
|
|
240
313
|
// src/delivery-dedupe.ts
|
|
241
314
|
var DeliveryDedupe = class {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HyleAuth, a as HyleClient } from './client-
|
|
2
|
-
export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client-
|
|
3
|
-
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, M as Mount,
|
|
1
|
+
import { H as HyleAuth, a as HyleClient } from './client-DK-S2580.cjs';
|
|
2
|
+
export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client-DK-S2580.cjs';
|
|
3
|
+
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, H as HylePreview, d as HyleProtected, L as ListItem, M as Mount, e as Mounts, f as MountsResult, N as NavItem, g as NavNode, h as NavTree, R as ReactionCounts, i as ReactionKind, j as Resolved, k as ResolvedArticle, l as ResolvedDisabled, m as ResolvedList, n as ResolvedNotFound, o as ResolvedRedirect, T as ThemeRef, p as TocEntry, V as VoteValue } from './types-b9QbmEDd.cjs';
|
|
4
4
|
export { C as CommentEvent, a as CommentEventType, R as RevalidationCallbackOptions, b as RevalidationCallbackRoute, c as RevalidationPayload, d as createRevalidationCallbackRoute, p as parseCommentEvent } from './revalidation-callback-BQl77tQR.cjs';
|
|
5
5
|
|
|
6
6
|
declare class Cp1ClientError extends Error {
|
|
@@ -11,26 +11,29 @@ declare class Cp1ClientError extends Error {
|
|
|
11
11
|
constructor(code: string, message: string, status: number, requestId: string, details?: Record<string, unknown>);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** Where a build writes to hyle's control surface, and as whom. */
|
|
15
|
+
type ControlTarget = {
|
|
15
16
|
/** hyle's origin. */
|
|
16
17
|
readonly baseUrl: string;
|
|
17
18
|
/** The workspace to write, from `client.mounts()`; the credential must be granted on it. */
|
|
18
19
|
readonly workspaceId: string;
|
|
19
|
-
/** The host's complete list of reserved paths (a replace). */
|
|
20
|
-
readonly paths: readonly string[];
|
|
21
20
|
readonly host: string;
|
|
22
21
|
readonly buildId: string;
|
|
23
22
|
readonly fetch?: typeof fetch;
|
|
24
23
|
readonly timeoutMs?: number;
|
|
25
24
|
readonly allowInsecureHttp?: boolean;
|
|
26
25
|
} & ({
|
|
27
|
-
/** A CONTROL credential (hyle_tc_...) holding
|
|
26
|
+
/** A CONTROL credential (hyle_tc_...) holding the route's permission on the workspace. Never a target (read) token. */
|
|
28
27
|
readonly token: string;
|
|
29
28
|
readonly auth?: never;
|
|
30
29
|
} | {
|
|
31
30
|
readonly auth: HyleAuth;
|
|
32
31
|
readonly token?: never;
|
|
33
32
|
});
|
|
33
|
+
type HostSyncInput = ControlTarget & {
|
|
34
|
+
/** The host's complete list of reserved paths (a replace). */
|
|
35
|
+
readonly paths: readonly string[];
|
|
36
|
+
};
|
|
34
37
|
interface HostSyncResult {
|
|
35
38
|
/** What hyle stored: sorted, de-duplicated. */
|
|
36
39
|
readonly paths: readonly string[];
|
|
@@ -44,10 +47,9 @@ interface HostSyncResult {
|
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
|
-
* Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths
|
|
48
|
-
* same list changes nothing), so a retry or a
|
|
49
|
-
*
|
|
50
|
-
* for anything hyle answers or the network does.
|
|
50
|
+
* Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`, with
|
|
51
|
+
* hyle.workspace.sync_host. Idempotent (resending the same list changes nothing), so a retry or a
|
|
52
|
+
* repeated deploy is safe. Throws as `put` describes.
|
|
51
53
|
*/
|
|
52
54
|
declare function syncHostReserved(input: HostSyncInput): Promise<HostSyncResult>;
|
|
53
55
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HyleAuth, a as HyleClient } from './client
|
|
2
|
-
export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client
|
|
3
|
-
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, M as Mount,
|
|
1
|
+
import { H as HyleAuth, a as HyleClient } from './client--ighAWaj.js';
|
|
2
|
+
export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client--ighAWaj.js';
|
|
3
|
+
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, H as HylePreview, d as HyleProtected, L as ListItem, M as Mount, e as Mounts, f as MountsResult, N as NavItem, g as NavNode, h as NavTree, R as ReactionCounts, i as ReactionKind, j as Resolved, k as ResolvedArticle, l as ResolvedDisabled, m as ResolvedList, n as ResolvedNotFound, o as ResolvedRedirect, T as ThemeRef, p as TocEntry, V as VoteValue } from './types-b9QbmEDd.js';
|
|
4
4
|
export { C as CommentEvent, a as CommentEventType, R as RevalidationCallbackOptions, b as RevalidationCallbackRoute, c as RevalidationPayload, d as createRevalidationCallbackRoute, p as parseCommentEvent } from './revalidation-callback-BQl77tQR.js';
|
|
5
5
|
|
|
6
6
|
declare class Cp1ClientError extends Error {
|
|
@@ -11,26 +11,29 @@ declare class Cp1ClientError extends Error {
|
|
|
11
11
|
constructor(code: string, message: string, status: number, requestId: string, details?: Record<string, unknown>);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** Where a build writes to hyle's control surface, and as whom. */
|
|
15
|
+
type ControlTarget = {
|
|
15
16
|
/** hyle's origin. */
|
|
16
17
|
readonly baseUrl: string;
|
|
17
18
|
/** The workspace to write, from `client.mounts()`; the credential must be granted on it. */
|
|
18
19
|
readonly workspaceId: string;
|
|
19
|
-
/** The host's complete list of reserved paths (a replace). */
|
|
20
|
-
readonly paths: readonly string[];
|
|
21
20
|
readonly host: string;
|
|
22
21
|
readonly buildId: string;
|
|
23
22
|
readonly fetch?: typeof fetch;
|
|
24
23
|
readonly timeoutMs?: number;
|
|
25
24
|
readonly allowInsecureHttp?: boolean;
|
|
26
25
|
} & ({
|
|
27
|
-
/** A CONTROL credential (hyle_tc_...) holding
|
|
26
|
+
/** A CONTROL credential (hyle_tc_...) holding the route's permission on the workspace. Never a target (read) token. */
|
|
28
27
|
readonly token: string;
|
|
29
28
|
readonly auth?: never;
|
|
30
29
|
} | {
|
|
31
30
|
readonly auth: HyleAuth;
|
|
32
31
|
readonly token?: never;
|
|
33
32
|
});
|
|
33
|
+
type HostSyncInput = ControlTarget & {
|
|
34
|
+
/** The host's complete list of reserved paths (a replace). */
|
|
35
|
+
readonly paths: readonly string[];
|
|
36
|
+
};
|
|
34
37
|
interface HostSyncResult {
|
|
35
38
|
/** What hyle stored: sorted, de-duplicated. */
|
|
36
39
|
readonly paths: readonly string[];
|
|
@@ -44,10 +47,9 @@ interface HostSyncResult {
|
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
|
-
* Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths
|
|
48
|
-
* same list changes nothing), so a retry or a
|
|
49
|
-
*
|
|
50
|
-
* for anything hyle answers or the network does.
|
|
50
|
+
* Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`, with
|
|
51
|
+
* hyle.workspace.sync_host. Idempotent (resending the same list changes nothing), so a retry or a
|
|
52
|
+
* repeated deploy is safe. Throws as `put` describes.
|
|
51
53
|
*/
|
|
52
54
|
declare function syncHostReserved(input: HostSyncInput): Promise<HostSyncResult>;
|
|
53
55
|
|
package/dist/index.js
CHANGED
|
@@ -23,8 +23,8 @@ import {
|
|
|
23
23
|
staleAfterResync,
|
|
24
24
|
syncHostReserved,
|
|
25
25
|
verifyHyleSignature
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-YHXE3TGS.js";
|
|
27
|
+
import "./chunk-VXARM37R.js";
|
|
28
28
|
export {
|
|
29
29
|
CACHE_TAG_PATTERN,
|
|
30
30
|
Cp1ClientError,
|
package/dist/mermaid-diagram.cjs
CHANGED
|
@@ -1375,6 +1375,37 @@ var AUTO_RENDER_GROUPS = 25;
|
|
|
1375
1375
|
var CLAMP_LINES = 12;
|
|
1376
1376
|
var isClampedSource = (source) => source.trimEnd().split("\n").length > CLAMP_LINES;
|
|
1377
1377
|
var DARK_VARIABLES = { edgeLabelBackground: "#333333" };
|
|
1378
|
+
var DIAGRAM_COLOUR_ROLES = ["bg", "node", "node-text", "node-border", "line", "accent", "muted"];
|
|
1379
|
+
var THEME_COLOUR = /^(?:#[0-9a-f]{6}(?:[0-9a-f]{2})?|transparent)$/;
|
|
1380
|
+
function diagramThemeVariables(colours, dark) {
|
|
1381
|
+
const [bg, node, text, border, line, accent, muted] = colours;
|
|
1382
|
+
return {
|
|
1383
|
+
darkMode: dark,
|
|
1384
|
+
background: bg,
|
|
1385
|
+
primaryColor: node,
|
|
1386
|
+
primaryTextColor: text,
|
|
1387
|
+
primaryBorderColor: border,
|
|
1388
|
+
secondaryColor: bg,
|
|
1389
|
+
secondaryTextColor: text,
|
|
1390
|
+
secondaryBorderColor: muted,
|
|
1391
|
+
tertiaryColor: bg,
|
|
1392
|
+
tertiaryTextColor: text,
|
|
1393
|
+
tertiaryBorderColor: muted,
|
|
1394
|
+
lineColor: line,
|
|
1395
|
+
textColor: text,
|
|
1396
|
+
titleColor: text,
|
|
1397
|
+
edgeLabelBackground: bg,
|
|
1398
|
+
clusterBkg: bg,
|
|
1399
|
+
clusterBorder: muted,
|
|
1400
|
+
noteBkgColor: bg,
|
|
1401
|
+
noteTextColor: text,
|
|
1402
|
+
noteBorderColor: accent,
|
|
1403
|
+
activationBorderColor: accent,
|
|
1404
|
+
actorLineColor: muted,
|
|
1405
|
+
signalColor: line,
|
|
1406
|
+
signalTextColor: text
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1378
1409
|
var COLOR = /^(rgba?|oklab|oklch|lab|lch)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/;
|
|
1379
1410
|
function isDark(css) {
|
|
1380
1411
|
const m = COLOR.exec(css.trim());
|
|
@@ -1397,7 +1428,8 @@ function watchPageTheme(el, onTheme) {
|
|
|
1397
1428
|
const scheme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1398
1429
|
const update = () => {
|
|
1399
1430
|
const style = getComputedStyle(el);
|
|
1400
|
-
|
|
1431
|
+
const colours = DIAGRAM_COLOUR_ROLES.map((role) => style.getPropertyValue(`--hyle-diagram-${role}`).trim());
|
|
1432
|
+
onTheme(pickMermaidTheme(style.backgroundColor, scheme.matches, style.colorScheme), colours.every((c) => THEME_COLOUR.test(c)) ? colours.join(" ") : "");
|
|
1401
1433
|
};
|
|
1402
1434
|
update();
|
|
1403
1435
|
const observer = new MutationObserver(update);
|
|
@@ -1511,13 +1543,14 @@ var DiagramBoundary = class extends import_react2.Component {
|
|
|
1511
1543
|
};
|
|
1512
1544
|
var queue = Promise.resolve();
|
|
1513
1545
|
var afterPaint = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
1514
|
-
async function renderSvg(id, source, theme, onSvg, stillWanted) {
|
|
1546
|
+
async function renderSvg(id, source, theme, colours, onSvg, stillWanted) {
|
|
1515
1547
|
const { default: mermaid } = await import("mermaid");
|
|
1516
1548
|
if (stillWanted) {
|
|
1517
1549
|
await afterPaint();
|
|
1518
1550
|
if (!stillWanted()) return;
|
|
1519
1551
|
}
|
|
1520
|
-
|
|
1552
|
+
const look = colours ? { theme: "base", themeVariables: diagramThemeVariables(colours.split(" "), theme === "dark") } : { theme, ...theme === "dark" ? { themeVariables: DARK_VARIABLES } : {} };
|
|
1553
|
+
mermaid.initialize({ startOnLoad: false, securityLevel: "strict", ...look, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
|
|
1521
1554
|
const drawing = mermaid.render(id, stripMermaidConfig(source)).then((out) => onSvg({ markup: out.svg, id, theme })).finally(() => document.getElementById(`d${id}`)?.remove());
|
|
1522
1555
|
await withTimeout(drawing, RENDER_TIMEOUT_MS);
|
|
1523
1556
|
}
|
|
@@ -1533,6 +1566,7 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
|
|
|
1533
1566
|
const [Viewer, setViewer] = (0, import_react2.useState)(null);
|
|
1534
1567
|
const [viewerFailed, setViewerFailed] = (0, import_react2.useState)(false);
|
|
1535
1568
|
const [theme, setTheme] = (0, import_react2.useState)(null);
|
|
1569
|
+
const [colours, setColours] = (0, import_react2.useState)("");
|
|
1536
1570
|
const [near, setNear] = (0, import_react2.useState)(false);
|
|
1537
1571
|
const [svg, setSvg] = (0, import_react2.useState)(null);
|
|
1538
1572
|
const [failed, setFailed] = (0, import_react2.useState)(false);
|
|
@@ -1543,7 +1577,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
|
|
|
1543
1577
|
const refocus = (0, import_react2.useRef)(false);
|
|
1544
1578
|
const allowed = !large || asked;
|
|
1545
1579
|
const clamped = large && isClampedSource(source);
|
|
1546
|
-
(0, import_react2.useEffect)(() =>
|
|
1580
|
+
(0, import_react2.useEffect)(() => {
|
|
1581
|
+
if (!figure.current) return void 0;
|
|
1582
|
+
return watchPageTheme(figure.current, (next, themed) => {
|
|
1583
|
+
setTheme(next);
|
|
1584
|
+
setColours(themed);
|
|
1585
|
+
});
|
|
1586
|
+
}, []);
|
|
1547
1587
|
(0, import_react2.useEffect)(() => figure.current ? whenNearViewport(figure.current, () => setNear(true)) : void 0, []);
|
|
1548
1588
|
(0, import_react2.useEffect)(() => {
|
|
1549
1589
|
const toPrint = window.matchMedia("print");
|
|
@@ -1597,13 +1637,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
|
|
|
1597
1637
|
setSvg(out);
|
|
1598
1638
|
setFailed(false);
|
|
1599
1639
|
};
|
|
1600
|
-
queue = queue.then(() => current ? renderSvg(id, source, theme, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
|
|
1640
|
+
queue = queue.then(() => current ? renderSvg(id, source, theme, colours, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
|
|
1601
1641
|
if (current) setFailed(true);
|
|
1602
1642
|
});
|
|
1603
1643
|
return () => {
|
|
1604
1644
|
current = false;
|
|
1605
1645
|
};
|
|
1606
|
-
}, [source, theme, wanted, attempt, large]);
|
|
1646
|
+
}, [source, theme, colours, wanted, attempt, large]);
|
|
1607
1647
|
(0, import_react2.useEffect)(() => {
|
|
1608
1648
|
if (!refocus.current || svg === null && !failed) return;
|
|
1609
1649
|
refocus.current = false;
|
package/dist/mermaid-diagram.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
MAX_MERMAID_SOURCE,
|
|
6
6
|
RENDER_TIMEOUT_MS,
|
|
7
7
|
afterFullscreen,
|
|
8
|
+
diagramThemeVariables,
|
|
8
9
|
isClampedSource,
|
|
9
10
|
isLargeDiagram,
|
|
10
11
|
nextMermaidId,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
watchPageTheme,
|
|
13
14
|
whenNearViewport,
|
|
14
15
|
withTimeout
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SFFBZFEN.js";
|
|
16
17
|
import {
|
|
17
18
|
VIEWER_LABELS_EN
|
|
18
19
|
} from "./chunk-QVYQM5R2.js";
|
|
@@ -62,13 +63,14 @@ var DiagramBoundary = class extends Component {
|
|
|
62
63
|
};
|
|
63
64
|
var queue = Promise.resolve();
|
|
64
65
|
var afterPaint = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
65
|
-
async function renderSvg(id, source, theme, onSvg, stillWanted) {
|
|
66
|
+
async function renderSvg(id, source, theme, colours, onSvg, stillWanted) {
|
|
66
67
|
const { default: mermaid } = await import("mermaid");
|
|
67
68
|
if (stillWanted) {
|
|
68
69
|
await afterPaint();
|
|
69
70
|
if (!stillWanted()) return;
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
const look = colours ? { theme: "base", themeVariables: diagramThemeVariables(colours.split(" "), theme === "dark") } : { theme, ...theme === "dark" ? { themeVariables: DARK_VARIABLES } : {} };
|
|
73
|
+
mermaid.initialize({ startOnLoad: false, securityLevel: "strict", ...look, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
|
|
72
74
|
const drawing = mermaid.render(id, stripMermaidConfig(source)).then((out) => onSvg({ markup: out.svg, id, theme })).finally(() => document.getElementById(`d${id}`)?.remove());
|
|
73
75
|
await withTimeout(drawing, RENDER_TIMEOUT_MS);
|
|
74
76
|
}
|
|
@@ -84,6 +86,7 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
|
|
|
84
86
|
const [Viewer, setViewer] = useState(null);
|
|
85
87
|
const [viewerFailed, setViewerFailed] = useState(false);
|
|
86
88
|
const [theme, setTheme] = useState(null);
|
|
89
|
+
const [colours, setColours] = useState("");
|
|
87
90
|
const [near, setNear] = useState(false);
|
|
88
91
|
const [svg, setSvg] = useState(null);
|
|
89
92
|
const [failed, setFailed] = useState(false);
|
|
@@ -94,7 +97,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
|
|
|
94
97
|
const refocus = useRef(false);
|
|
95
98
|
const allowed = !large || asked;
|
|
96
99
|
const clamped = large && isClampedSource(source);
|
|
97
|
-
useEffect(() =>
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!figure.current) return void 0;
|
|
102
|
+
return watchPageTheme(figure.current, (next, themed) => {
|
|
103
|
+
setTheme(next);
|
|
104
|
+
setColours(themed);
|
|
105
|
+
});
|
|
106
|
+
}, []);
|
|
98
107
|
useEffect(() => figure.current ? whenNearViewport(figure.current, () => setNear(true)) : void 0, []);
|
|
99
108
|
useEffect(() => {
|
|
100
109
|
const toPrint = window.matchMedia("print");
|
|
@@ -148,13 +157,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
|
|
|
148
157
|
setSvg(out);
|
|
149
158
|
setFailed(false);
|
|
150
159
|
};
|
|
151
|
-
queue = queue.then(() => current ? renderSvg(id, source, theme, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
|
|
160
|
+
queue = queue.then(() => current ? renderSvg(id, source, theme, colours, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
|
|
152
161
|
if (current) setFailed(true);
|
|
153
162
|
});
|
|
154
163
|
return () => {
|
|
155
164
|
current = false;
|
|
156
165
|
};
|
|
157
|
-
}, [source, theme, wanted, attempt, large]);
|
|
166
|
+
}, [source, theme, colours, wanted, attempt, large]);
|
|
158
167
|
useEffect(() => {
|
|
159
168
|
if (!refocus.current || svg === null && !failed) return;
|
|
160
169
|
refocus.current = false;
|
package/dist/mermaid-image.cjs
CHANGED
|
@@ -1329,6 +1329,8 @@ var import_react2 = require("react");
|
|
|
1329
1329
|
|
|
1330
1330
|
// src/react/mermaid-config.ts
|
|
1331
1331
|
var MAX_MERMAID_SOURCE = 1024 * 1024;
|
|
1332
|
+
var DIAGRAM_COLOUR_ROLES = ["bg", "node", "node-text", "node-border", "line", "accent", "muted"];
|
|
1333
|
+
var THEME_COLOUR = /^(?:#[0-9a-f]{6}(?:[0-9a-f]{2})?|transparent)$/;
|
|
1332
1334
|
var COLOR = /^(rgba?|oklab|oklch|lab|lch)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/;
|
|
1333
1335
|
function isDark(css) {
|
|
1334
1336
|
const m = COLOR.exec(css.trim());
|
|
@@ -1351,7 +1353,8 @@ function watchPageTheme(el, onTheme) {
|
|
|
1351
1353
|
const scheme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1352
1354
|
const update = () => {
|
|
1353
1355
|
const style = getComputedStyle(el);
|
|
1354
|
-
|
|
1356
|
+
const colours = DIAGRAM_COLOUR_ROLES.map((role) => style.getPropertyValue(`--hyle-diagram-${role}`).trim());
|
|
1357
|
+
onTheme(pickMermaidTheme(style.backgroundColor, scheme.matches, style.colorScheme), colours.every((c) => THEME_COLOUR.test(c)) ? colours.join(" ") : "");
|
|
1355
1358
|
};
|
|
1356
1359
|
update();
|
|
1357
1360
|
const observer = new MutationObserver(update);
|