@devvit/client 0.11.18-next-2025-06-18-22-55-08-ef205533e.0 → 0.11.18-next-2025-06-23-18-16-12-5cc8127bb.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.
@@ -1,5 +1,5 @@
1
1
  export { navigateTo } from './navigate-to.js';
2
- export { connectRealtime, disconnectRealtime } from './realtime.js';
2
+ export { connectRealtime } from './realtime.js';
3
3
  export { showForm } from './show-form.js';
4
4
  export { showToast, type Toast } from './show-toast.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
package/effects/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { navigateTo } from './navigate-to.js';
2
- export { connectRealtime, disconnectRealtime } from './realtime.js';
2
+ export { connectRealtime } from './realtime.js';
3
3
  export { showForm } from './show-form.js';
4
4
  export { showToast } from './show-toast.js';
@@ -9,19 +9,27 @@ type ConnectRealtimeOptions = {
9
9
  * Connects to a realtime channel for receiving messages.
10
10
  *
11
11
  * @param opts - Connection options including channel name and callbacks
12
- * @throws Error if channel is already connected or connection fails
12
+ * @returns A Connection object with a disconnect method
13
13
  */
14
- export declare const connectRealtime: (opts: Readonly<ConnectRealtimeOptions>) => Promise<void>;
14
+ export declare const connectRealtime: (opts: Readonly<ConnectRealtimeOptions>) => Promise<Connection>;
15
15
  /**
16
- * Disconnects from a realtime channel.
17
- *
18
- * This works by sending a list of all channels we want to remain subscribed to,
19
- * excluding the channel we want to disconnect from. The effect handler compares this
20
- * new list with existing subscriptions and triggers disconnect for any channel
21
- * that's no longer in the list.
22
- *
23
- * @param channel - The channel name to disconnect from
16
+ * Clears all connections. Used for testing purposes.
17
+ * @internal
24
18
  */
25
- export declare const disconnectRealtime: (channel: string) => Promise<void>;
19
+ export declare const __clearConnections: () => void;
20
+ declare class Connection {
21
+ #private;
22
+ constructor(opts: Readonly<ConnectRealtimeOptions>);
23
+ /**
24
+ * Disconnects from the realtime channel.
25
+ *
26
+ * This works by sending a list of all channels we want to remain subscribed to,
27
+ * excluding the channel we want to disconnect from. The effect handler compares this
28
+ * new list with existing subscriptions and triggers disconnect for any channel
29
+ * that's no longer in the list.
30
+ */
31
+ disconnect(): Promise<void>;
32
+ onMessage: (ev: MessageEvent) => void;
33
+ }
26
34
  export {};
27
35
  //# sourceMappingURL=realtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../src/effects/realtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC,CAAC;AAQF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,MAAM,QAAQ,CAAC,sBAAsB,CAAC,KAAG,OAAO,CAAC,IAAI,CAW1F,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CAatE,CAAC"}
1
+ {"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../src/effects/realtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC,CAAC;AAQF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,QAAQ,CAAC,sBAAsB,CAAC,KACrC,OAAO,CAAC,UAAU,CAepB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,IAErC,CAAC;AAEF,cAAM,UAAU;;gBAGF,IAAI,EAAE,QAAQ,CAAC,sBAAsB,CAAC;IAIlD;;;;;;;OAOG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBjC,SAAS,GAAI,IAAI,YAAY,KAAG,IAAI,CAgClC;CACH"}
@@ -19,11 +19,12 @@ const connectionsByChannel = new Map();
19
19
  * Connects to a realtime channel for receiving messages.
20
20
  *
21
21
  * @param opts - Connection options including channel name and callbacks
22
- * @throws Error if channel is already connected or connection fails
22
+ * @returns A Connection object with a disconnect method
23
23
  */
24
24
  export const connectRealtime = async (opts) => {
25
- if (connectionsByChannel.has(opts.channel))
26
- return;
25
+ if (connectionsByChannel.has(opts.channel)) {
26
+ return connectionsByChannel.get(opts.channel);
27
+ }
27
28
  const connection = new Connection(opts);
28
29
  connectionsByChannel.set(opts.channel, connection);
29
30
  addEventListener('message', connection.onMessage);
@@ -31,29 +32,14 @@ export const connectRealtime = async (opts) => {
31
32
  realtimeSubscriptions: { subscriptionIds: [...connectionsByChannel.keys()] },
32
33
  type: 0,
33
34
  });
35
+ return connection;
34
36
  };
