Skip to content

Commit

Permalink
Merge pull request #2857 from entrylabs/develop
Browse files Browse the repository at this point in the history
Master 4.0.13
  • Loading branch information
leunge authored Oct 29, 2024
2 parents 630e56e + 6345f65 commit 2fa7315
Show file tree
Hide file tree
Showing 42 changed files with 23,655 additions and 4,476 deletions.
48 changes: 41 additions & 7 deletions extern/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,14 @@ Lang.Blocks = {
ROBOID_acceleration_y: 'y acceleration',
ROBOID_acceleration_z: 'z acceleration',
learn_popup_title: 'Input Data',
arduino_noti_text: 'Mobile devices will be\n supported later on.',
arduino_noti_text:
'HW connection is\nonly supported on desktop.\n \nPlease contact HW\nmanufacturer for tablet.',
arduino_lite_alert:
'Device not found.\nPlease check if firmware\nis installed on device,\nor if PC and device are connected.',
arduino_lite_reconnect: 'Retry',
arduino_lite_download_firmware: 'Download Firmware',
arduino_lite_download_firmware: 'Download firmware',
arduino_lite_download_driver: 'Download Driver',
arduino_lite_connect: 'Web Connection',
arduino_lite_connect: 'Connect through web',
arduino_lite_disconnect: 'Cancel',
arduino_lite_guide: '• connection guide',
arduino_lite_connected_noti: 'Please save the project\nwith the device selected.',
Expand All @@ -579,9 +582,17 @@ Lang.Blocks = {
ARDUINO_download_source: '• Entry Arduino code',
ARDUINO_connected: 'Hardware connected',
ARDUINO_connect: '* Connect hardware',
ARDUINO_reconnect: 'Connect Hardware',
ARDUINO_reconnect: 'Connect HW',
hardware_connect_helper: 'Help (Korean Only)',
hardware_noti_installed: 'When using connection program',
hardware_noti_not_installed: 'When using web browser',
hardware_device_name_title: 'Name:',
hardware_device_name_title_robot: 'Name:',
hardware_device_name_content: 'None',
hardware_program_download: 'Download program',
hardware_connected_noti: 'Please check connection program.',
ROBOT_reconnect: 'Connect Robot',
ARDUINO_open_connector: 'Open Connector',
ARDUINO_open_connector: 'Open program',
ARDUINO_cloud_pc_connector: 'Connect to Cloud PC',
CALC_get_x_coordinate: 'X Coordinate',
CALC_get_y_coordinate: 'Y Coordinate',
Expand Down Expand Up @@ -1852,6 +1863,7 @@ Lang.Buttons = {
create: 'Create Class',
done: 'Done',
accept: 'Accept',
select: 'Select',
refuse: 'Refuse',
yes: 'Yes',
button_no: 'No',
Expand Down Expand Up @@ -5405,10 +5417,32 @@ Lang.Workspace = {
send_backward: 'Send Backward',
upload_error_msg: 'Unable to upload as image is suspected of violating usage policy.',
confirm_firmware_hwlite_block_title: 'Verify firmware Installation',
confirm_firmware_hwlite_block_msg:
'The firmware must be installed\n to connect the %1\n to the Entry wirelessly.',
confirm_firmware_hwlite_block_msg: 'To use %1 in Entry,\n please install the firmware first.',
confirm_firmware_hwlite_block_pass: 'Already installed',
confirm_firmware_hwlite_block_download: 'Install firmware',
confirm_firmware_hwlite_block_usb_connect: 'USB connect',
progress_firmware_hwlite_title: 'Install firmware',
progress_firmware_hwlite_step1_title: 'Check USB port',
progress_firmware_hwlite_step1_content1: 'Connect the device and PC with USB.',
progress_firmware_hwlite_step1_content2:
'Select the device to connect.\nWait for a USB connection.',
progress_firmware_hwlite_step1_content3: 'USB connection detected.',
progress_firmware_hwlite_step2_title: 'Install firmware',
progress_firmware_hwlite_step2_content1: 'Installing firmware.\nPlease wait.',
progress_firmware_hwlite_step2_content_complete: 'Installation is complete.',
progress_firmware_hwlite_step2_content_fail: 'Firmware installation failed.',
progress_firmware_hwlite_step2_content_select: 'Select the firmware version to install.',
progress_firmware_hwlite_button_select: 'Check',
progress_firmware_hwlite_button_reselect: 'Retry',
progress_firmware_hwlite_button_install: 'Install firmware',
progress_firmware_hwlite_button_connect_device: 'Connect device',
progress_firmware_hwlite_button_retry: 'Retry',
usbconnect_fail_alert: "USB connection failed. Check the connection status and click 'Retry'.",
select_hwlite_block_duplicated: 'Please select only one hardware device.',
select_hwlite_block_none: 'Please select the hardware device to connect.',
select_firmware_hwlite_title: 'Download Firmware',
select_firmware_hwlite_content:
'Please download and install the appropriate firmware \n for your hardware version.',
select_flash_firmware_hwlite_title: 'Select firmware to install',
select_flash_firmware_hwlite_content:
'Please select the version of\n the Microbit you want to connect to.\n When the installation is complete,\n a message is displayed.',
Expand Down
2 changes: 1 addition & 1 deletion extern/lang/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ Lang.Blocks = {
hardware_noti_not_installed: '프로그램 설치 없이 연결할 때',
hardware_program_download: '연결 프로그램 다운로드',
hardware_device_name_title: '연결한 하드웨어:',
hardware_device_name_title_robot: '연결한 로봇:',
hardware_device_name_content: '없음',
hardware_connected_noti: '하드웨어 연결 프로그램을\n확인해 주세요.',
arduino_noti_text:
Expand Down Expand Up @@ -5541,7 +5542,6 @@ Lang.Workspace = {
confirm_firmware_hwlite_block_download: '펌웨어 다운로드',
confirm_firmware_hwlite_block_usb_connect: 'USB 연결',
confirm_firmware_hwlite_block_pass: '이미 설치함',
confirm_firmware_hwlite_block_usb_connect: 'USB 연결',
progress_firmware_hwlite_title: '펌웨어 설치',
progress_firmware_hwlite_step1_title: 'USB 연결 확인',
progress_firmware_hwlite_step1_content1: 'USB로 기기와 PC를 연결하고 아래 버튼을 눌러 주세요.',
Expand Down
23 changes: 17 additions & 6 deletions extern/util/CanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
self._selection = [0, 0];
self._wasOver = false;
self._topPosition = o.topPosition; // parse box shadow

self.boxShadow(self._boxShadow, true); // calculate the full width and height with padding, borders and shadows

self._calcWH(); // setup the off-DOM canvas
Expand Down Expand Up @@ -741,7 +740,7 @@
nav.indexOf('android') >= 0; // add support for mobile

var isMobile = typeof window.orientation !== 'undefined';

var hasHiddenFocus = false;
if (
isMobile &&
!isChromeMobile &&
Expand All @@ -762,12 +761,23 @@
);
input.style.width = self._width;
input.style.height = 0;
document.body.appendChild(input);
const form = document.createElement('form');
form.appendChild(input);
document.body.appendChild(form);
input.focus();
input.addEventListener(
'blur',
function() {
self.blur(self);
if (!hasHiddenFocus) {
self.blur(self);
}
},
false
);
input.addEventListener(
'focus',
() => {
self.focus();
},
false
);
Expand All @@ -776,11 +786,12 @@
} // move the real focus to the hidden input

var hasSelection = self._selection[0] > 0 || self._selection[1] > 0;

hasHiddenFocus = true;
self._hiddenInput.focus();

hasHiddenFocus = false;
self._hiddenInput.selectionStart = hasSelection ? self._selection[0] : self._cursorPos;
self._hiddenInput.selectionEnd = hasSelection ? self._selection[1] : self._cursorPos;

return self.render();
},

Expand Down
4 changes: 0 additions & 4 deletions extern/util/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ EntryStatic.getAllBlocks = function () {
'arduino_open',
'hardware_program_download',
'arduino_cloud_pc_open',
// 'arduino_connect',
'arduino_lite_disconnect',
'hardware_device_name_title',
'hardware_device_name_content',
Expand All @@ -503,9 +502,6 @@ EntryStatic.getAllBlocks = function () {
'arduino_lite_reconnect',
'hardware_noti_not_installed',
'arduino_lite_download_firmware',
// 'arduino_download_connector',
// 'download_guide',
// 'arduino_download_source',
'arduino_lite_connect',
'arduino_lite_guide',
'arduino_noti',
Expand Down
36 changes: 21 additions & 15 deletions extern/util/static_mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,30 +434,38 @@ EntryStatic.getAllBlocks = function () {
{
category: 'hw_sensor',
visible: false,
blocks: ['practical_course_dummy'].concat(
EntryStatic.DynamicPracticalHardwareBlocks['hw_sensor']
),
blocks: [
'practical_course_dummy',
'hardware_device_name_title_sensor',
'hardware_device_name_content_sensor',
].concat(EntryStatic.DynamicPracticalHardwareBlocks['hw_sensor']),
},
{
category: 'hw_motor',
visible: false,
blocks: ['practical_course_dummy'].concat(
EntryStatic.DynamicPracticalHardwareBlocks['hw_motor']
),
blocks: [
'practical_course_dummy',
'hardware_device_name_title_motor',
'hardware_device_name_content_motor',
].concat(EntryStatic.DynamicPracticalHardwareBlocks['hw_motor']),
},
{
category: 'hw_led',
visible: false,
blocks: ['practical_course_dummy'].concat(
EntryStatic.DynamicPracticalHardwareBlocks['hw_led']
),
blocks: [
'practical_course_dummy',
'hardware_device_name_title_led',
'hardware_device_name_content_led',
].concat(EntryStatic.DynamicPracticalHardwareBlocks['hw_led']),
},
{
category: 'hw_melody',
visible: false,
blocks: ['practical_course_dummy'].concat(
EntryStatic.DynamicPracticalHardwareBlocks['hw_melody']
),
blocks: [
'practical_course_dummy',
'hardware_device_name_title_melody',
'hardware_device_name_content_melody',
].concat(EntryStatic.DynamicPracticalHardwareBlocks['hw_melody']),
},
{
category: 'hw_robot',
Expand All @@ -467,10 +475,8 @@ EntryStatic.getAllBlocks = function () {
'arduino_open',
'arduino_connect',
'hardware_program_download',
// 'arduino_download_connector',
// 'download_guide',
'arduino_connected',
'hardware_device_name_title',
'hardware_device_name_title_robot',
'hardware_device_name_content',
'hardware_connected_noti',
'robot_noti',
Expand Down
Binary file added images/hardware/avatarbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hardware/robico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hw/robico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hw_lite/robotis_koalabot_lite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@entrylabs/entry",
"title": "EntryJS",
"description": "JavaScript library for visual programming",
"version": "4.0.12",
"version": "4.0.13",
"main": "dist/entry.min.js",
"homepage": "https://playentry.org",
"author": {
Expand Down
3 changes: 2 additions & 1 deletion src/class/AILearning.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,11 @@ function createDataTable(classes, name) {
const [{ samples }] = classes;
const [sample = {}] = samples || [];
let data = sample.data;
data.id = data.id || data._id;
if (typeof data === 'string') {
data = JSON.parse(data);
}
if (data && data.id && !DataTable.getSource(data.id)) {
if (data && data?.id && !DataTable.getSource(data?.id)) {
DataTable.addSource(data, false);
}
return data;
Expand Down
23 changes: 18 additions & 5 deletions src/class/hw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export default class Hardware {
return;
}
this.communicationType = this.hwModule.communicationType || 'auto';
Entry.block.changeBlockText('hardware_device_name_content', this.hwModule.title.ko);
this.setDeviceNameContent(true);
this._banClassAllHardware();
Entry.dispatchEvent('hwChanged');

Expand All @@ -363,6 +363,22 @@ export default class Hardware {
}
}

// INFO: 블록메뉴의 '연결한 하드웨어:' 블럭의 값을 세팅하는 함수.
// setName이 true이면 연결된 하드웨어명을, false이면 기본값(없음)으로 세팅한다.
setDeviceNameContent(setName: boolean) {
const deviceName = setName
? this.hwModule.title[Lang.type]
: Lang.Blocks.hardware_device_name_content;
if (this.hwModule?.hasPracticalCourse && EntryStatic.isPracticalCourse) {
Entry.block.changeBlockText('hardware_device_name_content_sensor', deviceName);
Entry.block.changeBlockText('hardware_device_name_content_motor', deviceName);
Entry.block.changeBlockText('hardware_device_name_content_led', deviceName);
Entry.block.changeBlockText('hardware_device_name_content_melody', deviceName);
} else {
Entry.block.changeBlockText('hardware_device_name_content', deviceName);
}
}

private _initHardwareObject() {
const { hardwareEnable } = Entry;
this.popupHelper = createHardwarePopup(() => {
Expand Down Expand Up @@ -596,10 +612,7 @@ export default class Hardware {
Entry.propertyPanel && Entry.propertyPanel.removeMode('hw');
this.currentDeviceKey = undefined;
this.hwModule = undefined;
Entry.block.changeBlockText(
'hardware_device_name_content',
Lang.Blocks.hardware_device_name_content
);
this.setDeviceNameContent(false);
Entry.dispatchEvent('hwChanged');
Entry.toast.alert(
Lang.Msgs.hw_connection_termination_title,
Expand Down
2 changes: 1 addition & 1 deletion src/class/learning/Cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Cluster {

setTable() {
const tableSource = DataTable.getSource(this.#table.id);
if (this.#table.fieldsInfo.length !== tableSource.fields.length) {
if (this.#table?.fieldsInfo?.length !== tableSource?.fields?.length) {
Entry.toast.alert(Lang.Msgs.warn, Lang.AiLearning.train_param_error);
throw Error(Lang.AiLearning.train_param_error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/class/learning/LearningBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class LearningBase {

setTable() {
const tableSource = DataTable.getSource(this.table.id);
if (this.table.fieldsInfo.length !== tableSource.fields.length) {
if (this.table?.fieldsInfo?.length !== tableSource?.fields?.length) {
Entry.toast.alert(Lang.Msgs.warn, Lang.AiLearning.train_param_error);
throw Error(Lang.AiLearning.train_param_error);
}
Expand Down
9 changes: 7 additions & 2 deletions src/class/learning/NumberClassification.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class NumberClassification {
this.init({ ...params });
}

init({ name, url, table, trainParam, modelId, loadModel }) {
init({ name, url, table, trainParam, modelId, loadModel, result }) {
this.#name = name;
this.#table = table;
this.result = result;
this.#trainCallback = (value) => {
this.#view.setValue(value);
};
Expand All @@ -68,7 +69,7 @@ class NumberClassification {

setTable() {
const tableSource = DataTable.getSource(this.#table.id);
if (this.#table.fieldsInfo.length !== tableSource.fields.length) {
if (this.#table?.fieldsInfo?.length !== tableSource?.fields?.length) {
Entry.toast.alert(Lang.Msgs.warn, Lang.AiLearning.train_param_error);
throw Error(Lang.AiLearning.train_param_error);
}
Expand Down Expand Up @@ -148,6 +149,10 @@ class NumberClassification {
return this.#predictResult;
}

getTrainResult() {
return this.result;
}

getLabels() {
const { data: trainData, labels } = convertTableToKnnData(this.#table);
return _uniq(labels[0]).sort((a, b) => String(a).localeCompare(String(b)));
Expand Down
18 changes: 16 additions & 2 deletions src/class/pixi/etc/PIXICanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ import * as PIXI from 'pixi.js';

// add support for mobile
const isMobile = typeof window.orientation !== 'undefined';
var hasHiddenFocus = false;
if (
isMobile &&
!isChromeMobile &&
Expand All @@ -789,12 +790,23 @@ import * as PIXI from 'pixi.js';
(self._canvas ? self._canvas.offsetTop : 0)}px`;
input.style.width = self._width;
input.style.height = 0;
document.body.appendChild(input);
const form = document.createElement('form');
form.appendChild(input);
document.body.appendChild(form);
input.focus();
input.addEventListener(
'blur',
() => {
self.blur(self);
if (!hasHiddenFocus) {
self.blur(self);
}
},
false
);
input.addEventListener(
'focus',
() => {
self.focus();
},
false
);
Expand All @@ -804,7 +816,9 @@ import * as PIXI from 'pixi.js';

// move the real focus to the hidden input
const hasSelection = self._selection[0] > 0 || self._selection[1] > 0;
hasHiddenFocus = true;
self._hiddenInput.focus();
hasHiddenFocus = false;
self._hiddenInput.selectionStart = hasSelection ? self._selection[0] : self._cursorPos;
self._hiddenInput.selectionEnd = hasSelection ? self._selection[1] : self._cursorPos;

Expand Down
Loading

0 comments on commit 2fa7315

Please sign in to comment.