@seed-hypermedia/client 0.0.113 → 0.0.115
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/dist/auto-link.mjs +3 -3
- package/dist/blocks-to-markdown.mjs +3 -2
- package/dist/capability.mjs +2 -2
- package/dist/{chunk-UHAYFVBP.mjs → chunk-3LMBGHBE.mjs} +75 -5
- package/dist/{chunk-3P4J4WDY.mjs → chunk-54K7Z3BG.mjs} +1 -1
- package/dist/{chunk-KMACFX6U.mjs → chunk-BGWUWAFJ.mjs} +1 -1
- package/dist/{chunk-URLWDK7P.mjs → chunk-BZOAANTM.mjs} +1 -1
- package/dist/{chunk-2PRZIGCZ.mjs → chunk-DQMPCZVZ.mjs} +14 -5
- package/dist/chunk-HSDV6WEU.mjs +10 -0
- package/dist/{chunk-5VBVPSXD.mjs → chunk-HZQXXBOH.mjs} +2 -2
- package/dist/chunk-JELXCUZJ.mjs +49 -0
- package/dist/{chunk-3TERIXHU.mjs → chunk-LWCFLZRZ.mjs} +7 -30
- package/dist/{chunk-OXZCRYUS.mjs → chunk-MJFOPYAB.mjs} +1 -1
- package/dist/{chunk-YF2CLLSQ.mjs → chunk-MTJRBDF2.mjs} +3 -3
- package/dist/{chunk-AUKAVTTK.mjs → chunk-MZMGRUTQ.mjs} +1 -1
- package/dist/{chunk-YC433TGZ.mjs → chunk-QIKOXXTT.mjs} +1 -1
- package/dist/{chunk-GLY3UZ3W.mjs → chunk-UQWQXOBZ.mjs} +1 -1
- package/dist/{chunk-LQTTR4ZP.mjs → chunk-V2XTXDGG.mjs} +1 -1
- package/dist/{chunk-NLH5MKTK.mjs → chunk-ZVPHEP3X.mjs} +1 -1
- package/dist/client.mjs +2 -2
- package/dist/comment.mjs +2 -2
- package/dist/document-state.mjs +2 -2
- package/dist/editorblock-to-hmblock.mjs +2 -2
- package/dist/hm-resolver.d.ts +13 -0
- package/dist/hm-resolver.mjs +6 -2
- package/dist/hm-types.d.ts +5 -452
- package/dist/hm-types.mjs +1 -3
- package/dist/hmblock-to-editorblock.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +20 -16
- package/dist/pdf-to-blocks.mjs +3 -3
- package/dist/resource-read.mjs +4 -4
- package/dist/schema-engine.mjs +2 -2
- package/dist/schema-registry.generated.mjs +1 -1
- package/dist/schema-resolve.mjs +4 -4
- package/dist/schema-subtypes.mjs +4 -4
- package/dist/schema-types.generated.d.ts +14 -5
- package/dist/signed-blob.mjs +2 -2
- package/dist/tei-to-blocks.mjs +2 -2
- package/dist/unicode.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-ALW35WVX.mjs +0 -75
- package/dist/chunk-MLR4UDOJ.mjs +0 -10
package/dist/auto-link.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
documentContainsLinkToChild,
|
|
5
5
|
documentHasSelfQuery,
|
|
6
6
|
shouldAutoLinkParent
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HZQXXBOH.mjs";
|
|
8
8
|
import "./chunk-O5MHN2EO.mjs";
|
|
9
9
|
import "./chunk-PJ2RFT5A.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-BGWUWAFJ.mjs";
|
|
11
11
|
import "./chunk-LVAHHQIK.mjs";
|
|
12
12
|
import "./chunk-DR3HJ6BV.mjs";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-LWCFLZRZ.mjs";
|
|
14
14
|
import "./chunk-AHQWDCHV.mjs";
|
|
15
15
|
import "./chunk-7P6ASYW6.mjs";
|
|
16
16
|
export {
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
emitFrontmatter,
|
|
8
8
|
parseDraftFilename,
|
|
9
9
|
slugify
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-DQMPCZVZ.mjs";
|
|
11
|
+
import "./chunk-3LMBGHBE.mjs";
|
|
12
|
+
import "./chunk-LWCFLZRZ.mjs";
|
|
12
13
|
import "./chunk-AHQWDCHV.mjs";
|
|
13
14
|
import "./chunk-7P6ASYW6.mjs";
|
|
14
15
|
export {
|
package/dist/capability.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCapability,
|
|
3
3
|
resolveCapability
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-V2XTXDGG.mjs";
|
|
5
5
|
import "./chunk-LVAHHQIK.mjs";
|
|
6
6
|
import "./chunk-NBCHK76Q.mjs";
|
|
7
7
|
import "./chunk-DR3HJ6BV.mjs";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-LWCFLZRZ.mjs";
|
|
9
9
|
import "./chunk-AHQWDCHV.mjs";
|
|
10
10
|
import "./chunk-3TPCJCVO.mjs";
|
|
11
11
|
import "./chunk-7P6ASYW6.mjs";
|
|
@@ -2,13 +2,22 @@ import {
|
|
|
2
2
|
entityQueryPathToHmIdPath,
|
|
3
3
|
parseFragment,
|
|
4
4
|
unpackHmId
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LWCFLZRZ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
pageParamsFromUrl
|
|
8
8
|
} from "./chunk-AHQWDCHV.mjs";
|
|
9
9
|
|
|
10
10
|
// src/hm-resolver.ts
|
|
11
|
+
function hmDomainUrlToWebUrl(input) {
|
|
12
|
+
if (!input.startsWith("hm://")) return null;
|
|
13
|
+
const parsed = unpackHmId(input);
|
|
14
|
+
if (!(parsed == null ? void 0 : parsed.uid.includes("."))) return null;
|
|
15
|
+
const url = new URL(`https://${input.slice("hm://".length)}`);
|
|
16
|
+
if (url.username || url.password) throw new Error("Hypermedia domain URLs cannot contain credentials");
|
|
17
|
+
return url.href;
|
|
18
|
+
}
|
|
11
19
|
async function resolveHypermediaUrl(url, opts) {
|
|
20
|
+
url = hmDomainUrlToWebUrl(url) || url;
|
|
12
21
|
let latest = false;
|
|
13
22
|
let blockRef = null;
|
|
14
23
|
let blockRange = null;
|
|
@@ -132,10 +141,11 @@ async function resolveHypermediaUrl(url, opts) {
|
|
|
132
141
|
return null;
|
|
133
142
|
}
|
|
134
143
|
async function resolveId(input, opts) {
|
|
135
|
-
const
|
|
144
|
+
const domainUrl = hmDomainUrlToWebUrl(input);
|
|
145
|
+
const parsed = domainUrl ? null : unpackHmId(input);
|
|
136
146
|
if (parsed) return parsed;
|
|
137
|
-
if (input.startsWith("http://") || input.startsWith("https://")) {
|
|
138
|
-
const resolved = await resolveHypermediaUrl(input, opts);
|
|
147
|
+
if (domainUrl || input.startsWith("http://") || input.startsWith("https://")) {
|
|
148
|
+
const resolved = await resolveHypermediaUrl(domainUrl || input, opts);
|
|
139
149
|
if (resolved == null ? void 0 : resolved.hmId) return resolved.hmId;
|
|
140
150
|
throw new Error(`URL does not appear to be a Seed Hypermedia resource: ${input}`);
|
|
141
151
|
}
|
|
@@ -203,8 +213,68 @@ function resolveProfilePath(siteUid, pathSegments) {
|
|
|
203
213
|
path: [":profile"]
|
|
204
214
|
};
|
|
205
215
|
}
|
|
216
|
+
var COMMENT_VIEW_TERMS = /* @__PURE__ */ new Set([":comments", ":comment", ":discussions"]);
|
|
217
|
+
var COMMENT_PANEL_PREFIXES = /* @__PURE__ */ new Set(["comments", "comment", "discussions"]);
|
|
218
|
+
function extractCommentIdFromPanel(panel) {
|
|
219
|
+
if (!panel) return null;
|
|
220
|
+
const [viewTerm, first, second] = panel.split("/");
|
|
221
|
+
if (!viewTerm || !COMMENT_PANEL_PREFIXES.has(viewTerm)) return null;
|
|
222
|
+
if (first && second) return `${first}/${second}`;
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
function extractCommentIdFromPath(pathParts) {
|
|
226
|
+
if (pathParts.length >= 3) {
|
|
227
|
+
const thirdToLast = pathParts[pathParts.length - 3];
|
|
228
|
+
if (thirdToLast && COMMENT_VIEW_TERMS.has(thirdToLast)) {
|
|
229
|
+
return `${pathParts[pathParts.length - 2]}/${pathParts[pathParts.length - 1]}`;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (pathParts.length >= 2) {
|
|
233
|
+
const secondToLast = pathParts[pathParts.length - 2];
|
|
234
|
+
if (secondToLast && COMMENT_VIEW_TERMS.has(secondToLast)) return pathParts[pathParts.length - 1] || null;
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
function parseReplyCommentId(reply) {
|
|
239
|
+
if (!reply) return null;
|
|
240
|
+
const [first, second] = reply.split("/");
|
|
241
|
+
if (first && second) return `${first}/${second}`;
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
function extractCommentIdFromUrl(url) {
|
|
245
|
+
const isWeb = url.startsWith("http://") || url.startsWith("https://");
|
|
246
|
+
let panelCommentId = null;
|
|
247
|
+
let pathCommentId = null;
|
|
248
|
+
let reply = null;
|
|
249
|
+
if (isWeb) {
|
|
250
|
+
let parsedUrl;
|
|
251
|
+
try {
|
|
252
|
+
parsedUrl = new URL(url);
|
|
253
|
+
} catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
panelCommentId = extractCommentIdFromPanel(parsedUrl.searchParams.get("panel"));
|
|
257
|
+
reply = parseReplyCommentId(parsedUrl.searchParams.get("reply"));
|
|
258
|
+
const unpacked = unpackHmId(url);
|
|
259
|
+
const pathParts = (unpacked == null ? void 0 : unpacked.path) ?? parsedUrl.pathname.split("/").filter(Boolean);
|
|
260
|
+
pathCommentId = extractCommentIdFromPath(pathParts);
|
|
261
|
+
} else {
|
|
262
|
+
const [withoutHash] = url.split("#");
|
|
263
|
+
const [withoutQuery, queryString] = withoutHash.split("?");
|
|
264
|
+
const searchParams = new URLSearchParams(queryString);
|
|
265
|
+
panelCommentId = extractCommentIdFromPanel(searchParams.get("panel"));
|
|
266
|
+
reply = parseReplyCommentId(searchParams.get("reply"));
|
|
267
|
+
const parsed = unpackHmId(withoutQuery);
|
|
268
|
+
pathCommentId = (parsed == null ? void 0 : parsed.path) ? extractCommentIdFromPath(parsed.path) : null;
|
|
269
|
+
}
|
|
270
|
+
const threadCommentId = panelCommentId || pathCommentId;
|
|
271
|
+
if (!threadCommentId) return null;
|
|
272
|
+
return reply ?? threadCommentId;
|
|
273
|
+
}
|
|
206
274
|
|
|
207
275
|
export {
|
|
276
|
+
hmDomainUrlToWebUrl,
|
|
208
277
|
resolveHypermediaUrl,
|
|
209
|
-
resolveId
|
|
278
|
+
resolveId,
|
|
279
|
+
extractCommentIdFromUrl
|
|
210
280
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveId
|
|
3
|
+
} from "./chunk-3LMBGHBE.mjs";
|
|
1
4
|
import {
|
|
2
5
|
normalizeQuerySort,
|
|
3
6
|
unpackHmId
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LWCFLZRZ.mjs";
|
|
5
8
|
|
|
6
9
|
// src/blocks-to-markdown.ts
|
|
7
10
|
import { stringify as stringifyYaml } from "yaml";
|
|
@@ -728,13 +731,20 @@ async function resolveInlineEmbed(ann, type, ctx) {
|
|
|
728
731
|
return `[\u2197 ${fallbackLabel(link)}`;
|
|
729
732
|
}
|
|
730
733
|
}
|
|
734
|
+
async function resolveMarkdownReferenceId(link, ctx) {
|
|
735
|
+
return resolveId(link, {
|
|
736
|
+
domainResolver: async (domain) => {
|
|
737
|
+
const info = await ctx.client.request("GetDomain", { domain });
|
|
738
|
+
return info.registeredAccountUid ? { registeredAccountUid: info.registeredAccountUid, isGateway: info.isGateway } : null;
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
}
|
|
731
742
|
async function resolveEmbeddedResource(link, ctx) {
|
|
732
743
|
var _a, _b;
|
|
733
744
|
const cacheKey = `embed:${link}`;
|
|
734
745
|
const cached = ctx.cache.get(cacheKey);
|
|
735
746
|
if (cached) return cached;
|
|
736
|
-
const id =
|
|
737
|
-
if (!id) throw new Error("Invalid HM link");
|
|
747
|
+
const id = await resolveMarkdownReferenceId(link, ctx);
|
|
738
748
|
const resource = await ctx.client.request("Resource", id);
|
|
739
749
|
let resolved;
|
|
740
750
|
if (resource.type === "document") {
|
|
@@ -771,8 +781,7 @@ async function resolveReference(link, ctx, mentionKind) {
|
|
|
771
781
|
const cacheKey = `${mentionKind || "legacy"}:${link}`;
|
|
772
782
|
const cached = ctx.cache.get(cacheKey);
|
|
773
783
|
if (cached) return cached;
|
|
774
|
-
const id =
|
|
775
|
-
if (!id) throw new Error("Invalid HM link");
|
|
784
|
+
const id = await resolveMarkdownReferenceId(link, ctx);
|
|
776
785
|
let resolved;
|
|
777
786
|
const profileAccountUid = ((_a = id.path) == null ? void 0 : _a[0]) === ":profile" ? id.path[1] || id.uid : !((_b = id.path) == null ? void 0 : _b.length) ? id.uid : null;
|
|
778
787
|
if (profileAccountUid && mentionKind !== "document") {
|