@devvit/client 0.11.19 → 0.11.20-next-2025-07-23-16-35-06-4e9bd2820.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,9 @@
1
- import type { Effect } from '@devvit/protos';
1
+ import type { Effect as SharedEffects } from '@devvit/protos';
2
+ import { WebViewImmersiveModeEffect } from '@devvit/protos/types/devvit/ui/effects/web_view/v1alpha/immersive_mode.js';
2
3
  import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
4
+ type Effect = Omit<SharedEffects, 'interval'> & {
5
+ immersiveMode?: WebViewImmersiveModeEffect | undefined;
6
+ };
3
7
  /**
4
8
  * Emits an effect to the parent window and handles the response if required.
5
9
  *
@@ -14,4 +18,5 @@ import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/even
14
18
  * 2. Effects that don't require a response: Posts the message and resolves immediately
15
19
  */
16
20
  export declare const emitEffect: (effect: Effect) => Promise<WebViewInternalEventMessage | undefined>;
21
+ export {};
17
22
  //# sourceMappingURL=emit-effect.d.ts.map
@@ -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;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"}
1
+ {"version":3,"file":"emit-effect.d.ts","sourceRoot":"","sources":["../../src/effects/emit-effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2EAA2E,CAAC;AAKvH,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AAIxG,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG;IAC9C,aAAa,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAkC1F,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { WebViewImmersiveModeEffect } from '@devvit/protos/types/devvit/ui/effects/web_view/v1alpha/immersive_mode.js';
1
2
  import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
2
3
  import { EFFECTS_WITH_RESPONSE } from './constants.js';
3
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immersive-mode-listeners.test.d.ts","sourceRoot":"","sources":["../../src/effects/immersive-mode-listeners.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The presentation mode of the web view.
3
+ * 'inline' The web view is displayed inline within a feed or post detail page
4
+ * 'immersive' The web view is displayed in a larger modal presentation
5
+ */
6
+ export type ImmersiveMode = 'inline' | 'immersive';
7
+ /**
8
+ * A listener that is called when the immersive mode changes.
9
+ * @param immersiveMode The new immersive mode, either 'inline' or 'immersive'.
10
+ */
11
+ export type ImmersiveListener = (immersiveMode: ImmersiveMode) => void;
12
+ /**
13
+ * Requests immersive mode for the web view.
14
+ * This will display the web view in a larger modal presentation.
15
+ *
16
+ * @param event The event that triggered the request, must be a trusted event.
17
+ * @returns A promise that resolves when the effect is emitted.
18
+ *
19
+ * @example
20
+ * button.addEventListener('click', async (event) => {
21
+ * await requestImmersiveMode(event);
22
+ * });
23
+ */
24
+ export declare function requestImmersiveMode(event: Event): Promise<void>;
25
+ /**
26
+ * Exits immersive mode for the web view.
27
+ * This will display the web view in an inline presentation.
28
+ *
29
+ * @param event The event that triggered the request, must be a trusted event.
30
+ * @returns A promise that resolves when the effect is emitted.
31
+ *
32
+ * @example
33
+ * button.addEventListener('click', async (event) => {
34
+ * await emitImmersiveModeEffect(event);
35
+ * });
36
+ */
37
+ export declare function exitImmersiveMode(event: Event): Promise<void>;
38
+ /**
39
+ * Adds a listener that is called when the immersive mode changes.
40
+ * The listener will be called with the new immersive mode, either 'inline' or 'immersive'.
41
+ *
42
+ * @param callback The callback to be called when the immersive mode changes.
43
+ */
44
+ export declare function addImmersiveModeChangeEventListener(callback: ImmersiveListener): void;
45
+ /**
46
+ * Removes a listener that was previously added with `addImmersiveModeChangeEventListener`.
47
+ *
48
+ * @param callback The callback to be removed.
49
+ */
50
+ export declare function removeImmersiveModeChangeEventListener(callback: ImmersiveListener): void;
51
+ //# sourceMappingURL=immersive-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immersive-mode.d.ts","sourceRoot":"","sources":["../../src/effects/immersive-mode.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;AAIvE;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAErF;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAExF"}
@@ -0,0 +1,75 @@
1
+ import { WebViewImmersiveMode } from '@devvit/protos/types/devvit/ui/effects/web_view/v1alpha/immersive_mode.js';
2
+ import { emitEffect } from './emit-effect.js';
3
+ const immersiveListeners = new Set();
4
+ /**
5
+ * Requests immersive mode for the web view.
6
+ * This will display the web view in a larger modal presentation.
7
+ *
8
+ * @param event The event that triggered the request, must be a trusted event.
9
+ * @returns A promise that resolves when the effect is emitted.
10
+ *
11
+ * @example
12
+ * button.addEventListener('click', async (event) => {
13
+ * await requestImmersiveMode(event);
14
+ * });
15
+ */
16
+ export function requestImmersiveMode(event) {
17
+ return emitImmersiveModeEffect(2, event);
18
+ }
19
+ /**
20
+ * Exits immersive mode for the web view.
21
+ * This will display the web view in an inline presentation.
22
+ *
23
+ * @param event The event that triggered the request, must be a trusted event.
24
+ * @returns A promise that resolves when the effect is emitted.
25
+ *
26
+ * @example
27
+ * button.addEventListener('click', async (event) => {
28
+ * await emitImmersiveModeEffect(event);
29
+ * });
30
+ */
31
+ export function exitImmersiveMode(event) {
32
+ return emitImmersiveModeEffect(1, event);
33
+ }
34
+ /**
35
+ * Adds a listener that is called when the immersive mode changes.
36
+ * The listener will be called with the new immersive mode, either 'inline' or 'immersive'.
37
+ *
38
+ * @param callback The callback to be called when the immersive mode changes.
39
+ */
40
+ export function addImmersiveModeChangeEventListener(callback) {
41
+ immersiveListeners.add(callback);
42
+ }
43
+ /**
44
+ * Removes a listener that was previously added with `addImmersiveModeChangeEventListener`.
45
+ *
46
+ * @param callback The callback to be removed.
47
+ */
48
+ export function removeImmersiveModeChangeEventListener(callback) {
49
+ immersiveListeners.delete(callback);
50
+ }
51
+ async function emitImmersiveModeEffect(mode, event) {
52
+ if (!event.isTrusted) {
53
+ console.error('Immersive mode effect ignored due to untrusted event');
54
+ throw new Error('Untrusted event');
55
+ }
56
+ const type = 9;
57
+ await emitEffect({ type, immersiveMode: { immersiveMode: mode } });
58
+ }
59
+ /**
60
+ * Handles incoming messages from the client, like when the user closes the immersive modal
61
+ */
62
+ if (typeof addEventListener === 'function') {
63
+ addEventListener('message', (event) => {
64
+ const { type, data } = event.data;
65
+ if (type !== 'devvit-message') {
66
+ return;
67
+ }
68
+ if (!data.immersiveMode) {
69
+ return;
70
+ }
71
+ const immersiveMode = event.data.data?.immersiveMode?.immersiveMode;
72
+ const modeString = immersiveMode === 2 ? 'immersive' : 'inline';
73
+ immersiveListeners.forEach((listener) => listener(modeString));
74
+ });
75
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immersive-mode.test.d.ts","sourceRoot":"","sources":["../../src/effects/immersive-mode.test.ts"],"names":[],"mappings":""}
package/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export { context } from './context.js';
2
- export { emitEffect, navigateTo, showForm, showToast } from './effects/index.js';
2
+ export { addImmersiveModeChangeEventListener, exitImmersiveMode, removeImmersiveModeChangeEventListener, requestImmersiveMode, } from './effects/immersive-mode.js';
3
+ export { navigateTo } from './effects/navigate-to.js';
4
+ export { showForm } from './effects/show-form.js';
5
+ export { showToast } from './effects/show-toast.js';
3
6
  export type { PostData } from '@devvit/shared-types/PostData.js';
4
7
  //# 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,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjF,YAAY,EAAE,QAAQ,EAAE,MAAM,kCAAkC,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,EACL,mCAAmC,EACnC,iBAAiB,EACjB,sCAAsC,EACtC,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC"}
package/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
  export { context } from './context.js';
2
- export { emitEffect, navigateTo, showForm, showToast } from './effects/index.js';
2
+ export { addImmersiveModeChangeEventListener, exitImmersiveMode, removeImmersiveModeChangeEventListener, requestImmersiveMode, } from './effects/immersive-mode.js';
3
+ export { navigateTo } from './effects/navigate-to.js';
4
+ export { showForm } from './effects/show-form.js';
5
+ export { showToast } from './effects/show-toast.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/client",
3
- "version": "0.11.19",
3
+ "version": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,16 +25,16 @@
25
25
  },
26
26
  "types": "./index.d.ts",
27
27
  "dependencies": {
28
- "@devvit/protos": "0.11.19",
29
- "@devvit/reddit": "0.11.19",
30
- "@devvit/shared": "0.11.19",
31
- "@devvit/shared-types": "0.11.19",
32
- "@devvit/web-view-scripts": "0.11.19"
28
+ "@devvit/protos": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
29
+ "@devvit/reddit": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
30
+ "@devvit/shared": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
31
+ "@devvit/shared-types": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
32
+ "@devvit/web-view-scripts": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@ampproject/filesize": "4.3.0",
36
- "@devvit/repo-tools": "0.11.19",
37
- "@devvit/tsconfig": "0.11.19",
36
+ "@devvit/repo-tools": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
37
+ "@devvit/tsconfig": "0.11.20-next-2025-07-23-16-35-06-4e9bd2820.0",
38
38
  "esbuild": "0.23.0",
39
39
  "eslint": "9.11.1",
40
40
  "typescript": "5.8.3",
@@ -46,9 +46,9 @@
46
46
  "filesize": {
47
47
  "dist/client.min.js": {
48
48
  "gzip": "23 KB",
49
- "none": "105 KB"
49
+ "none": "106 KB"
50
50
  }
51
51
  },
52
52
  "source": "./src/index.ts",
53
- "gitHead": "f730f695127ca675c4c651e691b9475e35e91ca2"
53
+ "gitHead": "3907b5ce758ea9f664816b328bed931603106bb7"
54
54
  }
@@ -1,5 +0,0 @@
1
- export { emitEffect } from './emit-effect.js';
2
- export { navigateTo } from './navigate-to.js';
3
- export { showForm } from './show-form.js';
4
- export { showToast } from './show-toast.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/effects/index.js DELETED
@@ -1,4 +0,0 @@
1
- export { emitEffect } from './emit-effect.js';
2
- export { navigateTo } from './navigate-to.js';
3
- export { showForm } from './show-form.js';
4
- export { showToast } from './show-toast.js';