@devvit/public-api 0.10.23-next-2024-06-18-de746495c.0 → 0.10.23-next-2024-06-18-ac263ba60.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useChannel.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/blocks/useChannel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,cAAc,
|
1
|
+
{"version":3,"file":"useChannel.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/blocks/useChannel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,cAAc,CA2H/E"}
|
@@ -5,6 +5,7 @@ import { Hook } from '../../../types/hooks.js';
|
|
5
5
|
import { ChannelStatus } from '../../../types/realtime.js';
|
6
6
|
export function makeUseChannelHook(reconciler) {
|
7
7
|
function useChannel(options) {
|
8
|
+
const debug = false;
|
8
9
|
const hookIndex = reconciler.currentHookIndex;
|
9
10
|
const currentState = reconciler.getCurrentComponentState();
|
10
11
|
const previousState = reconciler.getPreviousComponentState();
|
@@ -13,6 +14,8 @@ export function makeUseChannelHook(reconciler) {
|
|
13
14
|
const installationId = reconciler.metadata[Header.Installation]?.values[0];
|
14
15
|
assertNonNull(installationId, 'useChannel - installation is missing from Context');
|
15
16
|
async function send(data) {
|
17
|
+
if (debug)
|
18
|
+
console.debug('[realtime] sends', data);
|
16
19
|
const name = currentState[hookIndex].channel;
|
17
20
|
if (currentState[hookIndex].active) {
|
18
21
|
if (currentState[hookIndex].connected) {
|
@@ -28,6 +31,8 @@ export function makeUseChannelHook(reconciler) {
|
|
28
31
|
}
|
29
32
|
function subscribe() {
|
30
33
|
if (!currentState[hookIndex].active) {
|
34
|
+
if (debug)
|
35
|
+
console.debug('[realtime] subscribe');
|
31
36
|
const name = currentState[hookIndex].channel;
|
32
37
|
currentState[hookIndex].active = true;
|
33
38
|
reconciler.addRealtimeChannel(name);
|
@@ -35,6 +40,8 @@ export function makeUseChannelHook(reconciler) {
|
|
35
40
|
}
|
36
41
|
function unsubscribe() {
|
37
42
|
if (currentState[hookIndex].active) {
|
43
|
+
if (debug)
|
44
|
+
console.debug('[realtime] unsubscribe');
|
38
45
|
const name = currentState[hookIndex].channel;
|
39
46
|
currentState[hookIndex].active = false;
|
40
47
|
reconciler.removeRealtimeChannel(name);
|
@@ -45,14 +52,20 @@ export function makeUseChannelHook(reconciler) {
|
|
45
52
|
let result;
|
46
53
|
switch (event.status) {
|
47
54
|
case RealtimeSubscriptionStatus.REALTIME_SUBSCRIBED:
|
55
|
+
if (debug)
|
56
|
+
console.debug('[realtime] onSubscribed()');
|
48
57
|
currentState[hookIndex].connected = true;
|
49
58
|
result = options.onSubscribed?.();
|
50
59
|
break;
|
51
60
|
case RealtimeSubscriptionStatus.REALTIME_UNSUBSCRIBED:
|
61
|
+
if (debug)
|
62
|
+
console.debug('[realtime] onUnsubscribed()');
|
52
63
|
currentState[hookIndex].connected = false;
|
53
64
|
result = options.onUnsubscribed?.();
|
54
65
|
break;
|
55
66
|
default:
|
67
|
+
if (debug)
|
68
|
+
console.debug('[realtime] receives', event.event?.data);
|
56
69
|
result = options.onMessage(event.event?.data ?? {});
|
57
70
|
break;
|
58
71
|
}
|
package/meta.json
CHANGED
@@ -11378,7 +11378,7 @@
|
|
11378
11378
|
"format": "esm"
|
11379
11379
|
},
|
11380
11380
|
"src/devvit/internals/blocks/useChannel.ts": {
|
11381
|
-
"bytes":
|
11381
|
+
"bytes": 4798,
|
11382
11382
|
"imports": [
|
11383
11383
|
{
|
11384
11384
|
"path": "../protos/dist/index.js",
|
@@ -14317,7 +14317,7 @@
|
|
14317
14317
|
"bytesInOutput": 1181
|
14318
14318
|
},
|
14319
14319
|
"src/devvit/internals/blocks/useChannel.ts": {
|
14320
|
-
"bytesInOutput":
|
14320
|
+
"bytesInOutput": 4141
|
14321
14321
|
},
|
14322
14322
|
"src/apis/ui/helpers/getFormValues.ts": {
|
14323
14323
|
"bytesInOutput": 723
|
@@ -14539,7 +14539,7 @@
|
|
14539
14539
|
"bytesInOutput": 4450
|
14540
14540
|
}
|
14541
14541
|
},
|
14542
|
-
"bytes":
|
14542
|
+
"bytes": 15006659
|
14543
14543
|
}
|
14544
14544
|
}
|
14545
14545
|
}
|
package/meta.min.json
CHANGED
@@ -2608,7 +2608,7 @@
|
|
2608
2608
|
"format": "esm"
|
2609
2609
|
},
|
2610
2610
|
"src/devvit/internals/blocks/useChannel.ts": {
|
2611
|
-
"bytes":
|
2611
|
+
"bytes": 4798,
|
2612
2612
|
"imports": [
|
2613
2613
|
{
|
2614
2614
|
"path": "@devvit/protos",
|
@@ -4657,7 +4657,7 @@
|
|
4657
4657
|
"imports": [],
|
4658
4658
|
"exports": [],
|
4659
4659
|
"inputs": {},
|
4660
|
-
"bytes":
|
4660
|
+
"bytes": 1145866
|
4661
4661
|
},
|
4662
4662
|
"dist/public-api.min.js": {
|
4663
4663
|
"imports": [
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@devvit/public-api",
|
3
|
-
"version": "0.10.23-next-2024-06-18-
|
3
|
+
"version": "0.10.23-next-2024-06-18-ac263ba60.0",
|
4
4
|
"license": "BSD-3-Clause",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -30,8 +30,8 @@
|
|
30
30
|
},
|
31
31
|
"types": "./index.d.ts",
|
32
32
|
"dependencies": {
|
33
|
-
"@devvit/protos": "0.10.23-next-2024-06-18-
|
34
|
-
"@devvit/shared-types": "0.10.23-next-2024-06-18-
|
33
|
+
"@devvit/protos": "0.10.23-next-2024-06-18-ac263ba60.0",
|
34
|
+
"@devvit/shared-types": "0.10.23-next-2024-06-18-ac263ba60.0",
|
35
35
|
"base64-js": "1.5.1",
|
36
36
|
"clone-deep": "4.0.1",
|
37
37
|
"core-js": "3.27.2",
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"@ampproject/filesize": "4.3.0",
|
42
42
|
"@devvit/eslint-config": "0.10.22",
|
43
43
|
"@devvit/repo-tools": "0.10.22",
|
44
|
-
"@devvit/tsconfig": "0.10.23-next-2024-06-18-
|
44
|
+
"@devvit/tsconfig": "0.10.23-next-2024-06-18-ac263ba60.0",
|
45
45
|
"@microsoft/api-extractor": "7.41.0",
|
46
46
|
"@reddit/faceplate-ui": "11.3.3",
|
47
47
|
"@types/clone-deep": "4.0.1",
|
@@ -64,5 +64,5 @@
|
|
64
64
|
}
|
65
65
|
},
|
66
66
|
"source": "./src/index.ts",
|
67
|
-
"gitHead": "
|
67
|
+
"gitHead": "82ff71441b5ee1665fa133ad934fd73001396ce3"
|
68
68
|
}
|