@tdacorp/hyle-sdk 0.22.2 → 0.24.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 +48 -1
- package/dist/check-routes-bin.js +41 -8
- package/dist/{chunk-KU7LWK4E.js → chunk-4REU4HJI.js} +40 -9
- package/dist/{chunk-ZIW6FDU2.js → chunk-5TKJH2XC.js} +2 -2
- package/dist/{chunk-DUPT6XLB.js → chunk-BDFMNY76.js} +18 -1
- package/dist/{chunk-7T5EEJHK.js → chunk-SY2FMIRZ.js} +1 -1
- package/dist/{chunk-IW3TUD4G.js → chunk-Y3BACEWA.js} +1 -1
- package/dist/{client-BGjmEWhN.d.cts → client-BErei7cE.d.ts} +8 -1
- package/dist/{client-D0LTpr3Y.d.ts → client-DrB2vcTi.d.cts} +8 -1
- package/dist/comments.cjs +5 -1
- package/dist/comments.js +5 -1
- package/dist/{embed-CbtsbZs3.d.cts → embed-B7T--kTT.d.cts} +1 -1
- package/dist/{embed-Cf_2ZR5x.d.ts → embed-DavTgSU4.d.ts} +1 -1
- package/dist/html.cjs +5 -1
- package/dist/html.js +2 -2
- package/dist/index.cjs +41 -8
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/next.cjs +265 -70
- package/dist/next.d.cts +47 -7
- package/dist/next.d.ts +47 -7
- package/dist/next.js +224 -65
- package/dist/react.cjs +5 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +3 -3
- package/dist/{resolve-BnIv7aB7.d.cts → resolve-03IVloXU.d.cts} +1 -1
- package/dist/{resolve-BysHtZ_i.d.ts → resolve-BseM68oy.d.ts} +1 -1
- package/dist/{types-D09Z072G.d.cts → types-Dx-fEiZd.d.cts} +33 -1
- package/dist/{types-D09Z072G.d.ts → types-Dx-fEiZd.d.ts} +33 -1
- package/dist/use-cache.cjs +41 -8
- 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 +1 -1
package/dist/react.cjs
CHANGED
|
@@ -73,7 +73,11 @@ var PREVIEW_TOKEN_SOURCE = "hyle_pv_[A-Za-z0-9_-]{43}";
|
|
|
73
73
|
var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
74
74
|
var PREVIEW_PARAM = "hyle_preview";
|
|
75
75
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
76
|
-
var
|
|
76
|
+
var PROTECTED_PARAM = "hyle_protected";
|
|
77
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
78
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
79
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
80
|
+
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
77
81
|
function hostAssetSrc(src) {
|
|
78
82
|
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
|
79
83
|
return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}${query}` : src;
|
package/dist/react.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-
|
|
4
|
-
export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-
|
|
3
|
+
import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-B7T--kTT.cjs';
|
|
4
|
+
export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-B7T--kTT.cjs';
|
|
5
5
|
export { H as HastLimitError, i as isSafeUrl, s as sanitizeHast, a as scopeId } from './sanitize-BpY_AdZh.cjs';
|
|
6
|
-
import {
|
|
6
|
+
import { m as ResolvedArticle, L as ListItem, r as TocEntry, o as ResolvedList, c as EngageListing, T as ThemeRef } from './types-Dx-fEiZd.cjs';
|
|
7
7
|
import 'hast';
|
|
8
8
|
|
|
9
9
|
interface HastContentProps {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-
|
|
4
|
-
export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-
|
|
3
|
+
import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-DavTgSU4.js';
|
|
4
|
+
export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-DavTgSU4.js';
|
|
5
5
|
export { H as HastLimitError, i as isSafeUrl, s as sanitizeHast, a as scopeId } from './sanitize-BpY_AdZh.js';
|
|
6
|
-
import {
|
|
6
|
+
import { m as ResolvedArticle, L as ListItem, r as TocEntry, o as ResolvedList, c as EngageListing, T as ThemeRef } from './types-Dx-fEiZd.js';
|
|
7
7
|
import 'hast';
|
|
8
8
|
|
|
9
9
|
interface HastContentProps {
|
package/dist/react.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isClampedSource,
|
|
21
21
|
isLargeDiagram,
|
|
22
22
|
stripMermaidConfig
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5TKJH2XC.js";
|
|
24
24
|
import {
|
|
25
25
|
HastLimitError,
|
|
26
26
|
VIEWER_LABELS_EN,
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
sanitizeHast,
|
|
29
29
|
scopeId,
|
|
30
30
|
stringsFor
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-Y3BACEWA.js";
|
|
32
|
+
import "./chunk-BDFMNY76.js";
|
|
33
33
|
export {
|
|
34
34
|
ArticlePage,
|
|
35
35
|
Comments,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as Resolved } from './types-Dx-fEiZd.cjs';
|
|
2
2
|
|
|
3
3
|
/** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
|
|
4
4
|
type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree", format?: "md") => Promise<Resolved>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as Resolved } from './types-Dx-fEiZd.js';
|
|
2
2
|
|
|
3
3
|
/** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
|
|
4
4
|
type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree", format?: "md") => Promise<Resolved>;
|
|
@@ -177,6 +177,8 @@ interface Mounts {
|
|
|
177
177
|
readonly supported_locales: readonly string[];
|
|
178
178
|
readonly mounts: readonly Mount[];
|
|
179
179
|
readonly reserved: readonly string[];
|
|
180
|
+
/** The slugs of live protected shares on this workspace (hyle ADR 0040); absent from an older server. */
|
|
181
|
+
readonly protected?: readonly string[];
|
|
180
182
|
/** Absent without a theme and from an older server. */
|
|
181
183
|
readonly theme?: ThemeRef;
|
|
182
184
|
readonly cache: CacheInfo;
|
|
@@ -276,5 +278,35 @@ type HylePreview =
|
|
|
276
278
|
} | {
|
|
277
279
|
readonly kind: "disabled";
|
|
278
280
|
};
|
|
281
|
+
/** The `data` of GET /cp1/read/_protected (hyle ADR 0040): a protected share's document. `documents` lists the share's pages in order. */
|
|
282
|
+
interface HyleProtectedShare {
|
|
283
|
+
readonly cp: 1;
|
|
284
|
+
readonly kind: "protected";
|
|
285
|
+
readonly name: string;
|
|
286
|
+
/** When the share stops working, or null for none. */
|
|
287
|
+
readonly expires_at: string | null;
|
|
288
|
+
readonly documents: readonly {
|
|
289
|
+
readonly doc_slug: string;
|
|
290
|
+
readonly title: string;
|
|
291
|
+
readonly position: number;
|
|
292
|
+
}[];
|
|
293
|
+
/** The document this answer draws. */
|
|
294
|
+
readonly doc_slug: string;
|
|
295
|
+
/** The article's asset addresses carry the share slug. */
|
|
296
|
+
readonly article: ResolvedArticle;
|
|
297
|
+
}
|
|
298
|
+
type HyleProtected = HyleProtectedShare | {
|
|
299
|
+
readonly kind: "notfound";
|
|
300
|
+
} | {
|
|
301
|
+
readonly kind: "disabled";
|
|
302
|
+
};
|
|
303
|
+
/** The `data` of GET /cp1/read/_protected/gate: a live share exists at the slug (no name, it is behind the password), or why none does. */
|
|
304
|
+
type HyleProtectedGate = {
|
|
305
|
+
readonly kind: "gate";
|
|
306
|
+
} | {
|
|
307
|
+
readonly kind: "notfound";
|
|
308
|
+
} | {
|
|
309
|
+
readonly kind: "disabled";
|
|
310
|
+
};
|
|
279
311
|
|
|
280
|
-
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, HylePreview as H, ListItem as L, Mount as M, NavItem as N, ReactionCounts as R, ThemeRef as T, VoteValue as V, ArticleContent as a, EngageHeldComment as b, EngageListing as c,
|
|
312
|
+
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, HylePreview as H, ListItem as L, Mount as M, NavItem as N, ReactionCounts as R, ThemeRef as T, VoteValue as V, ArticleContent as a, EngageHeldComment as b, EngageListing as c, HyleProtected as d, HyleProtectedGate as e, HyleProtectedShare as f, Mounts as g, MountsResult as h, NavNode as i, NavTree as j, ReactionKind as k, Resolved as l, ResolvedArticle as m, ResolvedDisabled as n, ResolvedList as o, ResolvedNotFound as p, ResolvedRedirect as q, TocEntry as r };
|
|
@@ -177,6 +177,8 @@ interface Mounts {
|
|
|
177
177
|
readonly supported_locales: readonly string[];
|
|
178
178
|
readonly mounts: readonly Mount[];
|
|
179
179
|
readonly reserved: readonly string[];
|
|
180
|
+
/** The slugs of live protected shares on this workspace (hyle ADR 0040); absent from an older server. */
|
|
181
|
+
readonly protected?: readonly string[];
|
|
180
182
|
/** Absent without a theme and from an older server. */
|
|
181
183
|
readonly theme?: ThemeRef;
|
|
182
184
|
readonly cache: CacheInfo;
|
|
@@ -276,5 +278,35 @@ type HylePreview =
|
|
|
276
278
|
} | {
|
|
277
279
|
readonly kind: "disabled";
|
|
278
280
|
};
|
|
281
|
+
/** The `data` of GET /cp1/read/_protected (hyle ADR 0040): a protected share's document. `documents` lists the share's pages in order. */
|
|
282
|
+
interface HyleProtectedShare {
|
|
283
|
+
readonly cp: 1;
|
|
284
|
+
readonly kind: "protected";
|
|
285
|
+
readonly name: string;
|
|
286
|
+
/** When the share stops working, or null for none. */
|
|
287
|
+
readonly expires_at: string | null;
|
|
288
|
+
readonly documents: readonly {
|
|
289
|
+
readonly doc_slug: string;
|
|
290
|
+
readonly title: string;
|
|
291
|
+
readonly position: number;
|
|
292
|
+
}[];
|
|
293
|
+
/** The document this answer draws. */
|
|
294
|
+
readonly doc_slug: string;
|
|
295
|
+
/** The article's asset addresses carry the share slug. */
|
|
296
|
+
readonly article: ResolvedArticle;
|
|
297
|
+
}
|
|
298
|
+
type HyleProtected = HyleProtectedShare | {
|
|
299
|
+
readonly kind: "notfound";
|
|
300
|
+
} | {
|
|
301
|
+
readonly kind: "disabled";
|
|
302
|
+
};
|
|
303
|
+
/** The `data` of GET /cp1/read/_protected/gate: a live share exists at the slug (no name, it is behind the password), or why none does. */
|
|
304
|
+
type HyleProtectedGate = {
|
|
305
|
+
readonly kind: "gate";
|
|
306
|
+
} | {
|
|
307
|
+
readonly kind: "notfound";
|
|
308
|
+
} | {
|
|
309
|
+
readonly kind: "disabled";
|
|
310
|
+
};
|
|
279
311
|
|
|
280
|
-
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, HylePreview as H, ListItem as L, Mount as M, NavItem as N, ReactionCounts as R, ThemeRef as T, VoteValue as V, ArticleContent as a, EngageHeldComment as b, EngageListing as c,
|
|
312
|
+
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, HylePreview as H, ListItem as L, Mount as M, NavItem as N, ReactionCounts as R, ThemeRef as T, VoteValue as V, ArticleContent as a, EngageHeldComment as b, EngageListing as c, HyleProtected as d, HyleProtectedGate as e, HyleProtectedShare as f, Mounts as g, MountsResult as h, NavNode as i, NavTree as j, ReactionKind as k, Resolved as l, ResolvedArticle as m, ResolvedDisabled as n, ResolvedList as o, ResolvedNotFound as p, ResolvedRedirect as q, TocEntry as r };
|
package/dist/use-cache.cjs
CHANGED
|
@@ -35,7 +35,14 @@ var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
|
35
35
|
var PREVIEW_HEADER = "cp-preview";
|
|
36
36
|
var PREVIEW_PARAM = "hyle_preview";
|
|
37
37
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
38
|
-
var
|
|
38
|
+
var PROTECTED_PARAM = "hyle_protected";
|
|
39
|
+
var PROTECTED_HEADER = "cp-protected";
|
|
40
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
41
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
42
|
+
var PROTECTED_DOC_SLUG = /^[a-z0-9-]+$/;
|
|
43
|
+
var PROTECTED_PASSWORD = /^[\x21\x23-\x24\x26-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]{12,128}$/;
|
|
44
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
45
|
+
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
39
46
|
|
|
40
47
|
// src/errors.ts
|
|
41
48
|
var Cp1ClientError = class extends Error {
|
|
@@ -67,8 +74,8 @@ function mapNode(node, mark, depth) {
|
|
|
67
74
|
...Array.isArray(children) ? { children: children.map((child) => mapNode(child, mark, depth + 1)) } : {}
|
|
68
75
|
};
|
|
69
76
|
}
|
|
70
|
-
function
|
|
71
|
-
const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${
|
|
77
|
+
function withAssetQuery(article, query) {
|
|
78
|
+
const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${query}`) : value;
|
|
72
79
|
const { publication, content } = article;
|
|
73
80
|
return {
|
|
74
81
|
...article,
|
|
@@ -116,7 +123,7 @@ var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound",
|
|
|
116
123
|
var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
117
124
|
function isMounts(data) {
|
|
118
125
|
const mounts = data.mounts;
|
|
119
|
-
return typeof data.workspace_id === "string" && isStrings(data.reserved) && isStrings(data.supported_locales) && Array.isArray(mounts) && mounts.every((m) => typeof m?.prefix === "string" && typeof m.default_section === "string");
|
|
126
|
+
return typeof data.workspace_id === "string" && isStrings(data.reserved) && isStrings(data.supported_locales) && Array.isArray(mounts) && mounts.every((m) => typeof m?.prefix === "string" && typeof m.default_section === "string") && (data.protected === void 0 || isStrings(data.protected));
|
|
120
127
|
}
|
|
121
128
|
function checkBaseUrl(baseUrl, allowInsecureHttp) {
|
|
122
129
|
let origin;
|
|
@@ -197,13 +204,37 @@ function createHyleClient(options) {
|
|
|
197
204
|
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
198
205
|
const article = data?.article;
|
|
199
206
|
if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
200
|
-
return { kind: "preview", expires_at: data.expires_at, article:
|
|
207
|
+
return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
|
|
208
|
+
}
|
|
209
|
+
async function protectedGate(slug) {
|
|
210
|
+
if (!PROTECTED_SLUG.test(slug)) return { kind: "notfound" };
|
|
211
|
+
const reply = await get("/cp1/read/_protected/gate", new URLSearchParams({ path: slug }), { cache: "no-store" });
|
|
212
|
+
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
213
|
+
const data = reply.parsed?.data;
|
|
214
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
215
|
+
if (data?.cp === 1 && data.kind === "gate") return { kind: "gate" };
|
|
216
|
+
throw failure(reply);
|
|
217
|
+
}
|
|
218
|
+
async function protectedShare(slug, password, docSlug) {
|
|
219
|
+
if (!PROTECTED_SLUG.test(slug) || docSlug !== void 0 && !PROTECTED_DOC_SLUG.test(docSlug) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
|
|
220
|
+
const path = docSlug === void 0 ? slug : `${slug}/${docSlug}`;
|
|
221
|
+
const reply = await get("/cp1/read/_protected", new URLSearchParams({ path }), { headers: { [PROTECTED_HEADER]: password }, cache: "no-store" });
|
|
222
|
+
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
223
|
+
const data = reply.parsed?.data;
|
|
224
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
225
|
+
const article = data?.article;
|
|
226
|
+
const { name, expires_at: expires, documents, doc_slug: current } = data ?? {};
|
|
227
|
+
if (data?.cp !== 1 || data.kind !== "protected" || typeof name !== "string" || typeof expires !== "string" && expires !== null || !Array.isArray(documents) || typeof current !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
228
|
+
return { cp: 1, kind: "protected", name, expires_at: expires, documents, doc_slug: current, article: withAssetQuery(article, `${PROTECTED_PARAM}=${slug}`) };
|
|
201
229
|
}
|
|
202
230
|
async function asset(file, opts = {}) {
|
|
203
231
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
204
232
|
const { previewToken } = opts;
|
|
205
233
|
if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
|
|
206
|
-
const
|
|
234
|
+
const { protectedAccess } = opts;
|
|
235
|
+
if (protectedAccess !== void 0 && !(PROTECTED_SLUG.test(protectedAccess.slug) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a share slug and password");
|
|
236
|
+
const query = protectedAccess === void 0 ? "" : `?protected=${encodeURIComponent(protectedAccess.slug)}`;
|
|
237
|
+
const url = `${base}/cp1/read/assets/${file}${query}`;
|
|
207
238
|
const headers = new Headers();
|
|
208
239
|
const applied = applyCredential(headers, options, "GET", url);
|
|
209
240
|
if (applied) await applied;
|
|
@@ -212,7 +243,9 @@ function createHyleClient(options) {
|
|
|
212
243
|
if (value) headers.set(name, value);
|
|
213
244
|
}
|
|
214
245
|
if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
|
|
215
|
-
|
|
246
|
+
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, protectedAccess.password);
|
|
247
|
+
const uncached = previewToken !== void 0 || protectedAccess !== void 0;
|
|
248
|
+
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
|
|
216
249
|
}
|
|
217
250
|
async function theme(opts = {}) {
|
|
218
251
|
const url = `${base}/cp1/read/theme.css`;
|
|
@@ -221,7 +254,7 @@ function createHyleClient(options) {
|
|
|
221
254
|
if (applied) await applied;
|
|
222
255
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
223
256
|
}
|
|
224
|
-
return { resolve, mounts, pushPosts, preview, asset, theme };
|
|
257
|
+
return { resolve, mounts, pushPosts, preview, protectedGate, protected: protectedShare, asset, theme };
|
|
225
258
|
}
|
|
226
259
|
|
|
227
260
|
// src/tag-validation.ts
|
package/dist/use-cache.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HyleAuth } from './client-
|
|
2
|
-
import { H as HyleResolver } from './resolve-
|
|
3
|
-
import './types-
|
|
1
|
+
import { H as HyleAuth } from './client-DrB2vcTi.cjs';
|
|
2
|
+
import { H as HyleResolver } from './resolve-03IVloXU.cjs';
|
|
3
|
+
import './types-Dx-fEiZd.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The exact caching strategy: a `'use cache'` function that fetches, then tags its own entry with the tags the response
|
package/dist/use-cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HyleAuth } from './client-
|
|
2
|
-
import { H as HyleResolver } from './resolve-
|
|
3
|
-
import './types-
|
|
1
|
+
import { H as HyleAuth } from './client-BErei7cE.js';
|
|
2
|
+
import { H as HyleResolver } from './resolve-BseM68oy.js';
|
|
3
|
+
import './types-Dx-fEiZd.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The exact caching strategy: a `'use cache'` function that fetches, then tags its own entry with the tags the response
|
package/dist/use-cache.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_REVALIDATE
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SY2FMIRZ.js";
|
|
4
4
|
import {
|
|
5
5
|
createHyleClient,
|
|
6
6
|
isValidCacheTag
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-4REU4HJI.js";
|
|
8
|
+
import "./chunk-BDFMNY76.js";
|
|
9
9
|
|
|
10
10
|
// src/next/use-cache.ts
|
|
11
11
|
import { cacheLife, cacheTag } from "next/cache";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tdacorp/hyle-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "hyle SDK: a typed client for hyle's resolve endpoint, a hast renderer for React, and a Next.js catch-all page with tag-based revalidation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|