fauna-api 0.0.0-stage → 1.0.676

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 (171) hide show
  1. package/dist/brands.d.ts +2 -0
  2. package/dist/brands.js +2 -0
  3. package/dist/index.d.ts +64 -0
  4. package/dist/index.js +121 -0
  5. package/dist/src/ant/chat.d.ts +130 -0
  6. package/dist/src/ant/chat.js +467 -0
  7. package/dist/src/ant/format.d.ts +40 -0
  8. package/dist/src/ant/format.js +143 -0
  9. package/dist/src/ant/graph.d.ts +130 -0
  10. package/dist/src/ant/graph.js +449 -0
  11. package/dist/src/ant/index.d.ts +16 -0
  12. package/dist/src/ant/index.js +61 -0
  13. package/dist/src/ant/persona.d.ts +151 -0
  14. package/dist/src/ant/persona.js +136 -0
  15. package/dist/src/ant/timeline.d.ts +283 -0
  16. package/dist/src/ant/timeline.js +1025 -0
  17. package/dist/src/authentification.d.ts +45 -0
  18. package/dist/src/authentification.js +194 -0
  19. package/dist/src/billing.d.ts +135 -0
  20. package/dist/src/billing.js +128 -0
  21. package/dist/src/calendar.d.ts +83 -0
  22. package/dist/src/calendar.js +133 -0
  23. package/dist/src/chats.d.ts +113 -0
  24. package/dist/src/chats.js +100 -0
  25. package/dist/src/cicada/contacts.d.ts +31 -0
  26. package/dist/src/cicada/contacts.js +28 -0
  27. package/dist/src/cicada/conversations.d.ts +73 -0
  28. package/dist/src/cicada/conversations.js +236 -0
  29. package/dist/src/cicada/inboxes.d.ts +48 -0
  30. package/dist/src/cicada/inboxes.js +82 -0
  31. package/dist/src/cicada/index.d.ts +16 -0
  32. package/dist/src/cicada/index.js +61 -0
  33. package/dist/src/cicada/phone.d.ts +48 -0
  34. package/dist/src/cicada/phone.js +306 -0
  35. package/dist/src/drive.d.ts +80 -0
  36. package/dist/src/drive.js +472 -0
  37. package/dist/src/extensions/index.d.ts +4 -0
  38. package/dist/src/extensions/index.js +5 -0
  39. package/dist/src/extensions/web/index.d.ts +6 -0
  40. package/dist/src/extensions/web/index.js +7 -0
  41. package/dist/src/extensions/web/session.d.ts +106 -0
  42. package/dist/src/extensions/web/session.js +469 -0
  43. package/dist/src/extensions/web/tools.d.ts +13 -0
  44. package/dist/src/extensions/web/tools.js +72 -0
  45. package/dist/src/friends.d.ts +39 -0
  46. package/dist/src/friends.js +119 -0
  47. package/dist/src/groups.d.ts +82 -0
  48. package/dist/src/groups.js +269 -0
  49. package/dist/src/inbox.d.ts +11 -0
  50. package/dist/src/inbox.js +35 -0
  51. package/dist/src/integrations.d.ts +52 -0
  52. package/dist/src/integrations.js +205 -0
  53. package/dist/src/magpie/explorer.d.ts +14 -0
  54. package/dist/src/magpie/explorer.js +36 -0
  55. package/dist/src/magpie/index.d.ts +16 -0
  56. package/dist/src/magpie/index.js +61 -0
  57. package/dist/src/magpie/portfolio.d.ts +52 -0
  58. package/dist/src/magpie/portfolio.js +179 -0
  59. package/dist/src/magpie/quotes.d.ts +35 -0
  60. package/dist/src/magpie/quotes.js +47 -0
  61. package/dist/src/magpie/room.d.ts +61 -0
  62. package/dist/src/magpie/room.js +238 -0
  63. package/dist/src/maps.d.ts +159 -0
  64. package/dist/src/maps.js +171 -0
  65. package/dist/src/marmot/browser.d.ts +139 -0
  66. package/dist/src/marmot/browser.js +389 -0
  67. package/dist/src/marmot/index.d.ts +20 -0
  68. package/dist/src/marmot/index.js +65 -0
  69. package/dist/src/marmot/media.d.ts +56 -0
  70. package/dist/src/marmot/media.js +265 -0
  71. package/dist/src/marmot/research.d.ts +337 -0
  72. package/dist/src/marmot/research.js +1138 -0
  73. package/dist/src/marmot/scraper.d.ts +59 -0
  74. package/dist/src/marmot/scraper.js +94 -0
  75. package/dist/src/marmot/web.d.ts +402 -0
  76. package/dist/src/marmot/web.js +2586 -0
  77. package/dist/src/marmot/workspace.d.ts +81 -0
  78. package/dist/src/marmot/workspace.js +263 -0
  79. package/dist/src/parrot/agent.d.ts +53 -0
  80. package/dist/src/parrot/agent.js +93 -0
  81. package/dist/src/parrot/chat.d.ts +84 -0
  82. package/dist/src/parrot/chat.js +237 -0
  83. package/dist/src/parrot/format.d.ts +128 -0
  84. package/dist/src/parrot/format.js +639 -0
  85. package/dist/src/parrot/generative.d.ts +261 -0
  86. package/dist/src/parrot/generative.js +185 -0
  87. package/dist/src/parrot/index.d.ts +22 -0
  88. package/dist/src/parrot/index.js +67 -0
  89. package/dist/src/parrot/room.d.ts +225 -0
  90. package/dist/src/parrot/room.js +466 -0
  91. package/dist/src/parrot/routing.d.ts +90 -0
  92. package/dist/src/parrot/routing.js +78 -0
  93. package/dist/src/parrot/share.d.ts +126 -0
  94. package/dist/src/parrot/share.js +261 -0
  95. package/dist/src/parrot/socket.d.ts +41 -0
  96. package/dist/src/parrot/socket.js +478 -0
  97. package/dist/src/payments.d.ts +73 -0
  98. package/dist/src/payments.js +107 -0
  99. package/dist/src/private/cards.css +75 -0
  100. package/dist/src/rooms.d.ts +76 -0
  101. package/dist/src/rooms.js +168 -0
  102. package/dist/src/shared/schema.d.ts +24 -0
  103. package/dist/src/shared/schema.js +1 -0
  104. package/dist/src/shared/server.d.ts +65 -0
  105. package/dist/src/shared/server.js +302 -0
  106. package/dist/src/termite/environment.d.ts +110 -0
  107. package/dist/src/termite/environment.js +263 -0
  108. package/dist/src/termite/index.d.ts +14 -0
  109. package/dist/src/termite/index.js +59 -0
  110. package/dist/src/termite/os.d.ts +326 -0
  111. package/dist/src/termite/os.js +572 -0
  112. package/dist/src/termite/versioning.d.ts +94 -0
  113. package/dist/src/termite/versioning.js +217 -0
  114. package/dist/src/tickets.d.ts +43 -0
  115. package/dist/src/tickets.js +138 -0
  116. package/dist/src/travel.d.ts +85 -0
  117. package/dist/src/travel.js +44 -0
  118. package/dist/src/ui/authentification.d.ts +24 -0
  119. package/dist/src/ui/authentification.js +177 -0
  120. package/dist/src/ui/brands.css +11 -0
  121. package/dist/src/ui/brands.d.ts +7 -0
  122. package/dist/src/ui/brands.js +14 -0
  123. package/dist/src/ui/browser.d.ts +74 -0
  124. package/dist/src/ui/browser.js +470 -0
  125. package/dist/src/ui/chat.d.ts +183 -0
  126. package/dist/src/ui/chat.js +2379 -0
  127. package/dist/src/ui/chatPanel.d.ts +109 -0
  128. package/dist/src/ui/chatPanel.js +768 -0
  129. package/dist/src/ui/chatSequence.d.ts +36 -0
  130. package/dist/src/ui/chatSequence.js +42 -0
  131. package/dist/src/ui/crown.d.ts +19 -0
  132. package/dist/src/ui/crown.js +199 -0
  133. package/dist/src/ui/cursor.d.ts +73 -0
  134. package/dist/src/ui/cursor.js +175 -0
  135. package/dist/src/ui/device.d.ts +33 -0
  136. package/dist/src/ui/device.js +49 -0
  137. package/dist/src/ui/drive.d.ts +69 -0
  138. package/dist/src/ui/drive.js +1243 -0
  139. package/dist/src/ui/generative.d.ts +39 -0
  140. package/dist/src/ui/generative.js +313 -0
  141. package/dist/src/ui/hover.d.ts +6 -0
  142. package/dist/src/ui/hover.js +210 -0
  143. package/dist/src/ui/index.d.ts +42 -0
  144. package/dist/src/ui/index.js +87 -0
  145. package/dist/src/ui/integrations.d.ts +13 -0
  146. package/dist/src/ui/integrations.js +175 -0
  147. package/dist/src/ui/maps.d.ts +87 -0
  148. package/dist/src/ui/maps.js +547 -0
  149. package/dist/src/ui/roster.d.ts +32 -0
  150. package/dist/src/ui/roster.js +163 -0
  151. package/dist/src/ui/talk.d.ts +12 -0
  152. package/dist/src/ui/talk.js +560 -0
  153. package/dist/src/ui/tickets.d.ts +13 -0
  154. package/dist/src/ui/tickets.js +966 -0
  155. package/dist/src/ui/toast.d.ts +7 -0
  156. package/dist/src/ui/toast.js +258 -0
  157. package/dist/src/ui/tokenText.d.ts +18 -0
  158. package/dist/src/ui/tokenText.js +96 -0
  159. package/dist/src/ui/tokenized.d.ts +42 -0
  160. package/dist/src/ui/tokenized.js +622 -0
  161. package/dist/src/ui/ui.css +4763 -0
  162. package/dist/src/ui/view.d.ts +23 -0
  163. package/dist/src/ui/view.js +584 -0
  164. package/dist/src/view.d.ts +113 -0
  165. package/dist/src/view.js +386 -0
  166. package/dist/src/webhooks.d.ts +66 -0
  167. package/dist/src/webhooks.js +78 -0
  168. package/dist/ui.d.ts +1 -0
  169. package/dist/ui.js +1 -0
  170. package/package.json +89 -6
  171. package/README.md +0 -3
