Commit dd8d25c
authored
Make
## Summary:
Previously, widget versions were encoded in three different places:
- In the `perseus` package, [on the WidgetExports type]. This version used to
be used for widget prop upgrades (the data migration strategy that preceded
the parsers, now removed). It is now used by the editors to determine the
version number that gets stamped on newly-created widgets.
- In `perseus-core`, [in the parser code].
- In `perseus-core`, [on the WidgetLogic type].
These three sources of truth could get out of sync. Also, not every package can
import `perseus` (for example, in the backend perseus service, we can't import
React code at all, so we can't use the `perseus` package) which means that some
code could not get a runtime representation of the current version of a widget
if the `WidgetLogic` didn't have the version.
This PR makes `WidgetLogic.version` the single source of truth for widget
versions, and adds tests for the parsers to make sure that they output the
correct version number. `WidgetExports.version` has been deleted, and the
editors now use `WidgetLogic.version` instead.
In the process of making this change, I noticed a bug in the Measurer widget
parser where it did not parse version 0 options correctly: it zeroed out the
image properties. This PR also fixes that bug. Only one widget in our content
corpus was affected.
[on the WidgetExports type]: https://github.com/Khan/perseus/blob/4a130c0367d9e83953c4b37c19881f81437bca39/packages/perseus/src/types.ts#L436
[in the parser code]: https://github.com/Khan/perseus/blob/449a085f7d7136fba5ba198e291b2d44f1f2cd74/packages/perseus-core/src/parse-perseus-json/perseus-parsers/radio-widget.ts#L54
[on the WidgetLogic type]: https://github.com/Khan/perseus/blob/135eaf6c330bd3b5092bda458d2b90d450e7d9a5/packages/perseus-core/src/widgets/logic-export.types.ts#L62
Issue: none
## Test plan:
CI checks should pass.
Author: benchristel
Reviewers: benchristel, jeremywiebe, handeyeco
Required Reviewers:
Approved By: jeremywiebe
Checks: ✅ 11 checks were successful, ⏭️ 1 check has been skipped
Pull Request URL: #3784WidgetLogic.version the source of truth for widget versions (#3784)1 parent be10fbb commit dd8d25c
20 files changed
Lines changed: 535 additions & 98 deletions
File tree
- .changeset
- packages
- perseus-core/src
- parse-perseus-json
- perseus-parsers
- regression-tests
- __snapshots__
- item-data
- widgets
- measurer
- perseus-editor/src
- __tests__
- perseus/src
- __tests__
- widgets
- expression
- measurer
- radio
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 47 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
504 | | - | |
| 504 | + | |
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
| |||
Lines changed: 231 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13007 | 13007 | | |
13008 | 13008 | | |
13009 | 13009 | | |
13010 | | - | |
| 13010 | + | |
13011 | 13011 | | |
13012 | 13012 | | |
13013 | 13013 | | |
| |||
13017 | 13017 | | |
13018 | 13018 | | |
13019 | 13019 | | |
| 13020 | + | |
| 13021 | + | |
| 13022 | + | |
| 13023 | + | |
13020 | 13024 | | |
13021 | 13025 | | |
13022 | 13026 | | |
| |||
13114 | 13118 | | |
13115 | 13119 | | |
13116 | 13120 | | |
13117 | | - | |
| 13121 | + | |
13118 | 13122 | | |
13119 | 13123 | | |
13120 | 13124 | | |
| |||
13223 | 13227 | | |
13224 | 13228 | | |
13225 | 13229 | | |
| 13230 | + | |
| 13231 | + | |
| 13232 | + | |
| 13233 | + | |
| 13234 | + | |
| 13235 | + | |
| 13236 | + | |
| 13237 | + | |
| 13238 | + | |
| 13239 | + | |
| 13240 | + | |
| 13241 | + | |
| 13242 | + | |
| 13243 | + | |
| 13244 | + | |
| 13245 | + | |
| 13246 | + | |
| 13247 | + | |
| 13248 | + | |
| 13249 | + | |
| 13250 | + | |
| 13251 | + | |
| 13252 | + | |
| 13253 | + | |
| 13254 | + | |
| 13255 | + | |
| 13256 | + | |
| 13257 | + | |
| 13258 | + | |
| 13259 | + | |
| 13260 | + | |
| 13261 | + | |
| 13262 | + | |
| 13263 | + | |
| 13264 | + | |
| 13265 | + | |
| 13266 | + | |
| 13267 | + | |
| 13268 | + | |
| 13269 | + | |
| 13270 | + | |
| 13271 | + | |
| 13272 | + | |
| 13273 | + | |
| 13274 | + | |
| 13275 | + | |
| 13276 | + | |
| 13277 | + | |
| 13278 | + | |
| 13279 | + | |
| 13280 | + | |
| 13281 | + | |
| 13282 | + | |
| 13283 | + | |
| 13284 | + | |
| 13285 | + | |
| 13286 | + | |
| 13287 | + | |
| 13288 | + | |
| 13289 | + | |
| 13290 | + | |
| 13291 | + | |
| 13292 | + | |
| 13293 | + | |
| 13294 | + | |
| 13295 | + | |
| 13296 | + | |
| 13297 | + | |
| 13298 | + | |
| 13299 | + | |
| 13300 | + | |
| 13301 | + | |
| 13302 | + | |
| 13303 | + | |
| 13304 | + | |
| 13305 | + | |
| 13306 | + | |
| 13307 | + | |
| 13308 | + | |
| 13309 | + | |
| 13310 | + | |
| 13311 | + | |
| 13312 | + | |
| 13313 | + | |
| 13314 | + | |
| 13315 | + | |
| 13316 | + | |
| 13317 | + | |
| 13318 | + | |
| 13319 | + | |
| 13320 | + | |
| 13321 | + | |
| 13322 | + | |
| 13323 | + | |
| 13324 | + | |
| 13325 | + | |
| 13326 | + | |
| 13327 | + | |
| 13328 | + | |
| 13329 | + | |
| 13330 | + | |
| 13331 | + | |
| 13332 | + | |
| 13333 | + | |
| 13334 | + | |
| 13335 | + | |
| 13336 | + | |
| 13337 | + | |
| 13338 | + | |
| 13339 | + | |
| 13340 | + | |
| 13341 | + | |
| 13342 | + | |
| 13343 | + | |
| 13344 | + | |
| 13345 | + | |
| 13346 | + | |
| 13347 | + | |
| 13348 | + | |
| 13349 | + | |
| 13350 | + | |
| 13351 | + | |
| 13352 | + | |
| 13353 | + | |
| 13354 | + | |
| 13355 | + | |
| 13356 | + | |
| 13357 | + | |
| 13358 | + | |
| 13359 | + | |
| 13360 | + | |
| 13361 | + | |
| 13362 | + | |
| 13363 | + | |
| 13364 | + | |
| 13365 | + | |
| 13366 | + | |
| 13367 | + | |
| 13368 | + | |
| 13369 | + | |
| 13370 | + | |
| 13371 | + | |
| 13372 | + | |
| 13373 | + | |
| 13374 | + | |
| 13375 | + | |
| 13376 | + | |
| 13377 | + | |
| 13378 | + | |
| 13379 | + | |
| 13380 | + | |
| 13381 | + | |
| 13382 | + | |
| 13383 | + | |
| 13384 | + | |
| 13385 | + | |
| 13386 | + | |
| 13387 | + | |
| 13388 | + | |
| 13389 | + | |
| 13390 | + | |
| 13391 | + | |
| 13392 | + | |
| 13393 | + | |
| 13394 | + | |
| 13395 | + | |
| 13396 | + | |
| 13397 | + | |
| 13398 | + | |
| 13399 | + | |
| 13400 | + | |
| 13401 | + | |
| 13402 | + | |
| 13403 | + | |
| 13404 | + | |
| 13405 | + | |
| 13406 | + | |
| 13407 | + | |
| 13408 | + | |
| 13409 | + | |
| 13410 | + | |
| 13411 | + | |
| 13412 | + | |
| 13413 | + | |
| 13414 | + | |
| 13415 | + | |
| 13416 | + | |
| 13417 | + | |
| 13418 | + | |
| 13419 | + | |
| 13420 | + | |
| 13421 | + | |
| 13422 | + | |
| 13423 | + | |
| 13424 | + | |
| 13425 | + | |
| 13426 | + | |
| 13427 | + | |
| 13428 | + | |
| 13429 | + | |
| 13430 | + | |
| 13431 | + | |
| 13432 | + | |
| 13433 | + | |
| 13434 | + | |
| 13435 | + | |
| 13436 | + | |
| 13437 | + | |
| 13438 | + | |
| 13439 | + | |
| 13440 | + | |
| 13441 | + | |
| 13442 | + | |
| 13443 | + | |
| 13444 | + | |
| 13445 | + | |
| 13446 | + | |
| 13447 | + | |
| 13448 | + | |
| 13449 | + | |
| 13450 | + | |
| 13451 | + | |
| 13452 | + | |
| 13453 | + | |
| 13454 | + | |
13226 | 13455 | | |
13227 | 13456 | | |
13228 | 13457 | | |
| |||
0 commit comments