@gryt/core 0.7.0 → 0.8.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/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export { inviteLink, isPublicHost, normalizeCode, normalizeHost, parseServerInpu
|
|
|
7
7
|
export { NAME_POOL, pickRandomName } from "./profile/randomName.js";
|
|
8
8
|
export { cellState, CUSTOM_VALUE, describeRules, EVERYONE_VALUE, indexRules, nextCellState, scopeChoiceFromValue, scopeChoiceValue, scopeOptions, scopeSetPayload, withCell, type CellState, type ChannelRule, type RuleEffect, type ScopeChoice, } from "./permissions/channelRules.js";
|
|
9
9
|
export { groupMembersByRole, OFFLINE_GROUP_KEY, UNGROUPED_GROUP_KEY, type GroupableMember, type GroupableRole, type MemberGroup, } from "./members/groups.js";
|
|
10
|
+
export { senderStreamId } from "./webrtc/senderStreamId.js";
|
|
11
|
+
export { describeFolderRules, folderFollowNote, folderPhrase, } from "./permissions/folderRules.js";
|
package/dist/index.js
CHANGED
|
@@ -9,3 +9,5 @@ export { inviteLink, isPublicHost, normalizeCode, normalizeHost, parseServerInpu
|
|
|
9
9
|
export { NAME_POOL, pickRandomName } from "./profile/randomName.js";
|
|
10
10
|
export { cellState, CUSTOM_VALUE, describeRules, EVERYONE_VALUE, indexRules, nextCellState, scopeChoiceFromValue, scopeChoiceValue, scopeOptions, scopeSetPayload, withCell, } from "./permissions/channelRules.js";
|
|
11
11
|
export { groupMembersByRole, OFFLINE_GROUP_KEY, UNGROUPED_GROUP_KEY, } from "./members/groups.js";
|
|
12
|
+
export { senderStreamId } from "./webrtc/senderStreamId.js";
|
|
13
|
+
export { describeFolderRules, folderFollowNote, folderPhrase, } from "./permissions/folderRules.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChannelRule } from "./channelRules.js";
|
|
2
|
+
/** "the X folder", or "its folder" when nothing is named. */
|
|
3
|
+
export declare function folderPhrase(folderName: string | null): string;
|
|
4
|
+
/** Shown once a channel has permissions of its own instead of following its folder. */
|
|
5
|
+
export declare function folderFollowNote(folderName: string | null): string;
|
|
6
|
+
/**
|
|
7
|
+
* The folder's half of `describeRules`: reading denied here hides the folder
|
|
8
|
+
* along with every channel in it that follows it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function describeFolderRules(rules: ChannelRule[], roleNames: Map<string, string>): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** "the X folder", or "its folder" when nothing is named. */
|
|
2
|
+
export function folderPhrase(folderName) {
|
|
3
|
+
return folderName ? `the ${folderName} folder` : "its folder";
|
|
4
|
+
}
|
|
5
|
+
/** Shown once a channel has permissions of its own instead of following its folder. */
|
|
6
|
+
export function folderFollowNote(folderName) {
|
|
7
|
+
return `Has its own permissions instead of ${folderPhrase(folderName)}'s.`;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The folder's half of `describeRules`: reading denied here hides the folder
|
|
11
|
+
* along with every channel in it that follows it.
|
|
12
|
+
*/
|
|
13
|
+
export function describeFolderRules(rules, roleNames) {
|
|
14
|
+
if (rules.length === 0) {
|
|
15
|
+
return "Everyone on the server can see and use the channels in this folder.";
|
|
16
|
+
}
|
|
17
|
+
const hidden = rules
|
|
18
|
+
.filter((r) => r.permission === "read_messages" && r.effect === "deny")
|
|
19
|
+
.map((r) => roleNames.get(r.roleId) ?? r.roleId);
|
|
20
|
+
const others = rules.filter((r) => r.permission !== "read_messages").length;
|
|
21
|
+
if (hidden.length === 0) {
|
|
22
|
+
return `${others} change${others === 1 ? "" : "s"} to what roles can do in this folder's channels.`;
|
|
23
|
+
}
|
|
24
|
+
const list = hidden.length === 1
|
|
25
|
+
? hidden[0]
|
|
26
|
+
: `${hidden.slice(0, -1).join(", ")} and ${hidden[hidden.length - 1]}`;
|
|
27
|
+
const rest = others > 0 ? `, and ${others} other change${others === 1 ? "" : "s"}` : "";
|
|
28
|
+
return `${list} won't see this folder or anything in it${rest}.`;
|
|
29
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stream id for a role: the first one given on this connection, kept in place
|
|
3
|
+
* across a `replaceTrack` swap. With no connection, `streamId` is returned unchanged.
|
|
4
|
+
*/
|
|
5
|
+
export declare function senderStreamId<Role extends string>(pc: object | null | undefined, role: Role, streamId: string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Keyed by connection, so a reconnect — a new connection object — starts over. */
|
|
2
|
+
const byConnection = new WeakMap();
|
|
3
|
+
/**
|
|
4
|
+
* The stream id for a role: the first one given on this connection, kept in place
|
|
5
|
+
* across a `replaceTrack` swap. With no connection, `streamId` is returned unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export function senderStreamId(pc, role, streamId) {
|
|
8
|
+
if (!pc)
|
|
9
|
+
return streamId;
|
|
10
|
+
let ids = byConnection.get(pc);
|
|
11
|
+
if (!ids) {
|
|
12
|
+
ids = {};
|
|
13
|
+
byConnection.set(pc, ids);
|
|
14
|
+
}
|
|
15
|
+
return (ids[role] ??= streamId);
|
|
16
|
+
}
|
package/package.json
CHANGED