Merge pull request #9459 from BenHenning/merge-develop-into-experimental-branch

chore: Merge develop into experimental branch (experimental)
This commit is contained in:
Ben Henning
2025-11-04 14:11:42 -08:00
committed by GitHub
91 changed files with 1389 additions and 3144 deletions

View File

@@ -31,6 +31,15 @@ body:
1.
2.
3.
- type: textarea
id: priority
attributes:
label: Priority
description: Please help us understand the priority for this issue. The more information provided will help the team better assess urgency and complexity.
placeholder: |
Work effort: Is this a quick fix or will it require a significant amount of work? Is there a clear path to a solution or is further investigation required?
Impact: Which part of the service is impacted? How many users are experencing this issue?
Is there a known workaround for this issue? If so, please describe. If not, does it prevent a user from doing a core task?
- type: textarea
id: stack-trace
attributes:

View File

@@ -20,6 +20,10 @@ updates:
target-branch: 'develop'
schedule:
interval: 'weekly'
ignore:
# See notes in welcome_new_contributors.yml for details on this.
- dependency-name: 'actions/first-interaction'
versions: ['*']
commit-message:
prefix: 'chore(deps)'
labels:

View File

@@ -24,7 +24,7 @@ jobs:
npm run prepareDemos
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: appengine_files
path: _deploy/
@@ -36,13 +36,13 @@ jobs:
needs: prepare
steps:
- name: Download prepared files
uses: actions/download-artifact@v5
uses: actions/download-artifact@v6
with:
name: appengine_files
path: _deploy/
- name: Deploy to App Engine
uses: google-github-actions/deploy-appengine@v2.1.7
uses: google-github-actions/deploy-appengine@v3.0.1
# For parameters see:
# https://github.com/google-github-actions/deploy-appengine#inputs
with:

View File

@@ -19,7 +19,7 @@ jobs:
pull-requests: write
steps:
- name: Assign requested reviewer
uses: actions/github-script@v7
uses: actions/github-script@v8
with:
script: |
try {

View File

@@ -36,7 +36,7 @@ jobs:
ssh://git@github.com/
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}

View File

@@ -33,7 +33,7 @@ jobs:
ssh://git@github.com/
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}
@@ -57,7 +57,7 @@ jobs:
- uses: actions/checkout@v5
- name: Use Node.js 20.x
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20.x
@@ -74,7 +74,7 @@ jobs:
- uses: actions/checkout@v5
- name: Use Node.js 20.x
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20.x

View File

@@ -3,8 +3,30 @@ on:
types:
- opened
- edited
name: conventional-release-labels
name: commit lint & label
jobs:
lint:
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
permissions:
pull-requests: read
contents: read
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v5
with:
node-version: lts/*
cache: npm
- name: Install dependencies
run: npm ci
- name: Check PR title
id: check-pr-title
run: echo "$PR_TITLE" | npx commitlint --verbose
label:
runs-on: ubuntu-latest
permissions:

View File

@@ -37,7 +37,7 @@ jobs:
path: blockly-keyboard-experimentation
- name: Use Node.js 20.x
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20.x

View File

@@ -15,7 +15,7 @@ jobs:
# Add the type: cleanup label
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
- uses: actions/github-script@v8
with:
script: |
// Note that pull requests are considered issues and "shared"

View File

@@ -9,7 +9,12 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/first-interaction@v3
# NOTE TO DEVELOPER: Per #9447 this is pinned to v1.3.0 and all updates
# have been disabled for it. There are some largely incompatibilities on
# v2 and v3 of the action that, without resolution, will break the first
# interaction experience for new contributors. This dependency should not
# be upgraded until those issues are resolved.
- uses: actions/first-interaction@v1.3.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: >

View File

@@ -1,8 +1,8 @@
# Blockly
Google's Blockly is a library that adds a visual code editor to web and mobile apps. The Blockly editor uses interlocking, graphical blocks to represent code concepts like variables, logical expressions, loops, and more. It allows users to apply programming principles without having to worry about syntax or the intimidation of a blinking cursor on the command line. All code is free and open source.
Google's Blockly is a library that adds a visual code editor to web and mobile apps. The Blockly editor uses interlocking, graphical blocks to represent code concepts like variables, logical expressions, loops, and more. It allows users to apply programming principles without having to worry about syntax or the intimidation of a blinking cursor on the command line. All code is [free and open source](https://github.com/google/blockly/blob/develop/LICENSE).
![](https://developers.google.com/blockly/images/sample.png)
![Sample](./sample.svg)
## Getting Started with Blockly
@@ -13,13 +13,11 @@ Blockly has many resources for learning how to use the library. Start at our [Go
- [More codelabs](https://blocklycodelabs.dev/)
- [Demos and plugins](https://google.github.io/blockly-samples/)
Help us focus our development efforts by telling us [what you are doing with
Blockly](https://developers.google.com/blockly/registration). The questionnaire only takes
a few minutes and will help us better support the Blockly community.
Help us focus our development efforts by telling us [what you are doing with Blockly](https://developers.google.com/blockly/registration). The questionnaire only takes a few minutes and will help us better support the Blockly community.
### Installing Blockly
Blockly is [available on npm](https://www.npmjs.com/package/blockly).
Blockly is [available on npm](https://www.npmjs.com/package/blockly):
```bash
npm install blockly
@@ -34,7 +32,7 @@ For more information on installing and using Blockly, see the [Getting Started a
### blockly-samples
We have a number of resources such as example code, demos, and plugins in another repository called [blockly-samples](https://github.com/google/blockly-samples/). A plugin is a self-contained piece of code that adds functionality to Blockly. Plugins can add fields, define themes, create renderers, and much more. For more information, see the [Plugins documentation](https://developers.google.com/blockly/guides/plugins/overview).
We have a number of resources such as [examples](https://github.com/google/blockly-samples/tree/master/examples), [codelabs](https://github.com/google/blockly-samples/tree/master/codelabs), and [plugins](https://github.com/google/blockly-samples/tree/master/plugins) in another repository called [blockly-samples](https://github.com/google/blockly-samples). A plugin is a self-contained piece of code that adds functionality to Blockly. Plugins can add fields, define themes, create renderers, and much more. For more information, see the [Plugins documentation](https://developers.google.com/blockly/guides/programming/plugin_overview).
## Contributing to Blockly

View File

@@ -726,21 +726,21 @@ const PROCEDURES_MUTATORARGUMENT = {
if (sourceBlock.isInFlyout) {
return varName;
}
const model = outerWs.getVariable(varName, '');
const variableMap = outerWs.getVariableMap();
const model = variableMap.getVariable(varName, '');
if (model && model.getName() !== varName) {
// Rename the variable (case change)
outerWs.renameVariableById(model.getId(), varName);
variableMap.renameVariable(model, varName);
}
if (!model) {
if (this.editingInteractively) {
if (!this.editingVariable) {
this.editingVariable = outerWs.createVariable(varName, '');
this.editingVariable = variableMap.createVariable(varName, '');
} else {
outerWs.renameVariableById(this.editingVariable.getId(), varName);
variableMap.renameVariable(this.editingVariable, varName);
}
} else {
outerWs.createVariable(varName, '');
variableMap.createVariable(varName, '');
}
}
return varName;

39
commitlint.config.mjs Normal file
View File

@@ -0,0 +1,39 @@
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Rules configuration for commitlint.
* https://commitlint.js.org/reference/rules.html#subject-full-stop
*
* Extends the conventional-commit spec at
* https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional
*/
export default {
extends: ['@commitlint/config-conventional'],
rules: {
// Warn if not in this list. Allow for judicious creativity.
'type-enum': [
1,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'refactor',
'release',
'revert',
'test',
],
],
'subject-case': [0],
},
helpUrl:
'https://developers.google.com/blockly/guides/contribute/get-started/commits',
};

View File

@@ -43,9 +43,11 @@ export class FlyoutButton
/** The radius of the flyout button's borders. */
static BORDER_RADIUS = 4;
/** The key to the function called when this button is activated. */
readonly callbackKey: string;
private readonly text: string;
private readonly position: Coordinate;
private readonly callbackKey: string;
private readonly cssClass: string | null;
/** Mouse up event data. */
@@ -97,12 +99,13 @@ export class FlyoutButton
this.position = new Coordinate(0, 0);
/** The key to the function called when this button is clicked. */
/**
* The key to the function called when this button is activated.
* Check both the uppercase and lowercase version, because the docs
* say `callbackKey` but the type says `callbackkey`.
*/
this.callbackKey =
(json as AnyDuringMigration)[
'callbackKey'
] /* Check the lower case version
too to satisfy IE */ ||
(json as AnyDuringMigration)['callbackKey'] ||
(json as AnyDuringMigration)['callbackkey'];
/** If specified, a CSS class to add to this button. */

View File

@@ -467,6 +467,15 @@ export class Gesture {
/* opt_noCaptureIdentifier */ true,
),
);
this.boundEvents.push(
browserEvents.conditionalBind(
document,
'pointercancel',
null,
this.handleUp.bind(this),
/* opt_noCaptureIdentifier */ true,
),
);
e.preventDefault();
e.stopPropagation();

View File

@@ -14,6 +14,7 @@
import {BlockSvg} from '../block_svg.js';
import {Field} from '../field.js';
import {Icon} from '../icons/icon.js';
import type {IFocusableNode} from '../interfaces/i_focusable_node.js';
import {RenderedConnection} from '../rendered_connection.js';
@@ -66,6 +67,8 @@ export class Marker {
return node.getSourceBlock() as BlockSvg;
} else if (node instanceof RenderedConnection) {
return node.getSourceBlock();
} else if (node instanceof Icon) {
return node.getSourceBlock() as BlockSvg;
}
return null;

View File

@@ -46,7 +46,6 @@ export const TOUCH_MAP: {[key: string]: string[]} = {
'mouseup': ['pointerup', 'pointercancel'],
'touchend': ['pointerup'],
'touchcancel': ['pointercancel'],
'pointerup': ['pointerup', 'pointercancel'],
};
/** PID of queued long-press task. */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -1,91 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blockly Demo: Minimap</title>
<script src="../../dist/blockly_compressed.js"></script>
<script src="../../dist/blocks_compressed.js"></script>
<script src="../../build/msg/en.js"></script>
<script src="minimap.js"></script>
<style>
body {
background-color: #fff;
font-family: sans-serif;
}
h1 {
font-weight: normal;
font-size: 140%;
}
</style>
</head>
<body>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Minimap</h1>
<p>This is a simple demo showing how a minimap can be implemented.</p>
<table width="100%">
<tr>
<td>
<div id="masterDiv" style="height: 480px; width: 900px;"></div>
</td>
<td>
<div id="mapDiv" style="height: 480px; width: 200px;"></div>
</td>
</tr>
</table>
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>
<block type="math_number">
<field name="NUM">123</field>
</block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
<block type="variables_get"><field name="VAR">i</field></block>
<block type="variables_get"><field name="VAR">j</field></block>
<block type="variables_get"><field name="VAR">k</field></block>
</xml>
<script>
// Inject master workspace.
var masterWorkspace = Blockly.inject('masterDiv', {
media: '../../media/',
scrollbars: true,
toolbox: document.getElementById('toolbox')
});
// Inject workspace for minimap.
var minimapWorkspace = Blockly.inject('mapDiv', {
media: '../../media/',
readOnly: true,
zoom: {
controls: false,
wheel: true,
startScale: 0.1, // Change this according to your needs.
maxScale: 0.1,
minScale: 0.01
}
});
// Initialize the minimap.
Minimap.init(masterWorkspace,minimapWorkspace);
</script>
<style>
.minimap{
position: absolute;
}
.mapDragger{
cursor: move;
fill: rgb(0,0,255);
stroke-width: .5;
stroke: rgb(0,0,0);
fill-opacity: .1;
}
</style>
</body>
</html>

