@devvit/public-api 0.11.12-next-2025-03-26-76fc1f81e.0 → 0.11.12-next-2025-03-26-b56e4b84d.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 +1 @@
1
- {"version":3,"file":"UIClient.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/UIClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,yCAAyC,CAAC;AAG9F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,wBAAgB,KAAK,IAAI,SAAS,CAMjC;AAED,qBAAa,QAAS,YAAW,SAAS;;gBAO5B,aAAa,EAAE,aAAa;IAOxC,IAAI,OAAO,IAAI,eAAe,CAE7B;IAED,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI;IAgC/D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAC7B,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAwB7B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC7B,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IACtC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAC5B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAClC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAkC7B"}
1
+ {"version":3,"file":"UIClient.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/UIClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,yCAAyC,CAAC;AAG9F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,wBAAgB,KAAK,IAAI,SAAS,CAMjC;AAED,qBAAa,QAAS,YAAW,SAAS;;gBAO5B,aAAa,EAAE,aAAa;IAOxC,IAAI,OAAO,IAAI,eAAe,CAE7B;IAED,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI;IAgC/D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAC7B,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAwB7B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC7B,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IACtC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAC5B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAClC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAqC7B"}
@@ -38,7 +38,10 @@ export class UIClient {
38
38
  webView: {
39
39
  postMessage: {
40
40
  webViewId,
41
- app: { message: msg },
41
+ app: {
42
+ message: msg, // This is deprecated, but populated for backwards compatibility
43
+ jsonString: JSON.stringify(msg), // Encode as JSON for consistency with the mobile clients
44
+ },
42
45
  },
43
46
  },
44
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useWebView.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useWebView.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AA+F9B;;KAEK;AACL,wBAAgB,UAAU,CAAC,IAAI,SAAS,SAAS,GAAG,SAAS,EAAE,EAAE,SAAS,SAAS,GAAG,SAAS,EAC7F,OAAO,EAAE,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,GACnC,gBAAgB,CAAC,EAAE,CAAC,CAUtB"}
1
+ {"version":3,"file":"useWebView.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useWebView.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AA+G9B;;KAEK;AACL,wBAAgB,UAAU,CAAC,IAAI,SAAS,SAAS,GAAG,SAAS,EAAE,EAAE,SAAS,SAAS,GAAG,SAAS,EAC7F,OAAO,EAAE,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,GACnC,gBAAgB,CAAC,EAAE,CAAC,CAUtB"}
@@ -12,6 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _WebViewHook_hookId, _WebViewHook_url, _WebViewHook_onMessage, _WebViewHook_onUnmount, _WebViewHook_renderContext, _WebViewHook_emitFullscreenEffect;
13
13
  import { EffectType } from '@devvit/protos';
14
14
  import { WebViewVisibility } from '@devvit/protos';
15
+ import { StringUtil } from '@devvit/shared-types/StringUtil.js';
15
16
  import { registerHook } from './BlocksHandler.js';
16
17
  class WebViewHook {
17
18
  constructor(params, options) {
@@ -24,19 +25,31 @@ class WebViewHook {
24
25
  _WebViewHook_onUnmount.set(this, void 0);
25
26
  _WebViewHook_renderContext.set(this, void 0);
26
27
  /**
27
- * Send a message from a Devvit app to a web view.
28
+ * Send a message from a Devvit app to a web view (fullscreen).
28
29
  */
29
30
  this.postMessage = (message) => {
30
- // Handle messages sent from Devvit app -> web view
31
- __classPrivateFieldGet(this, _WebViewHook_renderContext, "f").emitEffect(`postMessage${this.state.messageCount++}`, {
32
- type: EffectType.EFFECT_WEB_VIEW,
33
- webView: {
34
- postMessage: {
35
- webViewId: __classPrivateFieldGet(this, _WebViewHook_hookId, "f"),
36
- app: { message },
31
+ try {
32
+ // Encode message as JSON for consistency with the mobile clients
33
+ const jsonString = JSON.stringify(message);
34
+ // Handle messages sent from Devvit app -> web view
35
+ __classPrivateFieldGet(this, _WebViewHook_renderContext, "f").emitEffect(`postMessage${this.state.messageCount++}`, {
36
+ type: EffectType.EFFECT_WEB_VIEW,
37
+ webView: {
38
+ postMessage: {
39
+ webViewId: __classPrivateFieldGet(this, _WebViewHook_hookId, "f"),
40
+ app: {
41
+ message, // This is deprecated, but populated for mobile client backwards compatibility
42
+ jsonString,
43
+ },
44
+ },
37
45
  },
38
- },
39
- });
46
+ });
47
+ }
48
+ catch (e) {
49
+ console.error(StringUtil.caughtToString(e));
50
+ // Safety net if something went wrong with JSON.stringify
51
+ throw Error('Something went wrong. Please check the contents of your postMessage.');
52
+ }
40
53
  };
41
54
  /**
42
55
  * Triggers the fullscreen effect to show the web view in fullscreen mode.
@@ -86,8 +99,14 @@ class WebViewHook {
86
99
  }
87
100
  else if (event.webView?.postMessage) {
88
101
  // Handle messages sent from web view -> Devvit app
89
- const { message } = event.webView.postMessage;
90
- await __classPrivateFieldGet(this, _WebViewHook_onMessage, "f").call(this, message, this);
102
+ if (event.webView.postMessage.jsonString) {
103
+ const parsedJson = JSON.parse(event.webView.postMessage.jsonString);
104
+ await __classPrivateFieldGet(this, _WebViewHook_onMessage, "f").call(this, parsedJson, this);
105
+ }
106
+ else {
107
+ // Fallback to deprecated message field for mobile client backwards compatibility
108
+ await __classPrivateFieldGet(this, _WebViewHook_onMessage, "f").call(this, event.webView.postMessage.message, this);
109
+ }
91
110
  }
92
111
  }
93
112
  }
package/meta.json CHANGED
@@ -868,7 +868,7 @@
868
868
  "format": "esm"
869
869
  },
870
870
  "../protos/dist/types/devvit/ui/effects/web_view/v1alpha/post_message.js": {
871
- "bytes": 9569,
871
+ "bytes": 10201,
872
872
  "imports": [
873
873
  {
874
874
  "path": "../../node_modules/protobufjs/minimal.js",
@@ -6731,7 +6731,7 @@
6731
6731
  "format": "esm"
6732
6732
  },
6733
6733
  "../protos/dist/types/devvit/ui/events/v1alpha/web_view.js": {
6734
- "bytes": 7845,
6734
+ "bytes": 8442,
6735
6735
  "imports": [
6736
6736
  {
6737
6737
  "path": "../../node_modules/protobufjs/minimal.js",
@@ -8407,7 +8407,7 @@
8407
8407
  "format": "esm"
8408
8408
  },
8409
8409
  "src/devvit/internals/blocks/handler/UIClient.ts": {
8410
- "bytes": 4383,
8410
+ "bytes": 4574,
8411
8411
  "imports": [
8412
8412
  {
8413
8413
  "path": "../protos/dist/index.js",
@@ -9569,7 +9569,7 @@
9569
9569
  "format": "esm"
9570
9570
  },
9571
9571
  "src/devvit/internals/blocks/handler/useWebView.ts": {
9572
- "bytes": 3887,
9572
+ "bytes": 4876,
9573
9573
  "imports": [
9574
9574
  {
9575
9575
  "path": "../protos/dist/index.js",
@@ -9581,6 +9581,11 @@
9581
9581
  "kind": "import-statement",
9582
9582
  "original": "@devvit/protos"
9583
9583
  },
9584
+ {
9585
+ "path": "../shared-types/dist/StringUtil.js",
9586
+ "kind": "import-statement",
9587
+ "original": "@devvit/shared-types/StringUtil.js"
9588
+ },
9584
9589
  {
9585
9590
  "path": "src/devvit/internals/blocks/handler/BlocksHandler.ts",
9586
9591
  "kind": "import-statement",
@@ -9853,7 +9858,7 @@
9853
9858
  "bytesInOutput": 2720
9854
9859
  },
9855
9860
  "../protos/dist/types/devvit/ui/effects/web_view/v1alpha/post_message.js": {
9856
- "bytesInOutput": 8779
9861
+ "bytesInOutput": 9321
9857
9862
  },
9858
9863
  "../protos/dist/types/devvit/ui/effects/v1alpha/create_order.js": {
9859
9864
  "bytesInOutput": 10718
@@ -10042,7 +10047,7 @@
10042
10047
  "bytesInOutput": 24682
10043
10048
  },
10044
10049
  "../protos/dist/types/devvit/ui/events/v1alpha/web_view.js": {
10045
- "bytesInOutput": 7256
10050
+ "bytesInOutput": 7778
10046
10051
  },
10047
10052
  "../protos/dist/types/devvit/ui/events/v1alpha/handle_ui.js": {
10048
10053
  "bytesInOutput": 5254
@@ -10213,7 +10218,7 @@
10213
10218
  "bytesInOutput": 830
10214
10219
  },
10215
10220
  "src/devvit/internals/blocks/handler/UIClient.ts": {
10216
- "bytesInOutput": 3234
10221
+ "bytesInOutput": 3468
10217
10222
  },
10218
10223
  "src/devvit/internals/blocks/handler/useChannel.ts": {
10219
10224
  "bytesInOutput": 5148
@@ -10327,10 +10332,10 @@
10327
10332
  "bytesInOutput": 370
10328
10333
  },
10329
10334
  "src/devvit/internals/blocks/handler/useWebView.ts": {
10330
- "bytesInOutput": 3408
10335
+ "bytesInOutput": 4058
10331
10336
  }
10332
10337
  },
10333
- "bytes": 12455648
10338
+ "bytes": 12462200
10334
10339
  }
10335
10340
  }
10336
10341
  }
package/meta.min.json CHANGED
@@ -1247,7 +1247,7 @@
1247
1247
  "format": "esm"
1248
1248
  },
1249
1249
  "src/devvit/internals/blocks/handler/UIClient.ts": {
1250
- "bytes": 4383,
1250
+ "bytes": 4574,
1251
1251
  "imports": [
1252
1252
  {
1253
1253
  "path": "@devvit/protos",
@@ -2409,7 +2409,7 @@
2409
2409
  "format": "esm"
2410
2410
  },
2411
2411
  "src/devvit/internals/blocks/handler/useWebView.ts": {
2412
- "bytes": 3887,
2412
+ "bytes": 4876,
2413
2413
  "imports": [
2414
2414
  {
2415
2415
  "path": "@devvit/protos",
@@ -2421,6 +2421,11 @@
2421
2421
  "kind": "import-statement",
2422
2422
  "external": true
2423
2423
  },
2424
+ {
2425
+ "path": "../shared-types/dist/StringUtil.js",
2426
+ "kind": "import-statement",
2427
+ "original": "@devvit/shared-types/StringUtil.js"
2428
+ },
2424
2429
  {
2425
2430
  "path": "src/devvit/internals/blocks/handler/BlocksHandler.ts",
2426
2431
  "kind": "import-statement",
@@ -2511,7 +2516,7 @@
2511
2516
  "imports": [],
2512
2517
  "exports": [],
2513
2518
  "inputs": {},
2514
- "bytes": 1058641
2519
+ "bytes": 1060144
2515
2520
  },
2516
2521
  "dist/public-api.min.js": {
2517
2522
  "imports": [
@@ -2942,7 +2947,7 @@
2942
2947
  "bytesInOutput": 65
2943
2948
  },
2944
2949
  "src/devvit/internals/blocks/handler/UIClient.ts": {
2945
- "bytesInOutput": 1288
2950
+ "bytesInOutput": 1317
2946
2951
  },
2947
2952
  "../shared-types/dist/useForm.js": {
2948
2953
  "bytesInOutput": 74
@@ -3056,10 +3061,10 @@
3056
3061
  "bytesInOutput": 178
3057
3062
  },
3058
3063
  "src/devvit/internals/blocks/handler/useWebView.ts": {
3059
- "bytesInOutput": 1396
3064
+ "bytesInOutput": 1684
3060
3065
  }
3061
3066
  },
3062
- "bytes": 218687
3067
+ "bytes": 219004
3063
3068
  }
3064
3069
  }
3065
3070
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/public-api",
3
- "version": "0.11.12-next-2025-03-26-76fc1f81e.0",
3
+ "version": "0.11.12-next-2025-03-26-b56e4b84d.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,17 +30,17 @@
30
30
  },
31
31
  "types": "./index.d.ts",
32
32
  "dependencies": {
33
- "@devvit/metrics": "0.11.12-next-2025-03-26-76fc1f81e.0",
34
- "@devvit/protos": "0.11.12-next-2025-03-26-76fc1f81e.0",
35
- "@devvit/shared-types": "0.11.12-next-2025-03-26-76fc1f81e.0",
33
+ "@devvit/metrics": "0.11.12-next-2025-03-26-b56e4b84d.0",
34
+ "@devvit/protos": "0.11.12-next-2025-03-26-b56e4b84d.0",
35
+ "@devvit/shared-types": "0.11.12-next-2025-03-26-b56e4b84d.0",
36
36
  "base64-js": "1.5.1",
37
37
  "clone-deep": "4.0.1",
38
38
  "moderndash": "4.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@ampproject/filesize": "4.3.0",
42
- "@devvit/repo-tools": "0.11.12-next-2025-03-26-76fc1f81e.0",
43
- "@devvit/tsconfig": "0.11.12-next-2025-03-26-76fc1f81e.0",
42
+ "@devvit/repo-tools": "0.11.12-next-2025-03-26-b56e4b84d.0",
43
+ "@devvit/tsconfig": "0.11.12-next-2025-03-26-b56e4b84d.0",
44
44
  "@microsoft/api-extractor": "7.41.0",
45
45
  "@reddit/faceplate-ui": "18.0.1",
46
46
  "@types/clone-deep": "4.0.1",
@@ -61,5 +61,5 @@
61
61
  }
62
62
  },
63
63
  "source": "./src/index.ts",
64
- "gitHead": "a30fde0bc20afa06a34dcfe181d629a31bd922ed"
64
+ "gitHead": "85ce2e579d5de8990b36d77131c6ccdc1095c109"
65
65
  }
package/public-api.d.ts CHANGED
@@ -4990,6 +4990,7 @@ declare const CustomPostDefinition: {
4990
4990
  webView?: {
4991
4991
  postMessage?: {
4992
4992
  message?: any;
4993
+ jsonString?: string;
4993
4994
  } | undefined;
4994
4995
  fullScreen?: {
4995
4996
  visibility?: WebViewVisibility_2;
@@ -5091,6 +5092,7 @@ declare const CustomPostDefinition: {
5091
5092
  webView?: {
5092
5093
  postMessage?: {
5093
5094
  message?: any;
5095
+ jsonString?: string;
5094
5096
  } | undefined;
5095
5097
  fullScreen?: {
5096
5098
  visibility?: WebViewVisibility_2;
@@ -5249,6 +5251,7 @@ declare const CustomPostDefinition: {
5249
5251
  webViewId?: string;
5250
5252
  app?: {
5251
5253
  message?: any;
5254
+ jsonString?: string | undefined;
5252
5255
  } | undefined;
5253
5256
  state?: {
5254
5257
  state?: {
@@ -5336,6 +5339,7 @@ declare const CustomPostDefinition: {
5336
5339
  webView?: {
5337
5340
  postMessage?: {
5338
5341
  message?: any;
5342
+ jsonString?: string;
5339
5343
  } | undefined;
5340
5344
  fullScreen?: {
5341
5345
  visibility?: WebViewVisibility_2;
@@ -5651,6 +5655,7 @@ declare const CustomPostDefinition: {
5651
5655
  webViewId?: string;
5652
5656
  app?: {
5653
5657
  message?: any;
5658
+ jsonString?: string | undefined;
5654
5659
  } | undefined;
5655
5660
  state?: {
5656
5661
  state?: {
@@ -5738,6 +5743,7 @@ declare const CustomPostDefinition: {
5738
5743
  webView?: {
5739
5744
  postMessage?: {
5740
5745
  message?: any;
5746
+ jsonString?: string;
5741
5747
  } | undefined;
5742
5748
  fullScreen?: {
5743
5749
  visibility?: WebViewVisibility_2;
@@ -6016,6 +6022,7 @@ declare const CustomPostDefinition: {
6016
6022
  webView?: {
6017
6023
  postMessage?: {
6018
6024
  message?: any;
6025
+ jsonString?: string;
6019
6026
  } | undefined;
6020
6027
  fullScreen?: {
6021
6028
  visibility?: WebViewVisibility_2;
@@ -6117,6 +6124,7 @@ declare const CustomPostDefinition: {
6117
6124
  webView?: {
6118
6125
  postMessage?: {
6119
6126
  message?: any;
6127
+ jsonString?: string;
6120
6128
  } | undefined;
6121
6129
  fullScreen?: {
6122
6130
  visibility?: WebViewVisibility_2;
@@ -6275,6 +6283,7 @@ declare const CustomPostDefinition: {
6275
6283
  webViewId?: string;
6276
6284
  app?: {
6277
6285
  message?: any;
6286
+ jsonString?: string | undefined;
6278
6287
  } | undefined;
6279
6288
  state?: {
6280
6289
  state?: {
@@ -6362,6 +6371,7 @@ declare const CustomPostDefinition: {
6362
6371
  webView?: {
6363
6372
  postMessage?: {
6364
6373
  message?: any;
6374
+ jsonString?: string;
6365
6375
  } | undefined;
6366
6376
  fullScreen?: {
6367
6377
  visibility?: WebViewVisibility_2;
@@ -6677,6 +6687,7 @@ declare const CustomPostDefinition: {
6677
6687
  webViewId?: string;
6678
6688
  app?: {
6679
6689
  message?: any;
6690
+ jsonString?: string | undefined;
6680
6691
  } | undefined;
6681
6692
  state?: {
6682
6693
  state?: {
@@ -6764,6 +6775,7 @@ declare const CustomPostDefinition: {
6764
6775
  webView?: {
6765
6776
  postMessage?: {
6766
6777
  message?: any;
6778
+ jsonString?: string;
6767
6779
  } | undefined;
6768
6780
  fullScreen?: {
6769
6781
  visibility?: WebViewVisibility_2;
@@ -53584,8 +53596,13 @@ declare const WatchRequest: {
53584
53596
  * type: devvit-message
53585
53597
  */
53586
53598
  declare interface WebViewAppMessage {
53587
- /** Any serializable value given to postMessage in a WebView */
53599
+ /**
53600
+ * Any serializable value given to postMessage in a WebView
53601
+ * @deprecated Use json_string instead
53602
+ */
53588
53603
  message?: any | undefined;
53604
+ /** JSON string payload */
53605
+ jsonString?: string | undefined;
53589
53606
  }
53590
53607
 
53591
53608
  declare const WebViewAppMessage: {
@@ -53692,8 +53709,13 @@ declare const WebViewPostMessageEffect: {
53692
53709
 
53693
53710
  /** Fired when the content of a WebView calls window.parent.postMessage() */
53694
53711
  declare interface WebViewPostMessageEvent {
53695
- /** Can be a Struct or a scalar value since postMessage doesn't restrict the type of 'message'. */
53712
+ /**
53713
+ * Can be a Struct or a scalar value since postMessage doesn't restrict the type of 'message'.
53714
+ * @deprecated Use json_string instead
53715
+ */
53696
53716
  message?: any | undefined;
53717
+ /** JSON string payload */
53718
+ jsonString: string;
53697
53719
  }
53698
53720
 
53699
53721
  declare const WebViewPostMessageEvent: {