Skip to content

Commit

Permalink
Update Blockly to v10 (#3275)
Browse files Browse the repository at this point in the history
Change-Id: I7e5416732f574de36c4558dfa6f90b7fb1a8f1ca
Co-Author: Mark Friedman <[email protected]>
Co-Author: Beka Westberg <[email protected]>
  • Loading branch information
ewpatton authored and jisqyv committed Jan 15, 2025
1 parent 842b6d5 commit 932d4e5
Show file tree
Hide file tree
Showing 464 changed files with 35,928 additions and 12,526 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "appinventor/lib/blockly"]
path = appinventor/lib/blockly
url = https://github.com/mit-cml/blockly.git
[submodule "appinventor/lib/closure-library"]
path = appinventor/lib/closure-library
url = https://github.com/mit-cml/closure-library.git
Expand Down
86 changes: 60 additions & 26 deletions appinventor/appengine/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
App Inventor appengine app
====================================================================== -->

<project name="appengine" default="all">
<project name="appengine" default="all" xmlns:if="ant:if" xmlns:unless="ant:unless">
<description>
Appengine server and client code
</description>
Expand All @@ -26,6 +26,7 @@
===================================================================== -->

<property name="release" value="false"/>
<property name="sourceMaps" value="false"/>

<condition property="client.module"
value="com.google.appinventor.YaClient"
Expand All @@ -39,20 +40,6 @@
<equals arg1="${release}" arg2="true" />
</condition>

<scriptdef name="generateguid" language="javascript">
<attribute name="property" />
<![CDATA[
try {
load("nashorn:mozilla_compat.js");
}
catch (exception) {
// Ignore the exception as the compat mode is only needed for Java 8
}
importClass( java.util.UUID );
project.setProperty( attributes.get( "property" ), UUID.randomUUID() );
]]>
</scriptdef>

<condition property="XstartOnFirstThread" value="-XstartOnFirstThread">
<os family="mac"/>
</condition>
Expand All @@ -61,7 +48,7 @@
</condition>

<target name="all"
depends="AiServerLib,AiClientLib,AiRebindLib,YaClientApp,Keystore,WarLibs,InstallAuthKey">
depends="AiServerLib,AiClientLib,AiRebindLib,YaClientApp,CopyToBuildWarPost,Keystore,WarLibs,InstallAuthKey">
</target>

<target name="tests"
Expand Down Expand Up @@ -131,7 +118,9 @@
depends="init,blocklyeditor_BlocklyTranslationGenerator,BuildDocs">
<mkdir dir="${build.war.dir}" />
<copy todir="${build.war.dir}/">
<fileset dir="war" />
<fileset dir="war">
<exclude name="index.jsp" />
</fileset>
<fileset dir="${docs.dir}">
<include name="companions/*"/>
</fileset>
Expand Down Expand Up @@ -170,15 +159,6 @@
<exclude name="media/*.css"/>
</fileset>
</copy>
<copy file="${build.dir}/blocklyeditor/blockly-all.js" tofile="${build.war.dir}/WEB-INF/classes/com/google/appinventor/client/editor/youngandroid/blockly.js" />

<!-- Move Blockly translations into place -->
<mkdir dir="${build.war.dir}/WEB-INF/classes/com/google/appinventor/client/editor/youngandroid/i18n"/>
<copy todir="${build.war.dir}/WEB-INF/classes/com/google/appinventor/client/editor/youngandroid/i18n">
<fileset dir="${build.dir}/blocklyeditor/msg">
<include name="*.json"/>
</fileset>
</copy>

<copy todir="${build.static.dir}">
<fileset dir="src/${appinventor.pkg}">
Expand Down Expand Up @@ -207,6 +187,50 @@
</copy>
</target>

<target name="CopyToBuildWarPost">
<mkdir dir="${build.war.dir}/ode" />
<checksum property="blocklyeditor_BlocklyChecksum" algorithm="SHA-256" if:true="${release}">
<fileset dir="${build.dir}">
<include name="blocklyeditor/blockly-all.js"/>
</fileset>
</checksum>
<property name="blocklyeditor_BlocklyChecksum" value="0"/>
<condition property="blocklyeditor_postfix" value="cache" else="nocache">
<equals arg1="${release}" arg2="true" />
</condition>
<copy file="${build.dir}/blocklyeditor/blockly-all.js" tofile="${build.war.dir}/ode/aiblockly-${blocklyeditor_BlocklyChecksum}.${blocklyeditor_postfix}.js" />
<copy todir="${build.war.dir}/ode">
<fileset dir="${build.dir}/blocklyeditor">
<include name="*.js.map"/>
</fileset>
</copy>
<filter token="blocklyeditor_BlocklyChecksum" value="${blocklyeditor_BlocklyChecksum}.${blocklyeditor_postfix}" />
<filter token="blocklyeditor_isRelease" value="${release}" />
<copy todir="${build.war.dir}" filtering="true">
<fileset dir="war">
<include name="index.jsp"/>
</fileset>
</copy>

<!-- Move Blockly translations into place -->
<mkdir dir="${build.war.dir}/WEB-INF/classes/com/google/appinventor/client/editor/youngandroid/i18n"/>
<copy todir="${build.war.dir}/WEB-INF/classes/com/google/appinventor/client/editor/youngandroid/i18n">
<fileset dir="${build.dir}/blocklyeditor/msg">
<include name="*.json"/>
</fileset>
</copy>
<copy todir="${build.war.dir}/ode/">
<fileset dir="${build.dir}/blocklyeditor/msg">
<include name="*.js"/>
</fileset>
</copy>