View File

@@ -1,302 +0,0 @@
/**
* Copyright 2017 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview JavaScript for Blockly's Minimap demo.
*/
'use strict';
/**
* Creating a separate namespace for minimap.
*/
var Minimap = {};
/**
* Initialize the workspace and minimap.
* @param {!Workspace} workspace The main workspace of the user.
* @param {!Workspace} minimap The workspace that will be used as a minimap.
*/
Minimap.init = function(workspace, minimap) {
this.workspace = workspace;
this.minimap = minimap;
// Adding scroll callback functionality to vScroll and hScroll just for this demo.
// IMPORTANT: This should be changed when there is proper UI event handling
// API available and should be handled by workspace's event listeners.
this.workspace.scrollbar.vScroll.setHandlePosition = function(newPosition) {
this.handlePosition_ = newPosition;
this.svgHandle_.setAttribute(this.positionAttribute_, this.handlePosition_);
// Code above is same as the original setHandlePosition function in core/scrollbar.js.
// New code starts from here.
// Get the absolutePosition.
var absolutePosition = (this.handlePosition_ / this.ratio);
// Firing the scroll change listener.
Minimap.onScrollChange(absolutePosition, this.horizontal_);
};
// Adding call back for horizontal scroll.
this.workspace.scrollbar.hScroll.setHandlePosition = function(newPosition) {
this.handlePosition_ = newPosition;
this.svgHandle_.setAttribute(this.positionAttribute_, this.handlePosition_);
// Code above is same as the original setHandlePosition function in core/scrollbar.js.
// New code starts from here.
// Get the absolutePosition.
var absolutePosition = (this.handlePosition_ / this.ratio);
// Firing the scroll change listener.
Minimap.onScrollChange(absolutePosition, this.horizontal_);
};
// Required to stop a positive feedback loop when user clicks minimap
// and the scroll changes, which in turn may change minimap.
this.disableScrollChange = false;
// Listen to events on the main workspace.
this.workspace.addChangeListener(Minimap.mirrorEvent);
//Get rectangle bounding the minimap div.
this.rect = document.getElementById('mapDiv').getBoundingClientRect();
// Create a svg overlay on the top of mapDiv for the minimap.
this.svg = Blockly.utils.dom.createSvgElement('svg', {
'xmlns': Blockly.utils.dom.SVG_NS,
'xmlns:html': Blockly.utils.dom.HTML_NS,
'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
'version': '1.1',
'height': this.rect.bottom-this.rect.top,
'width': this.rect.right-this.rect.left,
'class': 'minimap',
}, document.getElementById('mapDiv'));
this.svg.style.top = this.rect.top + 'px';
this.svg.style.left = this.rect.left + 'px';
// Creating a rectangle in the minimap that represents current view.
Blockly.utils.dom.createSvgElement('rect', {
'width': 100,
'height': 100,
'class': 'mapDragger'
}, this.svg);
// Rectangle in the minimap that represents current view.
this.mapDragger = this.svg.childNodes[0];
// Adding mouse events to the rectangle, to make it Draggable.
// Using Blockly.browserEvents.bind to attach mouse/touch listeners.
Blockly.browserEvents.bind(
this.mapDragger, 'mousedown', null, Minimap.mousedown);
//When the window change, we need to resize the minimap window.
window.addEventListener('resize', Minimap.repositionMinimap);
// Mouse up event for the minimap.
this.svg.addEventListener('mouseup', Minimap.updateMapDragger);
//Boolean to check whether I am dragging the surface or not.
this.isDragging = false;
};
Minimap.mousedown = function(e) {
// Using Blockly.browserEvents.bind to attach mouse/touch listeners.
Minimap.mouseMoveBindData = Blockly.browserEvents.bind(
document, 'mousemove', null, Minimap.mousemove);
Minimap.mouseUpBindData =
Blockly.browserEvents.bind(document, 'mouseup', null, Minimap.mouseup);
Minimap.isDragging = true;
e.stopPropagation();
};
Minimap.mouseup = function(e) {
Minimap.isDragging = false;
// Removing listeners.
Blockly.browserEvents.unbind(Minimap.mouseUpBindData);
Blockly.browserEvents.unbind(Minimap.mouseMoveBindData);
Minimap.updateMapDragger(e);
e.stopPropagation();
};
Minimap.mousemove = function(e) {
if (Minimap.isDragging) {
Minimap.updateMapDragger(e);
e.stopPropagation();
}
};
/**
* Run non-UI events from the main workspace on the minimap.
* @param {!Blockly.Events.Abstract} event Event that triggered in the main
* workspace.
*/
Minimap.mirrorEvent = function(event) {
if (event.isUiEvent) {
return; // Don't mirror UI events.
}
// Convert event to JSON. This could then be transmitted across the net.
var json = event.toJson();
// Convert JSON back into an event, then execute it.
var minimapEvent = Blockly.Events.fromJson(json, Minimap.minimap);
minimapEvent.run(true);
Minimap.scaleMinimap();
Minimap.setDraggerHeight();
Minimap.setDraggerWidth();
};
/**
* Called when window is resized. Repositions the minimap overlay.
*/
Minimap.repositionMinimap = function() {
Minimap.rect = document.getElementById('mapDiv').getBoundingClientRect();
Minimap.svg.style.top = Minimap.rect.top + 'px';
Minimap.svg.style.left = Minimap.rect.left + 'px';
};
/**
* Updates the rectangle's height.
*/
Minimap.setDraggerHeight = function() {
var workspaceMetrics = Minimap.workspace.getMetrics();
var draggerHeight = (workspaceMetrics.viewHeight / Minimap.workspace.scale) *
Minimap.minimap.scale;
// It's zero when first block is placed.
if (draggerHeight === 0) {
return;
}
Minimap.mapDragger.setAttribute('height', draggerHeight);
};
/**
* Updates the rectangle's width.
*/
Minimap.setDraggerWidth = function() {
var workspaceMetrics = Minimap.workspace.getMetrics();
var draggerWidth = (workspaceMetrics.viewWidth / Minimap.workspace.scale) *
Minimap.minimap.scale;
// It's zero when first block is placed.
if (draggerWidth === 0) {
return;
}
Minimap.mapDragger.setAttribute('width', draggerWidth);
};
/**
* Updates the overall position of the viewport of the minimap by appropriately
* using translate functions.
*/
Minimap.scaleMinimap = function() {
var minimapBoundingBox = Minimap.minimap.getBlocksBoundingBox();
var workspaceBoundingBox = Minimap.workspace.getBlocksBoundingBox();
var workspaceMetrics = Minimap.workspace.getMetrics();
var minimapMetrics = Minimap.minimap.getMetrics();
// Scaling the minimap such that all the blocks can be seen in the viewport.
// This padding is default because this is how to scrollbar(in main workspace)
// is implemented.
var topPadding = (workspaceMetrics.viewHeight) * Minimap.minimap.scale /
(2 * Minimap.workspace.scale);
var sidePadding = (workspaceMetrics.viewWidth) * Minimap.minimap.scale /
(2 * Minimap.workspace.scale);
// If actual padding is more than half view ports height,
// change it to actual padding.
if ((workspaceBoundingBox.y * Minimap.workspace.scale -
workspaceMetrics.contentTop) *
Minimap.minimap.scale / Minimap.workspace.scale > topPadding) {
topPadding = (workspaceBoundingBox.y * Minimap.workspace.scale -
workspaceMetrics.contentTop) *
Minimap.minimap.scale / Minimap.workspace.scale;
}
// If actual padding is more than half view ports height,
// change it to actual padding.
if ((workspaceBoundingBox.x * Minimap.workspace.scale -
workspaceMetrics.contentLeft) *
Minimap.minimap.scale / Minimap.workspace.scale > sidePadding) {
sidePadding = (workspaceBoundingBox.x * Minimap.workspace.scale -
workspaceMetrics.contentLeft) *
Minimap.minimap.scale / Minimap.workspace.scale;
}
var scalex = (minimapMetrics.viewWidth - 2 * sidePadding) /
minimapBoundingBox.width;
var scaley = (minimapMetrics.viewHeight - 2 * topPadding) /
minimapBoundingBox.height;
Minimap.minimap.setScale(Math.min(scalex, scaley));
// Translating the minimap.
Minimap.minimap.translate(
-minimapMetrics.contentLeft * Minimap.minimap.scale + sidePadding,
-minimapMetrics.contentTop * Minimap.minimap.scale + topPadding);
};
/**
* Handles the onclick event on the minimapBoundingBox.
* Changes mapDraggers position.
* @param {!Event} e Event from the mouse click.
*/
Minimap.updateMapDragger = function(e) {
var y = e.clientY;
var x = e.clientX;
var draggerHeight = Minimap.mapDragger.getAttribute('height');
var draggerWidth = Minimap.mapDragger.getAttribute('width');
var finalY = y - Minimap.rect.top - draggerHeight / 2;
var finalX = x - Minimap.rect.left - draggerWidth / 2;
var maxValidY = (Minimap.workspace.getMetrics().contentHeight -
Minimap.workspace.getMetrics().viewHeight) * Minimap.minimap.scale;
var maxValidX = (Minimap.workspace.getMetrics().contentWidth -
Minimap.workspace.getMetrics().viewWidth) * Minimap.minimap.scale;
if (y + draggerHeight / 2 > Minimap.rect.bottom) {
finalY = Minimap.rect.bottom - Minimap.rect.top - draggerHeight;
} else if (y < Minimap.rect.top + draggerHeight / 2) {
finalY = 0;
}
if (x + draggerWidth / 2 > Minimap.rect.right) {
finalX = Minimap.rect.right - Minimap.rect.left - draggerWidth;
} else if (x < Minimap.rect.left + draggerWidth / 2) {
finalX = 0;
}
// Do not go below lower bound of scrollbar.
if (finalY > maxValidY) {
finalY = maxValidY;
}
if (finalX > maxValidX) {
finalX = maxValidX;
}
Minimap.mapDragger.setAttribute('y', finalY);
Minimap.mapDragger.setAttribute('x', finalX);
// Required, otherwise creates a feedback loop.
Minimap.disableScrollChange = true;
Minimap.workspace.scrollbar.vScroll.set((finalY * Minimap.workspace.scale) /
Minimap.minimap.scale);
Minimap.workspace.scrollbar.hScroll.set((finalX * Minimap.workspace.scale) /
Minimap.minimap.scale);
Minimap.disableScrollChange = false;
};
/**
* Handles the onclick event on the minimapBoundingBox, parameters are passed by
* the event handler.
* @param {number} position This is the absolute position of the scrollbar.
* @param {boolean} horizontal Informs if the change event if for
* horizontal (true) or vertical (false) scrollbar.
*/
Minimap.onScrollChange = function(position, horizontal) {
if (!Minimap.disableScrollChange) {
Minimap.mapDragger.setAttribute(horizontal ? 'x' : 'y',
position * Minimap.minimap.scale / Minimap.workspace.scale);
}
};

