@devvit/public-api 0.10.22-next-2024-06-06-7f14615a7.0 → 0.10.22-next-2024-06-10-118002c24.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,14 +9,12 @@ 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 _BlocksHandler_instances, _BlocksHandler_root, _BlocksHandler_contextBuilder, _BlocksHandler_blocksTransformer, _BlocksHandler_loadHooks, _BlocksHandler_handleAsyncQueues, _BlocksHandler_attemptHook, _BlocksHandler_handleMainQueue, _BlocksHandler_renderRoot, _BlocksHandler_render, _BlocksHandler_renderList, _BlocksHandler_renderElement, _BlocksHandler_reifyProps, _BlocksHandler_resolveAsset;
13
- import { isAcceptableDataUrl, isRemoteUrl } from '@devvit/shared-types/imageUtil.js';
12
+ var _BlocksHandler_instances, _BlocksHandler_root, _BlocksHandler_contextBuilder, _BlocksHandler_blocksTransformer, _BlocksHandler_loadHooks, _BlocksHandler_handleAsyncQueues, _BlocksHandler_attemptHook, _BlocksHandler_handleMainQueue, _BlocksHandler_renderRoot, _BlocksHandler_render, _BlocksHandler_renderList, _BlocksHandler_renderElement, _BlocksHandler_reifyProps;
14
13
  import isEqual from 'lodash.isequal';
15
14
  import { BlocksTransformer } from '../BlocksTransformer.js';
16
15
  import { ContextBuilder } from './ContextBuilder.js';
17
16
  import { RenderContext } from './RenderContext.js';
18
17
  import { RenderInterruptError } from './types.js';
