@devvit/public-api 0.12.0-next-2025-04-30-2e2a14dbe.0 → 0.12.0-next-2025-08-12-20-19-11-8d352335b.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.
Files changed (173) hide show
  1. package/apis/AssetsClient/AssetsClient.d.ts +2 -2
  2. package/apis/AssetsClient/AssetsClient.d.ts.map +1 -1
  3. package/apis/AssetsClient/AssetsClient.js +5 -7
  4. package/apis/key-value-storage/KeyValueStorage.d.ts +1 -1
  5. package/apis/key-value-storage/KeyValueStorage.d.ts.map +1 -1
  6. package/apis/makeAPIClients.d.ts.map +1 -1
  7. package/apis/makeAPIClients.js +3 -0
  8. package/apis/media/MediaClient.js +1 -1
  9. package/apis/realtime/RealtimeClient.d.ts +1 -1
  10. package/apis/realtime/RealtimeClient.d.ts.map +1 -1
  11. package/apis/reddit/RedditAPIClient.d.ts +41 -41
  12. package/apis/reddit/RedditAPIClient.d.ts.map +1 -1
  13. package/apis/reddit/RedditAPIClient.js +150 -151
  14. package/apis/reddit/models/Comment.d.ts +4 -1
  15. package/apis/reddit/models/Comment.d.ts.map +1 -1
  16. package/apis/reddit/models/Comment.js +4 -1
  17. package/apis/reddit/models/Flair.d.ts +1 -1
  18. package/apis/reddit/models/Flair.d.ts.map +1 -1
  19. package/apis/reddit/models/Flair.js +2 -2
  20. package/apis/reddit/models/Listing.d.ts +1 -1
  21. package/apis/reddit/models/Listing.d.ts.map +1 -1
  22. package/apis/reddit/models/ModAction.d.ts +3 -0
  23. package/apis/reddit/models/ModAction.d.ts.map +1 -1
  24. package/apis/reddit/models/ModAction.js +1 -2
  25. package/apis/reddit/models/ModMail.d.ts +23 -23
  26. package/apis/reddit/models/ModMail.js +24 -24
  27. package/apis/reddit/models/ModNote.d.ts +1 -1
  28. package/apis/reddit/models/ModNote.d.ts.map +1 -1
  29. package/apis/reddit/models/ModNote.js +1 -1
  30. package/apis/reddit/models/Post.d.ts +32 -5
  31. package/apis/reddit/models/Post.d.ts.map +1 -1
  32. package/apis/reddit/models/Post.js +74 -7
  33. package/apis/reddit/models/PrivateMessage.d.ts +1 -1
  34. package/apis/reddit/models/PrivateMessage.d.ts.map +1 -1
  35. package/apis/reddit/models/PrivateMessage.js +1 -1
  36. package/apis/reddit/models/Subreddit.d.ts +27 -9
  37. package/apis/reddit/models/Subreddit.d.ts.map +1 -1
  38. package/apis/reddit/models/Subreddit.js +12 -18
  39. package/apis/reddit/models/User.d.ts +23 -2
  40. package/apis/reddit/models/User.d.ts.map +1 -1
  41. package/apis/reddit/models/User.js +2 -15
  42. package/apis/reddit/models/Vault.d.ts +4 -1
  43. package/apis/reddit/models/Vault.d.ts.map +1 -1
  44. package/apis/reddit/models/Vault.js +3 -8
  45. package/apis/reddit/models/index.d.ts +1 -1
  46. package/apis/reddit/models/index.d.ts.map +1 -1
  47. package/apis/reddit/models/index.js +1 -0
  48. package/apis/reddit/tests/utils/createTestRedditApiClient.d.ts +8 -0
  49. package/apis/reddit/tests/utils/createTestRedditApiClient.d.ts.map +1 -0
  50. package/apis/reddit/tests/utils/createTestRedditApiClient.js +16 -0
  51. package/apis/redis/RedisClient.d.ts +0 -1
  52. package/apis/redis/RedisClient.d.ts.map +1 -1
  53. package/apis/redis/RedisClient.js +6 -0
  54. package/apis/redis/RedisClient.tests.js +3 -0
  55. package/apis/scheduler/SchedulerClient.js +1 -1
  56. package/apis/ui/UIClient.d.ts +3 -1
  57. package/apis/ui/UIClient.d.ts.map +1 -1
  58. package/apis/ui/UIClient.js +13 -12
  59. package/devvit/Devvit.d.ts +2 -2
  60. package/devvit/Devvit.d.ts.map +1 -1
  61. package/devvit/Devvit.js +65 -18
  62. package/devvit/internals/app-settings.d.ts.map +1 -1
  63. package/devvit/internals/app-settings.js +1 -4
  64. package/devvit/internals/blocks/BlocksReconciler.d.ts +105 -0
  65. package/devvit/internals/blocks/BlocksReconciler.d.ts.map +1 -1
  66. package/devvit/internals/blocks/BlocksReconciler.js +15 -13
  67. package/devvit/internals/blocks/handler/BlocksHandler.d.ts.map +1 -1
  68. package/devvit/internals/blocks/handler/BlocksHandler.js +2 -1
  69. package/devvit/internals/blocks/handler/ContextBuilder.d.ts.map +1 -1
  70. package/devvit/internals/blocks/handler/ContextBuilder.js +3 -0
  71. package/devvit/internals/blocks/handler/UIClient.d.ts +7 -5
  72. package/devvit/internals/blocks/handler/UIClient.d.ts.map +1 -1
  73. package/devvit/internals/blocks/handler/UIClient.js +14 -13
  74. package/devvit/internals/blocks/handler/cache.d.ts +1 -1
  75. package/devvit/internals/blocks/handler/cache.d.ts.map +1 -1
  76. package/devvit/internals/blocks/handler/test-helpers.d.ts +1 -1
  77. package/devvit/internals/blocks/handler/test-helpers.d.ts.map +1 -1
  78. package/devvit/internals/blocks/handler/types.d.ts +1 -1
  79. package/devvit/internals/blocks/handler/types.d.ts.map +1 -1
  80. package/devvit/internals/blocks/handler/useAsync.d.ts +1 -1
  81. package/devvit/internals/blocks/handler/useAsync.d.ts.map +1 -1
  82. package/devvit/internals/blocks/handler/useChannel.d.ts +1 -1
  83. package/devvit/internals/blocks/handler/useChannel.d.ts.map +1 -1
  84. package/devvit/internals/blocks/handler/useForm.d.ts +1 -1
  85. package/devvit/internals/blocks/handler/useForm.d.ts.map +1 -1
  86. package/devvit/internals/blocks/handler/useState.d.ts +1 -1
  87. package/devvit/internals/blocks/handler/useState.d.ts.map +1 -1
  88. package/devvit/internals/blocks/handler/useWebView.d.ts +1 -1
  89. package/devvit/internals/blocks/handler/useWebView.d.ts.map +1 -1
  90. package/devvit/internals/blocks/handler/useWebView.js +23 -4
  91. package/devvit/internals/blocks/useChannel.d.ts.map +1 -1
  92. package/devvit/internals/cache.d.ts +1 -1
  93. package/devvit/internals/cache.d.ts.map +1 -1
  94. package/devvit/internals/context.d.ts +1 -1
  95. package/devvit/internals/context.d.ts.map +1 -1
  96. package/devvit/internals/context.js +10 -1
  97. package/devvit/internals/csrf.d.ts.map +1 -1
  98. package/devvit/internals/csrf.js +4 -5
  99. package/devvit/internals/helpers/color.d.ts +1 -1
  100. package/devvit/internals/helpers/color.d.ts.map +1 -1
  101. package/devvit/internals/helpers/devvitInternalMessage.d.ts.map +1 -1
  102. package/devvit/internals/helpers/devvitInternalMessage.js +1 -1
  103. package/devvit/internals/helpers/extendDevvitPrototype.d.ts +1 -6
  104. package/devvit/internals/helpers/extendDevvitPrototype.d.ts.map +1 -1
  105. package/devvit/internals/helpers/extendDevvitPrototype.js +1 -9
  106. package/devvit/internals/installation-settings.d.ts.map +1 -1
  107. package/devvit/internals/installation-settings.js +1 -4
  108. package/devvit/internals/menu-items.d.ts +1 -0
  109. package/devvit/internals/menu-items.d.ts.map +1 -1
  110. package/devvit/internals/menu-items.js +9 -3
  111. package/devvit/internals/semanticColors.d.ts +4 -0
  112. package/devvit/internals/semanticColors.d.ts.map +1 -1
  113. package/devvit/internals/semanticColors.js +4 -0
  114. package/devvit/internals/ui-event-handler.js +3 -3
  115. package/devvit/internals/upgrade-app-shim.d.ts +1 -5
  116. package/devvit/internals/upgrade-app-shim.d.ts.map +1 -1
  117. package/devvit/internals/upgrade-app-shim.js +0 -8
  118. package/index.d.ts +2 -2
  119. package/index.d.ts.map +1 -1
  120. package/index.js +1 -2
  121. package/meta.min.json +401 -342
  122. package/package.json +23 -20
  123. package/public-api.min.js +6 -6
  124. package/public-api.min.js.map +4 -4
  125. package/types/configuration.d.ts +12 -3
  126. package/types/configuration.d.ts.map +1 -1
  127. package/types/context.d.ts +10 -2
  128. package/types/context.d.ts.map +1 -1
  129. package/types/data.d.ts +1 -1
  130. package/types/data.d.ts.map +1 -1
  131. package/types/form.d.ts +6 -89
  132. package/types/form.d.ts.map +1 -1
  133. package/types/form.js +2 -5
  134. package/types/hooks.d.ts +1 -1
  135. package/types/hooks.d.ts.map +1 -1
  136. package/types/icons.d.ts +1 -1
  137. package/types/icons.d.ts.map +1 -1
  138. package/types/icons.js +1 -1
  139. package/types/json.d.ts +43 -0
  140. package/types/json.d.ts.map +1 -0
  141. package/types/json.js +1 -0
  142. package/types/kvStore.d.ts +1 -1
  143. package/types/kvStore.d.ts.map +1 -1
  144. package/types/media.d.ts +1 -1
  145. package/types/menu-item.d.ts +3 -14
  146. package/types/menu-item.d.ts.map +1 -1
  147. package/types/realtime.d.ts +1 -1
  148. package/types/realtime.d.ts.map +1 -1
  149. package/types/redis.d.ts +0 -1
  150. package/types/redis.d.ts.map +1 -1
  151. package/types/scheduler.d.ts +2 -2
  152. package/types/scheduler.d.ts.map +1 -1
  153. package/types/tid.d.ts +47 -0
  154. package/types/tid.d.ts.map +1 -0
  155. package/types/tid.js +114 -0
  156. package/types/ui-client.d.ts +12 -6
  157. package/types/ui-client.d.ts.map +1 -1
  158. package/types/web-view-ui-client.d.ts +1 -1
  159. package/types/web-view-ui-client.d.ts.map +1 -1
  160. package/version.json +6 -8
  161. package/apis/reddit/index.d.ts +0 -1104
  162. package/apis/reddit/index.d.ts.map +0 -1
  163. package/apis/reddit/index.js +0 -1442
  164. package/apis/reddit/tests/utils/createTestRedditApiContext.d.ts +0 -7
  165. package/apis/reddit/tests/utils/createTestRedditApiContext.d.ts.map +0 -1
  166. package/apis/reddit/tests/utils/createTestRedditApiContext.js +0 -23
  167. package/devvit/internals/async-metadata.d.ts +0 -2
  168. package/devvit/internals/async-metadata.d.ts.map +0 -1
  169. package/devvit/internals/async-metadata.js +0 -65
  170. package/meta.json +0 -10428
  171. package/public-api.d.ts +0 -60472
  172. package/public-api.iife.js +0 -102332
  173. package/tsdoc-metadata.json +0 -11