View File

@@ -1,53 +0,0 @@
# Blockly on Mobile Devices
This directory contains three examples of running the Blockly library on mobile
devices. The `html/` directory is a example of configuring a webpage for touch
devices, with a Blockly workspace that fills the screen.
The `mobile/html/` is also the basis for the Android and iOS demos. Each native
app copies this demo into the app's local resources, and required Blockly
library files, and hosts them in an embedded WebView.
Thus, developers can quickly iterate within the `mobile/html/` directory, and
see changes in both the Android and iOS native apps.
## Running the Mobile HTML Demo
Before running the mobile HTML demo, you need to create some symbolic links
in your local file system. Run the `mobile/html/ln_resources.sh` file from
the `mobile/html/` directory. This mimics the relative locations of the
Blockly files seen when loading the page in a native app's embedded WebView.
After doing this, opening `mobile/html/index.html` should open normally,
filling the page with one large Blockly workspace.
## The Android App
### Build and Run
Open the `demos/mobile/android/` directory in Android Studio. The project
files in the directory should be ready to build and run the demo in an emulator
or connected device.
### Android Copy Tasks
If you edit the `mobile/html/` demo to include new files, you will need to
update the native app project files to also copy those files.
In the Android project, two Gradle tasks are responsible for the copies.
In `mobile/android/app/build.gradle`, the tasks `copyBlocklyHtmlFile` and
`copyBlocklyMoreFiles` configure the copy actions.
## The iOS App
### Build and Run
Open the `demos/mobile/iOS/` directory in XCode. The project files in the
directory should be ready to build and run the demo in a simulator or connected
device.
### iOS Copy Script
The XCode project call out to `mobile/ios/cp_resources.sh` to copy the required
HTML and related files. If you've edited the `mobile/html/` demo to require new
files, update this script to copy these files, too.

View File

@@ -1,27 +0,0 @@
/build
/captures
/app/src/main/assets/blockly
.settings
.project
# Local Settings
local.properties
# Project files
*.komodoproject
.gradle
*.iml
.idea
# Build files
*.pyc
*.apk
*.ap_
*.class
*.dex
# OSX Files
.DS_Store
# Windows Files
Thumb.db

View File

@@ -1,45 +0,0 @@
# Blockly in an Android WebView
This code demonstrates how to get Blockly running in an Android app by
embedding it in a WebView.
### BlocklyWebViewFragment
Most of the work is done within the fragment class `BlocklyWebViewFragment`.
This fragment instantiates the WebView, loads the HTML
(`assets/blockly/webview.html`, copied from `demos/mobile/html/index.html`),
and provides a few helper methods.
### Copying web assets with gradle
This android project copies the necessary files from the main Blockly
repository (i.e., parent directory). In `app/build.gradle`, note the
`copyBlocklyHtmlFile` and `copyBlocklyMoreFiles` tasks.
In your own project, the HTML and related files can be placed directly in the
`assets/blockly` directory without the copy step. However, using the copy tasks
simplifies the synchronization with an iOS app using the same files.
### Loading Block Definitions and Generator functions
The `webview.html` loads the block definitions and generator functions directly
into the page, without support or coordination with the Android classes. This
assumes the app will always utilize the same blocks. This does not mean all
blocks are visible to the user all the time; that is controlled by the toolbox
and workspace files. This should accommodate almost all applications.
This does mean loading your own block definitions and generators will involve
editing the HTML, adding you own `<script>` tag, and possibly removing
the `blocks_compressed.js` if you do not use any standard blocks.
### Connecting a Developer Console
While the console output of the WebView will be visible in the Android log
(i.e., `logcat`), some times a more intrusive approach is required to isolate
a problem. For instructions on connecting the WebView to Chrome's Developer
Tools, see this article:
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/
The WebView must be visible in the connect device or emulator before the
WebView will included in the list of available pages to connect to.

View File

@@ -1,7 +0,0 @@
/build
# Files copied during build:
src/main/assets/blockly/blockly_compressed.js
src/main/assets/blockly/blocks_compressed.js
src/main/assets/blockly/media
src/main/assets/blockly/webview.html

View File

@@ -1,64 +0,0 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId 'com.google.blockly.android.webview.demo'
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
task copyBlocklyHtmlFile(type: Copy) {
from('../../html') {
include 'index.html', 'toolbox_standard.js'
}
into project(':app').file('./src/main/assets/blockly')
rename('index.html', 'webview.html')
}
task copyBlocklyDistFiles(type: Copy) {
from('../../../../dist') {
include 'blockly_compressed.js', 'blocks_compressed.js'
}
into project(':app').file('./src/main/assets/blockly')
}
task copyBlocklyBuildFiles(type: Copy) {
from('../../../../build') {
include 'msg/**'
}
into project(':app').file('./src/main/assets/blockly')
}
task copyBlocklyMediaFiles(type: Copy) {
from('../../../..') {
include 'media/**'
exclude 'media/test_*'
}
into project(':app').file('./src/main/assets/blockly')
}
project.afterEvaluate {
preBuild.dependsOn(copyBlocklyHtmlFile, copyBlocklyBuildFiles, copyBlocklyDistFiles, copyBlocklyMediaFiles)
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

View File

@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -1,26 +0,0 @@
package com.example.blocklywebview;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.blocklywebview", appContext.getPackageName());
}
}

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.blocklywebview">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.google.blockly.android.webview.demo.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -1,40 +0,0 @@
package com.google.blockly.android.webview;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
/**
* This fragments contains and manages the web view that hosts Blockly.
*/
public class BlocklyWebViewFragment extends Fragment {
protected @Nullable WebView mWebView = null;
@SuppressLint("SetJavaScriptEnabled")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
mWebView = new WebView(inflater.getContext());
mWebView.setWebChromeClient(new WebChromeClient());
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/blockly/webview.html");
return mWebView;
}
// TODO: Method to invoke code generation
// TODO: Method to load workspace from string (or InputStream?)
// TODO: Method to serialize workspace to string (or OutputStream?)
// TODO: Clear / reset workspace
// TODO: Load toolbox
// TODO: Listener for event JSON
// TODO: Method to evaluate JavaScript string in the WebView
}

View File

@@ -1,150 +0,0 @@
/**
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.blockly.android.webview;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.TextView;
import com.example.blocklywebview.R;
/**
* Helper class to create JavaScript dialogs.
* Adapted from android-9.0.0_r10/core/java/android/webkit/JsDialogHelper.java.
* Removes dialog title (page domain) and uses a larger prompt message area than original.
*/
public class JsDialogHelper {
private static final String TAG = "JsDialogHelper";
// Dialog types
/** An alert dialog, for console.alert(..). */
public static final int ALERT = 1;
/** An alert dialog, for console.confirm(..). */
public static final int CONFIRM = 2;
/** An alert dialog, for console.prompt(..). */
public static final int PROMPT = 3;
private final @Nullable String mDefaultValue;
private final JsResult mResult;
private final String mMessage;
private final int mType;
private final String mUrl;
public JsDialogHelper(JsResult result, int type, @Nullable String defaultValue,
String message, String url) {
if (type == PROMPT && !(result instanceof JsPromptResult)) {
throw new IllegalArgumentException("JsDialogHelper PROMPT requires JsPromptResult");
}
mResult = result;
mDefaultValue = defaultValue;
mMessage = message;
mType = type;
mUrl = url;
}
public JsDialogHelper(JsResult result, Message msg) {
mResult = result;
mDefaultValue = msg.getData().getString("default");
mMessage = msg.getData().getString("message");
mType = msg.getData().getInt("type");
mUrl = msg.getData().getString("url");
}
public boolean invokeCallback(WebChromeClient client, WebView webView) {
switch (mType) {
case ALERT:
return client.onJsAlert(webView, mUrl, mMessage, mResult);
case CONFIRM:
return client.onJsConfirm(webView, mUrl, mMessage, mResult);
case PROMPT:
return client.onJsPrompt(webView, mUrl, mMessage, mDefaultValue, (JsPromptResult) mResult);
default:
throw new IllegalArgumentException("Unexpected type: " + mType);
}
}
public void showDialog(Context context) {
if (!canShowAlertDialog(context)) {
Log.w(TAG, "Cannot create a dialog, the WebView context is not an Activity");
mResult.cancel();
return;
}
final EditText edit;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setOnCancelListener(new CancelListener());
if (mType != PROMPT) {
edit = null;
builder.setMessage(mMessage);
builder.setPositiveButton(android.R.string.ok, new PositiveListener(null));
} else {
final View view = LayoutInflater.from(context).inflate(R.layout.js_prompt, null);
edit = view.findViewById(R.id.js_prompt_value);
edit.setText(mDefaultValue);
builder.setPositiveButton(android.R.string.ok, new PositiveListener(edit));
((TextView) view.findViewById(R.id.js_prompt_message)).setText(mMessage);
builder.setView(view);
// TODO: Open keyboard and place text cursor.
}
if (mType != ALERT) {
builder.setNegativeButton(android.R.string.cancel, new CancelListener());
}
final AlertDialog dialog = builder.show();
}
private class CancelListener implements DialogInterface.OnCancelListener,
DialogInterface.OnClickListener {
@Override
public void onCancel(DialogInterface dialog) {
mResult.cancel();
}
@Override
public void onClick(DialogInterface dialog, int which) {
mResult.cancel();
}
}
private class PositiveListener implements DialogInterface.OnClickListener {
private final EditText mEdit;
public PositiveListener(EditText edit) {
mEdit = edit;
}
@Override
public void onClick(DialogInterface dialog, int which) {
if (mEdit == null) {
mResult.confirm();
} else {
((JsPromptResult) mResult).confirm(mEdit.getText().toString());
}
}
}
private static boolean canShowAlertDialog(Context context) {
return context instanceof Activity;
}
}

