Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E16n serialization (slightly more conservative version) #2279

Open
wants to merge 17 commits into
base: e16n
Choose a base branch
from

Conversation

cwillisf
Copy link
Contributor

This is the same as #2245 but does not move the Extension Manager into the Runtime. Instead, only the information about currently-loaded extensions is moved to the Runtime.

@cwillisf cwillisf force-pushed the e16n-serialization-conservative branch from 51b840e to 5920fad Compare September 16, 2019 23:37
src/blocks/data.js Outdated Show resolved Hide resolved
Copy link
Contributor

@kchadha kchadha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a preliminary review of this code. I tried to be pretty thorough in this pass, but did not look carefully at the documentation or the new _prepareSerializationInfo function yet. I think there's a lot to talk about here, so it might be good to discuss some of this in person.

src/engine/blocks.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
src/blocks/data.js Outdated Show resolved Hide resolved
Christopher Willis-Ford added 5 commits September 27, 2019 11:49
- Fix a lint error due to an unused constant.
- Don't return an extended opcode from `deserializeVariable` (more
  changes needed here).
- If `refreshBlocks` encounters an extension ID mismatch, keep the old
  ID instead of switching to the new one.
- Rename `decodeBlock` to `getExtensionAndOpcode` and clarify its
  purpose. In particular, distinguish it from `getExtensionIdForOpcode`.
@cwillisf cwillisf force-pushed the e16n-serialization-conservative branch from 37b9f9a to 695a8f7 Compare October 4, 2019 23:23
@cwillisf cwillisf added this to the October 2019 milestone Oct 5, 2019
@cwillisf cwillisf removed their assignment Oct 5, 2019
@cwillisf cwillisf requested a review from kchadha October 5, 2019 01:58
const result = {
opcode: 'variable',
fields: {
VARIABLE: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this field descriptor here. This block should only need the mutation.

// something that looks like the block's entry in `getInfo()`. If we do either of those things we'll need to
// decide how we want to handle the block's (x,y) position and `topLevel` flag.
const result = {
opcode: 'variable',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opcode is incorrect, the top level block opcode is the "extended" opcode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to avoid having the extension every mention the extended opcode, since in theory we might sometimes post-process the extension ID so that it isn't what the extension author expects. Instead I fix up the ID after the fact, in the function which calls this one.

parent: null,
shadow: false,
mutation: {
blockInfo: {
Copy link
Contributor

@kchadha kchadha Oct 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the comment above, I think it would be better for this function to just return this blockInfo object and have the rest of this top-level object constructed in either a helper function or by the sb3 deserialize code itself.

Comment on lines +781 to +782
serializeVariable (block, target) {
const variableName = block.mutation.blockInfo.text;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this function should just take blockInfo as an argument, and then some helper function outside of the extension definition should handle high level block things like setting the x and y.

Copy link
Contributor Author

@cwillisf cwillisf Oct 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that variables have their own custom way of serializing x and y, so it kind of needs to be here. That's also why the custom deserialize function needs to return the whole block instead of just the blockInfo guts :/

src/serialization/sb3.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
src/serialization/sb3.js Outdated Show resolved Hide resolved
if (customDeserialize) {
block = customDeserialize(block);
blocks[blockId] = block; // customDeserialize might have made a new object; make sure to keep it!
// the deserialize function should return opcode 'foo' and we'll fix it to 'ext_foo'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the comment earlier in this PR, if we're doing fix-up here anyways of what the customDeserialize function returns, I think we might as well construct the block JSON here instead of the customDeserialize function and have that function just return the blockInfo.

Copy link
Contributor

@kchadha kchadha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments in-line in the PR.

@kchadha
Copy link
Contributor

kchadha commented Nov 19, 2019

Unassigning myself from this PR since we discussed offline (a few weeks ago) that maybe custom serialization in the extension spec is not the right approach since we only want it in this specific case of the core variables extension. We can handle this special case in the "backend" (e.g. vm runtime or extension manager) instead of making this a developer facing feature. We also discussed removing this from the immediate scope of this "first phase" of the e16n project (wrapping up by the end of this year).

@kchadha kchadha removed their assignment Nov 19, 2019
@kchadha kchadha mentioned this pull request Nov 19, 2019
@towerofnix
Copy link
Contributor

towerofnix commented Nov 20, 2019

We can handle this special case in the "backend" (e.g. vm runtime or extension manager) instead of making this a developer facing feature. We also discussed removing this from the immediate scope of this "first phase" of the e16n project (wrapping up by the end of this year).

does this mean custom variable types are out of the question for developer extensions? not that I actually know what's going on in this code, nor that it'd mean that wouldn't be supported ever, but this was one of the most exciting things about extensions IMO (localstorage-based variables, etc).

@BryceLTaylor BryceLTaylor modified the milestones: October 2019, Overdue Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants