@devvit/public-api 0.10.23-next-2024-06-13-72bd939c1.0 → 0.10.23-next-2024-06-13-cad38246a.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -212,14 +212,23 @@ export class BlocksReconciler {
212
212
  const blockElement = element;
213
213
  // Intrinsic elements
214
214
  if (typeof blockElement.type === 'string') {
215
- const childrens = await Promise.all(blockElement.children.flatMap(async (child, i) => {
215
+ const childrens = [];
216
+ /**
217
+ * Resist the urge to clean this up with flatMap. We need to await each processBlock _in order_.
218
+ *
219
+ * Number of times this has caused a major headache: 3
220
+ *
221
+ * Please increment the counter above if you had to revert this.
222
+ */
223
+ for (let i = 0; i < blockElement.children.length; i++) {
224
+ const child = blockElement.children[i];
216
225
  if (child === undefined || child === null)
217
- return [];
218
- return await this.processBlock(child, idGenerator, [
226
+ continue;
227
+ childrens.push(await this.processBlock(child, idGenerator, [
219
228
  ...path,
220
229
  `${blockElement.type}.${i}`,
221
- ]);
222
- }));
230
+ ]));
231
+ }
223
232
  const children = childrens.flat();
224
233
  const collapsedChildren = __classPrivateFieldGet(this, _BlocksReconciler_instances, "m", _BlocksReconciler_flatten).call(this, children);
225
234
  await this.processProps(blockElement);
@@ -263,6 +272,12 @@ export class BlocksReconciler {
263
272
  // Ensure that the number of hooks are same from the previous render.
264
273
  if (!this.isInitialRender) {
265
274
  const previousState = this.getPreviousComponentState();
275
+ /**
276
+ * Note: This relies on the magic of {0: "a", 1: "b"} => ["a", "b"] and back under many circumstances.
277
+ * It is too magic, but as this component is complicated and deprecated, it is not worth fixing.
278
+ *
279
+ * In fact previousState is an array. This is confusing.
280
+ */
266
281
  const prevHookCount = Object.keys(previousState).length;
267
282
  if (prevHookCount !== this.currentHookIndex) {
268
283
  throw new Error('Invalid hook call. Hooks can only be called at the top-level of a function component. Make sure that you are not calling hooks inside loops, conditions, or nested functions.');
@@ -412,6 +427,10 @@ export class BlocksReconciler {
412
427
  // {"0": "one", "2": "three"} (length: 2; fails consistency check, see line 251)
413
428
  // After:
414
429
  // ["one", undefined, "three"] (length: 3)
430
+ /**
431
+ * Note: This relies on the magic of {0: "a", 1: "b"} => ["a", "b"] and back under many circumstances.
432
+ * It is too magic, but as this component is complicated and deprecated, it is not worth fixing.
433
+ */
415
434
  for (const key of Object.keys(this.renderState)) {
416
435
  this.renderState[key] = Object.values(this.renderState[key]);
417
436
  }
package/meta.json CHANGED
@@ -11894,7 +11894,7 @@
11894
11894
  "format": "esm"
11895
11895
  },
11896
11896
  "src/devvit/internals/blocks/BlocksReconciler.ts": {
11897
- "bytes": 18194,
11897
+ "bytes": 19088,
11898
11898
  "imports": [
11899
11899
  {
11900
11900
  "path": "../protos/dist/index.js",
@@ -14383,7 +14383,7 @@
14383
14383
  "bytesInOutput": 22653
14384
14384
  },
14385
14385
  "src/devvit/internals/blocks/BlocksReconciler.ts": {
14386
- "bytesInOutput": 14129
14386
+ "bytesInOutput": 14179
14387
14387
  },
14388
14388
  "src/devvit/internals/custom-post.ts": {
14389
14389
  "bytesInOutput": 697
@@ -14524,7 +14524,7 @@
14524
14524
  "bytesInOutput": 4450
14525
14525
  }
14526
14526
  },
14527
- "bytes": 14993506
14527
+ "bytes": 14994832
14528
14528
  }
14529
14529
  }
14530
14530
  }
package/meta.min.json CHANGED
@@ -3124,7 +3124,7 @@
3124
3124
  "format": "esm"
3125
3125
  },
3126
3126
  "src/devvit/internals/blocks/BlocksReconciler.ts": {
3127
- "bytes": 18194,
3127
+ "bytes": 19088,
3128
3128
  "imports": [
3129
3129
  {
3130
3130
  "path": "@devvit/protos",
@@ -4642,7 +4642,7 @@
4642
4642
  "imports": [],
4643
4643
  "exports": [],
4644
4644
  "inputs": {},
4645
- "bytes": 1135284
4645
+ "bytes": 1136297
4646
4646
  },
4647
4647
  "dist/public-api.min.js": {
4648
4648
  "imports": [
@@ -5277,7 +5277,7 @@
5277
5277
  "bytesInOutput": 350
5278
5278
  },
5279
5279
  "src/devvit/internals/blocks/BlocksReconciler.ts": {
5280
- "bytesInOutput": 7132
5280
+ "bytesInOutput": 7153
5281
5281
  },
5282
5282
  "src/apis/ui/helpers/getEffectsFromUIClient.ts": {
5283
5283
  "bytesInOutput": 34
@@ -5427,7 +5427,7 @@
5427
5427
  "bytesInOutput": 2135
5428
5428
  }
5429
5429
  },
5430
- "bytes": 242949
5430
+ "bytes": 242970
5431
5431
  }
5432
5432
  }
5433
5433
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/public-api",
3
- "version": "0.10.23-next-2024-06-13-72bd939c1.0",
3
+ "version": "0.10.23-next-2024-06-13-cad38246a.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.10.23-next-2024-06-13-72bd939c1.0",
34
- "@devvit/shared-types": "0.10.23-next-2024-06-13-72bd939c1.0",
33
+ "@devvit/protos": "0.10.23-next-2024-06-13-cad38246a.0",
34
+ "@devvit/shared-types": "0.10.23-next-2024-06-13-cad38246a.0",
35
35
  "base64-js": "1.5.1",
36
36
  "clone-deep": "4.0.1",
37
37
  "core-js": "3.27.2",
@@ -41,7 +41,7 @@
41
41
  "@ampproject/filesize": "4.3.0",
42
42
  "@devvit/eslint-config": "0.10.22",
43
43
  "@devvit/repo-tools": "0.10.22",
44
- "@devvit/tsconfig": "0.10.23-next-2024-06-13-72bd939c1.0",
44
+ "@devvit/tsconfig": "0.10.23-next-2024-06-13-cad38246a.0",
45
45
  "@microsoft/api-extractor": "7.41.0",
46
46
  "@reddit/faceplate-ui": "11.3.3",
47
47
  "@types/clone-deep": "4.0.1",
@@ -64,5 +64,5 @@
64
64
  }
65
65
  },
66
66
  "source": "./src/index.ts",
67
- "gitHead": "231786e8fd7fe4c8d9b1e9846a93846127943980"
67
+ "gitHead": "f7de895f786949d9b7b476e7d9f1b8fd2124755a"
68
68
  }