View File

@@ -1,32 +0,0 @@
package com.google.blockly.android.webview;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebView;
/**
* Provides native hooks for JavaScript console dialog functions.
*/
public class WebChromeClient extends android.webkit.WebChromeClient {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
new JsDialogHelper(result, JsDialogHelper.ALERT, null, message, url)
.showDialog(view.getContext());
return true;
}
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
new JsDialogHelper(result, JsDialogHelper.CONFIRM, null, message, url)
.showDialog(view.getContext());
return true;
}
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
JsPromptResult result) {
new JsDialogHelper(result, JsDialogHelper.PROMPT, defaultValue, message, url)
.showDialog(view.getContext());
return true;
}
}

View File

@@ -1,18 +0,0 @@
package com.google.blockly.android.webview.demo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.example.blocklywebview.R;
/**
* The primary activity of the demo application. The activity embeds the
* {@link com.google.blockly.android.webview.BlocklyWebViewFragment}.
*/
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

View File

@@ -1,34 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
<item
android:color="#00000000"
android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.google.blockly.android.webview.demo.MainActivity">
<fragment
android:id="@+id/blockly_webview"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:name="com.google.blockly.android.webview.BlocklyWebViewFragment"
/>
</android.support.constraint.ConstraintLayout>

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<TextView android:id="@+id/js_prompt_message"
style="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip"
/>
<EditText android:id="@+id/js_prompt_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:inputType="text"
android:selectAllOnFocus="true"
android:scrollHorizontally="true"
android:layout_marginTop="6dip"
/>
</LinearLayout>

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for a JavaScript dialog. "The page at <url of current page> says:" -->
<string name="js_dialog_title">The page at \"<xliff:g id="title">%s</xliff:g>\" says:</string>
<!-- Default title for a javascript dialog -->
<string name="js_dialog_title_default">JavaScript</string>
</resources>

View File

@@ -1,3 +0,0 @@
<resources>
<string name="app_name">Blockly WebView</string>
</resources>

View File

@@ -1,11 +0,0 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

View File

@@ -1,17 +0,0 @@
package com.example.blocklywebview;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@@ -1,27 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -1,13 +0,0 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

View File

@@ -1,6 +0,0 @@
#Thu Oct 04 16:59:44 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

View File

@@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1 +0,0 @@
include ':app'

View File

@@ -1,4 +0,0 @@
/blockly_compressed.js
/blocks_compressed.js
/media
/msg

View File

@@ -1,31 +0,0 @@
<!DOCTYPE html>
<!-- HTML file to host Blockly in a mobile WebView. -->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style type="text/css">
html, body, #blocklyDiv {
border: 0;
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
</style>
<script src="blockly_compressed.js"></script>
<script src="blocks_compressed.js"></script>
<!-- TODO: Select msg file based on locale. -->
<script src="msg/en.js"></script>
<script src="toolbox_standard.js"></script>
</head>
<body>
<div id="blocklyDiv"></div>
<script type="text/javascript">
var workspacePlayground = Blockly.inject('blocklyDiv', {
media: 'media/',
toolbox: BLOCKLY_TOOLBOX_XML['standard'],
zoom: {controls: true}
});
</script>
</body>
</html>

View File

@@ -1,22 +0,0 @@
#!/bin/bash -e
#
# Create symbolic links in this directory for the
# Blockly library files used by this demo's index.html.
if [[ ! -e ../../../dist/blockly_compressed.js ]]; then
echo "ERROR: Could not locate blockly_compressed.js. Run from demos/mobile/html/" 1>&2
exit 1 # terminate and indicate error
fi
if [ ! -L blockly_compressed.js ]; then
ln -s ../../../dist/blockly_compressed.js blockly_compressed.js
fi
if [ ! -L blocks_compressed.js ]; then
ln -s ../../../dist/blocks_compressed.js blocks_compressed.js
fi
if [ ! -L media ]; then
ln -s ../../../media media
fi
if [ ! -L msg ]; then
ln -s ../../../build/msg msg
fi

View File

@@ -1,333 +0,0 @@
var BLOCKLY_TOOLBOX_XML = BLOCKLY_TOOLBOX_XML || Object.create(null);
/* BEGINNING BLOCKLY_TOOLBOX_XML ASSIGNMENT. DO NOT EDIT. USE BLOCKLY DEVTOOLS. */
BLOCKLY_TOOLBOX_XML['standard'] =
// From XML string/file, replace ^\s?(\s*)?(<.*>)$ with \+$1'$2'
// Tweak first and last line.
'<xml xmlns="https://developers.google.com/blockly/xml">'
+ '<category name="Logic" colour="%{BKY_LOGIC_HUE}">'
+ '<block type="controls_if"></block>'
+ '<block type="logic_compare"></block>'
+ '<block type="logic_operation"></block>'
+ '<block type="logic_negate"></block>'
+ '<block type="logic_boolean"></block>'
+ '<block type="logic_null" disabled="true"></block>'
+ '<block type="logic_ternary"></block>'
+ '</category>'
+ '<category name="Loops" colour="%{BKY_LOOPS_HUE}">'
+ '<block type="controls_repeat_ext">'
+ '<value name="TIMES">'
+ '<shadow type="math_number">'
+ '<field name="NUM">10</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="controls_repeat" disabled="true"></block>'
+ '<block type="controls_whileUntil"></block>'
+ '<block type="controls_for">'
+ '<value name="FROM">'
+ '<shadow type="math_number">'
+ '<field name="NUM">1</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="TO">'
+ '<shadow type="math_number">'
+ '<field name="NUM">10</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="BY">'
+ '<shadow type="math_number">'
+ '<field name="NUM">1</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="controls_forEach"></block>'
+ '<block type="controls_flow_statements"></block>'
+ '</category>'
+ '<category name="Math" colour="%{BKY_MATH_HUE}">'
+ '<block type="math_number" gap="32">'
+ '<field name="NUM">123</field>'
+ '</block>'
+ '<block type="math_arithmetic">'
+ '<value name="A">'
+ '<shadow type="math_number">'
+ '<field name="NUM">1</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="B">'
+ '<shadow type="math_number">'
+ '<field name="NUM">1</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_single">'
+ '<value name="NUM">'
+ '<shadow type="math_number">'
+ '<field name="NUM">9</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_trig">'
+ '<value name="NUM">'
+ '<shadow type="math_number">'
+ '<field name="NUM">45</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_constant"></block>'
+ '<block type="math_number_property">'
+ '<value name="NUMBER_TO_CHECK">'
+ '<shadow type="math_number">'
+ '<field name="NUM">0</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_round">'
+ '<value name="NUM">'
+ '<shadow type="math_number">'
+ '<field name="NUM">3.1</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_on_list"></block>'
+ '<block type="math_modulo">'
+ '<value name="DIVIDEND">'
+ '<shadow type="math_number">'
+ '<field name="NUM">64</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="DIVISOR">'
+ '<shadow type="math_number">'
+ '<field name="NUM">10</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_constrain">'
+ '<value name="VALUE">'
+ '<shadow type="math_number">'
+ '<field name="NUM">50</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="LOW">'
+ '<shadow type="math_number">'
+ '<field name="NUM">1</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="HIGH">'
+ '<shadow type="math_number">'
+ '<field name="NUM">100</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_random_int">'
+ '<value name="FROM">'
+ '<shadow type="math_number">'
+ '<field name="NUM">1</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="TO">'
+ '<shadow type="math_number">'
+ '<field name="NUM">100</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="math_random_float"></block>'
+ '</category>'
+ '<category name="Text" colour="%{BKY_TEXTS_HUE}">'
+ '<block type="text"></block>'
+ '<block type="text_join"></block>'
+ '<block type="text_append">'
+ '<value name="TEXT">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_length">'
+ '<value name="VALUE">'
+ '<shadow type="text">'
+ '<field name="TEXT">abc</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_isEmpty">'
+ '<value name="VALUE">'
+ '<shadow type="text">'
+ '<field name="TEXT"></field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_indexOf">'
+ '<value name="VALUE">'
+ '<block type="variables_get">'
+ '<field name="VAR">text</field>'
+ '</block>'
+ '</value>'
+ '<value name="FIND">'
+ '<shadow type="text">'
+ '<field name="TEXT">abc</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_charAt">'
+ '<value name="VALUE">'
+ '<block type="variables_get">'
+ '<field name="VAR">text</field>'
+ '</block>'
+ '</value>'
+ '</block>'
+ '<block type="text_getSubstring">'
+ '<value name="STRING">'
+ '<block type="variables_get">'
+ '<field name="VAR">text</field>'
+ '</block>'
+ '</value>'
+ '</block>'
+ '<block type="text_changeCase">'
+ '<value name="TEXT">'
+ '<shadow type="text">'
+ '<field name="TEXT">abc</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_trim">'
+ '<value name="TEXT">'
+ '<shadow type="text">'
+ '<field name="TEXT">abc</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_count">'
+ '<value name="SUB">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '<value name="TEXT">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_replace">'
+ '<value name="FROM">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '<value name="TO">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '<value name="TEXT">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_reverse">'
+ '<value name="TEXT">'
+ '<shadow type="text"></shadow>'
+ '</value>'
+ '</block>'
+ '<label text="Input/Output:" web-class="ioLabel"></label>'
+ '<block type="text_print">'
+ '<value name="TEXT">'
+ '<shadow type="text">'
+ '<field name="TEXT">abc</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="text_prompt_ext">'
+ '<value name="TEXT">'
+ '<shadow type="text">'
+ '<field name="TEXT">abc</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '</category>'
+ '<category name="Lists" colour="%{BKY_LISTS_HUE}">'
+ '<block type="lists_create_with">'
+ '<mutation items="0"></mutation>'
+ '</block>'
+ '<block type="lists_create_with"></block>'
+ '<block type="lists_repeat">'
+ '<value name="NUM">'
+ '<shadow type="math_number">'
+ '<field name="NUM">5</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="lists_length"></block>'
+ '<block type="lists_isEmpty"></block>'
+ '<block type="lists_indexOf">'
+ '<value name="VALUE">'
+ '<block type="variables_get">'
+ '<field name="VAR">list</field>'
+ '</block>'
+ '</value>'
+ '</block>'
+ '<block type="lists_getIndex">'
+ '<value name="VALUE">'
+ '<block type="variables_get">'
+ '<field name="VAR">list</field>'
+ '</block>'
+ '</value>'
+ '</block>'
+ '<block type="lists_setIndex">'
+ '<value name="LIST">'
+ '<block type="variables_get">'
+ '<field name="VAR">list</field>'
+ '</block>'
+ '</value>'
+ '</block>'
+ '<block type="lists_getSublist">'
+ '<value name="LIST">'
+ '<block type="variables_get">'
+ '<field name="VAR">list</field>'
+ '</block>'
+ '</value>'
+ '</block>'
+ '<block type="lists_split">'
+ '<value name="DELIM">'
+ '<shadow type="text">'
+ '<field name="TEXT">,</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="lists_sort"></block>'
+ '<block type="lists_reverse"></block>'
+ '</category>'
+ '<category name="Colour" colour="%{BKY_COLOUR_HUE}">'
+ '<block type="colour_picker"></block>'
+ '<block type="colour_random"></block>'
+ '<block type="colour_rgb">'
+ '<value name="RED">'
+ '<shadow type="math_number">'
+ '<field name="NUM">100</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="GREEN">'
+ '<shadow type="math_number">'
+ '<field name="NUM">50</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="BLUE">'
+ '<shadow type="math_number">'
+ '<field name="NUM">0</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '<block type="colour_blend">'
+ '<value name="COLOUR1">'
+ '<shadow type="colour_picker">'
+ '<field name="COLOUR">#ff0000</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="COLOUR2">'
+ '<shadow type="colour_picker">'
+ '<field name="COLOUR">#3333ff</field>'
+ '</shadow>'
+ '</value>'
+ '<value name="RATIO">'
+ '<shadow type="math_number">'
+ '<field name="NUM">0.5</field>'
+ '</shadow>'
+ '</value>'
+ '</block>'
+ '</category>'
+ '<sep></sep>'
+ '<category name="Variables" colour="%{BKY_VARIABLES_HUE}" custom="VARIABLE"></category>'
+ '<category name="Functions" colour="%{BKY_PROCEDURES_HUE}" custom="PROCEDURE"></category>'
+ '</xml>';
/* END BLOCKLY_TOOLBOX_XML ASSIGNMENT. DO NOT EDIT. */

