@seed-hypermedia/client 0.0.89 → 0.0.91
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 +2 -2
- package/dist/capability.mjs +2 -2
- package/dist/{chunk-GIO2JLKT.mjs → chunk-2X45222K.mjs} +34 -1
- package/dist/{chunk-7QKG43UV.mjs → chunk-5H44WPFO.mjs} +1 -1
- package/dist/{chunk-IW5GLPEG.mjs → chunk-5ZHBEPRC.mjs} +1 -1
- package/dist/{chunk-BMPK76B2.mjs → chunk-6FBJVBS6.mjs} +3 -3
- package/dist/{chunk-J45O2Y7E.mjs → chunk-EBGUVS7T.mjs} +2 -2
- package/dist/{chunk-ZVJGJE2L.mjs → chunk-GOKN5MFV.mjs} +1 -1
- package/dist/{chunk-I273FRIR.mjs → chunk-HMTFZNX7.mjs} +1 -1
- package/dist/{chunk-OOSTK7CM.mjs → chunk-IS7QPOMQ.mjs} +3 -3
- package/dist/chunk-JSNDXUPG.mjs +407 -0
- package/dist/{chunk-GN76IN3M.mjs → chunk-LZOORGGJ.mjs} +1 -1
- package/dist/{chunk-STKAE4YB.mjs → chunk-OIL62HNH.mjs} +1 -1
- package/dist/{chunk-7OWFPOHI.mjs → chunk-P5R4E4AU.mjs} +1 -1
- package/dist/{chunk-XB6E7EVC.mjs → chunk-QVRJGK77.mjs} +1 -1
- package/dist/{chunk-W3MTG26Q.mjs → chunk-RPXAWYOC.mjs} +4 -1
- package/dist/chunk-TZMLZHCZ.mjs +230 -0
- package/dist/{chunk-DVJ3XGXS.mjs → chunk-UQL3R7WC.mjs} +1 -1
- package/dist/chunk-VWSAFDOL.mjs +110 -0
- package/dist/chunk-ZWKMAGDU.mjs +10 -0
- package/dist/client.mjs +2 -2
- package/dist/comment.mjs +2 -2
- package/dist/dag-json.d.ts +52 -0
- package/dist/dag-json.mjs +23 -0
- package/dist/document-state.mjs +2 -2
- package/dist/editorblock-to-hmblock.mjs +2 -2
- package/dist/hm-resolver.mjs +2 -2
- package/dist/hm-types.d.ts +2031 -49
- package/dist/hm-types.mjs +9 -1
- package/dist/hmblock-to-editorblock.mjs +2 -2
- package/dist/index.mjs +27 -27
- package/dist/markdown-to-blocks.mjs +1 -1
- package/dist/pdf-to-blocks.mjs +3 -3
- package/dist/resource-read.mjs +4 -4
- package/dist/schema-engine.d.ts +127 -0
- package/dist/schema-engine.mjs +83 -0
- package/dist/schema-registry.generated.d.ts +8 -0
- package/dist/schema-registry.generated.mjs +11 -0
- package/dist/schema-resolve.d.ts +135 -0
- package/dist/schema-resolve.mjs +45 -0
- package/dist/schema-subtypes.d.ts +36 -0
- package/dist/schema-subtypes.mjs +94 -0
- package/dist/schema-types.generated.d.ts +1598 -0
- package/dist/schema-types.generated.mjs +0 -0
- package/dist/signed-blob.d.ts +63 -0
- package/dist/signed-blob.mjs +123 -0
- package/dist/tei-to-blocks.mjs +2 -2
- package/dist/unicode.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
classifyRef
|
|
3
|
+
} from "./chunk-TZMLZHCZ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
kindOf,
|
|
6
|
+
nameForCid,
|
|
7
|
+
nameToUrl,
|
|
8
|
+
schemaCid
|
|
9
|
+
} from "./chunk-JSNDXUPG.mjs";
|
|
10
|
+
import {
|
|
11
|
+
HM_SCHEMAS
|
|
12
|
+
} from "./chunk-ZWKMAGDU.mjs";
|
|
13
|
+
import "./chunk-VWSAFDOL.mjs";
|
|
14
|
+
import {
|
|
15
|
+
unpackHmId
|
|
16
|
+
} from "./chunk-2X45222K.mjs";
|
|
17
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
18
|
+
|
|
19
|
+
// src/schema-subtypes.ts
|
|
20
|
+
function schemaRefKey(ref) {
|
|
21
|
+
var _a;
|
|
22
|
+
const cls = classifyRef(ref);
|
|
23
|
+
switch (cls.kind) {
|
|
24
|
+
case "none":
|
|
25
|
+
return null;
|
|
26
|
+
case "hm-bundled":
|
|
27
|
+
return `lib:${cls.name}`;
|
|
28
|
+
case "cid": {
|
|
29
|
+
const name = nameForCid(cls.cid);
|
|
30
|
+
return name ? `lib:${name}` : `cid:${cls.cid}`;
|
|
31
|
+
}
|
|
32
|
+
case "hm-doc": {
|
|
33
|
+
const id = unpackHmId(cls.url);
|
|
34
|
+
return id ? `hm://${id.uid}${((_a = id.path) == null ? void 0 : _a.length) ? `/${id.path.join("/")}` : ""}` : cls.url;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function extensionParentRef(schema) {
|
|
39
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return null;
|
|
40
|
+
const type = schema.type;
|
|
41
|
+
if (typeof type !== "string" || !type) return null;
|
|
42
|
+
return kindOf(type) === type ? type : null;
|
|
43
|
+
}
|
|
44
|
+
function libraryCandidates() {
|
|
45
|
+
return Object.entries(HM_SCHEMAS).map(([name, schema]) => {
|
|
46
|
+
const cid = schemaCid(name);
|
|
47
|
+
const url = nameToUrl(name);
|
|
48
|
+
return {
|
|
49
|
+
refs: [...url ? [url] : [], ...cid ? [`ipfs://${cid}`] : []],
|
|
50
|
+
parent: extensionParentRef(schema)
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function closeOverSubtypes(target, candidates) {
|
|
55
|
+
const targetKey = schemaRefKey(target);
|
|
56
|
+
const keys = /* @__PURE__ */ new Set();
|
|
57
|
+
const refs = [];
|
|
58
|
+
const add = (ref, key) => {
|
|
59
|
+
keys.add(key);
|
|
60
|
+
if (!refs.includes(ref)) refs.push(ref);
|
|
61
|
+
};
|
|
62
|
+
if (!targetKey) return { keys, refs };
|
|
63
|
+
add(target, targetKey);
|
|
64
|
+
const keyed = candidates.map((candidate) => ({
|
|
65
|
+
refs: candidate.refs.map((ref) => [ref, schemaRefKey(ref)]).filter((pair) => !!pair[1]),
|
|
66
|
+
parentKey: candidate.parent ? schemaRefKey(candidate.parent) : null
|
|
67
|
+
})).filter((candidate) => candidate.refs.length > 0);
|
|
68
|
+
let grew = true;
|
|
69
|
+
while (grew) {
|
|
70
|
+
grew = false;
|
|
71
|
+
for (const candidate of keyed) {
|
|
72
|
+
const known = candidate.refs.some(([, key]) => keys.has(key));
|
|
73
|
+
const inherits = !!candidate.parentKey && keys.has(candidate.parentKey);
|
|
74
|
+
if (!known && !inherits) continue;
|
|
75
|
+
for (const [ref, key] of candidate.refs) {
|
|
76
|
+
if (keys.has(key) && refs.includes(ref)) continue;
|
|
77
|
+
add(ref, key);
|
|
78
|
+
grew = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { keys, refs };
|
|
83
|
+
}
|
|
84
|
+
function inClosure(closure, ref) {
|
|
85
|
+
const key = schemaRefKey(ref);
|
|
86
|
+
return !!closure && !!key && closure.keys.has(key);
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
closeOverSubtypes,
|
|
90
|
+
extensionParentRef,
|
|
91
|
+
inClosure,
|
|
92
|
+
libraryCandidates,
|
|
93
|
+
schemaRefKey
|
|
94
|
+
};
|