@@ -1,3 +1,19 @@
1
+ import type { Block, BlockRenderRequest, Dimensions, Effect, FormSubmittedEvent, Metadata, RealtimeSubscriptionEvent, UIEvent } from '@devvit/protos';
2
+ import type { FormKey } from '@devvit/shared-types/useForm.js';
3
+ import type { AssetsClient } from '../../../apis/AssetsClient/AssetsClient.js';
4
+ import type { ModLogClient } from '../../../apis/modLog/ModLogClient.js';
5
+ import type { RealtimeClient } from '../../../apis/realtime/RealtimeClient.js';
6
+ import type { RedditAPIClient } from '../../../apis/reddit/RedditAPIClient.js';
7
+ import type { Form, FormFunction, MediaPlugin, Scheduler, SettingsClient, UIClient, UseChannelHook, UseFormHook, UseFormHookState, UseIntervalHook, UseIntervalHookState, UseStateHook } from '../../../types/index.js';
8
+ import type { JSONObject, PartialJSONObject } from '../../../types/json.js';
9
+ import type { KVStore } from '../../../types/kvStore.js';
10
+ import type { RedisClient } from '../../../types/redis.js';
11
+ import type { BlockElement } from '../../Devvit.js';
12
+ import { Devvit } from '../../Devvit.js';
13
+ import type { CacheHelper } from '../cache.js';
14
+ import type { LocalCache } from '../promise_cache.js';
15
+ import { BlocksTransformer } from './BlocksTransformer.js';
16
+ import type { EffectEmitter } from './EffectEmitter.js';
1
17
  export type ReifiedBlockElement = {
2
18
  type: string;
3
19
  props: {
@@ -6,5 +22,94 @@ export type ReifiedBlockElement = {
6
22
  children: ReifiedBlockElementOrLiteral[];
7
23
  };
8
24
  export type ReifiedBlockElementOrLiteral = ReifiedBlockElement | string;
25
+ /** Serializable. */
26
+ type ComponentState = {
27
+ [hookIndex: number]: UseIntervalHookState | UseFormHookState | JSONObject;
28
+ };
29
+ /** Serializable. */
30
+ type RenderState = {
31
+ [componentKey: string]: ComponentState;
32
+ };
9
33
  export declare function assertNotString(reified: ReifiedBlockElementOrLiteral): asserts reified is ReifiedBlockElement;
34
+ /**
35
+ * @experimental Do not use directly, for internal use only.
36
+ * An instance of this class should be instantiated for each OnRender call.
37
+ * This class is responsible for:
38
+ * - rendering JSX elements into Blocks.
39
+ * - managing state and hooks for each component.
40
+ * - drilling the shared clients into function components.
41
+ */
42
+ export declare class BlocksReconciler implements EffectEmitter {
43
+ #private;
44
+ component: JSX.ComponentFunction;
45
+ event: BlockRenderRequest | UIEvent | undefined;
46
+ state: {
47
+ __renderState: RenderState;
48
+ __postData?: {
49
+ thingId?: string;
50
+ };
51
+ __realtimeChannels?: string[];
52
+ __cache?: LocalCache;
53
+ };
54
+ metadata: Metadata;
55
+ modLog: ModLogClient;
56
+ reddit: RedditAPIClient;
57
+ kvStore: KVStore;
58
+ cache: CacheHelper;
59
+ redis: RedisClient;
60
+ scheduler: Scheduler;
61
+ dimensions?: Dimensions;
62
+ ui: UIClient;
63
+ settings: SettingsClient;
64
+ media: MediaPlugin;
65
+ assets: AssetsClient;
66
+ realtime: RealtimeClient;
67
+ hooks: {
68
+ useState: UseStateHook;
69
+ useInterval: UseIntervalHook;
70
+ useForm: UseFormHook;
71
+ useChannel: UseChannelHook;
72
+ };
73
+ emitEffect(_dedupeKey: string, effect: Effect): void;
74
+ renderState: RenderState;
75
+ currentComponentKey: string[];
76
+ currentHookIndex: number;
77
+ actions: Map<string, Function>;
78
+ forms: Map<FormKey, Form | FormFunction>;
79
+ realtimeChannels: string[];
80
+ realtimeUpdated: boolean;
81
+ pendingHooks: (() => Promise<void>)[];
82
+ isRendering: boolean;
83
+ transformer: BlocksTransformer;
84
+ effects: Effect[];
85
+ constructor(component: JSX.ComponentFunction, event: BlockRenderRequest | UIEvent | undefined, state: PartialJSONObject | undefined, metadata: Metadata, dimensions: Dimensions | undefined);
86
+ render(): Promise<Block>;
87
+ makeUniqueActionID(id: string): string;
88
+ reconcile(): Promise<void>;
89
+ buildBlocksUI(): Promise<Block>;
90
+ renderElement(ctx: Devvit.Context, element: JSX.Element): Promise<Block>;
91
+ processProps(block: BlockElement): Promise<void>;
92
+ processBlock(element: JSX.Element | JSX.Element[], idGenerator?: (id: string) => string, path?: string[]): Promise<ReifiedBlockElementOrLiteral>;
93
+ getCurrentComponentKey(): string[];
94
+ getCurrentComponentState<S>(): {
95
+ [hookIndex: number]: S;
96
+ };
97
+ getPreviousComponentState<S>(): {
98
+ [hookIndex: number]: S;
99
+ };
100
+ get isInitialRender(): boolean;
101
+ get isUserActionRender(): boolean;
102
+ get isEffectRender(): boolean;
103
+ get formSubmittedEvent(): FormSubmittedEvent | undefined | false;
104
+ get blockRenderEventId(): string | undefined | false;
105
+ get realtimeEvent(): RealtimeSubscriptionEvent | undefined | false;
106
+ runHook(hook: () => Promise<void>): void;
107
+ rerenderIn(delayMs: number): void;
108
+ addRealtimeChannel(channel: string): void;
109
+ removeRealtimeChannel(channel: string): void;
110
+ get realtimeEffect(): Effect[];
111
+ getEffects(): Effect[];
112
+ buildNextState(): void;
113
+ }
114
+ export {};
10
115
  //# sourceMappingURL=BlocksReconciler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksReconciler.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/blocks/BlocksReconciler.ts"],"names":[],"mappings":"AA6CA,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;IAC9C,QAAQ,EAAE,4BAA4B,EAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAYxE,wBAAgB,eAAe,CAC7B,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,OAAO,IAAI,mBAAmB,CAIxC"}
1
+ {"version":3,"file":"BlocksReconciler.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/blocks/BlocksReconciler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,kBAAkB,EAClB,QAAQ,EACR,yBAAyB,EACzB,OAAO,EACR,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCA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AE,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,CAAA;KAAE;IAa1D,IAAI,eAAe,IAAI,OAAO,CAM7B;IAED,IAAI,kBAAkB,IAAI,OAAO,CAMhC;IAED,IAAI,cAAc,IAAI,OAAO,CAM5B;IAED,IAAI,kBAAkB,IAAI,kBAAkB,GAAG,SAAS,GAAG,KAAK,CAM/D;IAED,IAAI,kBAAkB,IAAI,MAAM,GAAG,SAAS,GAAG,KAAK,CAMnD;IAED,IAAI,aAAa,IAAI,yBAAyB,GAAG,SAAS,GAAG,KAAK,CAWjE;IAED,OAAO,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAMxC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAajC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKzC,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK5C,IAAI,cAAc,IAAI,MAAM,EAAE,CAa7B;IAED,UAAU,IAAI,MAAM,EAAE;IAItB,cAAc,IAAI,IAAI;CAsBvB"}
@@ -78,7 +78,7 @@ function indentXML(xml) {
78
78
  return formatted;
79
79
  }
80
80
  /**
81
- * @internal
81
+ * @experimental Do not use directly, for internal use only.
82
82
  * An instance of this class should be instantiated for each OnRender call.
83
83
  * This class is responsible for:
84
84
  * - rendering JSX elements into Blocks.
@@ -123,6 +123,7 @@ export class BlocksReconciler {
123
123
  });
124
124
  this.cache = apiClients.cache;
125
125
  this.modLog = apiClients.modLog;
126
+ this.reddit = apiClients.reddit;
126
127
  this.kvStore = apiClients.kvStore;
127
128
  this.redis = apiClients.redis;
128
129
  this.settings = apiClients.settings;
@@ -210,14 +211,6 @@ export class BlocksReconciler {
210
211
  }
211
212
  }
212
213
  async processBlock(element, idGenerator = makeUniqueIdGenerator(), path = []) {
213
- // Strings - return as is
214
- if (typeof element === 'string') {
215
- return element;
216
- }
217
- // Numbers - transform to string
218
- if (typeof element === 'number') {
219
- return `${element}`;
220
- }
221
214
  const blockElement = element;
222
215
  // Intrinsic elements
223
216
  if (typeof blockElement.type === 'string') {
@@ -241,11 +234,12 @@ export class BlocksReconciler {
241
234
  const children = childrens.flat();
242
235
  const collapsedChildren = __classPrivateFieldGet(this, _BlocksReconciler_instances, "m", _BlocksReconciler_flatten).call(this, children);
243
236
  await this.processProps(blockElement);
244
- return {
237
+ const reified = {
245
238
  type: blockElement.type,
246
239
  props: blockElement.props,
247
240
  children: collapsedChildren,
248
241
  };
242
+ return reified;
249
243
  }
250
244
  // Function components
251
245
  if (typeof blockElement.type === 'function') {
@@ -256,16 +250,15 @@ export class BlocksReconciler {
256
250
  this.renderState[componentKey] = {};
257
251
  }
258
252
  const children = blockElement.children.flatMap((c) => c);
259
- const ctx = __classPrivateFieldGet(this, _BlocksReconciler_instances, "m", _BlocksReconciler_makeContextProps).call(this);
260
253
  const props = {
261
- ...ctx,
254
+ ...__classPrivateFieldGet(this, _BlocksReconciler_instances, "m", _BlocksReconciler_makeContextProps).call(this),
262
255
  ...blockElement.props,
263
256
  children,
264
257
  };
265
258
  let result;
266
259
  while (result === undefined) {
267
260
  try {
268
- result = await blockElement.type(props, ctx);
261
+ result = await blockElement.type(props, __classPrivateFieldGet(this, _BlocksReconciler_instances, "m", _BlocksReconciler_makeContextProps).call(this));
269
262
  }
270
263
  catch (promiseOrError) {
271
264
  // If the component throws a promise, wait for it to resolve and try again.
@@ -299,6 +292,14 @@ export class BlocksReconciler {
299
292
  return this.processBlock(result, idGenerator, [...path, blockElement.type.name]);
300
293
  }
301
294
  }
295
+ // Strings - return as is
296
+ if (typeof blockElement === 'string') {
297
+ return blockElement;
298
+ }
299
+ // Numbers - transform to string
300
+ if (typeof blockElement === 'number') {
301
+ return `${blockElement}`;
302
+ }
302
303
  let children = [];
303
304
  let pathPrefix = '';
304
305
  if (Array.isArray(blockElement)) {
@@ -455,6 +456,7 @@ _BlocksReconciler_rerenderAlreadyScheduled = new WeakMap(), _BlocksReconciler_in
455
456
  const props = {
456
457
  ...getContextFromMetadata(this.metadata, this.state.__postData?.thingId),
457
458
  modLog: this.modLog,
459
+ reddit: this.reddit,
458
460
  cache: this.cache,
459
461
  kvStore: this.kvStore,
460
462
  redis: this.redis,
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksHandler.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/BlocksHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAGb,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAgB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAe,IAAI,EAAE,UAAU,EAAE,WAAW,EAAS,MAAM,YAAY,CAAC;AAGpF;;;;;;GAMG;AACH,eAAO,IAAI,oBAAoB,EAAE,aAAa,GAAG,IAAW,CAAC;AAE7D,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CASxD;AAED,KAAK,mBAAmB,CAAC,CAAC,SAAS,IAAI,IAAI,WAAW,GAAG;IACvD;;;OAGG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,IAAI,EAAE,EAC3C,WAAW,EACX,GAAG,WAAW,EACf,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAiC5B;AAED,eAAO,IAAI,oBAAoB,EAAE,aAAa,GAAG,IAAW,CAAC;AAO7D;;;;GAIG;AACH,qBAAa,aAAa;;IAMxB,oBAAoB,EAAE,aAAa,GAAG,IAAI,CAAQ;gB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,CAAC,iBAAiB;IAMjC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAyZ1E"}
@@ -111,7 +111,8 @@ export class BlocksHandler {
111
111
  }
112
112
  async handle(request, metadata) {
113
113
  const context = new RenderContext(request, metadata);
114
- context.devvitContext = __classPrivateFieldGet(this, _BlocksHandler_contextBuilder, "f").buildContext(context, request, metadata);
114
+ const devvitContext = __classPrivateFieldGet(this, _BlocksHandler_contextBuilder, "f").buildContext(context, request, metadata);
115
+ context.devvitContext = devvitContext;
115
116
  let blocks;
116
117
  /**
117
118
  * Events on the main queue must be handled in order, so that state is updated in the correct order. Events
@@ -1 +1 @@
1
- {"version":3,"file":"ContextBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/ContextBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAY1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD,qBAAa,cAAc;IAClB,YAAY,CACjB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,OAAO;CA0ClB"}
1
+ {"version":3,"file":"ContextBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/ContextBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAa1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD,qBAAa,cAAc;IAClB,YAAY,CACjB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,OAAO;CA4ClB"}
@@ -4,6 +4,7 @@ import { KeyValueStorage } from '../../../../apis/key-value-storage/KeyValueStor
4
4
  import { MediaClient } from '../../../../apis/media/MediaClient.js';
5
5
  import { ModLogClient } from '../../../../apis/modLog/ModLogClient.js';
6
6
  import { RealtimeClient } from '../../../../apis/realtime/RealtimeClient.js';
7
+ import { RedditAPIClient } from '../../../../apis/reddit/RedditAPIClient.js';
7
8
  import { RedisClient } from '../../../../apis/redis/RedisClient.js';
8
9
  import { SchedulerClient } from '../../../../apis/scheduler/SchedulerClient.js';
9
10
  import { SettingsClient } from '../../../../apis/settings/SettingsClient.js';
@@ -19,6 +20,7 @@ export class ContextBuilder {
19
20
  const modLog = new ModLogClient(metadata);
20
21
  const kvStore = new KeyValueStorage(metadata);
21
22
  const redis = new RedisClient(metadata);
23
+ const reddit = new RedditAPIClient(metadata);
22
24
  const scheduler = new SchedulerClient(metadata);
23
25
  const settings = new SettingsClient(metadata);
24
26
  const ui = new UIClient(renderContext);
@@ -30,6 +32,7 @@ export class ContextBuilder {
30
32
  modLog,
31
33
  kvStore,
32
34
  redis,
35
+ reddit,
33
36
  scheduler,
34
37
  settings,
35
38
  media,
@@ -1,6 +1,7 @@
1
- import type { JSONObject } from '@devvit/shared-types/json.js';
1
+ import type { Form } from '@devvit/shared';
2
2
  import type { FormKey } from '@devvit/shared-types/useForm.js';
3
3
  import type { Comment, Post, Subreddit, User } from '../../../../apis/reddit/models/index.js';
4
+ import type { JSONObject } from '../../../../types/json.js';
4
5
  import type { Toast } from '../../../../types/toast.js';
5
6
  import type { UIClient as _UIClient } from '../../../../types/ui-client.js';
6
7
  import type { WebViewUIClient } from '../../../../types/web-view-ui-client.js';
@@ -11,12 +12,13 @@ export declare class UIClient implements _UIClient {
11
12
  constructor(renderContext: RenderContext);
12
13
  get webView(): WebViewUIClient;
13
14
  showForm(formKey: FormKey, data?: JSONObject | undefined): void;
15
+ showFormInternal(formKey: FormKey, data?: JSONObject | undefined, formInternalOverride?: Form | undefined): void;
14
16
  showToast(text: string): void;
15
17
  showToast(toast: Toast): void;
16
18
  navigateTo(url: string): void;
17
- navigateTo(subreddit: Subreddit): void;
18
- navigateTo(post: Post): void;
19
- navigateTo(comment: Comment): void;
20
- navigateTo(user: User): void;
19
+ navigateTo(subreddit: Pick<Subreddit, 'url'>): void;
20
+ navigateTo(post: Pick<Post, 'url'>): void;
21
+ navigateTo(comment: Pick<Comment, 'url'>): void;
22
+ navigateTo(user: Pick<User, 'url'>): void;
21
23
  }
22
24
  //# sourceMappingURL=UIClient.d.ts.map
@@ -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,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B,oBAAoB,CAAC,EAAE,IAAI,GAAG,SAAS,GACtC,IAAI;IAiCP,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,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,IAAI;IACnD,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI;IACzC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,IAAI;IAC/C,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI;CAkC1C"}
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _UIClient_renderContext, _UIClient_webViewMessageCount, _UIClient_webViewClient, _UIClient_webViewPostMessage;
13
- import { EffectType, Form, ToastAppearance } from '@devvit/protos';
13
+ import { EffectType, Form as FormProto, ToastAppearance, } from '@devvit/protos';
14
14
  import { assertValidFormFields } from '../../../../apis/ui/helpers/assertValidFormFields.js';
15
15
  import { transformFormFields } from '../../../../apis/ui/helpers/transformForm.js';
16
16
  import { _activeRenderContext } from './BlocksHandler.js';
@@ -55,13 +55,17 @@ export class UIClient {
55
55
  return __classPrivateFieldGet(this, _UIClient_webViewClient, "f");
56
56
  }
57
57
  showForm(formKey, data) {
58
+ return this.showFormInternal(formKey, data);
59
+ }
60
+ showFormInternal(formKey, data, formInternalOverride) {
58
61
  const formDefinition = getFormDefinition(__classPrivateFieldGet(this, _UIClient_renderContext, "f"), formKey);
59
62
  if (!formDefinition) {
60
63
  throw new Error('Form does not exist. Make sure you have added it using useForm.');
61
64
  }
62
- const formData = formDefinition.form instanceof Function
63
- ? formDefinition.form(data ?? {})
64
- : formDefinition.form;
65
+ const formData = formInternalOverride ??
66
+ (formDefinition.form instanceof Function
67
+ ? formDefinition.form(data ?? {})
68
+ : formDefinition.form);
65
69
  const form = {
66
70
  fields: [],
67
71
  id: formKey,
@@ -100,18 +104,15 @@ export class UIClient {
100
104
  });
101
105
  }
102
106
  navigateTo(thingOrUrl) {
103
- let url;
104
- if (typeof thingOrUrl === 'string') {
105
- // Validate URL
106
- url = new URL(thingOrUrl).toString();
107
- }
108
- else {
109
- url = new URL(thingOrUrl.permalink, 'https://www.reddit.com').toString();
107
+ const inputUrl = typeof thingOrUrl === 'string' ? thingOrUrl : thingOrUrl.url;
108
+ if (!URL.canParse(inputUrl)) {
109
+ throw new TypeError(`Invalid URL: ${inputUrl}`);
110
110
  }
111
- __classPrivateFieldGet(this, _UIClient_renderContext, "f").emitEffect(url, {
111
+ const normalizedUrl = new URL(inputUrl).toString();
112
+ __classPrivateFieldGet(this, _UIClient_renderContext, "f").emitEffect(normalizedUrl, {
112
113
  type: EffectType.EFFECT_NAVIGATE_TO_URL,
113
114
  navigateToUrl: {
114
- url,
115
+ url: normalizedUrl,
115
116
  },
116
117
  });
117
118
  }
@@ -1,4 +1,4 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
1
+ import type { JSONValue } from '../../../../types/json.js';
2
2
  import type { RedisClient } from '../../../../types/redis.js';
3
3
  import type { CacheOptions, Clock, LocalCache } from './promise_cache.js';
4
4
  import type { RenderContext } from './RenderContext.js';
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,SAAS,EAC5C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,EAAE,YAAY,KAClB,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,EACzD,KAAK,GAAE,KAAmB,GACzB,WAAW,CAGb"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,SAAS,EAC5C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,EAAE,YAAY,KAClB,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,EACzD,KAAK,GAAE,KAAmB,GACzB,WAAW,CAGb"}
@@ -1,5 +1,5 @@
1
1
  import { type UIRequest } from '@devvit/protos';
2
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
+ import type { JSONValue } from '../../../../types/json.js';
3
3
  import type { BlocksState, HookRef } from './types.js';
4
4
  export declare const findHookId: (ref: HookRef) => string;
5
5
  export declare const findHookState: (ref: HookRef) => JSONValue;
@@ -1 +1 @@
1
- {"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,UAAU,QAAS,OAAO,KAAG,MAEzC,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,SAE5C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,SAE5C,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,WAEvC,CAAC;AAEF,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED,eAAO,MAAM,oBAAoB,QAAS,OAAO,KAAG,SAYnD,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAS,OAAO,KAAG,SAUnD,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;CAUxB,CAAC"}
1
+ {"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG5E,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,KAAG,MAEzC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,KAAG,SAE5C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,KAAG,SAE5C,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,WAEvC,CAAC;AAEF,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED,eAAO,MAAM,oBAAoB,GAAI,KAAK,OAAO,KAAG,SAYnD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,KAAK,OAAO,KAAG,SAUnD,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;CAUxB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { UIEvent } from '@devvit/protos';
2
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
+ import type { JSONValue } from '../../../../types/json.js';
3
3
  import type { RenderContext, Tombstone } from './RenderContext.js';
4
4
  export type BlocksState = {
5
5
  [hookID: string]: JSONValue | Tombstone;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;;;;;;OAUG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IAEH,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAErB;;;OAGG;IAEH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,MAAM,C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AAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAErB;;;OAGG;IAEH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB;;;;OAIG;IACH,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IAEzB;;;;;;;;;OASG;IACH,aAAa,CAAC,IAAI,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,UAAU,IAAI,IAAI,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;CAAG"}
@@ -1,5 +1,5 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
1
  import type { AsyncUseStateInitializer, UseAsyncResult } from '../../../../types/hooks.js';
2
+ import type { JSONValue } from '../../../../types/json.js';
3
3
  export type AsyncOptions<S extends JSONValue> = {
4
4
  /**
5
5
  * The data loader will re-run if the value of `depends` changes.
@@ -1 +1 @@
1
- {"version":3,"file":"useAsync.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAK3F,MAAM,MAA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AEnE;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,CAAC,EAAE,OAAO,GAAG;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAYA;AAoHD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,EAC1C,WAAW,EAAE,wBAAwB,CAAC,CAAC,CAAC,EACxC,OAAO,GAAE,YAAY,CAAC,CAAC,CAAM,GAC5B,cAAc,CAAC,CAAC,CAAC,CAanB"}
@@ -1,5 +1,5 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
1
  import type { UseChannelResult } from '../../../../types/hooks.js';
2
+ import type { JSONValue } from '../../../../types/json.js';
3
3
  import type { ChannelOptions } from '../../../../types/realtime.js';
4
4
  export declare function useChannel<Message extends JSONValue>(opts: Readonly<ChannelOptions<Message>>): UseChannelResult<Message>;
5
5
  //# sourceMappingURL=useChannel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChannel.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useChannel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAgIpE,wBAAgB,UAAU,CAAC,OAAO,SAAS,SAAS,EAClD,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GACtC,gBAAgB,CAAC,OAAO,CAAC,CAc3B"}
1
+ {"version":3,"file":"useChannel.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useChannel.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAgIpE,wBAAgB,UAAU,CAAC,OAAO,SAAS,SAAS,EAClD,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GACtC,gBAAgB,CAAC,OAAO,CAAC,CAc3B"}
@@ -1,6 +1,6 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
1
  import type { FormKey } from '@devvit/shared-types/useForm.js';
3
2
  import type { Form, FormDefinition, FormFunction, FormToFormValues, FormValues } from '../../../../index.js';
3
+ import type { JSONValue } from '../../../../types/json.js';
4
4
  import type { RenderContext } from './RenderContext.js';
5
5
  import type { EventHandler, Hook, HookRef } from './types.js';
6
6
  declare class UseFormHook implements Hook, FormDefinition {
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAI/D,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9D,cAAM,WAAY,YAAW,IAAI,EAAE,cAAc;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,CAAQ;IACxB,SAAS,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACrC,aAAa,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACzC,IAAI,EAAE,IAAI,GAAG,YAAY,CAAC;IAC1B,QAAQ,E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C;IACrC,aAAa,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACzC,IAAI,EAAE,IAAI,GAAG,YAAY,CAAC;IAC1B,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAGrD,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAC1B,IAAI,EAAE,IAAI,GAAG,YAAY,EACzB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAWzD;AAED,wBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,GAAG,YAAY,EACzD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC9D,OAAO,CAOT;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE1D;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,WAAW,CAG7F"}
@@ -1,5 +1,5 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
1
  import type { UseStateInitializer, UseStateResult } from '../../../../types/hooks.js';
2
+ import type { JSONValue } from '../../../../types/json.js';
3
3
  export declare function useState(initialState: UseStateInitializer<boolean>): UseStateResult<boolean>;
4
4
  export declare function useState(initialState: UseStateInitializer<number>): UseStateResult<number>;
5
5
  export declare function useState(initialState: UseStateInitializer<string>): UseStateResult<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAEV,mBAAmB,EACnB,cAAc,EACf,MAAM,4BAA4B,CAAC;AAkHpC,wBAAgB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;AAC9F,wBAAgB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAC5F,wBAAgB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAC5F,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,EAC1C,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACnC,cAAc,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../../../../../src/devvit/internals/blocks/handler/useState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,mBAAmB,EACnB,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAkH3D,wBAAgB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;AAC9F,wBAAgB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAC5F,wBAAgB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAC5F,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,EAC1C,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACnC,cAAc,CAAC,CAAC,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
2
1
  import type { UseWebViewOptions, UseWebViewResult } from '../../../../index.js';
2
+ import type { JSONValue } from '../../../../types/json.js';
3
3
  /**
4
4
  * Use this hook to handle a web view's visibility state and any messages sent to your app.
5
5
  * */
@@ -1 +1 @@
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;AAmH9B;;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":"AAMA,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAwI3D;;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"}
@@ -9,15 +9,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
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
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _WebViewHook_hookId, _WebViewHook_url, _WebViewHook_onMessage, _WebViewHook_onUnmount, _WebViewHook_renderContext, _WebViewHook_emitFullscreenEffect;
12
+ var _WebViewHook_hookId, _WebViewHook_url, _WebViewHook_onMessage, _WebViewHook_onUnmount, _WebViewHook_renderContext, _WebViewHook_invalidate, _WebViewHook_emitFullscreenEffect;
13
13
  import { EffectType } from '@devvit/protos';
14
14
  import { WebViewVisibility } from '@devvit/protos';
15
+ import { apiPathPrefix } from '@devvit/shared-types/constants.js';
15
16
  import { StringUtil } from '@devvit/shared-types/StringUtil.js';
16
17
  import { webViewMessageIsInternalAndClientScope } from '../../helpers/devvitInternalMessage.js';
17
18
  import { registerHook } from './BlocksHandler.js';
18
19
  class WebViewHook {
19
20
  constructor(params, options) {
20
- this.state = { messageCount: 0 };
21
+ this.state = { messageCount: 0, isMounted: false };
21
22
  _WebViewHook_hookId.set(this, void 0);
22
23
  // This url is the path to the asset that will be loaded in the web view.
23
24
  // It is ensured to be a valid path prior to the effect being emitted.
@@ -25,6 +26,7 @@ class WebViewHook {
25
26
  _WebViewHook_onMessage.set(this, void 0);
26
27
  _WebViewHook_onUnmount.set(this, void 0);
27
28
  _WebViewHook_renderContext.set(this, void 0);
29
+ _WebViewHook_invalidate.set(this, void 0);
28
30
  /**
29
31
  * Send a message from a Devvit app to a web view (fullscreen).
30
32
  */
@@ -56,9 +58,20 @@ class WebViewHook {
56
58
  * Triggers the fullscreen effect to show the web view in fullscreen mode.
57
59
  */
58
60
  this.mount = () => {
61
+ // If already mounted, do nothing
62
+ if (this.state.isMounted) {
63
+ console.warn('Webview is already mounted!');
64
+ return;
65
+ }
59
66
  const assets = __classPrivateFieldGet(this, _WebViewHook_renderContext, "f")?.devvitContext?.assets;
67
+ let url;
68
+ if (__classPrivateFieldGet(this, _WebViewHook_url, "f").startsWith(apiPathPrefix))
69
+ url = __classPrivateFieldGet(this, _WebViewHook_url, "f");
60
70
  // Get the public URL for the asset. Returns an empty string if the asset is not found.
61
- const url = assets.getURL(__classPrivateFieldGet(this, _WebViewHook_url, "f"), { webView: true });
71
+ else {
72
+ const asset = __classPrivateFieldGet(this, _WebViewHook_url, "f").replace(/[#?].*/, '');
73
+ url = `${assets.getURL(asset, { webView: true })}${__classPrivateFieldGet(this, _WebViewHook_url, "f").slice(asset.length)}`;
74
+ }
62
75
  if (!url) {
63
76
  throw Error(`useWebView fullscreen request failed; web view asset could not be found`);
64
77
  }
@@ -88,6 +101,10 @@ class WebViewHook {
88
101
  __classPrivateFieldSet(this, _WebViewHook_onMessage, options.onMessage, "f");
89
102
  __classPrivateFieldSet(this, _WebViewHook_onUnmount, options.onUnmount, "f");
90
103
  __classPrivateFieldSet(this, _WebViewHook_renderContext, params.context, "f");
104
+ __classPrivateFieldSet(this, _WebViewHook_invalidate, params.invalidate, "f");
105
+ }
106
+ onStateLoaded() {
107
+ // No need to remount here since the UI events will handle the state
91
108
  }
92
109
  /**
93
110
  * Handles UI events originating from the web view and calls associated callbacks for the Devvit app to handle.
@@ -95,6 +112,8 @@ class WebViewHook {
95
112
  async onUIEvent(event) {
96
113
  if (event.webView?.fullScreen) {
97
114
  const isVisible = event.webView.fullScreen.visibility === WebViewVisibility.WEBVIEW_VISIBLE;
115
+ this.state.isMounted = isVisible;
116
+ __classPrivateFieldGet(this, _WebViewHook_invalidate, "f").call(this); // Ensure the state change is persisted
98
117
  if (!isVisible && __classPrivateFieldGet(this, _WebViewHook_onUnmount, "f"))
99
118
  await __classPrivateFieldGet(this, _WebViewHook_onUnmount, "f").call(this, this);
100
119
  }
@@ -111,7 +130,7 @@ class WebViewHook {
111
130
  }
112
131
  }
113
132
  }
114
- _WebViewHook_hookId = new WeakMap(), _WebViewHook_url = new WeakMap(), _WebViewHook_onMessage = new WeakMap(), _WebViewHook_onUnmount = new WeakMap(), _WebViewHook_renderContext = new WeakMap(), _WebViewHook_emitFullscreenEffect = new WeakMap();
133
+ _WebViewHook_hookId = new WeakMap(), _WebViewHook_url = new WeakMap(), _WebViewHook_onMessage = new WeakMap(), _WebViewHook_onUnmount = new WeakMap(), _WebViewHook_renderContext = new WeakMap(), _WebViewHook_invalidate = new WeakMap(), _WebViewHook_emitFullscreenEffect = new WeakMap();
115
134
  /**
116
135
  * Use this hook to handle a web view's visibility state and any messages sent to your app.
117
136
  * */
@@ -1 +1 @@
1
- {"version":3,"file":"useChannel.d.ts","sourceRoot":"","sources":["../../../../src/devvit/internals/blocks/useChannel.ts"],"names":[],"mappings":"AAMA,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,CA8H/E"}
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;AAKjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,cAAc,CA8H/E"}
@@ -1,4 +1,4 @@
1
- import type { JSONValue } from '@devvit/shared-types/json.js';
1
+ import type { JSONValue } from '../../types/json.js';
2
2
  import type { RedisClient } from '../../types/redis.js';
3
3
  import type { BlocksReconciler } from './blocks/BlocksReconciler.js';
4
4
  import type { CacheOptions, Clock, LocalCache } from './promise_cache.js';
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/devvit/internals/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,SAAS,EAC5C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,EAAE,YAAY,KAClB,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,EACpE,KAAK,GAAE,KAAmB,GACzB,WAAW,CAGb"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/devvit/internals/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,SAAS,EAC5C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,EAAE,YAAY,KAClB,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,EACpE,KAAK,GAAE,KAAmB,GACzB,WAAW,CAGb"}
@@ -1,4 +1,4 @@
1
- import type { Metadata } from '@devvit/protos';
1
+ import { type Metadata } from '@devvit/protos';
2
2
  import type { BaseContext } from '../../types/context.js';
3
3
  export declare function getContextFromMetadata(metadata: Metadata, postId?: string, commentId?: string): BaseContext;
4
4
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/devvit/internals/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK/C,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,wBAAwB,CAAC;AAG5E,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,WAAW,CA2Cb"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/devvit/internals/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM/D,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,wBAAwB,CAAC;AAG5E,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,WAAW,CAoDb"}