@@ -0,0 +1,75 @@
1
+ /* The card for links to another Fauna product. Sites theme it through --product-card-*. */
2
+ .product-card {
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ z-index: 1000;
7
+ display: flex;
8
+ align-items: center;
9
+ gap: 12px;
10
+ width: max-content;
11
+ max-width: min(330px, calc(100vw - 24px));
12
+ padding: 12px 16px 12px 12px;
13
+ border: 1px solid var(--product-card-border, rgba(255, 255, 255, 0.1));
14
+ border-radius: var(--product-card-radius, 14px);
15
+ background: var(--product-card-background, #151515);
16
+ box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.65);
17
+ color: var(--product-card-color, #f5f3ea);
18
+ font-family: var(--product-card-font, inherit);
19
+ font-size: 14px;
20
+ line-height: 1.35;
21
+ text-align: left;
22
+ pointer-events: none;
23
+ visibility: hidden;
24
+ opacity: 0;
25
+ transition: opacity 0.15s ease, visibility 0.15s;
26
+ }
27
+ .product-card.is-open {
28
+ visibility: visible;
29
+ opacity: 1;
30
+ }
31
+ .product-card-icon {
32
+ flex: none;
33
+ display: block;
34
+ width: 40px;
35
+ height: 40px;
36
+ border-radius: 26%;
37
+ }
38
+ .product-card-icon[hidden] {
39
+ display: none;
40
+ }
41
+ .product-card-crown {
42
+ background: #151515;
43
+ box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
44
+ }
45
+ .product-card-text {
46
+ display: flex;
47
+ flex-direction: column;
48
+ min-width: 0;
49
+ }
50
+ .product-card-name {
51
+ font-size: 15px;
52
+ font-weight: 600;
53
+ }
54
+ .product-card-tagline {
55
+ color: var(--product-card-muted, rgba(245, 243, 234, 0.72));
56
+ }
57
+ .product-card-domain {
58
+ margin-top: 3px;
59
+ font-size: 12px;
60
+ color: var(--product-card-muted, rgba(245, 243, 234, 0.72));
61
+ opacity: 0.8;
62
+ }
63
+
64
+ /* Links to another product inside copy. */
65
+ a.product-ref {
66
+ color: inherit;
67
+ text-decoration: underline;
68
+ text-decoration-thickness: 1px;
69
+ text-underline-offset: 0.18em;
70
+ text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
71
+ transition: text-decoration-color 0.2s;
72
+ }
73
+ a.product-ref:hover {
74
+ text-decoration-color: currentColor;
75
+ }
@@ -0,0 +1,76 @@
1
+ import { ApiKey, Credentials, Profile } from "./authentification.js";
2
+ import { Presence, Room, Hooks as ServerHooks } from "./shared/server.js";
3
+ /** What a member may do: `read` sees the state, `write` can also set it. */
4
+ export type Role = 'read' | 'write';
5
+ /** Who is in a room: every member of a group, or one person by email. */
6
+ export type Member = ({
7
+ group: string;
8
+ } | {
9
+ email: string;
10
+ }) & {
11
+ role: Role;
12
+ };
13
+ /** A live room an app (or a person) owns. Everyone in it sees `state` change live. */
14
+ export type LiveRoom = {
15
+ id: string;
16
+ name: string;
17
+ members: Member[];
18
+ /** Any JSON, up to 256 KB, always set whole. Fauna never reads it. */
19
+ state: unknown;
20
+ /** Goes up by one with every state change. */
21
+ version: number;
22
+ created: Date;
23
+ updated: Date;
24
+ };
25
+ /** What `create` takes. Every field is optional. */
26
+ export type Draft = {
27
+ name?: string;
28
+ members?: Member[];
29
+ state?: unknown;
30
+ };
31
+ /** Someone in a room: their profile, and which of the room's groups they're in. */
32
+ export type Person = {
33
+ profile: Profile;
34
+ groups: string[];
35
+ };
36
+ /** Room hooks, plus `onState` whenever someone changes the state. */
37
+ export type Hooks = ServerHooks & Partial<{
38
+ onState(room: StateRoom, state: unknown, version: number): void;
39
+ }>;
40
+ /**
41
+ * Make a live room. Signed in with an API key, the key owns it; otherwise you do.
42
+ * Only the owner changes who is in it or deletes it.
43
+ */
44
+ export declare function create(authorization: Credentials | ApiKey, draft?: Draft): Promise<LiveRoom>;
45
+ /** A room you own or are a member of, with its state. */
46
+ export declare function get(authorization: Credentials | ApiKey, id: string): Promise<LiveRoom>;
47
+ /** Everyone in a room, each group's members listed. Anyone who can read the room. */
48
+ export declare function people(authorization: Credentials | ApiKey, id: string): Promise<Person[]>;
49
+ /** Replace who is in a room. Owner only. */
50
+ export declare function setMembers(authorization: Credentials | ApiKey, id: string, members: Member[]): Promise<LiveRoom>;
51
+ /**
52
+ * Replace a room's state; everyone in it sees the change. The owner and writers
53
+ * only. With `ifVersion`, it writes only while the room is still at that version.
54
+ * Resolves to the new version.
55
+ */
56
+ export declare function setState(authorization: Credentials | ApiKey, id: string, state: unknown, ifVersion?: number): Promise<number>;
57
+ /** Delete a room; everyone in it is disconnected. Owner only. */
58
+ export declare function remove(authorization: Credentials | ApiKey, id: string): Promise<void>;
59
+ /** A live room you are in: its state, kept current, and who else is here. */
60
+ export declare class StateRoom extends Room {
61
+ name: string;
62
+ state: unknown;
63
+ version: number;
64
+ /** What you may do here. The owner writes. */
65
+ role: Role;
66
+ hydrate(snapshot: any): void;
67
+ handleEvent(packet: any): boolean;
68
+ /** Replace the state for everyone here. Writers only; with `ifVersion`, only while the room is at that version. */
69
+ setState(state: unknown, ifVersion?: number): void;
70
+ static connect(authorization: Credentials | ApiKey, target: {
71
+ id: string;
72
+ }, hooks?: Hooks): Promise<{
73
+ room: StateRoom;
74
+ self: Presence;
75
+ }>;
76
+ }
@@ -0,0 +1,168 @@
1
+ import { Fauna } from "../index.js";
2
+ import { Room, connect as connectServer } from "./shared/server.js";
3
+ function hydrate(raw) {
4
+ return { ...raw, created: new Date(raw.created), updated: new Date(raw.updated) };
5
+ }
6
+ /**
7
+ * Make a live room. Signed in with an API key, the key owns it; otherwise you do.
8
+ * Only the owner changes who is in it or deletes it.
9
+ */
10
+ export async function create(authorization, draft = {}) {
11
+ const response = await fetch(`${Fauna.getURL()}/rooms`, {
12
+ method: "POST",
13
+ headers: {
14
+ "Content-Type": "application/json",
15
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
16
+ },
17
+ body: JSON.stringify(draft)
18
+ });
19
+ if (!response.ok) {
20
+ throw new Error(await response.text());
21
+ }
22
+ return hydrate(await response.json());
23
+ }
24
+ /** A room you own or are a member of, with its state. */
25
+ export async function get(authorization, id) {
26
+ const response = await fetch(`${Fauna.getURL()}/rooms/${encodeURIComponent(id)}`, {
27
+ method: "GET",
28
+ headers: {
29
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
30
+ }
31
+ });
32
+ if (!response.ok) {
33
+ throw new Error(await response.text());
34
+ }
35
+ return hydrate(await response.json());
36
+ }
37
+ /** Everyone in a room, each group's members listed. Anyone who can read the room. */
38
+ export async function people(authorization, id) {
39
+ const response = await fetch(`${Fauna.getURL()}/rooms/${encodeURIComponent(id)}/people`, {
40
+ method: "GET",
41
+ headers: {
42
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
43
+ }
44
+ });
45
+ if (!response.ok) {
46
+ throw new Error(await response.text());
47
+ }
48
+ return await response.json();
49
+ }
50
+ /** Replace who is in a room. Owner only. */
51
+ export async function setMembers(authorization, id, members) {
52
+ const response = await fetch(`${Fauna.getURL()}/rooms/${encodeURIComponent(id)}/members`, {
53
+ method: "PUT",
54
+ headers: {
55
+ "Content-Type": "application/json",
56
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
57
+ },
58
+ body: JSON.stringify({ members })
59
+ });
60
+ if (!response.ok) {
61
+ throw new Error(await response.text());
62
+ }
63
+ return hydrate(await response.json());
64
+ }
65
+ /**
66
+ * Replace a room's state; everyone in it sees the change. The owner and writers
67
+ * only. With `ifVersion`, it writes only while the room is still at that version.
68
+ * Resolves to the new version.
69
+ */
70
+ export async function setState(authorization, id, state, ifVersion) {
71
+ const response = await fetch(`${Fauna.getURL()}/rooms/${encodeURIComponent(id)}/state`, {
72
+ method: "PUT",
73
+ headers: {
74
+ "Content-Type": "application/json",
75
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
76
+ },
77
+ body: JSON.stringify({ state, ifVersion })
78
+ });
79
+ if (!response.ok) {
80
+ throw new Error(await response.text());
81
+ }
82
+ return (await response.json()).version;
83
+ }
84
+ /** Delete a room; everyone in it is disconnected. Owner only. */
85
+ export async function remove(authorization, id) {
86
+ const response = await fetch(`${Fauna.getURL()}/rooms/${encodeURIComponent(id)}`, {
87
+ method: "DELETE",
88
+ headers: {
89
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
90
+ }
91
+ });
92
+ if (!response.ok) {
93
+ throw new Error(await response.text());
94
+ }
95
+ }
96
+ /** A live room you are in: its state, kept current, and who else is here. */
97
+ export class StateRoom extends Room {
98
+ constructor() {
99
+ super(...arguments);
100
+ Object.defineProperty(this, "name", {
101
+ enumerable: true,
102
+ configurable: true,
103
+ writable: true,
104
+ value: ''
105
+ });
106
+ Object.defineProperty(this, "state", {
107
+ enumerable: true,
108
+ configurable: true,
109
+ writable: true,
110
+ value: null
111
+ });
112
+ Object.defineProperty(this, "version", {
113
+ enumerable: true,
114
+ configurable: true,
115
+ writable: true,
116
+ value: 0
117
+ });
118
+ /** What you may do here. The owner writes. */
119
+ Object.defineProperty(this, "role", {
120
+ enumerable: true,
121
+ configurable: true,
122
+ writable: true,
123
+ value: 'read'
124
+ });
125
+ }
126
+ hydrate(snapshot) {
127
+ if (!snapshot || typeof snapshot !== "object")
128
+ return;
129
+ this.name = snapshot.name ?? '';
130
+ this.state = snapshot.state ?? null;
131
+ this.version = Number(snapshot.version ?? 0);
132
+ this.role = snapshot.role === 'write' ? 'write' : 'read';
133
+ }
134
+ handleEvent(packet) {
135
+ if (packet?.event !== 'state')
136
+ return false;
137
+ this.state = packet.data?.state ?? null;
138
+ this.version = Number(packet.data?.version ?? this.version);
139
+ return true;
140
+ }
141
+ /** Replace the state for everyone here. Writers only; with `ifVersion`, only while the room is at that version. */
142
+ setState(state, ifVersion) {
143
+ this.post({ event: 'set-state', data: { state, ifVersion } });
144
+ }
145
+ static async connect(authorization, target, hooks) {
146
+ let room;
147
+ const user = hooks ?? {};
148
+ const self = await connectServer({ authorization, server: `fauna:live:${target.id}` }, `${Fauna.getURL()}/rooms/live`, {
149
+ ...user,
150
+ createRoom: (endpoint, ws, a, id, state) => {
151
+ room = (user.createRoom?.(endpoint, ws, a, id, state)
152
+ ?? new StateRoom(endpoint, ws, a, id));
153
+ return room;
154
+ },
155
+ onConnection: (r, state) => {
156
+ r.hydrate(state);
157
+ user.onConnection?.(r, state);
158
+ },
159
+ onEvent: (r, packet) => {
160
+ const handled = r.handleEvent(packet);
161
+ if (handled)
162
+ user.onState?.(r, r.state, r.version);
163
+ return user.onEvent?.(r, packet) ?? handled;
164
+ },
165
+ });
166
+ return { room, self };
167
+ }
168
+ }
@@ -0,0 +1,24 @@
1
+ export type Schema = ObjectSchema | ArraySchema | PrimitiveSchema;
2
+ export type ObjectSchema = {
3
+ type: 'OBJECT';
4
+ description?: string;
5
+ anyOf?: Schema[];
6
+ properties?: Record<string, Schema>;
7
+ required?: string[];
8
+ };
9
+ export type ArraySchema = {
10
+ type: 'ARRAY';
11
+ description?: string;
12
+ anyOf?: Schema[];
13
+ items?: Schema;
14
+ maximum?: number;
15
+ minimum?: number;
16
+ };
17
+ export type PrimitiveSchema = {
18
+ type: 'STRING' | 'NUMBER' | 'INTEGER' | 'BOOLEAN';
19
+ description?: string;
20
+ minimum?: number;
21
+ maximum?: number;
22
+ pattern?: string;
23
+ enum?: string[];
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ import { ApiKey, Credentials, Profile } from "../authentification.js";
2
+ export type Authorization = {
3
+ authorization: Credentials | ApiKey;
4
+ server: string;
5
+ group?: string;
6
+ } | {
7
+ authorization: Credentials | ApiKey;
8
+ accessCode: string;
9
+ };
10
+ export type Hooks = Partial<{
11
+ createRoom(endpoint: string, ws: WebSocket, authorization: Authorization, id: string, state: any): Room;
12
+ createPresence(room: Room, data: {
13
+ id: string;
14
+ profile: Profile;
15
+ } & Partial<{
16
+ position: [number, number, number];
17
+ status: string;
18
+ }>): Presence;
19
+ removePresence(room: Room, presence: Presence): void;
20
+ onConnection(room: Room, state: any): void;
21
+ onEvent(room: Room, packet: any): boolean;
22
+ /** Fired after the presence list changes (join / leave / update). */
23
+ onPresence(room: Room): void;
24
+ /** Room was destroyed (host left, empty reap, or TTL). Socket is closing. */
25
+ onClosed(room: Room, info?: {
26
+ reason?: string;
27
+ }): void;
28
+ }>;
29
+ export declare class Presence {
30
+ readonly room: Room;
31
+ readonly id: string;
32
+ readonly profile: Profile;
33
+ private _position;
34
+ private _status?;
35
+ constructor(room: Room, id: string, profile: Profile);
36
+ get position(): [number, number, number];
37
+ get status(): string;
38
+ move(position: [number, number, number]): void;
39
+ setStatus(status: string): void;
40
+ update(patch: Partial<{
41
+ position: [number, number, number];
42
+ status: string;
43
+ }>): void;
44
+ toJSON(): {
45
+ id: string;
46
+ profile: Profile;
47
+ position: [number, number, number];
48
+ status: string;
49
+ };
50
+ }
51
+ export declare class Room {
52
+ readonly endpoint: string;
53
+ readonly ws: WebSocket;
54
+ readonly authorization: Authorization;
55
+ readonly id: string;
56
+ protected presences: Presence[];
57
+ constructor(endpoint: string, ws: WebSocket, authorization: Authorization, id: string);
58
+ getPresences(): Presence[];
59
+ /** The caller's Credentials or ApiKey from the live authorization pack. */
60
+ getAuthorization(): Credentials | ApiKey;
61
+ post(packet: any): void;
62
+ disconnect(): void;
63
+ generateAccessCode(): Promise<string>;
64
+ }
65
+ export declare function connect(authorization: Authorization, endpoint: string, hooks?: Hooks): Promise<Presence>;