@neta-art/cohub 8.12.1 → 8.14.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 +7 -5
- package/dist/chunks/environment.d.ts +16 -3
- package/dist/chunks/environment.js +15 -1
- package/dist/chunks/http.d.ts +103 -9
- package/dist/chunks/http.js +44 -1
- package/dist/chunks/websocket.d.ts +1 -1
- package/dist/http.d.ts +3 -3
- package/dist/http.js +2 -2
- package/dist/index.d.ts +36 -6
- package/dist/index.js +472 -83
- package/dist/space-picker.d.ts +27 -0
- package/dist/space-picker.js +35 -0
- package/docs/app-runtime-guide.md +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/space-picker.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Framework-agnostic Space picker model: pure filtering, search, and ordering
|
|
4
|
+
* shared by every host's consent dialog and Space chooser. Hosts supply their
|
|
5
|
+
* own recency signal; this module never touches storage.
|
|
6
|
+
*/
|
|
7
|
+
type SpacePickerFilter = "recent" | "all" | "mine" | "pinned";
|
|
8
|
+
type SpacePickerItem = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string | null;
|
|
11
|
+
ownerUserUuid?: string | null;
|
|
12
|
+
isPinned?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type SpacePickerOptions = {
|
|
15
|
+
filter: SpacePickerFilter;
|
|
16
|
+
query?: string;
|
|
17
|
+
viewerUserUuid?: string | null;
|
|
18
|
+
/** Space ids ordered by most-recently visited first. */
|
|
19
|
+
recentSpaceIds?: readonly string[];
|
|
20
|
+
limit?: number;
|
|
21
|
+
};
|
|
22
|
+
declare function normalizeSpacePickerQuery(value: string): string;
|
|
23
|
+
declare function orderSpacePickerItems<T extends SpacePickerItem>(items: readonly T[], recentSpaceIds?: readonly string[]): T[];
|
|
24
|
+
declare function filterSpacePickerItems<T extends SpacePickerItem>(items: readonly T[], options: SpacePickerOptions): T[];
|
|
25
|
+
declare function selectSpacePickerItems<T extends SpacePickerItem>(items: readonly T[], options: SpacePickerOptions): T[];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { SpacePickerFilter, SpacePickerItem, SpacePickerOptions, filterSpacePickerItems, normalizeSpacePickerQuery, orderSpacePickerItems, selectSpacePickerItems };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/space-picker.ts
|
|
2
|
+
function normalizeSpacePickerQuery(value) {
|
|
3
|
+
return value.trim().toLocaleLowerCase();
|
|
4
|
+
}
|
|
5
|
+
function orderSpacePickerItems(items, recentSpaceIds = []) {
|
|
6
|
+
const recentIndex = new Map(recentSpaceIds.map((id, index) => [id, index]));
|
|
7
|
+
return [...items].sort((a, b) => {
|
|
8
|
+
const recentA = recentIndex.get(a.id);
|
|
9
|
+
const recentB = recentIndex.get(b.id);
|
|
10
|
+
if (recentA !== void 0 || recentB !== void 0) {
|
|
11
|
+
if (recentA === void 0) return 1;
|
|
12
|
+
if (recentB === void 0) return -1;
|
|
13
|
+
return recentA - recentB;
|
|
14
|
+
}
|
|
15
|
+
return (a.name ?? a.id).localeCompare(b.name ?? b.id);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function filterSpacePickerItems(items, options) {
|
|
19
|
+
const recentIds = new Set(options.recentSpaceIds ?? []);
|
|
20
|
+
const effectiveFilter = options.filter === "recent" && recentIds.size === 0 ? "all" : options.filter;
|
|
21
|
+
const normalizedQuery = normalizeSpacePickerQuery(options.query ?? "");
|
|
22
|
+
return items.filter((item) => {
|
|
23
|
+
if (effectiveFilter === "mine" && item.ownerUserUuid !== options.viewerUserUuid) return false;
|
|
24
|
+
if (effectiveFilter === "pinned" && !item.isPinned) return false;
|
|
25
|
+
if (effectiveFilter === "recent" && !recentIds.has(item.id)) return false;
|
|
26
|
+
if (!normalizedQuery) return true;
|
|
27
|
+
return normalizeSpacePickerQuery(item.name ?? item.id).includes(normalizedQuery);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function selectSpacePickerItems(items, options) {
|
|
31
|
+
const ordered = orderSpacePickerItems(filterSpacePickerItems(items, options), options.recentSpaceIds ?? []);
|
|
32
|
+
return options.limit === void 0 ? ordered : ordered.slice(0, options.limit);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { filterSpacePickerItems, normalizeSpacePickerQuery, orderSpacePickerItems, selectSpacePickerItems };
|
|
@@ -65,7 +65,7 @@ These runtime-only APIs form the foundation; everything else is standard SDK:
|
|
|
65
65
|
|
|
66
66
|
| API | What it does | Returns |
|
|
67
67
|
|---|---|---|
|
|
68
|
-
| `client.context()` | Asks the host for the App's identity | `{ app, space, viewer?, invocation?, permissions }` or `null` |
|
|
68
|
+
| `client.context()` | Asks the host for the App's identity | `{ app, space, viewer?, invocation?, shell?, permissions }` or `null` |
|
|
69
69
|
| `client.auth.request({ scopes, reason, spaceId?, alwaysAsk? })` | Ensures the app holds these scopes; silent when a grant already covers them, consent dialog otherwise | `true` / `false` |
|
|
70
70
|
| `client.auth.requestSpace({ scopes, reason, alwaysAsk? })` | One consent: the viewer picks a Space and grants the scopes on it | `{ granted, space }` |
|
|
71
71
|
| `client.auth.requestCreateSpace({ scopes, space, reason })` | One consent: create a viewer-owned Space (`CreateSpaceInput`) and grant the scopes on it | `{ granted, space }` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.0",
|
|
4
4
|
"description": "Cohub SDK for spaces, sessions, boards, and realtime agent collaboration.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
"types": "./dist/debugger.d.ts",
|
|
46
46
|
"import": "./dist/debugger.js"
|
|
47
47
|
},
|
|
48
|
+
"./space-picker": {
|
|
49
|
+
"types": "./dist/space-picker.d.ts",
|
|
50
|
+
"import": "./dist/space-picker.js"
|
|
51
|
+
},
|
|
48
52
|
"./board": {
|
|
49
53
|
"types": "./dist/board/index.d.ts",
|
|
50
54
|
"import": "./dist/board/index.js"
|