@seed-hypermedia/client 0.0.121 → 0.0.122
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/apps.d.ts +8 -0
- package/dist/apps.mjs +14 -1
- package/package.json +1 -1
package/dist/apps.d.ts
CHANGED
|
@@ -14,6 +14,12 @@ import type { AnySigner } from './signer';
|
|
|
14
14
|
export declare const HM_APP_TYPE = "hm://hyper.media/app";
|
|
15
15
|
export declare const HM_TOOL_TYPE = "hm://hyper.media/tool";
|
|
16
16
|
export declare const HM_PAGE_TYPE = "hm://hyper.media/page";
|
|
17
|
+
export declare const HM_AGENT_TYPE = "hm://hyper.media/agent";
|
|
18
|
+
/**
|
|
19
|
+
* Documents that host tools and pages: apps and agents (the two are converging into one concept).
|
|
20
|
+
* Both list their children as card embeds and run their tools the same way.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isToolHostType(type: unknown): boolean;
|
|
17
23
|
/** The file a tool's code folder must contain: `export default async function (input) {…}`. */
|
|
18
24
|
export declare const TOOL_ENTRY_FILE = "index.ts";
|
|
19
25
|
/** Starting code for a tool created without any. */
|
|
@@ -42,6 +48,8 @@ export declare function parentDocumentId(id: UnpackedHypermediaId): UnpackedHype
|
|
|
42
48
|
* content stays where it is, after the listed children.
|
|
43
49
|
*/
|
|
44
50
|
export declare function appChildrenOps(appId: UnpackedHypermediaId, content: HMBlockNode[] | undefined, children: UnpackedHypermediaId[]): DocumentOperation[];
|
|
51
|
+
/** Ops that turn a document body from `before` into `after` (block ids kept where they match). */
|
|
52
|
+
export declare function replaceContentOps(before: HMBlockNode[] | undefined, after: HMBlockNode[]): DocumentOperation[];
|
|
45
53
|
/** Ops that append `child` to an app's list, or none when it is already listed. */
|
|
46
54
|
export declare function addAppChildOps(appId: UnpackedHypermediaId, content: HMBlockNode[] | undefined, child: UnpackedHypermediaId): DocumentOperation[];
|
|
47
55
|
/** Ops that drop `child` from an app's list, or none when it is not listed. */
|
package/dist/apps.mjs
CHANGED
|
@@ -29,6 +29,10 @@ import { CID } from "multiformats/cid";
|
|
|
29
29
|
var HM_APP_TYPE = "hm://hyper.media/app";
|
|
30
30
|
var HM_TOOL_TYPE = "hm://hyper.media/tool";
|
|
31
31
|
var HM_PAGE_TYPE = "hm://hyper.media/page";
|
|
32
|
+
var HM_AGENT_TYPE = "hm://hyper.media/agent";
|
|
33
|
+
function isToolHostType(type) {
|
|
34
|
+
return type === HM_APP_TYPE || type === HM_AGENT_TYPE;
|
|
35
|
+
}
|
|
32
36
|
var TOOL_ENTRY_FILE = "index.ts";
|
|
33
37
|
var TOOL_CODE_TEMPLATE = `export default async function (input) {
|
|
34
38
|
return {}
|
|
@@ -87,6 +91,12 @@ function appChildrenOps(appId, content, children) {
|
|
|
87
91
|
const rest = (content ?? []).filter((node) => !childBlockIds.has(node.block.id ?? "")).map((node) => hmBlockNodeToBlockNode(node));
|
|
88
92
|
return computeReplaceOps(createBlocksMap(oldNodes), [...listed, ...rest]);
|
|
89
93
|
}
|
|
94
|
+
function replaceContentOps(before, after) {
|
|
95
|
+
return computeReplaceOps(
|
|
96
|
+
createBlocksMap((before ?? []).map((node) => toAPIBlockNode(node))),
|
|
97
|
+
after.map((node) => hmBlockNodeToBlockNode(node))
|
|
98
|
+
);
|
|
99
|
+
}
|
|
90
100
|
function addAppChildOps(appId, content, child) {
|
|
91
101
|
const listed = appEmbeddedChildren(appId, content).map((entry) => entry.id);
|
|
92
102
|
if (listed.some((id) => packHmId(id) === packHmId(versionless(child)))) return [];
|
|
@@ -155,6 +165,7 @@ function newBlockId() {
|
|
|
155
165
|
return Array.from(bytes, (byte) => alphabet[byte & 63]).join("");
|
|
156
166
|
}
|
|
157
167
|
export {
|
|
168
|
+
HM_AGENT_TYPE,
|
|
158
169
|
HM_APP_TYPE,
|
|
159
170
|
HM_PAGE_TYPE,
|
|
160
171
|
HM_TOOL_TYPE,
|
|
@@ -166,6 +177,8 @@ export {
|
|
|
166
177
|
appEmbeddedChildren,
|
|
167
178
|
createDocumentUpdateBlobs,
|
|
168
179
|
isAppChildId,
|
|
180
|
+
isToolHostType,
|
|
169
181
|
parentDocumentId,
|
|
170
|
-
removeAppChildOps
|
|
182
|
+
removeAppChildOps,
|
|
183
|
+
replaceContentOps
|
|
171
184
|
};
|