19
- import { useAsync } from './useAsync.js';
20
18
  /**
21
19
  * This can be a global/singleton because render is synchronous.
22
20
  *
@@ -87,7 +85,7 @@ export class BlocksHandler {
87
85
  _BlocksHandler_instances.add(this);
88
86
  _BlocksHandler_root.set(this, void 0);
89
87
  _BlocksHandler_contextBuilder.set(this, new ContextBuilder());
90
- _BlocksHandler_blocksTransformer.set(this, new BlocksTransformer());
88
+ _BlocksHandler_blocksTransformer.set(this, new BlocksTransformer(() => this._latestRenderContext?.devvitContext?.assets));
91
89
  this._latestRenderContext = null;
92
90
  console.log('BlocksHandler v1');
93
91
  __classPrivateFieldSet(this, _BlocksHandler_root, root, "f");
@@ -220,8 +218,8 @@ export class BlocksHandler {
220
218
  console.error('Effects were mutated during rendering', context._effects, effectsCopy);
221
219
  }
222
220
  if (tags) {
223
- blocks = await __classPrivateFieldGet(this, _BlocksHandler_blocksTransformer, "f").createBlocksElementOrThrow(tags);
224
- blocks = await __classPrivateFieldGet(this, _BlocksHandler_blocksTransformer, "f").ensureRootBlock(blocks);
221
+ blocks = __classPrivateFieldGet(this, _BlocksHandler_blocksTransformer, "f").createBlocksElementOrThrow(tags);
222
+ blocks = __classPrivateFieldGet(this, _BlocksHandler_blocksTransformer, "f").ensureRootBlock(blocks);
225
223
  }
226
224
  }
227
225
  return {
@@ -357,28 +355,14 @@ async function _BlocksHandler_handleAsyncQueues(context, ...batch) {
357
355
  }
358
356
  }
359
357
  else {
360
- const value = props[key];
358
+ // push value through the JSON parser to filter incompatible types
359
+ const value = JSON.parse(JSON.stringify(props[key]));
361
360
  if (value !== undefined && value !== null) {
362
- reifiedProps[key] = key === 'url' ? __classPrivateFieldGet(this, _BlocksHandler_instances, "m", _BlocksHandler_resolveAsset).call(this, value) : value;
361
+ reifiedProps[key] = value;
363
362
  }
364
363
  }
365
364
  }
366
365
  return reifiedProps;
367
- }, _BlocksHandler_resolveAsset = function _BlocksHandler_resolveAsset(url) {
368
- const resolvedUrl = globalThis.devvit?.config?.assets?.[url];
369
- if (resolvedUrl) {
370
- // no work to be done, the asset map from the bundle was available and had the mapping
371
- return resolvedUrl;
372
- }
373
- // determine if the url can be used as-is
374
- if (isRemoteUrl(url) || isAcceptableDataUrl(url)) {
375
- return url;
376
- }
377
- // attempt to resolve the final URL with the AssetResolver plugin
378
- const { data, loading } = useAsync(async () => {
379
- return (await this._latestRenderContext?.devvitContext.assets.getURL(url)) ?? null;
380
- });
381
- return loading ? '' : data ?? '[missing]';
382
366
  };
383
367
  function isBlockElement(e) {
384
368
  return typeof e === 'object' && e != null && 'type' in e;
@@ -1,5 +1,5 @@
1
1
  import type { Metadata, UIRequest } from '@devvit/protos';
2
- import { Devvit } from '../../../Devvit.js';
2
+ import type { Devvit } from '../../../Devvit.js';
3
3
  import type { RenderContext } from './RenderContext.js';
4
4
  export declare class ContextBuilder {
5
5
  buildContext(renderContext: RenderContext, request: UIRequest, metadata: Metadata): Devvit.Context;
@@ -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,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBxD,qBAAa,cAAc;IAClB,YAAY,CACjB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,OAAO;CA2ClB"}
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;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBxD,qBAAa,cAAc;IAClB,YAAY,CACjB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,OAAO;CA2ClB"}
@@ -8,7 +8,6 @@ import { RedditAPIClient } from '../../../../apis/reddit/RedditAPIClient.js';
8
8
  import { RedisClient } from '../../../../apis/redis/RedisClient.js';
9
9
  import { SchedulerClient } from '../../../../apis/scheduler/SchedulerClient.js';
10
10
  import { SettingsClient } from '../../../../apis/settings/SettingsClient.js';
11
- import { Devvit } from '../../../Devvit.js';
12
11
  import { getContextFromMetadata } from '../../context.js';
13
12
  import { UIClient } from './UIClient.js';
14
13
  import { useChannel } from './useChannel.js';
@@ -31,7 +30,7 @@ export class ContextBuilder {
31
30
  const settings = new SettingsClient(metadata);
32
31
  const ui = new UIClient(renderContext);
33
32
  const media = new MediaClient(metadata);
34
- const assets = new AssetsClient(metadata, () => Devvit.assetsPlugin);
33
+ const assets = new AssetsClient();
35
34
  const realtime = new RealtimeClient(metadata);
36
35
  const cache = UnimplementedProxy;
37
36
  const apiClients = {
package/meta.json CHANGED
@@ -11452,12 +11452,12 @@
11452
11452
  "format": "esm"
11453
11453
  },
11454
11454
  "src/apis/AssetsClient/AssetsClient.ts": {
11455
- "bytes": 3761,
11455
+ "bytes": 2616,
11456
11456
  "imports": [
11457
11457
  {
11458
- "path": "../../devvit/Devvit.js",
11458
+ "path": "src/devvit/Devvit.ts",
11459
11459
  "kind": "import-statement",
11460
- "external": true
11460
+ "original": "../../devvit/Devvit.js"
11461
11461
  },
11462
11462
  {
11463
11463
  "path": "<runtime>",
@@ -11679,7 +11679,7 @@
11679
11679
  "format": "esm"
11680
11680
  },
11681
11681
  "src/apis/makeAPIClients.ts": {
11682
- "bytes": 3418,
11682
+ "bytes": 3345,
11683
11683
  "imports": [
11684
11684
  {
11685
11685
  "path": "src/devvit/internals/blocks/useChannel.ts",
@@ -11701,11 +11701,6 @@
11701
11701
  "kind": "import-statement",
11702
11702
  "original": "../devvit/internals/blocks/useState.js"
11703
11703
  },
11704
- {
11705
- "path": "src/index.ts",
11706
- "kind": "import-statement",
11707
- "original": "../index.js"
11708
- },
11709
11704
  {
11710
11705
  "path": "src/apis/AssetsClient/AssetsClient.ts",
11711
11706
  "kind": "import-statement",
@@ -11837,11 +11832,6 @@
11837
11832
  ],
11838
11833
  "format": "esm"
11839
11834
  },
11840
- "../shared-types/dist/imageUtil.js": {
11841
- "bytes": 2722,
11842
- "imports": [],
11843
- "format": "esm"
11844
- },
11845
11835
  "src/apis/ui/helpers/getEffectsFromUIClient.ts": {
11846
11836
  "bytes": 368,
11847
11837
  "imports": [],
@@ -11869,7 +11859,7 @@
11869
11859
  "format": "esm"
11870
11860
  },
11871
11861
  "src/devvit/internals/blocks/BlocksTransformer.ts": {
11872
- "bytes": 27859,
11862
+ "bytes": 28008,
11873
11863
  "imports": [
11874
11864
  {
11875
11865
  "path": "../protos/dist/index.js",
@@ -11885,12 +11875,17 @@
11885
11875
  "path": "src/devvit/internals/helpers/color.ts",
11886
11876
  "kind": "import-statement",
11887
11877
  "original": "../helpers/color.js"
11878
+ },
11879
+ {
11880
+ "path": "<runtime>",
11881
+ "kind": "import-statement",
11882
+ "external": true
11888
11883
  }
11889
11884
  ],
11890
11885
  "format": "esm"
11891
11886
  },
11892
11887
  "src/devvit/internals/blocks/BlocksReconciler.ts": {
11893
- "bytes": 19632,
11888
+ "bytes": 18195,
11894
11889
  "imports": [
11895
11890
  {
11896
11891
  "path": "../protos/dist/index.js",
@@ -11902,11 +11897,6 @@
11902
11897
  "kind": "import-statement",
11903
11898
  "original": "@devvit/shared-types/Header.js"
11904
11899
  },
11905
- {
11906
- "path": "../shared-types/dist/imageUtil.js",
11907
- "kind": "import-statement",
11908
- "original": "@devvit/shared-types/imageUtil.js"
11909
- },
11910
11900
  {
11911
11901
  "path": "src/apis/makeAPIClients.ts",
11912
11902
  "kind": "import-statement",
@@ -12401,7 +12391,7 @@
12401
12391
  "format": "esm"
12402
12392
  },
12403
12393
  "src/devvit/internals/blocks/handler/ContextBuilder.ts": {
12404
- "bytes": 3111,
12394
+ "bytes": 3081,
12405
12395
  "imports": [
12406
12396
  {
12407
12397
  "path": "../shared-types/dist/Header.js",
@@ -12453,11 +12443,6 @@
12453
12443
  "kind": "import-statement",
12454
12444
  "original": "../../../../apis/settings/SettingsClient.js"
12455
12445
  },
12456
- {
12457
- "path": "src/devvit/Devvit.ts",
12458
- "kind": "import-statement",
12459
- "original": "../../../Devvit.js"
12460
- },
12461
12446
  {
12462
12447
  "path": "src/devvit/internals/context.ts",
12463
12448
  "kind": "import-statement",
@@ -12491,50 +12476,14 @@
12491
12476
  ],
12492
12477
  "format": "esm"
12493
12478
  },
12494
- "../shared-types/dist/CircuitBreaker.js": {
12495
- "bytes": 943,
12496
- "imports": [],
12497
- "format": "esm"
12498
- },
12499
- "src/devvit/internals/blocks/handler/useAsync.ts": {
12500
- "bytes": 4653,
12501
- "imports": [
12502
- {
12503
- "path": "src/devvit/internals/blocks/handler/BlocksHandler.ts",
12504
- "kind": "import-statement",
12505
- "original": "./BlocksHandler.js"
12506
- },
12507
- {
12508
- "path": "../../node_modules/lodash.isequal/index.js",
12509
- "kind": "import-statement",
12510
- "original": "lodash.isequal"
12511
- },
12512
- {
12513
- "path": "../shared-types/dist/CircuitBreaker.js",
12514
- "kind": "import-statement",
12515
- "original": "@devvit/shared-types/CircuitBreaker.js"
12516
- },
12517
- {
12518
- "path": "<runtime>",
12519
- "kind": "import-statement",
12520
- "external": true
12521
- }
12522
- ],
12523
- "format": "esm"
12524
- },
12525
12479
  "src/devvit/internals/blocks/handler/BlocksHandler.ts": {
12526
- "bytes": 16152,
12480
+ "bytes": 15102,
12527
12481
  "imports": [
12528
12482
  {
12529
12483
  "path": "@devvit/protos",
12530
12484
  "kind": "import-statement",
12531
12485
  "external": true
12532
12486
  },
12533
- {
12534
- "path": "../shared-types/dist/imageUtil.js",
12535
- "kind": "import-statement",
12536
- "original": "@devvit/shared-types/imageUtil.js"
12537
- },
12538
12487
  {
12539
12488
  "path": "../../node_modules/lodash.isequal/index.js",
12540
12489
  "kind": "import-statement",
@@ -12560,11 +12509,6 @@
12560
12509
  "kind": "import-statement",
12561
12510
  "original": "./types.js"
12562
12511
  },
12563
- {
12564
- "path": "src/devvit/internals/blocks/handler/useAsync.ts",
12565
- "kind": "import-statement",
12566
- "original": "./useAsync.js"
12567
- },
12568
12512
  {
12569
12513
  "path": "<runtime>",
12570
12514
  "kind": "import-statement",
@@ -12600,7 +12544,7 @@
12600
12544
  "format": "esm"
12601
12545
  },
12602
12546
  "src/devvit/Devvit.ts": {
12603
- "bytes": 34309,
12547
+ "bytes": 33892,
12604
12548
  "imports": [
12605
12549
  {
12606
12550
  "path": "../protos/dist/index.js",
@@ -13361,6 +13305,37 @@
13361
13305
  ],
13362
13306
  "format": "esm"
13363
13307
  },
13308
+ "../shared-types/dist/CircuitBreaker.js": {
13309
+ "bytes": 943,
13310
+ "imports": [],
13311
+ "format": "esm"
13312
+ },
13313
+ "src/devvit/internals/blocks/handler/useAsync.ts": {
13314
+ "bytes": 4653,
13315
+ "imports": [
13316
+ {
13317
+ "path": "src/devvit/internals/blocks/handler/BlocksHandler.ts",
13318
+ "kind": "import-statement",
13319
+ "original": "./BlocksHandler.js"
13320
+ },
13321
+ {
13322
+ "path": "../../node_modules/lodash.isequal/index.js",
13323
+ "kind": "import-statement",
13324
+ "original": "lodash.isequal"
13325
+ },
13326
+ {
13327
+ "path": "../shared-types/dist/CircuitBreaker.js",
13328
+ "kind": "import-statement",
13329
+ "original": "@devvit/shared-types/CircuitBreaker.js"
13330
+ },
13331
+ {
13332
+ "path": "<runtime>",
13333
+ "kind": "import-statement",
13334
+ "external": true
13335
+ }
13336
+ ],
13337
+ "format": "esm"
13338
+ },
13364
13339
  "src/index.ts": {
13365
13340
  "bytes": 707,
13366
13341
  "imports": [
@@ -14099,7 +14074,7 @@
14099
14074
  "bytesInOutput": 3165
14100
14075
  },
14101
14076
  "../protos/dist/types/devvit/plugin/assetresolver/assetresolver.js": {
14102
- "bytesInOutput": 13679
14077
+ "bytesInOutput": 12946
14103
14078
  },
14104
14079
  "../protos/dist/types/devvit/gateway/v1alpha/triggers.js": {
14105
14080
  "bytesInOutput": 9704
@@ -14333,10 +14308,10 @@
14333
14308
  "bytesInOutput": 1356
14334
14309
  },
14335
14310
  "src/apis/AssetsClient/AssetsClient.ts": {
14336
- "bytesInOutput": 2760
14311
+ "bytesInOutput": 1873
14337
14312
  },
14338
14313
  "src/apis/key-value-storage/KeyValueStorage.ts": {
14339
- "bytesInOutput": 971
14314
+ "bytesInOutput": 963
14340
14315
  },
14341
14316
  "src/apis/media/MediaClient.ts": {
14342
14317
  "bytesInOutput": 525
@@ -14366,10 +14341,10 @@
14366
14341
  "bytesInOutput": 146
14367
14342
  },
14368
14343
  "src/apis/realtime/RealtimeClient.ts": {
14369
- "bytesInOutput": 346
14344
+ "bytesInOutput": 341
14370
14345
  },
14371
14346
  "src/apis/makeAPIClients.ts": {
14372
- "bytesInOutput": 2008
14347
+ "bytesInOutput": 1973
14373
14348
  },
14374
14349
  "src/devvit/internals/context.ts": {
14375
14350
  "bytesInOutput": 711
@@ -14380,9 +14355,6 @@
14380
14355
  "src/devvit/internals/app-settings.ts": {
14381
14356
  "bytesInOutput": 614
14382
14357
  },
14383
- "../shared-types/dist/imageUtil.js": {
14384
- "bytesInOutput": 1773
14385
- },
14386
14358
  "src/apis/ui/helpers/getEffectsFromUIClient.ts": {
14387
14359
  "bytesInOutput": 69
14388
14360
  },
@@ -14396,10 +14368,10 @@
14396
14368
  "bytesInOutput": 5194
14397
14369
  },
14398
14370
  "src/devvit/internals/blocks/BlocksTransformer.ts": {
14399
- "bytesInOutput": 22491
14371
+ "bytesInOutput": 22616
14400
14372
  },
14401
14373
  "src/devvit/internals/blocks/BlocksReconciler.ts": {
14402
- "bytesInOutput": 14788
14374
+ "bytesInOutput": 14171
14403
14375
  },
14404
14376
  "src/devvit/internals/custom-post.ts": {
14405
14377
  "bytesInOutput": 697
@@ -14426,7 +14398,7 @@
14426
14398
  "bytesInOutput": 3085
14427
14399
  },
14428
14400
  "src/devvit/internals/blocks/handler/BlocksHandler.ts": {
14429
- "bytesInOutput": 13522
14401
+ "bytesInOutput": 12588
14430
14402
  },
14431
14403
  "src/devvit/internals/blocks/handler/useForm.ts": {
14432
14404
  "bytesInOutput": 915
@@ -14450,19 +14422,13 @@
14450
14422
  "bytesInOutput": 2428
14451
14423
  },
14452
14424
  "src/devvit/internals/blocks/handler/ContextBuilder.ts": {
14453
- "bytesInOutput": 1558
14454
- },
14455
- "src/devvit/internals/blocks/handler/useAsync.ts": {
14456
- "bytesInOutput": 4060
14457
- },
14458
- "../shared-types/dist/CircuitBreaker.js": {
14459
- "bytesInOutput": 50
14425
+ "bytesInOutput": 1523
14460
14426
  },
14461
14427
  "src/devvit/internals/ui-request-handler.ts": {
14462
14428
  "bytesInOutput": 618
14463
14429
  },
14464
14430
  "src/devvit/Devvit.ts": {
14465
- "bytesInOutput": 19374
14431
+ "bytesInOutput": 19173
14466
14432
  },
14467
14433
  "src/apis/reddit/helpers/makeGettersEnumerable.ts": {
14468
14434
  "bytesInOutput": 344
@@ -14538,9 +14504,15 @@
14538
14504
  },
14539
14505
  "src/apis/ui/helpers/svg.ts": {
14540
14506
  "bytesInOutput": 370
14507
+ },
14508
+ "src/devvit/internals/blocks/handler/useAsync.ts": {
14509
+ "bytesInOutput": 4060
14510
+ },
14511
+ "../shared-types/dist/CircuitBreaker.js": {
14512
+ "bytesInOutput": 50
14541
14513
  }
14542
14514
  },
14543
- "bytes": 14961084
14515
+ "bytes": 14942813
14544
14516
  }
14545
14517
  }
14546
14518
  }