<!-- Compile the Blockly translations map -->
<javac destdir="${build.war.dir}/WEB-INF/classes" srcdir="${public.build.dir}/../blocklyeditor" source="1.8" target="1.8">
<include name="msg/i18n.java"/>
</javac>
</target>

<!-- =====================================================================
Create the keystore that is used by AiServerLib to encrypt user and
project IDs.
Expand Down Expand Up @@ -632,10 +656,20 @@
<arg line="-logLevel INFO"/>
<arg value="-extra"/>
<arg value="${build.extra.dir}"/>
<arg line="-setProperty locale=${locale}" if:set="locale"/>
<arg line="${client.flags} ${client.module}"/>
</java>
<copy todir="${build.war.dir}/ode"
file="${appinventor.dir}/appengine/extra/cdnok.js" />
<copy todir="${build.war.dir}/ode" if:true="${sourceMaps}">
<fileset dir="${build.war.dir}/WEB-INF/deploy/ode/symbolMaps">
<include name="*.json"/>
</fileset>
<fileset dir="${src.dir}/">
<include name="${appinventor.pkg}/client/**/*.java"/>
<include name="${appinventor.pkg}/shared/**/*.java"/>
</fileset>
</copy>
</target>

<target name="devmode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,7 @@
<extend-property name="locale" values="ja"/>

<set-property-fallback name="locale" value="en"/>

<set-configuration-property name="includeSourceMapUrl" value="/ode/__HASH___sourceMap__FRAGMENT__.json"/>
<set-property name="compiler.useSourceMaps" value="true"/>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ private static native void exportMethodsToJavascript() /*-{
}-*/;

private static native boolean doPutAsset(String projectId, String filename, byte[] content) /*-{
return Blockly.ReplMgr.putAsset(projectId, filename, content, function() { window.parent.AssetManager_markAssetTransferred(filename) });
return $wnd.Blockly.ReplMgr.putAsset(projectId, filename, content, function() { window.parent.AssetManager_markAssetTransferred(filename) });
}-*/;

private static native void doCallBack(JavaScriptObject callback) /*-{
Expand Down
29 changes: 10 additions & 19 deletions appinventor/appengine/src/com/google/appinventor/client/Ode.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.appinventor.client.editor.youngandroid.TutorialPanel;
import com.google.appinventor.client.editor.youngandroid.YaFormEditor;
import com.google.appinventor.client.editor.youngandroid.YaProjectEditor;
import com.google.appinventor.client.editor.youngandroid.i18n.BlocklyMsg;
import com.google.appinventor.client.explorer.commands.ChainableCommand;
import com.google.appinventor.client.explorer.commands.CommandRegistry;
import com.google.appinventor.client.explorer.commands.SaveAllEditorsCommand;
Expand Down Expand Up @@ -738,7 +737,6 @@ public void onUncaughtException(Throwable e) {
.then0(this::handleGalleryId)
.then0(this::checkTos)
.then0(this::loadUserSettings)
.then0(this::loadTranslations) // translation based on user setting last locale
.then0(() -> Promise.allOf(
Promise.wrap(this::processSettings),
Promise.wrap(this::loadUserBackpack)
Expand Down Expand Up @@ -783,13 +781,6 @@ public void onUncaughtException(Throwable e) {
return null;
});

History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
openProject(event.getValue());
}
});

// load project based on current url
// TODO(sharon): Seems like a possible race condition here if the onValueChange
// handler defined above gets called before the getSystemConfig call sets
Expand Down Expand Up @@ -854,21 +845,15 @@ private Promise<Object> maybeOpenLastProject() {
return null;
}

private Promise<Boolean> loadTranslations() {
return BlocklyMsg.Loader.loadTranslations();
}

private Promise<String> loadUserBackpack() {
String backPackId = user.getBackpackId();
if (backPackId == null || backPackId.isEmpty()) {
LOG.info("backpack: No shared backpack");
return this.loadBackpack();
} else {
LOG.info("Have a shared backpack backPackId = " + backPackId);
return BlocklyMsg.Loader.loadTranslations().then(result -> {
BlocklyPanel.setSharedBackpackId(backPackId);
return null;
});
BlocklyPanel.setSharedBackpackId(backPackId);
return resolve("");
}
}

Expand Down Expand Up @@ -1054,6 +1039,13 @@ public void onMouseWheel(MouseWheelEvent event) {
RootPanel.get().addStyleName("dyslexic");
}

History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
openProject(event.getValue());
}
});

// There is no sure-fire way of preventing people from accidentally navigating away from ODE
// (e.g. by hitting the Backspace key). What we do need though is to make sure that people will
// not lose any work because of this. We hook into the window closing event to detect the
Expand Down Expand Up @@ -1523,8 +1515,7 @@ public static Promise<Boolean> handleUserLocale(UserSettings userSettings) {
userSettings.saveSettings(null);
}
}
return BlocklyMsg.Loader.loadTranslations()
.then(result -> resolve(true));
return resolve(true);
}

private void resizeWorkArea(WorkAreaPanel workArea) {
Expand Down
Loading

0 comments on commit 932d4e5

Please sign in to comment.