@devvit/public-api 0.11.1 → 0.11.2-next-2024-10-21-e213fb2ae.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,7 +64,10 @@ export type SubmitMediaOptions = CommonSubmitPostOptions & {
64
64
  videoPosterUrl: string;
65
65
  };
66
66
  export type SubmitSelfPostOptions = PostTextOptions & CommonSubmitPostOptions;
67
- export type SubmitCustomPostOptions = CommonSubmitPostOptions & {
67
+ export type SubmitCustomPostTextFallbackOptions = {
68
+ textFallback?: CustomPostTextFallbackOptions;
69
+ };
70
+ export type SubmitCustomPostOptions = CommonSubmitPostOptions & SubmitCustomPostTextFallbackOptions & {
68
71
  preview: JSX.Element;
69
72
  };
70
73
  export type CommonSubmitPostOptions = {
@@ -269,6 +272,35 @@ export declare class Post {
269
272
  isIgnoringReports(): boolean;
270
273
  isDistinguishedBy(): string | undefined;
271
274
  edit(options: PostTextOptions): Promise<void>;
275
+ /**
276
+ * Set the suggested sort for comments on a Post.
277
+ *
278
+ * @throws {Error} Throws an error if the suggested sort could not be set.
279
+ * @example
280
+ * ```ts
281
+ * const post = await reddit.getPostById(context.postId);
282
+ * await post.setSuggestedCommentSort("NEW");
283
+ * ```
284
+ */
285
+ setSuggestedCommentSort(suggestedSort: PostSuggestedCommentSort): Promise<void>;
286
+ /**
287
+ * Set a lightweight UI that shows while the custom post renders
288
+ *
289
+ * @param {JSX.ComponentFunction} ui - A JSX component function that returns a simple ui to be rendered.
290
+ * @throws {Error} Throws an error if the preview could not be set.
291
+ * @example
292
+ * ```ts
293
+ * const preview = (
294
+ * <vstack height="100%" width="100%" alignment="middle center">
295
+ * <text size="large">An updated preview!</text>
296
+ * </vstack>
297
+ * );
298
+ * const post = await reddit.getPostById(context.postId);
299
+ * await post.setCustomPostPreview(() => preview);
300
+ * ```
301
+ */
302
+ setCustomPostPreview(ui: JSX.ComponentFunction): Promise<void>;
303
+ setTextFallback(options: CustomPostTextFallbackOptions): Promise<void>;
272
304
  addComment(options: CommentSubmissionOptions): Promise<Comment>;
273
305
  delete(): Promise<void>;
274
306
  approve(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"Post.d.ts","sourceRoot":"","sources":["../../../../src/apis/reddit/models/Post.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAQpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAwB,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,eAAe,GAAG;IAC3D,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,4BAA4B,GAAG;IACjE,IAAI,EAAE,KAAK,GAAG,eAAe,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,QAAQ,CAAC,EACL,QAAQ,GACR,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ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,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC,SAAS,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAItC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzE;;;;;;OAMG;IACH,cAAc,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAorB/E"}
@@ -10,15 +10,19 @@ 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 _Post_id, _Post_authorId, _Post_authorName, _Post_createdAt, _Post_subredditId, _Post_subredditName, _Post_permalink, _Post_title, _Post_body, _Post_bodyHtml, _Post_url, _Post_score, _Post_numberOfComments, _Post_numberOfReports, _Post_thumbnail, _Post_approved, _Post_approvedAtUtc, _Post_bannedAtUtc, _Post_spam, _Post_stickied, _Post_removed, _Post_removedBy, _Post_removedByCategory, _Post_archived, _Post_edited, _Post_locked, _Post_nsfw, _Post_quarantined, _Post_spoiler, _Post_hidden, _Post_ignoringReports, _Post_distinguishedBy, _Post_flair, _Post_secureMedia, _Post_modReportReasons, _Post_userReportReasons, _Post_metadata;
13
- import { Block } from '@devvit/protos';
13
+ import { Block, CustomPostDefinition, Definition, UIEventHandlerDefinition, UIResponse, } from '@devvit/protos';
14
+ import { LinkedBundle } from '@devvit/protos/types/devvit/runtime/bundle.js';
14
15
  import { assertNonNull } from '@devvit/shared-types/NonNull.js';
15
16
  import { RichTextBuilder } from '@devvit/shared-types/richtext/RichTextBuilder.js';
16
17
  import { asT2ID, asT3ID, asT5ID, isT3ID } from '@devvit/shared-types/tid.js';
17
- import { fromByteArray } from 'base64-js';
18
+ import { fromByteArray, toByteArray } from 'base64-js';
18
19
  import { Devvit } from '../../../devvit/Devvit.js';
19
20
  import { BlocksReconciler } from '../../../devvit/internals/blocks/BlocksReconciler.js';
21
+ import { BlocksHandler } from '../../../devvit/internals/blocks/handler/BlocksHandler.js';
22
+ import { GraphQL } from '../graphql/GraphQL.js';
20
23
  import { makeGettersEnumerable } from '../helpers/makeGettersEnumerable.js';
21
24
  import { richtextToString } from '../helpers/richtextToString.js';
25
+ import { getCustomPostRichTextFallback } from '../helpers/textFallbackToRichtext.js';
22
26
  import { Comment } from './Comment.js';
23
27
  import { Listing } from './Listing.js';
24
28
  import { ModNote } from './ModNote.js';
@@ -360,6 +364,49 @@ export class Post {
360
364
  __classPrivateFieldSet(this, _Post_body, newPost.body, "f");
361
365
  __classPrivateFieldSet(this, _Post_edited, newPost.edited, "f");
362
366
  }
367
+ /**
368
+ * Set the suggested sort for comments on a Post.
369
+ *
370
+ * @throws {Error} Throws an error if the suggested sort could not be set.
371
+ * @example
372
+ * ```ts
373
+ * const post = await reddit.getPostById(context.postId);
374
+ * await post.setSuggestedCommentSort("NEW");
375
+ * ```
376
+ */
377
+ async setSuggestedCommentSort(suggestedSort) {
378
+ await Post.setSuggestedCommentSort({ id: this.id, subredditId: __classPrivateFieldGet(this, _Post_subredditId, "f"), suggestedSort }, __classPrivateFieldGet(this, _Post_metadata, "f"));
379
+ }
380
+ /**
381
+ * Set a lightweight UI that shows while the custom post renders
382
+ *
383
+ * @param {JSX.ComponentFunction} ui - A JSX component function that returns a simple ui to be rendered.
384
+ * @throws {Error} Throws an error if the preview could not be set.
385
+ * @example
386
+ * ```ts
387
+ * const preview = (
388
+ * <vstack height="100%" width="100%" alignment="middle center">
389
+ * <text size="large">An updated preview!</text>
390
+ * </vstack>
391
+ * );
392
+ * const post = await reddit.getPostById(context.postId);
393
+ * await post.setCustomPostPreview(() => preview);
394
+ * ```
395
+ */
396
+ async setCustomPostPreview(ui) {
397
+ const newPost = await Post.setCustomPostPreview({
398
+ id: this.id,
399
+ body: this.body,
400
+ ui,
401
+ }, __classPrivateFieldGet(this, _Post_metadata, "f"));
402
+ __classPrivateFieldSet(this, _Post_body, newPost.body, "f");
403
+ __classPrivateFieldSet(this, _Post_edited, newPost.edited, "f");
404
+ }
405
+ async setTextFallback(options) {
406
+ const newPost = await Post.setTextFallback(options, this.id, __classPrivateFieldGet(this, _Post_metadata, "f"));
407
+ __classPrivateFieldSet(this, _Post_body, newPost.body, "f");
408
+ __classPrivateFieldSet(this, _Post_edited, newPost.edited, "f");
409
+ }
363
410
  async addComment(options) {
364
411
  return Comment.submit({
365
412
  id: this.id,
@@ -484,12 +531,13 @@ export class Post {
484
531
  const reconciler = new BlocksReconciler(() => options.preview, undefined, {}, metadata, undefined);
485
532
  const previewBlock = await reconciler.buildBlocksUI();
486
533
  const encodedCached = Block.encode(previewBlock).finish();
487
- const { ...sanitizedOptions } = options;
534
+ const { textFallback, ...sanitizedOptions } = options;
535
+ const richtextFallback = textFallback ? getCustomPostRichTextFallback(textFallback) : '';
488
536
  const submitRequest = {
489
537
  kind: 'custom',
490
538
  sr: options.subredditName,
491
539
  richtextJson: fromByteArray(encodedCached),
492
- richtextFallback: '',
540
+ richtextFallback,
493
541
  ...sanitizedOptions,
494
542
  };
495
543
  response = await client.SubmitCustomPost(submitRequest, metadata);
@@ -548,6 +596,94 @@ export class Post {
548
596
  return Post.getById(id, metadata);
549
597
  }
550
598
  /** @internal */
599
+ static async setSuggestedCommentSort(options, metadata) {
600
+ const operationName = 'SetSuggestedSort';
601
+ const persistedQueryHash = 'cf6052acc7fefaa65b710625b81dba8041f258313aafe9730e2a3dc855e5d10d';
602
+ const response = await GraphQL.query(operationName, persistedQueryHash, {
603
+ input: {
604
+ subredditId: options.subredditId,
605
+ postId: options.id,
606
+ sort: options.suggestedSort,
607
+ },
608
+ }, metadata);
609
+ if (!response.data?.setSuggestedSort?.ok) {
610
+ throw new Error('Failed to set suggested sort');
611
+ }
612
+ }
613
+ /** @internal */
614
+ static async setCustomPostPreview(options, metadata) {
615
+ if (!metadata) {
616
+ throw new Error('Failed to set custom post preview. Metadata not found');
617
+ }
618
+ // Get skinny bundle from post
619
+ const bundleMatches = new RegExp(/DX_Bundle:\n\n {4}(?<bundle>[^\n]*)/g).exec(options.body ?? '');
620
+ if (!bundleMatches?.groups?.['bundle']) {
621
+ throw new Error(`Failed to set custom post preview. Couldn't find bundle in post ${options.id}`);
622
+ }
623
+ const origBundle = toByteArray(bundleMatches.groups['bundle']);
624
+ const myBundle = LinkedBundle.decode(origBundle);
625
+ // Ensure we have all the correct definitions
626
+ myBundle.provides = [CustomPostDefinition, UIEventHandlerDefinition].map((d) => Definition.toSerializable(d));
627
+ const newBundle = fromByteArray(LinkedBundle.encode(myBundle).finish());
628
+ // Get fallback text from post, if it exists
629
+ const fallbackMatches = new RegExp(/DX_RichtextFallback:\n\n {4}(?<fallback>[^\n]*)/g).exec(options.body ?? '');
630
+ const textFallback = fallbackMatches?.groups?.['fallback'];
631
+ const handler = new BlocksHandler(options.ui);
632
+ const handlerResponse = UIResponse.fromJSON(await handler.handle({ events: [] }, metadata));
633
+ const block = handlerResponse.blocks;
634
+ const cached = fromByteArray(Block.encode(block).finish());
635
+ const postRTJson = new RichTextBuilder()
636
+ .heading({ level: 1 }, (h) => h.rawText('DX_Bundle:'))
637
+ .codeBlock({ language: '' }, (c) => {
638
+ c.rawText(newBundle);
639
+ })
640
+ .heading({ level: 1 }, (h) => h.rawText('DX_Config:'))
641
+ .codeBlock({ language: '' }, (c) => {
642
+ c.rawText('EgA=');
643
+ })
644
+ .heading({ level: 1 }, (h) => h.rawText('DX_Cached:'))
645
+ .codeBlock({ language: '' }, (c) => {
646
+ c.rawText(cached);
647
+ });
648
+ if (textFallback) {
649
+ postRTJson
650
+ .heading({ level: 1 }, (h) => h.rawText('DX_RichtextFallback:'))
651
+ .codeBlock({ language: '' }, (c) => {
652
+ c.rawText(textFallback);
653
+ });
654
+ }
655
+ const operationName = 'UpdatePost';
656
+ const persistedQueryHash = 'ccc5f1da31a8d8c518b6607e81c2903a46f922cb6562c8b47fcc8988f0611360';
657
+ const response = await GraphQL.query(operationName, persistedQueryHash, {
658
+ input: {
659
+ postId: options.id,
660
+ content: {
661
+ richText: postRTJson.build(),
662
+ },
663
+ },
664
+ }, metadata);
665
+ if (!response.data?.updatePost?.ok) {
666
+ throw new Error('Failed to set custom post preview');
667
+ }
668
+ return Post.getById(options.id, metadata);
669
+ }
670
+ /** @internal */
671
+ static async setTextFallback(options, postId, metadata) {
672
+ if (!('text' in options) && !('richtext' in options)) {
673
+ throw new Error(`No text fallback provided for post ${postId}.`);
674
+ }
675
+ const client = Devvit.redditAPIPlugins.LinksAndComments;
676
+ const richtextFallback = getCustomPostRichTextFallback(options);
677
+ const response = await client.EditCustomPost({
678
+ thingId: postId,
679
+ richtextFallback,
680
+ }, metadata);
681
+ if (response.json?.errors?.length) {
682
+ throw new Error('Failed to set post text fallback');
683
+ }
684
+ return Post.getById(postId, metadata);
685
+ }
686
+ /** @internal */
551
687
  static async delete(id, metadata) {
552
688
  const client = Devvit.redditAPIPlugins.LinksAndComments;
553
689
  await client.Del({
package/meta.json CHANGED
@@ -11200,19 +11200,82 @@
11200
11200
  ],
11201
11201
  "format": "esm"
11202
11202
  },
11203
+ "../protos/dist/types/devvit/runtime/serializable.js": {
11204
+ "bytes": 8666,
11205
+ "imports": [
11206
+ {
11207
+ "path": "../../node_modules/protobufjs/minimal.js",
11208
+ "kind": "import-statement",
11209
+ "original": "protobufjs/minimal.js"
11210
+ },
11211
+ {
11212
+ "path": "../protos/dist/types/typeRegistry.js",
11213
+ "kind": "import-statement",
11214
+ "original": "../../typeRegistry.js"
11215
+ }
11216
+ ],
11217
+ "format": "esm"
11218
+ },
11219
+ "../protos/dist/types/devvit/runtime/bundle.js": {
11220
+ "bytes": 43724,
11221
+ "imports": [
11222
+ {
11223
+ "path": "../../node_modules/protobufjs/minimal.js",
11224
+ "kind": "import-statement",
11225
+ "original": "protobufjs/minimal.js"
11226
+ },
11227
+ {
11228
+ "path": "../protos/dist/types/google/protobuf/timestamp.js",
11229
+ "kind": "import-statement",
11230
+ "original": "../../google/protobuf/timestamp.js"
11231
+ },
11232
+ {
11233
+ "path": "../protos/dist/types/google/protobuf/wrappers.js",
11234
+ "kind": "import-statement",
11235
+ "original": "../../google/protobuf/wrappers.js"
11236
+ },
11237
+ {
11238
+ "path": "../protos/dist/types/typeRegistry.js",
11239
+ "kind": "import-statement",
11240
+ "original": "../../typeRegistry.js"
11241
+ },
11242
+ {
11243
+ "path": "../protos/dist/types/devvit/runtime/serializable.js",
11244
+ "kind": "import-statement",
11245
+ "original": "./serializable.js"
11246
+ }
11247
+ ],
11248
+ "format": "esm"
11249
+ },
11203
11250
  "../../node_modules/base64-js/index.js": {
11204
11251
  "bytes": 3932,
11205
11252
  "imports": [],
11206
11253
  "format": "cjs"
11207
11254
  },
11255
+ "src/apis/reddit/helpers/textFallbackToRichtext.ts": {
11256
+ "bytes": 742,
11257
+ "imports": [
11258
+ {
11259
+ "path": "../shared-types/dist/richtext/RichTextBuilder.js",
11260
+ "kind": "import-statement",
11261
+ "original": "@devvit/shared-types/richtext/RichTextBuilder.js"
11262
+ }
11263
+ ],
11264
+ "format": "esm"
11265
+ },
11208
11266
  "src/apis/reddit/models/Post.ts": {
11209
- "bytes": 36292,
11267
+ "bytes": 42806,
11210
11268
  "imports": [
11211
11269
  {
11212
11270
  "path": "../protos/dist/index.js",
11213
11271
  "kind": "import-statement",
11214
11272
  "original": "@devvit/protos"
11215
11273
  },
11274
+ {
11275
+ "path": "../protos/dist/types/devvit/runtime/bundle.js",
11276
+ "kind": "import-statement",
11277
+ "original": "@devvit/protos/types/devvit/runtime/bundle.js"
11278
+ },
11216
11279
  {
11217
11280
  "path": "../shared-types/dist/NonNull.js",
11218
11281
  "kind": "import-statement",
@@ -11243,6 +11306,16 @@
11243
11306
  "kind": "import-statement",
11244
11307
  "original": "../../../devvit/internals/blocks/BlocksReconciler.js"
11245
11308
  },
11309
+ {
11310
+ "path": "src/devvit/internals/blocks/handler/BlocksHandler.ts",
11311
+ "kind": "import-statement",
11312
+ "original": "../../../devvit/internals/blocks/handler/BlocksHandler.js"
11313
+ },
11314
+ {
11315
+ "path": "src/apis/reddit/graphql/GraphQL.ts",
11316
+ "kind": "import-statement",
11317
+ "original": "../graphql/GraphQL.js"
11318
+ },
11246
11319
  {
11247
11320
  "path": "src/apis/reddit/helpers/makeGettersEnumerable.ts",
11248
11321
  "kind": "import-statement",
@@ -11253,6 +11326,11 @@
11253
11326
  "kind": "import-statement",
11254
11327
  "original": "../helpers/richtextToString.js"
11255
11328
  },
11329
+ {
11330
+ "path": "src/apis/reddit/helpers/textFallbackToRichtext.ts",
11331
+ "kind": "import-statement",
11332
+ "original": "../helpers/textFallbackToRichtext.js"
11333
+ },
11256
11334
  {
11257
11335
  "path": "src/apis/reddit/models/Comment.ts",
11258
11336
  "kind": "import-statement",
@@ -12220,7 +12298,7 @@
12220
12298
  "bytesInOutput": 27924
12221
12299
  },
12222
12300
  "../../node_modules/base64-js/index.js": {
12223
- "bytesInOutput": 3902
12301
+ "bytesInOutput": 3904
12224
12302
  },
12225
12303
  "src/index.ts": {
12226
12304
  "bytesInOutput": 2191
@@ -12294,6 +12372,9 @@
12294
12372
  "../protos/dist/types/google/protobuf/empty.js": {
12295
12373
  "bytesInOutput": 1088
12296
12374
  },
12375
+ "../protos/dist/lib/Types.js": {
12376
+ "bytesInOutput": 1967
12377
+ },
12297
12378
  "../protos/dist/types/devvit/actor/reddit/context_action.js": {
12298
12379
  "bytesInOutput": 22818
12299
12380
  },
@@ -12735,8 +12816,17 @@
12735
12816
  "src/apis/reddit/models/Flair.ts": {
12736
12817
  "bytesInOutput": 10882
12737
12818
  },
12819
+ "../protos/dist/types/devvit/runtime/bundle.js": {
12820
+ "bytesInOutput": 38457
12821
+ },
12822
+ "../protos/dist/types/devvit/runtime/serializable.js": {
12823
+ "bytesInOutput": 7835
12824
+ },
12738
12825
  "src/apis/reddit/models/Post.ts": {
12739
- "bytesInOutput": 29229
12826
+ "bytesInOutput": 34982
12827
+ },
12828
+ "src/apis/reddit/helpers/textFallbackToRichtext.ts": {
12829
+ "bytesInOutput": 455
12740
12830
  },
12741
12831
  "src/apis/reddit/models/User.ts": {
12742
12832
  "bytesInOutput": 15898
@@ -12775,7 +12865,7 @@
12775
12865
  "bytesInOutput": 370
12776
12866
  }
12777
12867
  },
12778
- "bytes": 12550895
12868
+ "bytes": 12740413
12779
12869
  }
12780
12870
  }
12781
12871
  }
package/meta.min.json CHANGED
@@ -4159,14 +4159,30 @@
4159
4159
  "imports": [],
4160
4160
  "format": "cjs"
4161
4161
  },
4162
+ "src/apis/reddit/helpers/textFallbackToRichtext.ts": {
4163
+ "bytes": 742,
4164
+ "imports": [
4165
+ {
4166
+ "path": "../shared-types/dist/richtext/RichTextBuilder.js",
4167
+ "kind": "import-statement",
4168
+ "original": "@devvit/shared-types/richtext/RichTextBuilder.js"
4169
+ }
4170
+ ],
4171
+ "format": "esm"
4172
+ },
4162
4173
  "src/apis/reddit/models/Post.ts": {
4163
- "bytes": 36292,
4174
+ "bytes": 42806,
4164
4175
  "imports": [
4165
4176
  {
4166
4177
  "path": "@devvit/protos",
4167
4178
  "kind": "import-statement",
4168
4179
  "external": true
4169
4180
  },
4181
+ {
4182
+ "path": "@devvit/protos/types/devvit/runtime/bundle.js",
4183
+ "kind": "import-statement",
4184
+ "external": true
4185
+ },
4170
4186
  {
4171
4187
  "path": "../shared-types/dist/NonNull.js",
4172
4188
  "kind": "import-statement",
@@ -4197,6 +4213,16 @@
4197
4213
  "kind": "import-statement",
4198
4214
  "original": "../../../devvit/internals/blocks/BlocksReconciler.js"
4199
4215
  },
4216
+ {
4217
+ "path": "src/devvit/internals/blocks/handler/BlocksHandler.ts",
4218
+ "kind": "import-statement",
4219
+ "original": "../../../devvit/internals/blocks/handler/BlocksHandler.js"
4220
+ },
4221
+ {
4222
+ "path": "src/apis/reddit/graphql/GraphQL.ts",
4223
+ "kind": "import-statement",
4224
+ "original": "../graphql/GraphQL.js"
4225
+ },
4200
4226
  {
4201
4227
  "path": "src/apis/reddit/helpers/makeGettersEnumerable.ts",
4202
4228
  "kind": "import-statement",
@@ -4207,6 +4233,11 @@
4207
4233
  "kind": "import-statement",
4208
4234
  "original": "../helpers/richtextToString.js"
4209
4235
  },
4236
+ {
4237
+ "path": "src/apis/reddit/helpers/textFallbackToRichtext.ts",
4238
+ "kind": "import-statement",
4239
+ "original": "../helpers/textFallbackToRichtext.js"
4240
+ },
4210
4241
  {
4211
4242
  "path": "src/apis/reddit/models/Comment.ts",
4212
4243
  "kind": "import-statement",
@@ -4758,7 +4789,7 @@
4758
4789
  "imports": [],
4759
4790
  "exports": [],
4760
4791
  "inputs": {},
4761
- "bytes": 1213057
4792
+ "bytes": 1223919
4762
4793
  },
4763
4794
  "dist/public-api.min.js": {
4764
4795
  "imports": [
@@ -4892,6 +4923,11 @@
4892
4923
  "kind": "import-statement",
4893
4924
  "external": true
4894
4925
  },
4926
+ {
4927
+ "path": "@devvit/protos/types/devvit/runtime/bundle.js",
4928
+ "kind": "import-statement",
4929
+ "external": true
4930
+ },
4895
4931
  {
4896
4932
  "path": "@devvit/protos",
4897
4933
  "kind": "import-statement",
@@ -5556,7 +5592,10 @@
5556
5592
  "bytesInOutput": 4081
5557
5593
  },
5558
5594
  "src/apis/reddit/models/Post.ts": {
5559
- "bytesInOutput": 12594
5595
+ "bytesInOutput": 15129
5596
+ },
5597
+ "src/apis/reddit/helpers/textFallbackToRichtext.ts": {
5598
+ "bytesInOutput": 114
5560
5599
  },
5561
5600
  "src/apis/reddit/models/User.ts": {
5562
5601
  "bytesInOutput": 5941
@@ -5595,7 +5634,7 @@
5595
5634
  "bytesInOutput": 178
5596
5635
  }
5597
5636
  },
5598
- "bytes": 259015
5637
+ "bytes": 261664
5599
5638
  }
5600
5639
  }
5601
5640
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/public-api",
3
- "version": "0.11.1",
3
+ "version": "0.11.2-next-2024-10-21-e213fb2ae.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "types": "./index.d.ts",
32
32
  "dependencies": {
33
- "@devvit/protos": "0.11.1",
34
- "@devvit/shared-types": "0.11.1",
33
+ "@devvit/protos": "0.11.2-next-2024-10-21-e213fb2ae.0",
34
+ "@devvit/shared-types": "0.11.2-next-2024-10-21-e213fb2ae.0",
35
35
  "base64-js": "1.5.1",
36
36
  "clone-deep": "4.0.1",
37
37
  "core-js": "3.27.2",
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@ampproject/filesize": "4.3.0",
42
- "@devvit/repo-tools": "0.11.1",
43
- "@devvit/tsconfig": "0.11.1",
42
+ "@devvit/repo-tools": "0.11.2-next-2024-10-21-e213fb2ae.0",
43
+ "@devvit/tsconfig": "0.11.2-next-2024-10-21-e213fb2ae.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",
@@ -63,5 +63,5 @@
63
63
  }
64
64
  },
65
65
  "source": "./src/index.ts",
66
- "gitHead": "b7e0214655df6dcdd70c7944b9a14b0d752577ae"
66
+ "gitHead": "50c424e97fe6c1dc8012a59acab9c76c67342a98"
67
67
  }
package/public-api.d.ts CHANGED
@@ -2518,6 +2518,8 @@ declare interface BuildInfo {
2518
2518
  dependencies: {
2519
2519
  [key: string]: string;
2520
2520
  };
2521
+ /** Where the bundle can be executed */
2522
+ targetRuntime: TargetRuntime;
2521
2523
  }
2522
2524
 
2523
2525
  declare const BuildInfo: {
@@ -34433,6 +34435,35 @@ export declare class Post {
34433
34435
  isIgnoringReports(): boolean;
34434
34436
  isDistinguishedBy(): string | undefined;
34435
34437
  edit(options: PostTextOptions): Promise<void>;
34438
+ /**
34439
+ * Set the suggested sort for comments on a Post.
34440
+ *
34441
+ * @throws {Error} Throws an error if the suggested sort could not be set.
34442
+ * @example
34443
+ * ```ts
34444
+ * const post = await reddit.getPostById(context.postId);
34445
+ * await post.setSuggestedCommentSort("NEW");
34446
+ * ```
34447
+ */
34448
+ setSuggestedCommentSort(suggestedSort: PostSuggestedCommentSort): Promise<void>;
34449
+ /**
34450
+ * Set a lightweight UI that shows while the custom post renders
34451
+ *
34452
+ * @param {JSX.ComponentFunction} ui - A JSX component function that returns a simple ui to be rendered.
34453
+ * @throws {Error} Throws an error if the preview could not be set.
34454
+ * @example
34455
+ * ```ts
34456
+ * const preview = (
34457
+ * <vstack height="100%" width="100%" alignment="middle center">
34458
+ * <text size="large">An updated preview!</text>
34459
+ * </vstack>
34460
+ * );
34461
+ * const post = await reddit.getPostById(context.postId);
34462
+ * await post.setCustomPostPreview(() => preview);
34463
+ * ```
34464
+ */
34465
+ setCustomPostPreview(ui: JSX.ComponentFunction): Promise<void>;
34466
+ setTextFallback(options: CustomPostTextFallbackOptions): Promise<void>;
34436
34467
  addComment(options: CommentSubmissionOptions): Promise<Comment>;
34437
34468
  delete(): Promise<void>;
34438
34469
  approve(): Promise<void>;
@@ -41860,10 +41891,14 @@ declare const StylesheetRequest: {
41860
41891
  fromPartial(object: DeepPartial_2<StylesheetRequest>): StylesheetRequest;
41861
41892
  };
41862
41893
 
41863
- export declare type SubmitCustomPostOptions = CommonSubmitPostOptions & {
41894
+ export declare type SubmitCustomPostOptions = CommonSubmitPostOptions & SubmitCustomPostTextFallbackOptions & {
41864
41895
  preview: JSX.Element;
41865
41896
  };
41866
41897
 
41898
+ export declare type SubmitCustomPostTextFallbackOptions = {
41899
+ textFallback?: CustomPostTextFallbackOptions;
41900
+ };
41901
+
41867
41902
  export declare type SubmitLinkOptions = CommonSubmitPostOptions & {
41868
41903
  url: string;
41869
41904
  /**
@@ -47992,6 +48027,13 @@ declare type TableHeaderCellOptions = {
47992
48027
  declare interface TableRowContext extends TableCellContainer<TableRowContext> {
47993
48028
  }
47994
48029
 
48030
+ declare enum TargetRuntime {
48031
+ UNIVERSAL = 0,
48032
+ /** CLIENT - SERVER = 2; */
48033
+ CLIENT = 1,
48034
+ UNRECOGNIZED = -1
48035
+ }
48036
+
47995
48037
  declare interface TempBanRequest {
47996
48038
  /** id36 of a modmail conversation id */
47997
48039
  conversationId: string;