View File

@@ -1,25 +0,0 @@
# Files copied by cp_resources.sh
/Resources/Non-Localized/Blockly
# Xcode.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

View File

@@ -1,390 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
AB036C55211B89D600CCC9D8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB036C54211B89D600CCC9D8 /* WebKit.framework */; };
AB980111211A37B50025AFF2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB980110211A37B50025AFF2 /* AppDelegate.swift */; };
AB980113211A37B50025AFF2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB980112211A37B50025AFF2 /* ViewController.swift */; };
AB980116211A37B50025AFF2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB980114211A37B50025AFF2 /* Main.storyboard */; };
AB980118211A37B70025AFF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB980117211A37B70025AFF2 /* Assets.xcassets */; };
AB98011B211A37B70025AFF2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */; };
ABA1B7FC212214E7000D3CC5 /* Blockly in Resources */ = {isa = PBXBuildFile; fileRef = ABA1B7FB212214E7000D3CC5 /* Blockly */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
AB036C54211B89D600CCC9D8 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
AB98010D211A37B50025AFF2 /* Blockly WebView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Blockly WebView.app"; sourceTree = BUILT_PRODUCTS_DIR; };
AB980110211A37B50025AFF2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
AB980112211A37B50025AFF2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
AB980115211A37B50025AFF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
AB980117211A37B70025AFF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
AB98011A211A37B70025AFF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
AB98011C211A37B70025AFF2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
ABA1B7FB212214E7000D3CC5 /* Blockly */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Blockly; path = "Resources/Non-Localized/Blockly"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
AB98010A211A37B50025AFF2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AB036C55211B89D600CCC9D8 /* WebKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
AB036C53211B89D500CCC9D8 /* Frameworks */ = {
isa = PBXGroup;
children = (
AB036C54211B89D600CCC9D8 /* WebKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
AB980104211A37B50025AFF2 = {
isa = PBXGroup;
children = (
AB98010F211A37B50025AFF2 /* Blockly WebView */,
AB98010E211A37B50025AFF2 /* Products */,
AB036C53211B89D500CCC9D8 /* Frameworks */,
);
sourceTree = "<group>";
};
AB98010E211A37B50025AFF2 /* Products */ = {
isa = PBXGroup;
children = (
AB98010D211A37B50025AFF2 /* Blockly WebView.app */,
);
name = Products;
sourceTree = "<group>";
};
AB98010F211A37B50025AFF2 /* Blockly WebView */ = {
isa = PBXGroup;
children = (
ABA1B7F9212214B9000D3CC5 /* Resources */,
AB980110211A37B50025AFF2 /* AppDelegate.swift */,
AB980112211A37B50025AFF2 /* ViewController.swift */,
AB980114211A37B50025AFF2 /* Main.storyboard */,
AB980117211A37B70025AFF2 /* Assets.xcassets */,
AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */,
AB98011C211A37B70025AFF2 /* Info.plist */,
);
path = "Blockly WebView";
sourceTree = "<group>";
};
ABA1B7F9212214B9000D3CC5 /* Resources */ = {
isa = PBXGroup;
children = (
ABA1B7FA212214C6000D3CC5 /* Non-Localized */,
);
path = Resources;
sourceTree = "<group>";
};
ABA1B7FA212214C6000D3CC5 /* Non-Localized */ = {
isa = PBXGroup;
children = (
ABA1B7FB212214E7000D3CC5 /* Blockly */,
);
path = "Non-Localized";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
AB98010C211A37B50025AFF2 /* Blockly WebView */ = {
isa = PBXNativeTarget;
buildConfigurationList = AB98011F211A37B70025AFF2 /* Build configuration list for PBXNativeTarget "Blockly WebView" */;
buildPhases = (
AB980109211A37B50025AFF2 /* Sources */,
AB98010A211A37B50025AFF2 /* Frameworks */,
ABEDABD1212372E700A66667 /* ShellScript */,
AB98010B211A37B50025AFF2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Blockly WebView";
productName = "Blockly WebView";
productReference = AB98010D211A37B50025AFF2 /* Blockly WebView.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
AB980105211A37B50025AFF2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0940;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = Google;
TargetAttributes = {
AB98010C211A37B50025AFF2 = {
CreatedOnToolsVersion = 9.4.1;
};
};
};
buildConfigurationList = AB980108211A37B50025AFF2 /* Build configuration list for PBXProject "Blockly WebView" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = AB980104211A37B50025AFF2;
productRefGroup = AB98010E211A37B50025AFF2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
AB98010C211A37B50025AFF2 /* Blockly WebView */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
AB98010B211A37B50025AFF2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AB98011B211A37B70025AFF2 /* LaunchScreen.storyboard in Resources */,
AB980118211A37B70025AFF2 /* Assets.xcassets in Resources */,
AB980116211A37B50025AFF2 /* Main.storyboard in Resources */,
ABA1B7FC212214E7000D3CC5 /* Blockly in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
ABEDABD1212372E700A66667 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ./cp_resources.sh;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
AB980109211A37B50025AFF2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AB980113211A37B50025AFF2 /* ViewController.swift in Sources */,
AB980111211A37B50025AFF2 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
AB980114211A37B50025AFF2 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
AB980115211A37B50025AFF2 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
AB98011A211A37B70025AFF2 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
AB98011D211A37B70025AFF2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
AB98011E211A37B70025AFF2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
AB980120211A37B70025AFF2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 3KZF7Q7Q49;
INFOPLIST_FILE = "Blockly WebView/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.google.kidscoding.Blockly-WebView";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
AB980121211A37B70025AFF2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 3KZF7Q7Q49;
INFOPLIST_FILE = "Blockly WebView/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.google.kidscoding.Blockly-WebView";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
AB980108211A37B50025AFF2 /* Build configuration list for PBXProject "Blockly WebView" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AB98011D211A37B70025AFF2 /* Debug */,
AB98011E211A37B70025AFF2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AB98011F211A37B70025AFF2 /* Build configuration list for PBXNativeTarget "Blockly WebView" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AB980120211A37B70025AFF2 /* Debug */,
AB980121211A37B70025AFF2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = AB980105211A37B50025AFF2 /* Project object */;
}

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Blockly WebView.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Blockly WebView.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>Blockly WebView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

View File

@@ -1,46 +0,0 @@
//
// AppDelegate.swift
// Blockly WebView
//
// Created by Andrew Marshall on 8/7/18.
// Copyright © 2018 Google. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}

View File

@@ -1,98 +0,0 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -1,6 +0,0 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Blockly_WebView" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<wkWebView multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HmE-ZW-QKv">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<wkWebViewConfiguration key="configuration" allowsAirPlayForMediaPlayback="NO">
<dataDetectorTypes key="dataDetectorTypes"/>
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="webView" destination="HmE-ZW-QKv" id="OGc-PV-TAB"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-10" y="51"/>
</scene>
</scenes>
</document>

View File

@@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -1,110 +0,0 @@
// ViewController.swift
// Blockly WebView UI controller.
//
// Created by Andrew Marshall on 8/7/18.
// Copyright © 2018 Google. All rights reserved.
//
import UIKit
import WebKit
/// A basic ViewController for a WebView.
/// It handles the initial page load, and functions like window.prompt().
class ViewController: UIViewController, WKUIDelegate {
/// The name used to reference this iOS object when executing callbacks from the JS code.
/// If this value is changed, it should also be changed in the `CODE_GENERATOR_BRIDGE_JS` file.
fileprivate static let HOST_HTML = "Blockly/webview.html"
@IBOutlet weak var webView: WKWebView!
/// Additional setup after loading the UI NIB.
override func viewDidLoad() {
super.viewDidLoad()
webView.uiDelegate = self
// Do any additional setup after loading the view, typically from a nib.
loadWebContent()
}
/// Load the root HTML page into the webview.
func loadWebContent() {
if let htmlUrl = Bundle.main.url(forResource: "webview", withExtension: "html",
subdirectory: "Blockly") {
webView.load(URLRequest.init(url: htmlUrl))
} else {
NSLog("Failed to load HTML. Could not find resource.")
}
}
/// Handle window.alert() with a native dialog.
func webView(_ webView: WKWebView,
runJavaScriptAlertPanelWithMessage message: String,
initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping () -> Void) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let title = NSLocalizedString("OK", comment: "OK Button")
let ok = UIAlertAction(title: title, style: .default) { (action: UIAlertAction) -> Void in
alert.dismiss(animated: true, completion: nil)
}
alert.addAction(ok)
present(alert, animated: true)
completionHandler()
}
/// Handle window.confirm() with a native dialog.
func webView(_ webView: WKWebView,
runJavaScriptConfirmPanelWithMessage message: String,
initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping (Bool) -> Void) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let closeAndHandle = { (okayed: Bool) in
alert.dismiss(animated: true, completion: nil)
completionHandler(okayed)
}
let okTitle = NSLocalizedString("OK", comment: "OK button title")
let ok = UIAlertAction(title: okTitle, style: .default) { (action: UIAlertAction) -> Void in
closeAndHandle(true)
}
alert.addAction(ok)
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel button title")
let cancel = UIAlertAction(title: cancelTitle, style: .default) {
(action: UIAlertAction) -> Void in
closeAndHandle(false)
}
alert.addAction(cancel)
present(alert, animated: true)
}
/// Handle window.prompt() with a native dialog.
func webView(_ webView: WKWebView,
runJavaScriptTextInputPanelWithPrompt prompt: String,
defaultText: String?,
initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping (String?) -> Void) {
let alert = UIAlertController(title: prompt, message: nil, preferredStyle: .alert)
alert.addTextField { (textField) in
textField.text = defaultText
}
let okTitle = NSLocalizedString("OK", comment: "OK button title")
let okAction = UIAlertAction(title: okTitle, style: .default) { (_) in
let textInput = alert.textFields![0] as UITextField
completionHandler(textInput.text)
}
alert.addAction(okAction)
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel button title")
let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) { (_) in
completionHandler(nil)
}
alert.addAction(cancelAction)
present(alert, animated: true)
}
}

