@devvit/shared-types 0.12.3-next-2025-11-13-21-16-59-229dd7e60.0 → 0.12.3-next-2025-11-17-14-13-05-c85a5f760.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/client-context.d.ts +3 -0
- package/client/client-context.d.ts.map +1 -1
- package/client/emit-effect.d.ts +4 -6
- package/client/emit-effect.d.ts.map +1 -1
- package/client/emit-effect.js +14 -37
- package/package.json +5 -5
- package/shared/client.d.ts +9 -0
- package/shared/client.d.ts.map +1 -0
- package/shared/client.js +17 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { BaseContext } from '../shared/baseContext.js';
|
|
2
|
+
import type { Client } from '../shared/client.js';
|
|
2
3
|
import type { T2, T3 } from '../tid.js';
|
|
3
4
|
/**
|
|
4
5
|
* Devvit web client context for the lifetime of the web view.
|
|
5
6
|
*/
|
|
6
7
|
export type Context = BaseContext & {
|
|
8
|
+
/** Details about the platform the app was invoked from. */
|
|
9
|
+
client: Client | undefined;
|
|
7
10
|
/**
|
|
8
11
|
* The post author user ID, if applicable to the context and the account is
|
|
9
12
|
* active.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-context.d.ts","sourceRoot":"","sources":["../../src/client/client-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"client-context.d.ts","sourceRoot":"","sources":["../../src/client/client-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG;IAIlC,2DAA2D;IAC3D,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAI3B;;;;OAIG;IACH,YAAY,EAAE,EAAE,GAAG,SAAS,CAAC;IAC7B;;OAEG;IACH,MAAM,EAAE,EAAE,CAAC;CACZ,CAAC"}
|
package/client/emit-effect.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
import type { WebViewShareEffect } from '@devvit/protos/json/devvit/ui/effects/web_view/v1alpha/share.js';
|
|
1
|
+
import { EffectType } from '@devvit/protos/json/devvit/ui/effects/v1alpha/effect.js';
|
|
2
|
+
import { type WebViewInternalMessage } from '@devvit/protos/json/devvit/ui/effects/web_view/v1alpha/post_message.js';
|
|
4
3
|
import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
|
|
5
|
-
export type Effect = Omit<
|
|
6
|
-
|
|
7
|
-
share?: WebViewShareEffect;
|
|
4
|
+
export type Effect = Omit<WebViewInternalMessage, 'id' | 'scope' | 'type'> & {
|
|
5
|
+
type: EffectType;
|
|
8
6
|
};
|
|
9
7
|
/**
|
|
10
8
|
* Emits an effect to the parent window and handles the response if required.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-effect.d.ts","sourceRoot":"","sources":["../../src/client/emit-effect.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"emit-effect.d.ts","sourceRoot":"","sources":["../../src/client/emit-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AACrF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,wEAAwE,CAAC;AAChF,OAAO,EACL,2BAA2B,EAE5B,MAAM,2DAA2D,CAAC;AAEnE,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAQlG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GACrB,QAAQ,QAAQ,CAAC,MAAM,CAAC,KACvB,OAAO,CAAC,2BAA2B,GAAG,SAAS,CA2CjD,CAAC"}
|
package/client/emit-effect.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { EffectType
|
|
1
|
+
import { EffectType } from '@devvit/protos/json/devvit/ui/effects/v1alpha/effect.js';
|
|
2
2
|
import { WebViewInternalMessageScope, } from '@devvit/protos/json/devvit/ui/effects/web_view/v1alpha/post_message.js';
|
|
3
3
|
import { WebViewInternalEventMessage, WebViewMessageEvent_MessageData, } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js'; // to-do: use /json/ not /types/.
|
|
4
|
-
const EFFECTS_WITH_RESPONSE =
|
|
5
|
-
EffectType.EFFECT_SHOW_FORM,
|
|
6
|
-
EffectType.EFFECT_CAN_RUN_AS_USER,
|
|
7
|
-
EffectType.EFFECT_CREATE_ORDER,
|
|
8
|
-
|
|
4
|
+
const EFFECTS_WITH_RESPONSE = {
|
|
5
|
+
[EffectType.EFFECT_SHOW_FORM]: true,
|
|
6
|
+
[EffectType.EFFECT_CAN_RUN_AS_USER]: true,
|
|
7
|
+
[EffectType.EFFECT_CREATE_ORDER]: true,
|
|
8
|
+
};
|
|
9
9
|
/**
|
|
10
10
|
* Emits an effect to the parent window and handles the response if required.
|
|
11
11
|
*
|
|
@@ -22,34 +22,11 @@ const EFFECTS_WITH_RESPONSE = [
|
|
|
22
22
|
export const emitEffect = (effect) => {
|
|
23
23
|
return new Promise((resolve) => {
|
|
24
24
|
const message = {
|
|
25
|
+
...effect,
|
|
26
|
+
realtimeEffect: effect.realtime, // to-do: remove deprecated field.
|
|
25
27
|
scope: WebViewInternalMessageScope.CLIENT,
|
|
26
28
|
type: 'devvit-internal',
|
|
27
29
|
};
|
|
28
|
-
if (effect.realtimeSubscriptions) {
|
|
29
|
-
message.realtimeEffect = effect.realtimeSubscriptions; // deprecated field, should eventually be removed
|
|
30
|
-
message.realtime = effect.realtimeSubscriptions;
|
|
31
|
-
}
|
|
32
|
-
else if (effect.immersiveMode) {
|
|
33
|
-
message.immersiveMode = effect.immersiveMode;
|
|
34
|
-
}
|
|
35
|
-
else if (effect.share) {
|
|
36
|
-
message.share = effect.share;
|
|
37
|
-
}
|
|
38
|
-
else if (effect.showToast) {
|
|
39
|
-
message.showToast = effect.showToast;
|
|
40
|
-
}
|
|
41
|
-
else if (effect.navigateToUrl) {
|
|
42
|
-
message.navigateToUrl = effect.navigateToUrl;
|
|
43
|
-
}
|
|
44
|
-
else if (effect.showForm) {
|
|
45
|
-
message.showForm = effect.showForm;
|
|
46
|
-
}
|
|
47
|
-
else if (effect.createOrder) {
|
|
48
|
-
message.createOrder = effect.createOrder;
|
|
49
|
-
}
|
|
50
|
-
else if (effect.canRunAsUser) {
|
|
51
|
-
message.canRunAsUser = effect.canRunAsUser;
|
|
52
|
-
}
|
|
53
30
|
// For temporary backward compatibility, we set both `message.effect_type` above, and `effect` below
|
|
54
31
|
// Once mobile clients are updated to consume the strongly typed properties above, we can remove this block
|
|
55
32
|
// *Do not* add new effects here, use the strongly typed properties above
|
|
@@ -60,22 +37,22 @@ export const emitEffect = (effect) => {
|
|
|
60
37
|
message.effect = effect;
|
|
61
38
|
}
|
|
62
39
|
// Only set message id and add a listener for effects which require a response
|
|
63
|
-
if (EFFECTS_WITH_RESPONSE
|
|
64
|
-
const id =
|
|
40
|
+
if (EFFECTS_WITH_RESPONSE[effect.type]) {
|
|
41
|
+
const id = crypto.randomUUID();
|
|
65
42
|
message.id = id;
|
|
66
43
|
const handleEffect = (event) => {
|
|
67
44
|
if (event.data?.type === 'devvit-message' && event.data?.data?.id === id) {
|
|
68
45
|
const serializedMessage = WebViewInternalEventMessage.fromJSON(event.data.data);
|
|
69
46
|
resolve(serializedMessage);
|
|
70
|
-
|
|
47
|
+
removeEventListener('message', handleEffect);
|
|
71
48
|
}
|
|
72
49
|
};
|
|
73
|
-
|
|
50
|
+
addEventListener('message', handleEffect);
|
|
74
51
|
// Post message to the parent window, handled by client web view component
|
|
75
|
-
|
|
52
|
+
parent.postMessage(message, '*');
|
|
76
53
|
}
|
|
77
54
|
else {
|
|
78
|
-
|
|
55
|
+
parent.postMessage(message, '*');
|
|
79
56
|
// Resolve immediately for effects that don't expect a response.
|
|
80
57
|
resolve(undefined);
|
|
81
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/shared-types",
|
|
3
|
-
"version": "0.12.3-next-2025-11-
|
|
3
|
+
"version": "0.12.3-next-2025-11-17-14-13-05-c85a5f760.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
},
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@devvit/protos": "0.12.3-next-2025-11-
|
|
36
|
+
"@devvit/protos": "0.12.3-next-2025-11-17-14-13-05-c85a5f760.0",
|
|
37
37
|
"jsonschema": "1.4.1",
|
|
38
38
|
"uuid": "9.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@devvit/repo-tools": "0.12.3-next-2025-11-
|
|
42
|
-
"@devvit/tsconfig": "0.12.3-next-2025-11-
|
|
41
|
+
"@devvit/repo-tools": "0.12.3-next-2025-11-17-14-13-05-c85a5f760.0",
|
|
42
|
+
"@devvit/tsconfig": "0.12.3-next-2025-11-17-14-13-05-c85a5f760.0",
|
|
43
43
|
"@types/redis-mock": "0.17.1",
|
|
44
44
|
"@types/uuid": "9.0.0",
|
|
45
45
|
"chokidar-cli": "3.0.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"vitest": "1.6.1"
|
|
52
52
|
},
|
|
53
53
|
"source": "./src/index.ts",
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d6b2099fc657c233145a5aea310707b94b3f1401"
|
|
55
55
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeClientVersion } from '@devvit/protos/json/devvit/ui/effects/web_view/v1alpha/context.js';
|
|
2
|
+
/** The invoking client for the active request. */
|
|
3
|
+
export type Client = NativeClient;
|
|
4
|
+
/** The invoking Android or iOS client for the active request. */
|
|
5
|
+
export type NativeClient = {
|
|
6
|
+
name: 'ANDROID' | 'IOS';
|
|
7
|
+
version: NativeClientVersion;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/shared/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mEAAmE,CAAC;AAE7G,kDAAkD;AAClD,MAAM,MAAM,MAAM,GAAG,YAAY,CAAC;AAElC,iEAAiE;AACjE,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAC"}
|
package/shared/client.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// to-do: Provide Shreddit version number in `@devvit/client` when unpacking
|
|
3
|
+
// `BridgeContext`. Probably don't use `SemVer` here since it'd be
|
|
4
|
+
// `version.version`.
|
|
5
|
+
// export type = WebClient {
|
|
6
|
+
// name: 'WEB';
|
|
7
|
+
// version: {
|
|
8
|
+
// /** Major version. Eg, `1`. */
|
|
9
|
+
// major: number;
|
|
10
|
+
// /** Minor version. Eg, `2`. */
|
|
11
|
+
// minor: number;
|
|
12
|
+
// /** Patch version. Eg, `3`. */
|
|
13
|
+
// patch: number;
|
|
14
|
+
// /** Original version string. */
|
|
15
|
+
// string: string;
|
|
16
|
+
// };
|
|
17
|
+
// }
|