Skip to content

Commit

Permalink
Merge pull request #276 from Catrobat/release_1.3.0
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
wslany authored Mar 4, 2021
2 parents be6b358 + e863d77 commit 5e0a9e3
Show file tree
Hide file tree
Showing 34 changed files with 949 additions and 730 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/*config.js
dist/
release/
tools/
tools/
release_catroid/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ i18n/json
./jenkins/testresults/*
jest_html_reporters.html
release/
release_share/
release_catroid
1 change: 1 addition & 0 deletions i18n/catroid_strings/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@
<string name="comment_in_out">Disable/enable</string>
<string name="catblocks">Toggle 2D</string>
<string name="catblocks_reorder">Clean up scripts</string>
<string name="switch_to_1d">1D view</string>
<!-- -->


Expand Down
3 changes: 2 additions & 1 deletion i18n/strings_to_json_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,5 +556,6 @@
"ASSERTION_TAP_FOR": "${brick_touch_at} ${x_label} %1%2 ${y_label} %3%4 ${brick_tap_for} %5%6",
"CAST_WHEN_GAMEPAD_BUTTON": "${brick_when_gamepad_button} %1%2 ${brick_when_gamepad_button_tapped}",
"CLOSE": "${close}",
"SHOW_VARIABLE": "${brick_show_variable}"
"SHOW_VARIABLE": "${brick_show_variable}",
"SWITCH_TO_1D": "${switch_to_1d}"
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
"test:dev": "cross-env-shell NODE_ENV=development TYPE=testing \"yarn initiate && webpack-dev-server\"",
"initiate": "yarn translate",
"translate": "node i18n/create_json.js && node i18n/create_msg.js",
"clean": "rimraf dist ; rimraf release",
"clean": "rimraf dist ; rimraf release ; rimraf release_catroid",
"release:dev": "cross-env-shell NODE_ENV=development \"yarn initiate && webpack-dev-server --config webpack.release.dev.config.js\"",
"release:build": "cross-env-shell NODE_ENV=production \"yarn initiate && webpack --config webpack.release.build.config.js\"",
"release:builddev": "cross-env-shell NODE_ENV=development \"yarn initiate && webpack --config webpack.release.build.config.js\"",
"release:build": "cross-env-shell NODE_ENV=production TARGET=share \"yarn initiate && webpack --config webpack.release.build.config.js\"",
"catroid:builddev": "cross-env-shell NODE_ENV=development TARGET=catroid \"yarn initiate && webpack --config webpack.release.build.config.js\"",
"catroid:build": "cross-env-shell NODE_ENV=production TARGET=catroid \"yarn initiate && webpack --config webpack.release.build.config.js\"",
"lint:es": "yarn eslint --ext .js ./",
"lint:pr": "yarn prettier -c src test",
"lint": "yarn lint:es --max-warnings 0 && yarn lint:pr",
Expand Down
3 changes: 2 additions & 1 deletion src/common/js/parser/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export default class Formula {
static packValue(layout, key, value) {
if (['%v', '%l', '%r'].includes(key)) {
if (value.length > 0) {
return layout.replace(key, `${value.trim()}`);
const result = value.replace(/(\.[0-9]*[1-9])0+$|\.0*$/, '$1');
return layout.replace(key, `${result.trim()}`);
}
return layout.replace(key, '').trim();
}
Expand Down
68 changes: 66 additions & 2 deletions src/common/js/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class Script {
}

class Brick {
constructor(name) {
constructor(name, id) {
this.name = name;
if (id) {
this.id = id;
}
this.loopOrIfBrickList = [];
this.elseBrickList = [];
this.formValues = new Map();
Expand Down Expand Up @@ -535,7 +538,16 @@ function parseBrick(brick) {

const name = (brick.getAttribute('type') || 'emptyBlockName').match(/[a-zA-Z]+/)[0];

const currentBrick = new Brick(name);
let brickId = null;
const idTag = brick.getElementsByTagName('brickId');
if (idTag && idTag.length >= 1) {
brickId = idTag[0].innerHTML;
if (brickId) {
brickId = brickId.trim();
}
}

const currentBrick = new Brick(name, brickId);

for (let i = 0; i < brick.childNodes.length; i++) {
checkUsage(brick.childNodes[i], currentBrick);
Expand Down Expand Up @@ -692,6 +704,17 @@ function checkUsage(list, location) {
break;
}

case 'userDataList': {
const userDataList = list.children;
for (let j = 0; j < userDataList.length; j++) {
const userDataElement = flatReference(userDataList[j]);
const userDataCategory = userDataElement.getAttribute('category');
const userDataName = userDataElement.getElementsByTagName('name')[0].innerHTML;
location.formValues.set(userDataCategory, userDataName);
}
break;
}

case 'userDefinedBrickID': {
location.userBrickId = list.innerHTML;
break;
Expand Down Expand Up @@ -748,6 +771,47 @@ function workFormula(formula, input) {
* Only those methods are visible outside this module
*/
export class Parser {
/**
* For performance reasons only the requested object is parsed.
* The xml is filtered the the selected object is parsed.
*
* @static
* @param {string] xmlString code.xml as string
* @param {*} sceneName name of the scene containing the object to render
* @param {*} objectName name of the object to render
* @memberof Parser
*/
static convertObjectToJSON(xmlString, sceneName, objectName) {
if (typeof xmlString === 'string') {
try {
const xml = new window.DOMParser().parseFromString(xmlString, 'text/xml');
if (!isSupported(xml)) {
return undefined;
}

const xpath = `/program/scenes/scene[name='${sceneName}']/objectList/object[@name='${objectName}']`;
const xpathResult = xml.evaluate(xpath, xml, null, XPathResult.ANY_TYPE, null);
if (!xpathResult) {
return undefined;
}

const objectTag = xpathResult.iterateNext();
if (!objectTag) {
return undefined;
}

initParser(xml);
return parseObjects(objectTag);
} catch (e) {
catLog(e);
console.error(
`Failed to convert catroid program given as string into a XMLDocument, please verify that the string is a valid program`
);
return undefined;
}
}
}

/**
* Convert given XML to JSON object
* @static
Expand Down
4 changes: 2 additions & 2 deletions src/intern/js/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import '../css/style.css';
import { Playground } from './playground/playground';
import * as shareUtils from '../../library/js/share/utils';
import * as shareUtils from '../../library/js/integration/utils';
import Blockly from 'blockly';
import { CatBlocks } from '../../library/js/lib';
import { CatBlocks } from '../../library/js/lib_share';
import { Parser } from '../../common/js/parser/parser';
import { initShareAndRenderPrograms } from './render/utils';

Expand Down
2 changes: 1 addition & 1 deletion src/intern/js/playground/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Blockly from 'blockly';
import { jsonDomToWorkspace, zebraChangeColor } from '../../../library/js/share/utils';
import { jsonDomToWorkspace, zebraChangeColor } from '../../../library/js/integration/utils';
import { Parser } from '../../../common/js/parser/parser';

export class Playground {
Expand Down
3 changes: 1 addition & 2 deletions src/intern/js/render/render.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { renderProgram } from '../../../library/js/lib';
import { CatBlocks } from '../../../library/js/lib';
import { CatBlocks, renderProgram } from '../../../library/js/lib_share';
import { Parser } from '../../../common/js/parser/parser';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/intern/js/render/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { renderAllPrograms } from './render';
import { FileLoader } from './file_loader';
import { FileDropper } from './file_dropper';
import { PasteListener } from './paste_listener';
import { CatBlocks } from '../../../library/js/lib';
import { CatBlocks } from '../../../library/js/lib_share';

/**
* Gets the requested param from a passed URLSearchParam
Expand Down
15 changes: 15 additions & 0 deletions src/library/css/catroid.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
html,
body {
height: 100vh;
width: 100%;
}

#catroid-catblocks-container {
height: 100vh;
width: 100%;
}

#catroid-catblocks-container.blocklySvg {
height: 100vh;
width: 100%;
}
35 changes: 35 additions & 0 deletions src/library/css/common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.blocklyText {
fill: #fff;
font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, sans-serif;
font-size: 12pt;
font-weight: bold;
}

.blocklyNonEditableText > rect:not(.blocklyDropdownRect),
.blocklyEditableText > rect:not(.blocklyDropdownRect) {
fill: #fff;
}

.blocklyNonEditableText > text,
.blocklyEditableText > text,
.blocklyNonEditableText > g > text,
.blocklyEditableText > g > text {
fill: #575e75;
}

.blocklyDropdownText {
fill: #fff !important;
}

.search {
border: none;
}

#formulaPopupContent {
word-wrap: break-word;
}

.catblockls-blockly-invisible > .blocklyPath {
fill-opacity: 0;
stroke-opacity: 0;
}
41 changes: 0 additions & 41 deletions src/library/css/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,6 @@ img {
vertical-align: middle;
}

.blocklyText {
fill: #fff;
font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, sans-serif;
font-size: 12pt;
font-weight: bold;
}

.blocklyNonEditableText > rect:not(.blocklyDropdownRect),
.blocklyEditableText > rect:not(.blocklyDropdownRect) {
fill: #fff;
}

.blocklyNonEditableText > text,
.blocklyEditableText > text,
.blocklyNonEditableText > g > text,
.blocklyEditableText > g > text {
fill: #575e75;
}

.blocklyDropdownText {
fill: #fff !important;
}

.card-header {
cursor: pointer;
}
Expand Down Expand Up @@ -142,25 +119,7 @@ img {
font-weight: bold;
}

.search {
border: none;
}

#catblocks-program-container {
overflow-x: hidden;
overflow-y: auto;
}

#formulaPopupContent {
word-wrap: break-word;
}

.catblocks-script-modifiable {
height: 80vh;
width: 100%;
}

.catblocks-script-modifiable.blocklySvg {
height: 80vh;
width: 100%;
}
3 changes: 2 additions & 1 deletion src/library/js/blocks/bricks.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const shapeBricksExtention = () => {
'WhenBounceOffScript',
'WhenBackgroundChangesScript',
'WhenRaspiPinChangedBrick',
'UserDefinedScript'
'UserDefinedScript',
'EmptyScript'
].includes(blockName)
) {
this.hat = 'cap';
Expand Down
8 changes: 4 additions & 4 deletions src/library/js/blocks/categories/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export default {
args0: [
{
type: 'field_input',
name: 'for_item_in_userlist_list_spinner',
name: 'FOR_ITEM_IN_USERLIST_LIST',
text: 'unset'
},
{
Expand All @@ -391,11 +391,11 @@ export default {
width: 24,
alt: '(i)',
flip_rtl: true,
name: 'for_item_in_userlist_list_spinner_INFO'
name: 'FOR_ITEM_IN_USERLIST_LIST_INFO'
},
{
type: 'field_input',
name: 'for_item_in_userlist_variable_spinner',
name: 'FOR_ITEM_IN_USERLIST_VARIABLE',
text: 'unset'
},
{
Expand All @@ -405,7 +405,7 @@ export default {
width: 24,
alt: '(i)',
flip_rtl: true,
name: 'for_item_in_userlist_variable_spinner_INFO'
name: 'FOR_ITEM_IN_USERLIST_VARIABLE_INFO'
}
],
args1: [
Expand Down
4 changes: 2 additions & 2 deletions src/library/js/blocks/categories/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
},
{
type: 'field_input',
name: 'FOR_DURATION',
name: 'DURATION_IN_SECONDS',
text: 'unset'
},
{
Expand All @@ -130,7 +130,7 @@ export default {
width: 24,
alt: '(i)',
flip_rtl: true,
name: 'FOR_DURATION_INFO'
name: 'DURATION_IN_SECONDS_INFO'
}
]
},
Expand Down
11 changes: 11 additions & 0 deletions src/library/js/blocks/categories/dummy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @description dummy Catblock brick
*/

'use strict';

export default {
EmptyScript: {
message0: ' '
}
};
4 changes: 3 additions & 1 deletion src/library/js/blocks/categories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import sound from './sound';
import stitch from './stitch';
import user from './user';
import device from './device';
import dummy from './dummy';

export default {
arduino: arduino,
Expand All @@ -44,5 +45,6 @@ export default {
raspi: raspi,
sound: sound,
stitch: stitch,
user: user
user: user,
dummy: dummy
};
3 changes: 2 additions & 1 deletion src/library/js/blocks/colours.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const colourCodes = {
sound: { colourPrimary: '#9966FF', colourSecondary: '#6c51b4', colourTertiary: '#774DCB' },
stitch: { colourPrimary: '#BC4793', colourSecondary: '#bb3a8d', colourTertiary: '#b72a86' },
user: { colourPrimary: '#bbbbbb', colourSecondary: '#aaaaaa', colourTertiary: '#999999' },
default: { colourPrimary: '#34c8a5', colourSecondary: '#299377', colourTertiary: '#238770' }
default: { colourPrimary: '#34c8a5', colourSecondary: '#299377', colourTertiary: '#238770' },
dummy: { colourPrimary: '#ffffff', colourSecondary: '#ffffff', colourTertiary: '#ffffff' }
};

/**
Expand Down
2 changes: 0 additions & 2 deletions src/library/js/index.js

This file was deleted.

Loading

0 comments on commit 5e0a9e3

Please sign in to comment.