35
37
  /**
36
- * Disconnects from a realtime channel.
37
- *
38
- * This works by sending a list of all channels we want to remain subscribed to,
39
- * excluding the channel we want to disconnect from. The effect handler compares this
40
- * new list with existing subscriptions and triggers disconnect for any channel
41
- * that's no longer in the list.
42
- *
43
- * @param channel - The channel name to disconnect from
38
+ * Clears all connections. Used for testing purposes.
39
+ * @internal
44
40
  */
45
- export const disconnectRealtime = async (channel) => {
46
- const connection = connectionsByChannel.get(channel);
47
- if (!connection) {
48
- return;
49
- }
50
- // Get all current subscriptions except the one we're disconnecting
51
- const remainingChannels = [...connectionsByChannel.keys()].filter((ch) => ch !== channel);
52
- await emitEffect({
53
- realtimeSubscriptions: { subscriptionIds: remainingChannels },
54
- type: 0,
55
- });
56
- connectionsByChannel.delete(channel);
41
+ export const __clearConnections = () => {
42
+ connectionsByChannel.clear();
57
43
  };
58
44
  class Connection {
59
45
  constructor(opts) {
@@ -90,5 +76,26 @@ class Connection {
90
76
  };
91
77
  __classPrivateFieldSet(this, _Connection_opts, opts, "f");
92
78
  }
79
+ /**
80
+ * Disconnects from the realtime channel.
81
+ *
82
+ * This works by sending a list of all channels we want to remain subscribed to,
83
+ * excluding the channel we want to disconnect from. The effect handler compares this
84
+ * new list with existing subscriptions and triggers disconnect for any channel
85
+ * that's no longer in the list.
86
+ */
87
+ async disconnect() {
88
+ const connection = connectionsByChannel.get(__classPrivateFieldGet(this, _Connection_opts, "f").channel);
89
+ if (!connection) {
90
+ return;
91
+ }
92
+ // Get all current subscriptions except the one we're disconnecting
93
+ const remainingChannels = [...connectionsByChannel.keys()].filter((ch) => ch !== __classPrivateFieldGet(this, _Connection_opts, "f").channel);
94
+ await emitEffect({
95
+ realtimeSubscriptions: { subscriptionIds: remainingChannels },
96
+ type: 0,
97
+ });
98
+ connectionsByChannel.delete(__classPrivateFieldGet(this, _Connection_opts, "f").channel);
99
+ }
93
100
  }
94
101
  _Connection_opts = new WeakMap();
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { context } from './context.js';
2
- export { connectRealtime, disconnectRealtime, navigateTo, showForm, showToast, } from './effects/index.js';
2
+ export { connectRealtime, navigateTo, showForm, showToast } from './effects/index.js';
3
3
  export { type Toast } from './effects/show-toast.js';
4
4
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC"}
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { context } from './context.js';
2
- export { connectRealtime, disconnectRealtime, navigateTo, showForm, showToast, } from './effects/index.js';
2
+ export { connectRealtime, navigateTo, showForm, showToast } from './effects/index.js';
3
3
  export {} from './effects/show-toast.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/client",
3
- "version": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0",
3
+ "version": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,15 +25,15 @@
25
25
  },
26
26
  "types": "./index.d.ts",
27
27
  "dependencies": {
28
- "@devvit/protos": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0",
29
- "@devvit/reddit": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0",
30
- "@devvit/shared-types": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0",
31
- "@devvit/web-view-scripts": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0"
28
+ "@devvit/protos": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0",
29
+ "@devvit/reddit": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0",
30
+ "@devvit/shared-types": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0",
31
+ "@devvit/web-view-scripts": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@ampproject/filesize": "4.3.0",
35
- "@devvit/repo-tools": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0",
36
- "@devvit/tsconfig": "0.11.18-next-2025-06-18-22-55-08-ef205533e.0",
35
+ "@devvit/repo-tools": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0",
36
+ "@devvit/tsconfig": "0.11.18-next-2025-06-23-18-16-12-5cc8127bb.0",
37
37
  "esbuild": "0.23.0",
38
38
  "eslint": "9.11.1",
39
39
  "typescript": "5.8.3",
@@ -49,5 +49,5 @@
49
49
  }
50
50
  },
51
51
  "source": "./src/index.ts",
52
- "gitHead": "777f4e189f3889b68a4bbc1a0a2e8c96a81f949c"
52
+ "gitHead": "0b01d659306d7978c4842120b06da401731ff46f"
53
53
  }