@seed-hypermedia/client 0.0.113 → 0.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/auto-link.mjs +3 -3
  2. package/dist/blocks-to-markdown.mjs +3 -2
  3. package/dist/capability.mjs +2 -2
  4. package/dist/{chunk-YF2CLLSQ.mjs → chunk-2NMNRO4D.mjs} +3 -3
  5. package/dist/{chunk-NLH5MKTK.mjs → chunk-3IWI5CPN.mjs} +1 -1
  6. package/dist/{chunk-3P4J4WDY.mjs → chunk-DQPKO37T.mjs} +1 -1
  7. package/dist/{chunk-3TERIXHU.mjs → chunk-GMSNTW7N.mjs} +6 -20
  8. package/dist/chunk-HSDV6WEU.mjs +10 -0
  9. package/dist/{chunk-UHAYFVBP.mjs → chunk-IIH2GY7Y.mjs} +15 -4
  10. package/dist/{chunk-2PRZIGCZ.mjs → chunk-MPZWQQ4T.mjs} +14 -5
  11. package/dist/{chunk-AUKAVTTK.mjs → chunk-MZMGRUTQ.mjs} +1 -1
  12. package/dist/{chunk-YC433TGZ.mjs → chunk-O4WGAS2C.mjs} +1 -1
  13. package/dist/{chunk-URLWDK7P.mjs → chunk-PODYPZBY.mjs} +1 -1
  14. package/dist/{chunk-OXZCRYUS.mjs → chunk-QMWFLXP7.mjs} +1 -1
  15. package/dist/{chunk-5VBVPSXD.mjs → chunk-SOYMAPYD.mjs} +2 -2
  16. package/dist/{chunk-LQTTR4ZP.mjs → chunk-VUQJUPXS.mjs} +1 -1
  17. package/dist/{chunk-GLY3UZ3W.mjs → chunk-VYZX3LHX.mjs} +1 -1
  18. package/dist/{chunk-KMACFX6U.mjs → chunk-XHMBAW2Z.mjs} +1 -1
  19. package/dist/{chunk-ALW35WVX.mjs → chunk-ZQZF75CE.mjs} +11 -5
  20. package/dist/client.mjs +2 -2
  21. package/dist/comment.mjs +2 -2
  22. package/dist/document-state.mjs +2 -2
  23. package/dist/editorblock-to-hmblock.mjs +2 -2
  24. package/dist/hm-resolver.d.ts +2 -0
  25. package/dist/hm-resolver.mjs +4 -2
  26. package/dist/hm-types.d.ts +5 -71
  27. package/dist/hm-types.mjs +1 -1
  28. package/dist/hmblock-to-editorblock.mjs +2 -2
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.mjs +18 -16
  31. package/dist/pdf-to-blocks.mjs +3 -3
  32. package/dist/resource-read.mjs +4 -4
  33. package/dist/schema-engine.mjs +2 -2
  34. package/dist/schema-registry.generated.mjs +1 -1
  35. package/dist/schema-resolve.mjs +4 -4
  36. package/dist/schema-subtypes.mjs +4 -4
  37. package/dist/schema-types.generated.d.ts +14 -5
  38. package/dist/signed-blob.mjs +2 -2
  39. package/dist/tei-to-blocks.mjs +2 -2
  40. package/dist/unicode.mjs +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-MLR4UDOJ.mjs +0 -10
@@ -1,7 +1,10 @@
1
+ import {
2
+ resolveId
3
+ } from "./chunk-IIH2GY7Y.mjs";
1
4
  import {
2
5
  normalizeQuerySort,
3
6
  unpackHmId
4
- } from "./chunk-3TERIXHU.mjs";
7
+ } from "./chunk-GMSNTW7N.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 = unpackHmId(link);
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 = unpackHmId(link);
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") {
@@ -2,7 +2,7 @@ import {
2
2
  HM_SCHEMAS,
3
3
  HM_SCHEMA_MANIFEST,
4
4
  HM_SCHEMA_PAGES
5
- } from "./chunk-MLR4UDOJ.mjs";
5
+ } from "./chunk-HSDV6WEU.mjs";
6
6
 
7
7
  // src/schema-engine.ts
8
8
  var LIBRARY_AUTHORITY = "hyper.media";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-3TERIXHU.mjs";
3
+ } from "./chunk-GMSNTW7N.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getSupportedHMQueryFilters,
3
3
  isSurrogate
4
- } from "./chunk-3TERIXHU.mjs";
4
+ } from "./chunk-GMSNTW7N.mjs";
5
5
 
6
6
  // src/hmblock-to-editorblock.ts