View File

@@ -1,21 +0,0 @@
#!/bin/bash
set -eux
BLOCKLY_ROOT=../../..
IOS_RESOURCES=Resources/Non-Localized/Blockly
MORE_FILES_TO_COPY=(
"dist/blockly_compressed.js"
"dist/blocks_compressed.js"
"media"
"build/msg"
)
mkdir -p $IOS_RESOURCES/media
mkdir -p $IOS_RESOURCES/msg/js
rsync -rp ../html/index.html $IOS_RESOURCES/webview.html
rsync -rp ../html/toolbox_standard.js $IOS_RESOURCES/toolbox_standard.js
for i in "${MORE_FILES_TO_COPY[@]}"; do # The quotes are necessary here
TARGET_DIR=$(dirname $IOS_RESOURCES/$i)
rsync -rp $BLOCKLY_ROOT/$i $TARGET_DIR
done

View File

@@ -60,7 +60,7 @@ function buildTSOverride({files, tsconfig}) {
'sourceType': 'module',
parserOptions: {
'project': tsconfig,
'tsconfigRootDir': '.',
'tsconfigRootDir': process.cwd(),
},
globals: {
...globals.browser,

1395
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "blockly",
"version": "12.3.0",
"version": "12.3.1",
"description": "Blockly is a library for building visual programming editors.",
"keywords": [
"blockly"
@@ -104,6 +104,8 @@
"@blockly/dev-tools": "^9.0.2",
"@blockly/keyboard-navigation": "^4.0.0-beta.0",
"@blockly/theme-modern": "^7.0.1",
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@hyperjump/browser": "^1.1.4",
"@hyperjump/json-schema": "^1.5.0",
"@microsoft/api-documenter": "7.22.4",
@@ -120,7 +122,7 @@
"eslint-plugin-prettier": "^5.2.1",
"glob": "^11.0.1",
"globals": "^16.0.0",
"google-closure-compiler": "^20250709.0.0",
"google-closure-compiler": "^20251015.0.0",
"gulp": "^5.0.0",
"gulp-concat": "^2.6.1",
"gulp-gzip": "^1.4.2",

1
sample.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -98,6 +98,7 @@ function copyPlaygroundDeps() {
'./node_modules/@blockly/dev-tools/dist/index.js',
'./node_modules/@blockly/theme-modern/dist/index.js',
'./node_modules/@blockly/block-test/dist/index.js',
'./node_modules/@blockly/keyboard-navigation/dist/index.js',
];
return gulp.src(playgroundDeps, {base: '.'}).pipe(gulp.dest(demoStaticTmpDir));
}

View File

@@ -154,12 +154,15 @@ def findRgbVal(colour):
# Get info on the input file
def getFileInfo():
from pathlib import Path
if (len(sys.argv) < 2):
print("Please provide a filename")
sys.exit()
fileName = sys.argv[1]
try:
jsonFile = open(fileName).read()
fileName = str(Path(fileName).parent / f"new_{Path(fileName).stem}.json")
fileName = Path(fileName)
except IOError as err:
print('Could not find that file name')
sys.exit()
@@ -174,7 +177,7 @@ def createColourMap():
for key in jsonData.keys():
rgbVal = findRgbVal(jsonData[key])
colourObj[key] = findOtherColours(rgbVal)
f= open("new_" + fileName,"w+")
f= open(fileName,"w+")
f.write(json.dumps(colourObj, indent=2, sort_keys=True))
f.close()

View File

@@ -2088,6 +2088,7 @@ suite('Blocks', function () {
],
},
]);
this.variableMap = this.workspace.getVariableMap();
});
teardown(function () {
eventUtils.enable();
@@ -2426,13 +2427,14 @@ suite('Blocks', function () {
assertCollapsed(blockA);
});
});
suite('Renaming Vars', function () {
test('Simple Rename', function () {
const blockA = createRenderedBlock(this.workspace, 'variable_block');
blockA.setCollapsed(true);
const variable = this.workspace.getVariable('x', '');
this.workspace.renameVariableById(variable.getId(), 'y');
this.variableMap.renameVariable(variable, 'y');
this.clock.runAll();
assertCollapsed(blockA, 'y');
@@ -2441,8 +2443,8 @@ suite('Blocks', function () {
const blockA = createRenderedBlock(this.workspace, 'variable_block');
blockA.setCollapsed(true);
const variable = this.workspace.createVariable('y');
this.workspace.renameVariableById(variable.getId(), 'X');
const variable = this.variableMap.createVariable('y');
this.variableMap.renameVariable(variable, 'X');
this.clock.runAll();
assertCollapsed(blockA, 'X');

View File

@@ -33,6 +33,7 @@ suite('Procedures', function () {
'preCreatedTypedVarId',
);
defineRowBlock();
this.variableMap = this.workspace.getVariableMap();
});
teardown(function () {
@@ -453,7 +454,7 @@ suite('Procedures', function () {
mutatorIcon.setBubbleVisible(false);
const variable = this.workspace.getVariable('param1', '');
this.workspace.renameVariableById(variable.getId(), 'new name');
this.variableMap.renameVariable(variable, 'new name');
assert.isNotNull(
defBlock.getField('PARAMS'),
@@ -480,7 +481,7 @@ suite('Procedures', function () {
this.clock.runAll();
const variable = this.workspace.getVariable('param1', '');
this.workspace.renameVariableById(variable.getId(), 'new name');
this.variableMap.renameVariable(variable, 'new name');
assert.equal(
paramBlock.getFieldValue('NAME'),
@@ -506,7 +507,7 @@ suite('Procedures', function () {
mutatorIcon.setBubbleVisible(false);
const variable = this.workspace.getVariable('param1', '');
this.workspace.renameVariableById(variable.getId(), 'new name');
this.variableMap.renameVariable(variable, 'new name');
assert.isNotNull(
callBlock.getInput('ARG0'),
@@ -535,7 +536,7 @@ suite('Procedures', function () {
mutatorIcon.setBubbleVisible(false);
const variable = this.workspace.getVariable('param1', '');
this.workspace.renameVariableById(variable.getId(), 'preCreatedVar');
this.variableMap.renameVariable(variable, 'preCreatedVar');
assert.isNotNull(
defBlock.getField('PARAMS'),
@@ -562,7 +563,7 @@ suite('Procedures', function () {
this.clock.runAll();
const variable = this.workspace.getVariable('param1', '');
this.workspace.renameVariableById(variable.getId(), 'preCreatedVar');
this.variableMap.renameVariable(variable, 'preCreatedVar');
assert.equal(
paramBlock.getFieldValue('NAME'),
@@ -588,7 +589,7 @@ suite('Procedures', function () {
mutatorIcon.setBubbleVisible(false);
const variable = this.workspace.getVariable('param1', '');
this.workspace.renameVariableById(variable.getId(), 'preCreatedVar');
this.variableMap.renameVariable(variable, 'preCreatedVar');
assert.isNotNull(
callBlock.getInput('ARG0'),

View File

@@ -32,9 +32,10 @@ suite('Variables', function () {
],
},
]);
this.workspace.createVariable('foo', 'type1', '1');
this.workspace.createVariable('bar', 'type1', '2');
this.workspace.createVariable('baz', 'type1', '3');
this.variableMap = this.workspace.getVariableMap();
this.variableMap.createVariable('foo', 'type1', '1');
this.variableMap.createVariable('bar', 'type1', '2');
this.variableMap.createVariable('baz', 'type1', '3');
});
teardown(function () {
@@ -116,12 +117,11 @@ suite('Variables', function () {
);
});
});
suite('getVariable', function () {
test('By ID', function () {
const var1 = this.workspace.createVariable('name1', 'type1', 'id1');
const var2 = this.workspace.createVariable('name2', 'type1', 'id2');
const var3 = this.workspace.createVariable('name3', 'type2', 'id3');
const var1 = this.variableMap.createVariable('name1', 'type1', 'id1');
const var2 = this.variableMap.createVariable('name2', 'type1', 'id2');
const var3 = this.variableMap.createVariable('name3', 'type2', 'id3');
const result1 = Blockly.Variables.getVariable(this.workspace, 'id1');
const result2 = Blockly.Variables.getVariable(this.workspace, 'id2');
const result3 = Blockly.Variables.getVariable(this.workspace, 'id3');
@@ -132,9 +132,9 @@ suite('Variables', function () {
});
test('By name and type', function () {
const var1 = this.workspace.createVariable('name1', 'type1', 'id1');
const var2 = this.workspace.createVariable('name2', 'type1', 'id2');
const var3 = this.workspace.createVariable('name3', 'type2', 'id3');
const var1 = this.variableMap.createVariable('name1', 'type1', 'id1');
const var2 = this.variableMap.createVariable('name2', 'type1', 'id2');
const var3 = this.variableMap.createVariable('name3', 'type2', 'id3');
const result1 = Blockly.Variables.getVariable(
this.workspace,
null,
@@ -161,9 +161,9 @@ suite('Variables', function () {
});
test('Bad ID with name and type fallback', function () {
const var1 = this.workspace.createVariable('name1', 'type1', 'id1');
const var2 = this.workspace.createVariable('name2', 'type1', 'id2');
const var3 = this.workspace.createVariable('name3', 'type2', 'id3');
const var1 = this.variableMap.createVariable('name1', 'type1', 'id1');
const var2 = this.variableMap.createVariable('name2', 'type1', 'id2');
const var3 = this.variableMap.createVariable('name3', 'type2', 'id3');
const result1 = Blockly.Variables.getVariable(
this.workspace,
'badId',

View File

@@ -904,19 +904,20 @@ suite('Events', function () {
suite('Variable events', function () {
setup(function () {
this.variable = this.workspace.createVariable('name1', 'type1', 'id1');
this.variableMap = this.workspace.getVariableMap();
this.variable = this.variableMap.createVariable('name1', 'type1', 'id1');
});
/**
* Check if a variable with the given values exists.
* @param {Blockly.Workspace|Blockly.VariableMap} container The workspace or
* variableMap the checked variable belongs to.
* @param {Blockly.VariableMap} variableMap The variableMap
* the checked variable belongs to.
* @param {!string} name The expected name of the variable.
* @param {!string} type The expected type of the variable.
* @param {!string} id The expected id of the variable.
*/
function checkVariableValues(container, name, type, id) {
const variable = container.getVariableById(id);
function checkVariableValues(variableMap, name, type, id) {
const variable = variableMap.getVariableById(id);
assert.isDefined(variable);
assert.equal(name, variable.name);
assert.equal(type, variable.type);
@@ -994,7 +995,7 @@ suite('Events', function () {
varName: 'name2',
};
const event = eventUtils.fromJson(json, this.workspace);
const x = this.workspace.getVariableById('id2');
const x = this.variableMap.getVariableById('id2');
assert.isNull(x);
event.run(true);
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
@@ -1002,22 +1003,22 @@ suite('Events', function () {
test('Var delete', function () {
const event = new Blockly.Events.VarDelete(this.variable);
assert.isNotNull(this.workspace.getVariableById('id1'));
assert.isNotNull(this.variableMap.getVariableById('id1'));
event.run(true);
assert.isNull(this.workspace.getVariableById('id1'));
assert.isNull(this.variableMap.getVariableById('id1'));
});
test('Var rename', function () {
const event = new Blockly.Events.VarRename(this.variable, 'name2');
event.run(true);
assert.isNull(this.workspace.getVariable('name1'));
checkVariableValues(this.workspace, 'name2', 'type1', 'id1');
assert.isNull(this.variableMap.getVariable('name1'));
checkVariableValues(this.variableMap, 'name2', 'type1', 'id1');
});
});
suite('Run Backward', function () {
test('Var create', function () {
const event = new Blockly.Events.VarCreate(this.variable);
assert.isNotNull(this.workspace.getVariableById('id1'));
assert.isNotNull(this.variableMap.getVariableById('id1'));
event.run(false);
});
@@ -1029,16 +1030,16 @@ suite('Events', function () {
varName: 'name2',
};
const event = eventUtils.fromJson(json, this.workspace);
assert.isNull(this.workspace.getVariableById('id2'));
assert.isNull(this.variableMap.getVariableById('id2'));
event.run(false);
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
});
test('Var rename', function () {
const event = new Blockly.Events.VarRename(this.variable, 'name2');
event.run(false);
assert.isNull(this.workspace.getVariable('name2'));
checkVariableValues(this.workspace, 'name1', 'type1', 'id1');
assert.isNull(this.variableMap.getVariable('name2'));
checkVariableValues(this.variableMap, 'name1', 'type1', 'id1');
});
});
});
@@ -1431,7 +1432,9 @@ suite('Events', function () {
);
// Expect the workspace to not have a variable with ID 'test_block_id'.
assert.isNull(this.workspace.getVariableById(TEST_BLOCK_ID));
assert.isNull(
this.workspace.getVariableMap().getVariableById(TEST_BLOCK_ID),
);
} finally {
workspaceTeardown.call(this, workspaceSvg);
}
@@ -1481,7 +1484,9 @@ suite('Events', function () {
);
// Expect the workspace to have a variable with ID 'test_var_id'.
assert.isNotNull(this.workspace.getVariableById(TEST_VAR_ID));
assert.isNotNull(
this.workspace.getVariableMap().getVariableById(TEST_VAR_ID),
);
});
test('New block new var xml', function () {

View File

@@ -486,13 +486,15 @@ suite('Variable Fields', function () {
this.variableField = this.variableBlock.getField('VAR');
});
test('Rename & Keep Old ID', function () {
this.workspace.renameVariableById('id1', 'name2');
const variableMap = this.workspace.getVariableMap();
variableMap.renameVariable(variableMap.getVariableById('id1'), 'name2');
assert.equal(this.variableField.getText(), 'name2');
assert.equal(this.variableField.getValue(), 'id1');
});
test('Rename & Get New ID', function () {
this.workspace.createVariable('name2', null, 'id2');
this.workspace.renameVariableById('id1', 'name2');
const variableMap = this.workspace.getVariableMap();
variableMap.createVariable('name2', null, 'id2');
variableMap.renameVariable(variableMap.getVariableById('id1'), 'name2');
assert.equal(this.variableField.getText(), 'name2');
assert.equal(this.variableField.getValue(), 'id2');
});

View File

@@ -33,6 +33,7 @@ suite('JSO Serialization', function () {
defineStatementBlock();
createGenUidStubWithReturns(new Array(10).fill().map((_, i) => 'id' + i));
this.variableMap = this.workspace.getVariableMap();
});
teardown(function () {
@@ -834,7 +835,7 @@ suite('JSO Serialization', function () {
suite('Variables', function () {
test('Without type', function () {
this.workspace.createVariable('testVar', '', 'testId');
this.variableMap.createVariable('testVar', '', 'testId');
const jso = Blockly.serialization.workspaces.save(this.workspace);
const variable = jso['variables'][0];
assertProperty(variable, 'name', 'testVar');
@@ -843,7 +844,7 @@ suite('JSO Serialization', function () {
});
test('With type', function () {
this.workspace.createVariable('testVar', 'testType', 'testId');
this.variableMap.createVariable('testVar', 'testType', 'testId');
const jso = Blockly.serialization.workspaces.save(this.workspace);
const variable = jso['variables'][0];
assertProperty(variable, 'name', 'testVar');

View File

@@ -25,6 +25,7 @@ export function testAWorkspace() {
],
},
]);
this.variableMap = this.workspace.getVariableMap();
});
teardown(function () {
@@ -68,13 +69,13 @@ export function testAWorkspace() {
suite('clear', function () {
test('Trivial', function () {
sinon.stub(eventUtils.TEST_ONLY, 'setGroupInternal').returns(null);
this.workspace.createVariable('name1', 'type1', 'id1');
this.workspace.createVariable('name2', 'type2', 'id2');
this.variableMap.createVariable('name1', 'type1', 'id1');
this.variableMap.createVariable('name2', 'type2', 'id2');
this.workspace.newBlock('');
this.workspace.clear();
assert.equal(this.workspace.getTopBlocks(false).length, 0);
const varMapLength = this.workspace.getVariableMap().variableMap.size;
const varMapLength = this.variableMap.variableMap.size;
assert.equal(varMapLength, 0);
});
@@ -84,7 +85,7 @@ export function testAWorkspace() {
this.workspace.clear();
assert.equal(this.workspace.getTopBlocks(false).length, 0);
const varMapLength = this.workspace.getVariableMap().variableMap.size;
const varMapLength = this.variableMap.variableMap.size;
assert.equal(varMapLength, 0);
});
});
@@ -92,8 +93,8 @@ export function testAWorkspace() {
suite('deleteVariable', function () {
setup(function () {
// Create two variables of different types.
this.var1 = this.workspace.createVariable('name1', 'type1', 'id1');
this.var2 = this.workspace.createVariable('name2', 'type2', 'id2');
this.var1 = this.variableMap.createVariable('name1', 'type1', 'id1');
this.var2 = this.variableMap.createVariable('name2', 'type2', 'id2');
// Create blocks to refer to both of them.
createVarBlocksNoEvents(this.workspace, ['id1', 'id1', 'id2']);
});
@@ -101,12 +102,12 @@ export function testAWorkspace() {
test('deleteVariableById(id2) one usage', function () {
// Deleting variable one usage should not trigger confirm dialog.
const stub = sinon.stub(window, 'confirm').returns(true);
this.workspace.deleteVariableById('id2');
this.variableMap.deleteVariableById('id2');
sinon.assert.notCalled(stub);
const variable = this.workspace.getVariableById('id2');
const variable = this.variableMap.getVariableById('id2');
assert.isNull(variable);
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertBlockVarModelName(this.workspace, 0, 'name1');
stub.restore();
@@ -115,12 +116,12 @@ export function testAWorkspace() {
test('deleteVariableById(id1) multiple usages confirm', function () {
// Deleting variable with multiple usages triggers confirm dialog.
const stub = sinon.stub(window, 'confirm').returns(true);
this.workspace.deleteVariableById('id1');
this.variableMap.deleteVariableById('id1');
sinon.assert.calledOnce(stub);
const variable = this.workspace.getVariableById('id1');
const variable = this.variableMap.getVariableById('id1');
assert.isNull(variable);
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
assertBlockVarModelName(this.workspace, 0, 'name2');
stub.restore();
@@ -129,11 +130,11 @@ export function testAWorkspace() {
test('deleteVariableById(id1) multiple usages cancel', function () {
// Deleting variable with multiple usages triggers confirm dialog.
const stub = sinon.stub(window, 'confirm').returns(false);
this.workspace.deleteVariableById('id1');
this.variableMap.deleteVariableById('id1');
sinon.assert.calledOnce(stub);
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
assertBlockVarModelName(this.workspace, 0, 'name1');
assertBlockVarModelName(this.workspace, 1, 'name1');
assertBlockVarModelName(this.workspace, 2, 'name2');
@@ -144,50 +145,50 @@ export function testAWorkspace() {
suite('renameVariableById', function () {
setup(function () {
this.workspace.createVariable('name1', 'type1', 'id1');
this.variableMap.createVariable('name1', 'type1', 'id1');
});
test('No references rename to name2', function () {
this.workspace.renameVariableById('id1', 'name2');
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
this.variableMap.renameVariableById('id1', 'name2');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
// Renaming should not have created a new variable.
assert.equal(this.workspace.getAllVariables().length, 1);
assert.equal(this.variableMap.getAllVariables().length, 1);
});
test('Reference exists rename to name2', function () {
createVarBlocksNoEvents(this.workspace, ['id1']);
this.workspace.renameVariableById('id1', 'name2');
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
this.variableMap.renameVariableById('id1', 'name2');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
// Renaming should not have created a new variable.
assert.equal(this.workspace.getAllVariables().length, 1);
assert.equal(this.variableMap.getAllVariables().length, 1);
assertBlockVarModelName(this.workspace, 0, 'name2');
});
test('Reference exists different capitalization rename to Name1', function () {
createVarBlocksNoEvents(this.workspace, ['id1']);
this.workspace.renameVariableById('id1', 'Name1');
assertVariableValues(this.workspace, 'Name1', 'type1', 'id1');
this.variableMap.renameVariableById('id1', 'Name1');
assertVariableValues(this.variableMap, 'Name1', 'type1', 'id1');
// Renaming should not have created a new variable.
assert.equal(this.workspace.getAllVariables().length, 1);
assert.equal(this.variableMap.getAllVariables().length, 1);
assertBlockVarModelName(this.workspace, 0, 'Name1');
});
suite('Two variables rename overlap', function () {
test('Same type rename variable with id1 to name2', function () {
this.workspace.createVariable('name2', 'type1', 'id2');
this.variableMap.createVariable('name2', 'type1', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.renameVariableById('id1', 'name2');
// The second variable should remain unchanged.
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
// The first variable should have been deleted.
const variable = this.workspace.getVariableById('id1');
const variable = this.variableMap.getVariableById('id1');
assert.isNull(variable);
// There should only be one variable left.
assert.equal(this.workspace.getAllVariables().length, 1);
assert.equal(this.variableMap.getAllVariables().length, 1);
// Both blocks should now reference variable with name2.
assertBlockVarModelName(this.workspace, 0, 'name2');
@@ -195,14 +196,14 @@ export function testAWorkspace() {
});
test('Different type rename variable with id1 to name2', function () {
this.workspace.createVariable('name2', 'type2', 'id2');
this.variableMap.createVariable('name2', 'type2', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.renameVariableById('id1', 'name2');
// Variables with different type are allowed to have the same name.
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
// Both blocks should now reference variable with name2.
assertBlockVarModelName(this.workspace, 0, 'name2');
@@ -210,18 +211,18 @@ export function testAWorkspace() {
});
test('Same type different capitalization rename variable with id1 to Name2', function () {
this.workspace.createVariable('name2', 'type1', 'id2');
this.variableMap.createVariable('name2', 'type1', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'Name2');
this.variableMap.renameVariableById('id1', 'Name2');
// The second variable should be updated.
assertVariableValues(this.workspace, 'Name2', 'type1', 'id2');
assertVariableValues(this.variableMap, 'Name2', 'type1', 'id2');
// The first variable should have been deleted.
const variable = this.workspace.getVariableById('id1');
const variable = this.variableMap.getVariableById('id1');
assert.isNull(variable);
// There should only be one variable left.
assert.equal(this.workspace.getAllVariables().length, 1);
assert.equal(this.variableMap.getAllVariables().length, 1);
// Both blocks should now reference variable with Name2.
assertBlockVarModelName(this.workspace, 0, 'Name2');
@@ -229,15 +230,15 @@ export function testAWorkspace() {
});
test('Different type different capitalization rename variable with id1 to Name2', function () {
this.workspace.createVariable('name2', 'type2', 'id2');
this.variableMap.createVariable('name2', 'type2', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'Name2');
this.variableMap.renameVariableById('id1', 'Name2');
// Variables with different type are allowed to have the same name.
assertVariableValues(this.workspace, 'Name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'Name2', 'type1', 'id1');
// Second variable should remain unchanged.
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
// Only first block should use new capitalization.
assertBlockVarModelName(this.workspace, 0, 'Name2');
@@ -1477,180 +1478,184 @@ export function testAWorkspace() {
suite('renameVariableById', function () {
setup(function () {
this.workspace.createVariable('name1', 'type1', 'id1');
this.variableMap.createVariable('name1', 'type1', 'id1');
});
test('Reference exists no usages rename to name2', function () {
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.renameVariableById('id1', 'name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
});
test('Reference exists with usages rename to name2', function () {
createVarBlocksNoEvents(this.workspace, ['id1']);
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.renameVariableById('id1', 'name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertBlockVarModelName(this.workspace, 0, 'name1');
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
this.workspace.undo(true);
this.clock.runAll();
assertBlockVarModelName(this.workspace, 0, 'name2');
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
});
test('Reference exists different capitalization no usages rename to Name1', function () {
this.workspace.renameVariableById('id1', 'Name1');
this.variableMap.renameVariableById('id1', 'Name1');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'Name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'Name1', 'type1', 'id1');
});
test('Reference exists different capitalization with usages rename to Name1', function () {
createVarBlocksNoEvents(this.workspace, ['id1']);
this.workspace.renameVariableById('id1', 'Name1');
this.variableMap.renameVariableById('id1', 'Name1');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertBlockVarModelName(this.workspace, 0, 'name1');
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
this.workspace.undo(true);
this.clock.runAll();
assertBlockVarModelName(this.workspace, 0, 'Name1');
assertVariableValues(this.workspace, 'Name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'Name1', 'type1', 'id1');
});
suite('Two variables rename overlap', function () {
test('Same type no usages rename variable with id1 to name2', function () {
this.workspace.createVariable('name2', 'type1', 'id2');
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.createVariable('name2', 'type1', 'id2');
this.variableMap.renameVariableById('id1', 'name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
assert.isNull(this.workspace.getVariableById('id1'));
assertVariableValues(this.variableMap, 'name2', 'type1', 'id2');
assert.isNull(this.variableMap.getVariableById('id1'));
});
test('Same type with usages rename variable with id1 to name2', function () {
this.workspace.createVariable('name2', 'type1', 'id2');
const variable = this.variableMap.createVariable(
'name2',
'type1',
'id2',
);
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.renameVariableById('id1', 'name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertBlockVarModelName(this.workspace, 0, 'name1');
assertBlockVarModelName(this.workspace, 1, 'name2');
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
assert.isNull(this.workspace.getVariableById('id1'));
assertVariableValues(this.variableMap, 'name2', 'type1', 'id2');
assert.isNull(this.variableMap.getVariableById('id1'));
});
test('Same type different capitalization no usages rename variable with id1 to Name2', function () {
this.workspace.createVariable('name2', 'type1', 'id2');
this.workspace.renameVariableById('id1', 'Name2');
this.variableMap.createVariable('name2', 'type1', 'id2');
this.variableMap.renameVariableById('id1', 'Name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'Name2', 'type1', 'id2');
assert.isNull(this.workspace.getVariable('name1'));
assertVariableValues(this.variableMap, 'Name2', 'type1', 'id2');
assert.isNull(this.variableMap.getVariable('name1'));
});
test('Same type different capitalization with usages rename variable with id1 to Name2', function () {
this.workspace.createVariable('name2', 'type1', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'Name2');
this.variableMap.renameVariableById('id1', 'Name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertBlockVarModelName(this.workspace, 0, 'name1');
assertBlockVarModelName(this.workspace, 1, 'name2');
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type1', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'Name2', 'type1', 'id2');
assert.isNull(this.workspace.getVariableById('id1'));
assertVariableValues(this.variableMap, 'Name2', 'type1', 'id2');
assert.isNull(this.variableMap.getVariableById('id1'));
assertBlockVarModelName(this.workspace, 0, 'Name2');
assertBlockVarModelName(this.workspace, 1, 'Name2');
});
test('Different type no usages rename variable with id1 to name2', function () {
this.workspace.createVariable('name2', 'type2', 'id2');
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.createVariable('name2', 'type2', 'id2');
this.variableMap.renameVariableById('id1', 'name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
});
test('Different type with usages rename variable with id1 to name2', function () {
this.workspace.createVariable('name2', 'type2', 'id2');
this.variableMap.createVariable('name2', 'type2', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'name2');
this.variableMap.renameVariableById('id1', 'name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
assertBlockVarModelName(this.workspace, 0, 'name1');
assertBlockVarModelName(this.workspace, 1, 'name2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'name2', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
assertBlockVarModelName(this.workspace, 0, 'name2');
assertBlockVarModelName(this.workspace, 1, 'name2');
});
test('Different type different capitalization no usages rename variable with id1 to Name2', function () {
this.workspace.createVariable('name2', 'type2', 'id2');
this.workspace.renameVariableById('id1', 'Name2');
this.variableMap.createVariable('name2', 'type2', 'id2');
this.variableMap.renameVariableById('id1', 'Name2');
this.clock.runAll();
this.workspace.undo();
@@ -1660,27 +1665,27 @@ export function testAWorkspace() {
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'Name2', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'Name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
});
test('Different type different capitalization with usages rename variable with id1 to Name2', function () {
this.workspace.createVariable('name2', 'type2', 'id2');
this.variableMap.createVariable('name2', 'type2', 'id2');
createVarBlocksNoEvents(this.workspace, ['id1', 'id2']);
this.workspace.renameVariableById('id1', 'Name2');
this.variableMap.renameVariableById('id1', 'Name2');
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
assertVariableValues(this.workspace, 'name1', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'name1', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
assertBlockVarModelName(this.workspace, 0, 'name1');
assertBlockVarModelName(this.workspace, 1, 'name2');
this.workspace.undo(true);
this.clock.runAll();
assertVariableValues(this.workspace, 'Name2', 'type1', 'id1');
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
assertVariableValues(this.variableMap, 'Name2', 'type1', 'id1');
assertVariableValues(this.variableMap, 'name2', 'type2', 'id2');
assertBlockVarModelName(this.workspace, 0, 'Name2');
assertBlockVarModelName(this.workspace, 1, 'name2');
});

View File

@@ -119,6 +119,7 @@ suite('XML', function () {
suite('blockToDom', function () {
setup(function () {
this.workspace = new Blockly.Workspace();
this.variableMap = this.workspace.getVariableMap();
});
teardown(function () {
workspaceTeardown.call(this, this.workspace);
@@ -296,7 +297,7 @@ suite('XML', function () {
]);
});
test('Variable Trivial', function () {
this.workspace.createVariable('name1', '', 'id1');
this.variableMap.createVariable('name1', '', 'id1');
const block = new Blockly.Block(
this.workspace,
'field_variable_test_block',
@@ -306,7 +307,7 @@ suite('XML', function () {
assertVariableDomField(resultFieldDom, 'VAR', null, 'id1', 'name1');
});
test('Variable Typed', function () {
this.workspace.createVariable('name1', 'string', 'id1');
this.variableMap.createVariable('name1', 'string', 'id1');
const block = new Blockly.Block(
this.workspace,
'field_variable_test_block',
@@ -323,7 +324,7 @@ suite('XML', function () {
});
test('Variable Default Case', function () {
createGenUidStubWithReturns('1');
this.workspace.createVariable('name1');
this.variableMap.createVariable('name1');
Blockly.Events.disable();
const block = new Blockly.Block(
@@ -439,13 +440,14 @@ suite('XML', function () {
],
},
]);
this.variableMap = this.workspace.getVariableMap();
});
teardown(function () {
workspaceTeardown.call(this, this.workspace);
});
test('One Variable', function () {
createGenUidStubWithReturns('1');
this.workspace.createVariable('name1');
this.variableMap.createVariable('name1');
const resultDom = Blockly.Xml.variablesToDom(
this.workspace.getAllVariables(),
);
@@ -456,8 +458,8 @@ suite('XML', function () {
assert.equal(resultVariableDom.getAttribute('id'), '1');
});
test('Two Variable one block', function () {
this.workspace.createVariable('name1', '', 'id1');
this.workspace.createVariable('name2', 'type2', 'id2');
this.variableMap.createVariable('name1', '', 'id1');
this.variableMap.createVariable('name2', 'type2', 'id2');
// If events are enabled during block construction, it will create a
// default variable.
Blockly.Events.disable();