@devvit/public-api 0.10.23-next-2024-06-12-1b25bb8f2.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
  }
@@ -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;AAI5E,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,WAAW,CA4Bb"}
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;AAI/C,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,wBAAwB,CAAC;AAK5E,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,WAAW,CA4Bb"}
@@ -1,6 +1,6 @@
1
1
  import { Header } from '@devvit/shared-types/Header.js';
2
2
  import { assertNonNull } from '@devvit/shared-types/NonNull.js';
3
- import pkg from '../../../package.json' assert { type: 'json' };
3
+ import pkg from '../../version.json' assert { type: 'json' };
4
4
  let loggedVersion = false;
5
5
  export function getContextFromMetadata(metadata, postId, commentId) {
6
6
  const subredditId = metadata[Header.Subreddit]?.values[0];
package/meta.json CHANGED
@@ -11760,11 +11760,11 @@
11760
11760
  "format": "esm"
11761
11761
  },
11762
11762
  "package.json": {
11763
- "bytes": 2832,
11763
+ "bytes": 2819,
11764
11764
  "imports": []
11765
11765
  },
11766
11766
  "src/devvit/internals/context.ts": {
11767
- "bytes": 2686,
11767
+ "bytes": 2683,
11768
11768
  "imports": [
11769
11769
  {
11770
11770
  "path": "../shared-types/dist/Header.js",
@@ -11779,7 +11779,7 @@
11779
11779
  {
11780
11780
  "path": "package.json",
11781
11781
  "kind": "import-statement",
11782
- "original": "../../../package.json"
11782
+ "original": "../../version.json"
11783
11783
  }
11784
11784
  ],
11785
11785
  "format": "esm"
@@ -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",
@@ -14356,7 +14356,7 @@
14356
14356
  "bytesInOutput": 1973
14357
14357
  },
14358
14358
  "package.json": {
14359
- "bytesInOutput": 2943
14359
+ "bytesInOutput": 2930
14360
14360
  },
14361
14361
  "src/devvit/internals/context.ts": {
14362
14362
  "bytesInOutput": 1798
@@ -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": 14993539
14527
+ "bytes": 14994832
14528
14528
  }
14529
14529
  }
14530
14530
  }
package/meta.min.json CHANGED
@@ -2990,11 +2990,11 @@
2990
2990
  "format": "esm"
2991
2991
  },
2992
2992
  "package.json": {
2993
- "bytes": 2832,
2993
+ "bytes": 2819,
2994
2994
  "imports": []
2995
2995
  },
2996
2996
  "src/devvit/internals/context.ts": {
2997
- "bytes": 2686,
2997
+ "bytes": 2683,
2998
2998
  "imports": [
2999
2999
  {
3000
3000
  "path": "../shared-types/dist/Header.js",
@@ -3009,7 +3009,7 @@
3009
3009
  {
3010
3010
  "path": "package.json",
3011
3011
  "kind": "import-statement",
3012
- "original": "../../../package.json"
3012
+ "original": "../../version.json"
3013
3013
  }
3014
3014
  ],
3015
3015
  "format": "esm"
@@ -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": 1135300
4645
+ "bytes": 1136297
4646
4646
  },
4647
4647
  "dist/public-api.min.js": {
4648
4648
  "imports": [
@@ -5268,7 +5268,7 @@
5268
5268
  "bytesInOutput": 848
5269
5269
  },
5270
5270
  "package.json": {
5271
- "bytesInOutput": 2390
5271
+ "bytesInOutput": 2377
5272
5272
  },
5273
5273
  "src/devvit/internals/context.ts": {
5274
5274
  "bytesInOutput": 940
@@ -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": 242962
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-12-1b25bb8f2.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",
@@ -9,7 +9,7 @@
9
9
  "type": "module",
10
10
  "main": "./index.js",
11
11
  "scripts": {
12
- "build": "yarn build:icon-types && yarn build:semantic-colors && tsc && cp -af package.json devvit.tsconfig.json dist/ && yarn build:types && yarn build:min && yarn build:unmin",
12
+ "build": "yarn build:icon-types && yarn build:semantic-colors && tsc && cp -af devvit.tsconfig.json dist/ && yarn build:types && yarn build:min && yarn build:unmin",
13
13
  "build:icon-types": "make-icons src/types/icons.ts",
14
14
  "build:min": "esbuild --bundle --sourcemap=linked --target=es2020 --format=esm --metafile=dist/meta.min.json --outfile=dist/public-api.min.js --external:@devvit/protos --minify src/index.ts",
15
15
  "build:semantic-colors": "node scripts/make-semantic-colors.js",
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "types": "./index.d.ts",
32
32
  "dependencies": {
33
- "@devvit/protos": "0.10.23-next-2024-06-12-1b25bb8f2.0",
34
- "@devvit/shared-types": "0.10.23-next-2024-06-12-1b25bb8f2.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-12-1b25bb8f2.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": "16ba154de06de7f7ce0fcdd8551bfb47c57b5ef8"
67
+ "gitHead": "f7de895f786949d9b7b476e7d9f1b8fd2124755a"
68
68
  }