7
7
  function toEditorBlockType(hmBlockType) {
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-3TERIXHU.mjs";
18
+ } from "./chunk-GMSNTW7N.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-KMACFX6U.mjs";
10
+ } from "./chunk-XHMBAW2Z.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-3TERIXHU.mjs";
15
+ } from "./chunk-GMSNTW7N.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-3TERIXHU.mjs";
10
+ } from "./chunk-GMSNTW7N.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-YC433TGZ.mjs";
3
+ } from "./chunk-O4WGAS2C.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-2FJBS3V7.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-3TERIXHU.mjs";
4
+ } from "./chunk-GMSNTW7N.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -1,16 +1,22 @@
1
- import {
2
- resolveId
3
- } from "./chunk-UHAYFVBP.mjs";
4
1
  import {
5
2
  createSeedClient
6
- } from "./chunk-OXZCRYUS.mjs";
3
+ } from "./chunk-QMWFLXP7.mjs";
4
+ import {
5
+ hmDomainUrlToWebUrl,
6
+ resolveId
7
+ } from "./chunk-IIH2GY7Y.mjs";
7
8
  import {
8
9
  unpackHmId
9
- } from "./chunk-3TERIXHU.mjs";
10
+ } from "./chunk-GMSNTW7N.mjs";
10
11
 
11
12
  // src/resource-read.ts
12
13
  async function resolveIdWithClient(rawId, options = {}) {
13
14
  const commentId = extractCommentIdFromReadableUrl(rawId);
15
+ if (!commentId && hmDomainUrlToWebUrl(rawId)) {
16
+ const id2 = await resolveId(rawId, { domainResolver: options.domainResolver });
17
+ const client = options.client ?? createSeedClient(normalizeServerUrl(options.serverUrl || "https://hyper.media"));
18
+ return { id: id2, client, serverUrl: client.baseUrl };
19
+ }
14
20
  const parsed = commentId ? commentIdToHmId(commentId) : unpackHmId(rawId);
15
21
  if (parsed) {
16
22
  if (isWebUrl(rawId)) {
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-OXZCRYUS.mjs";
4
+ } from "./chunk-QMWFLXP7.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-O5MHN2EO.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-3TERIXHU.mjs";
10
+ import "./chunk-GMSNTW7N.mjs";
11
11
  import "./chunk-AHQWDCHV.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
package/dist/comment.mjs CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  deleteComment,
5
5
  trimTrailingEmptyBlocks,
6
6
  updateComment
7
- } from "./chunk-NLH5MKTK.mjs";
7
+ } from "./chunk-3IWI5CPN.mjs";
8
8
  import "./chunk-JKKS35IS.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-3TERIXHU.mjs";
11
+ import "./chunk-GMSNTW7N.mjs";
12
12
  import "./chunk-AHQWDCHV.mjs";
13
13
  import "./chunk-7P6ASYW6.mjs";
14
14
  export {
@@ -4,8 +4,8 @@ import {
4
4
  followToDocument,
5
5
  resolveDocumentState,
6
6
  resolveEditableDocument
7
- } from "./chunk-KMACFX6U.mjs";
8
- import "./chunk-3TERIXHU.mjs";
7
+ } from "./chunk-XHMBAW2Z.mjs";
8
+ import "./chunk-GMSNTW7N.mjs";
9
9
  import "./chunk-AHQWDCHV.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-3P4J4WDY.mjs";
4
+ } from "./chunk-DQPKO37T.mjs";
5
5
  import "./chunk-JKKS35IS.mjs";
6
- import "./chunk-3TERIXHU.mjs";
6
+ import "./chunk-GMSNTW7N.mjs";
7
7
  import "./chunk-AHQWDCHV.mjs";
8
8
  import "./chunk-7P6ASYW6.mjs";
9
9
  export {
@@ -35,6 +35,8 @@ export type ResolvedUrl = {
35
35
  type: string | null;
36
36
  panel: string | null;
37
37
  };
38
+ /** Converts a domain-based hm:// reference to its HTTPS resolution URL; canonical IDs return null. */
39
+ export declare function hmDomainUrlToWebUrl(input: string): string | null;
38
40
  export declare function resolveHypermediaUrl(url: string, opts?: ResolveOptions): Promise<ResolvedUrl | null>;
39
41
  /**
40
42
  * Resolve a string that may be an hm:// ID, a gateway URL, or a site web URL
@@ -1,11 +1,13 @@
1
1
  import {
2
+ hmDomainUrlToWebUrl,
2
3
  resolveHypermediaUrl,
3
4
  resolveId
4
- } from "./chunk-UHAYFVBP.mjs";
5
- import "./chunk-3TERIXHU.mjs";
5
+ } from "./chunk-IIH2GY7Y.mjs";
6
+ import "./chunk-GMSNTW7N.mjs";
6
7
  import "./chunk-AHQWDCHV.mjs";
7
8
  import "./chunk-7P6ASYW6.mjs";
8
9
  export {
10
+ hmDomainUrlToWebUrl,
9
11
  resolveHypermediaUrl,
10
12
  resolveId
11
13
  };