@devvit/client 0.11.18-next-2025-06-17-18-37-26-796bc421f.0 → 0.11.18-next-2025-06-17-21-41-57-eba065cfc.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/client-meta.min.json +4662 -42
- package/client.min.js +1 -1
- package/client.min.js.map +4 -4
- package/effects/{contants.d.ts → constants.d.ts} +1 -1
- package/effects/constants.d.ts.map +1 -0
- package/effects/emit-effect.d.ts +1 -1
- package/effects/emit-effect.d.ts.map +1 -1
- package/effects/emit-effect.js +10 -3
- package/effects/helpers/form-types.d.ts +7 -5
- package/effects/helpers/form-types.d.ts.map +1 -1
- package/effects/index.d.ts +1 -0
- package/effects/index.d.ts.map +1 -1
- package/effects/index.js +1 -0
- package/effects/realtime.d.ts +27 -0
- package/effects/realtime.d.ts.map +1 -0
- package/effects/realtime.js +94 -0
- package/effects/realtime.test.d.ts.map +1 -0
- package/effects/show-form.d.ts +1 -1
- package/effects/show-form.d.ts.map +1 -1
- package/effects/show-form.js +2 -3
- package/effects/types.d.ts +16 -17
- package/effects/types.d.ts.map +1 -1
- package/effects/types.js +1 -6
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/package.json +10 -10
- package/effects/contants.d.ts.map +0 -1
- /package/effects/{contants.js → constants.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/effects/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0DAA0D,CAAC;AAE3F,eAAO,MAAM,qBAAqB,EAAE,SAAS,UAAU,EAEtD,CAAC"}
|
package/effects/emit-effect.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effect } from '@devvit/protos';
|
|
2
|
-
import
|
|
2
|
+
import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
|
|
3
3
|
/**
|
|
4
4
|
* Emits an effect to the parent window and handles the response if required.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-effect.d.ts","sourceRoot":"","sources":["../../src/effects/emit-effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"emit-effect.d.ts","sourceRoot":"","sources":["../../src/effects/emit-effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AAIxG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAkC1F,CAAC"}
|
package/effects/emit-effect.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
|
|
2
|
+
import { EFFECTS_WITH_RESPONSE } from './constants.js';
|
|
2
3
|
/**
|
|
3
4
|
* Emits an effect to the parent window and handles the response if required.
|
|
4
5
|
*
|
|
@@ -17,15 +18,21 @@ export const emitEffect = (effect) => {
|
|
|
17
18
|
const message = {
|
|
18
19
|
scope: 0,
|
|
19
20
|
type: 'devvit-internal',
|
|
20
|
-
effect,
|
|
21
21
|
};
|
|
22
|
+
if (effect.realtimeSubscriptions) {
|
|
23
|
+
message.realtimeEffect = effect.realtimeSubscriptions;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
message.effect = effect;
|
|
27
|
+
}
|
|
22
28
|
// Only set message id and add a listener for effects which require a response
|
|
23
29
|
if (EFFECTS_WITH_RESPONSE.includes(effect.type)) {
|
|
24
30
|
const id = self.crypto.randomUUID();
|
|
25
31
|
message.id = id;
|
|
26
32
|
const handleEffect = (event) => {
|
|
27
33
|
if (event.data?.type === 'devvit-message' && event.data?.data?.id === id) {
|
|
28
|
-
|
|
34
|
+
const serializedMessage = WebViewInternalEventMessage.fromJSON(event.data.data);
|
|
35
|
+
resolve(serializedMessage);
|
|
29
36
|
window.removeEventListener('message', handleEffect);
|
|
30
37
|
}
|
|
31
38
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { FieldConfig_Boolean, FieldConfig_Number, FieldConfig_Paragraph, FieldConfig_Selection, FieldConfig_Selection_Item, FieldConfig_String } from '@devvit/protos';
|
|
2
|
+
import type { JSONObject } from '../types.js';
|
|
2
3
|
type Prettify<T> = {
|
|
3
4
|
[K in keyof T]: T[K];
|
|
4
5
|
};
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
6
|
+
export type FormAction = 'CANCELED' | 'SUBMITTED';
|
|
7
|
+
export type FormEffectResponse<T> = {
|
|
8
|
+
action: 'CANCELED';
|
|
9
|
+
} | {
|
|
10
|
+
action: 'SUBMITTED';
|
|
11
|
+
values: T;
|
|
8
12
|
};
|
|
9
|
-
type JSONArray = JSONValue[];
|
|
10
|
-
type JSONPrimitive = boolean | null | number | string;
|
|
11
13
|
export type FormValues = JSONObject;
|
|
12
14
|
export type BaseField<ValueType> = {
|
|
13
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-types.d.ts","sourceRoot":"","sources":["../../../src/effects/helpers/form-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"form-types.d.ts","sourceRoot":"","sources":["../../../src/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CAClC,GACG,oBAAoB,CAAC,KAAK,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,GAE1D;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAE3B,gEAAgE;AAChE,KAAK,oBAAoB,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,YAAY,GACnE;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO;CAAE,GAC7B,CAAC,SAAS,UAAU,GAAG,cAAc,GAAG,WAAW,GACjD,4BAA4B,CAAC,CAAC,EAAE,MAAM,CAAC,GACvC,CAAC,SAAS,WAAW,GACnB,4BAA4B,CAAC,CAAC,EAAE,MAAM,CAAC,GACvC,CAAC,SAAS,WAAW,GACnB;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE;CAAE,GAC9B,CAAC,SAAS,cAAc,GACtB,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GACnC,KAAK,CAAC;AAElB;;;GAGG;AACH,KAAK,4BAA4B,CAC/B,CAAC,SAAS,UAAU,GAAG,cAAc,GAAG,WAAW,GAAG,WAAW,EACjE,CAAC,IACC,CAAC,SAAS;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,YAAY,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,GAC1E;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;CAAE,GACvB;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;CAAE,CAAC"}
|
package/effects/index.d.ts
CHANGED
package/effects/index.d.ts.map
CHANGED
|
@@ -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,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,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
|
package/effects/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RealtimeEvent } from '@devvit/protos/types/devvit/events/v1alpha/realtime.js';
|
|
2
|
+
type ConnectRealtimeOptions = {
|
|
3
|
+
channel: string;
|
|
4
|
+
onConnect?: (channel: string) => void;
|
|
5
|
+
onDisconnect?: (channel: string) => void;
|
|
6
|
+
onMessage: (data: NonNullable<RealtimeEvent['data']>) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Connects to a realtime channel for receiving messages.
|
|
10
|
+
*
|
|
11
|
+
* @param opts - Connection options including channel name and callbacks
|
|
12
|
+
* @throws Error if channel is already connected or connection fails
|
|
13
|
+
*/
|
|
14
|
+
export declare const connectRealtime: (opts: Readonly<ConnectRealtimeOptions>) => Promise<void>;
|
|
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
|
|
24
|
+
*/
|
|
25
|
+
export declare const disconnectRealtime: (channel: string) => Promise<void>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=realtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../src/effects/realtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wDAAwD,CAAC;AAS5F,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,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC;CAC/D,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"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Connection_opts;
|
|
13
|
+
import { emitEffect } from './emit-effect.js';
|
|
14
|
+
const connectionsByChannel = new Map();
|
|
15
|
+
/* TODO: Clean up this API. Now that realtime has been removed from the
|
|
16
|
+
* EFFECTS_WITH_RESPONSE list, we probably don't need to await emitEffect.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Connects to a realtime channel for receiving messages.
|
|
20
|
+
*
|
|
21
|
+
* @param opts - Connection options including channel name and callbacks
|
|
22
|
+
* @throws Error if channel is already connected or connection fails
|
|
23
|
+
*/
|
|
24
|
+
export const connectRealtime = async (opts) => {
|
|
25
|
+
if (connectionsByChannel.has(opts.channel))
|
|
26
|
+
return;
|
|
27
|
+
const connection = new Connection(opts);
|
|
28
|
+
connectionsByChannel.set(opts.channel, connection);
|
|
29
|
+
addEventListener('message', connection.onMessage);
|
|
30
|
+
await emitEffect({
|
|
31
|
+
realtimeSubscriptions: { subscriptionIds: [...connectionsByChannel.keys()] },
|
|
32
|
+
type: 0,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
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
|
|
44
|
+
*/
|
|
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);
|
|
57
|
+
};
|
|
58
|
+
class Connection {
|
|
59
|
+
constructor(opts) {
|
|
60
|
+
_Connection_opts.set(this, void 0);
|
|
61
|
+
this.onMessage = (ev) => {
|
|
62
|
+
const { type, data } = ev.data;
|
|
63
|
+
if (type !== 'devvit-message') {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!data.realtimeEvent) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const { status, event } = data.realtimeEvent;
|
|
70
|
+
if (!event?.channel.endsWith(__classPrivateFieldGet(this, _Connection_opts, "f").channel)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Normalize the channel name (remove namespacing)
|
|
74
|
+
event.channel = __classPrivateFieldGet(this, _Connection_opts, "f").channel;
|
|
75
|
+
if (status === 0) {
|
|
76
|
+
__classPrivateFieldGet(this, _Connection_opts, "f").onConnect?.(__classPrivateFieldGet(this, _Connection_opts, "f").channel);
|
|
77
|
+
}
|
|
78
|
+
else if (status === 1) {
|
|
79
|
+
__classPrivateFieldGet(this, _Connection_opts, "f").onDisconnect?.(__classPrivateFieldGet(this, _Connection_opts, "f").channel);
|
|
80
|
+
}
|
|
81
|
+
else if (event.data) {
|
|
82
|
+
__classPrivateFieldGet(this, _Connection_opts, "f").onMessage(event.data);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.log('[realtime] Received event without data:', {
|
|
86
|
+
channel: __classPrivateFieldGet(this, _Connection_opts, "f").channel,
|
|
87
|
+
status,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__classPrivateFieldSet(this, _Connection_opts, opts, "f");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
_Connection_opts = new WeakMap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.test.d.ts","sourceRoot":"","sources":["../../src/effects/realtime.test.ts"],"names":[],"mappings":""}
|
package/effects/show-form.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Form, FormToFormValues } from './helpers/form-types.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { FormEffectResponse } from './helpers/form-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Opens a form in a modal.
|
|
5
5
|
* Returns a promise that resolves with the form submission results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show-form.d.ts","sourceRoot":"","sources":["../../src/effects/show-form.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"show-form.d.ts","sourceRoot":"","sources":["../../src/effects/show-form.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAWlE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GAAU,KAAK,CAAC,CAAC,SAAS,IAAI,EACjD,gBAAgB,CAAC,KAChB,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAgCjD,CAAC"}
|
package/effects/show-form.js
CHANGED
|
@@ -2,7 +2,6 @@ import { emitEffect } from './emit-effect.js';
|
|
|
2
2
|
import { assertValidFormFields } from './helpers/assert-valid-form-fields.js';
|
|
3
3
|
import { getFormValues } from './helpers/get-form-values.js';
|
|
4
4
|
import { transformFormFields } from './helpers/transform-form.js';
|
|
5
|
-
import { FormAction } from './types.js';
|
|
6
5
|
let _formKey = 1;
|
|
7
6
|
const getNextFormKey = () => {
|
|
8
7
|
_formKey++;
|
|
@@ -38,12 +37,12 @@ export const showForm = async (formDefinition) => {
|
|
|
38
37
|
});
|
|
39
38
|
if (!response || !response.formSubmitted) {
|
|
40
39
|
return {
|
|
41
|
-
action:
|
|
40
|
+
action: 'CANCELED',
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
const formResults = getFormValues(response.formSubmitted.results);
|
|
45
44
|
return {
|
|
46
|
-
action:
|
|
45
|
+
action: 'SUBMITTED',
|
|
47
46
|
values: formResults,
|
|
48
47
|
};
|
|
49
48
|
};
|
package/effects/types.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
} | {
|
|
16
|
-
action: FormAction.SUBMITTED;
|
|
17
|
-
values: T;
|
|
1
|
+
/**
|
|
2
|
+
* Any JSON type. Ie, a string, number, boolean, null, an array of these JSON
|
|
3
|
+
* types, or an object with JSON type values, recursively.
|
|
4
|
+
*
|
|
5
|
+
* This type is often used to type-check attempts to serialize and deserialize
|
|
6
|
+
* classes, functions, and other _JavaScript_-only types that cannot be
|
|
7
|
+
* represented losslessly in plain JSON.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/microsoft/TypeScript/issues/1897
|
|
10
|
+
* @see https://www.json.org
|
|
11
|
+
*/
|
|
12
|
+
export type JSONValue = JSONPrimitive | JSONArray | JSONObject;
|
|
13
|
+
export type JSONObject = {
|
|
14
|
+
[key: string]: JSONValue;
|
|
18
15
|
};
|
|
16
|
+
export type JSONArray = JSONValue[];
|
|
17
|
+
export type JSONPrimitive = boolean | null | number | string;
|
|
19
18
|
//# sourceMappingURL=types.d.ts.map
|
package/effects/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/effects/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/effects/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACtD,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AACpC,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
package/effects/types.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { context } from './context.js';
|
|
2
2
|
export * as ui from './effects/index.js';
|
|
3
|
+
export { connectRealtime, disconnectRealtime, navigateTo, showForm, showToast, } from './effects/index.js';
|
|
3
4
|
export { type Toast } from './effects/show-toast.js';
|
|
4
5
|
//# 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,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,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,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC"}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/client",
|
|
3
|
-
"version": "0.11.18-next-2025-06-17-
|
|
3
|
+
"version": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.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-17-
|
|
29
|
-
"@devvit/reddit": "0.11.18-next-2025-06-17-
|
|
30
|
-
"@devvit/shared-types": "0.11.18-next-2025-06-17-
|
|
31
|
-
"@devvit/web-view-scripts": "0.11.18-next-2025-06-17-
|
|
28
|
+
"@devvit/protos": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.0",
|
|
29
|
+
"@devvit/reddit": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.0",
|
|
30
|
+
"@devvit/shared-types": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.0",
|
|
31
|
+
"@devvit/web-view-scripts": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@ampproject/filesize": "4.3.0",
|
|
35
|
-
"@devvit/repo-tools": "0.11.18-next-2025-06-17-
|
|
36
|
-
"@devvit/tsconfig": "0.11.18-next-2025-06-17-
|
|
35
|
+
"@devvit/repo-tools": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.0",
|
|
36
|
+
"@devvit/tsconfig": "0.11.18-next-2025-06-17-21-41-57-eba065cfc.0",
|
|
37
37
|
"esbuild": "0.23.0",
|
|
38
38
|
"eslint": "9.11.1",
|
|
39
39
|
"typescript": "5.8.3",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"filesize": {
|
|
46
46
|
"dist/client.min.js": {
|
|
47
|
-
"gzip": "
|
|
48
|
-
"none": "
|
|
47
|
+
"gzip": "18 KB",
|
|
48
|
+
"none": "75.5 KB"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"source": "./src/index.ts",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "2fc69a3034a8d172196ec13dbc6d999e9ffac2b3"
|
|
53
53
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contants.d.ts","sourceRoot":"","sources":["../../src/effects/contants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0DAA0D,CAAC;AAE3F,eAAO,MAAM,qBAAqB,EAAE,SAAS,UAAU,EAEtD,CAAC"}
|
|
File without changes
|