Skip to content

Commit

Permalink
同步至官方2020-02-29
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyu2333 committed Feb 29, 2020
1 parent ac62f4f commit c353eb6
Show file tree
Hide file tree
Showing 21 changed files with 15,364 additions and 11,452 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ npm-*
# generated translation files
/translations
/locale
node_modules
3 changes: 3 additions & 0 deletions docs/project_state_diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/project_state_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "npm run clean && webpack --progress --colors --bail",
"clean": "rimraf ./build && mkdirp build && rimraf ./dist && mkdirp dist",
"deploy": "touch build/.nojekyll && gh-pages -t -d build -m \"Build for $(git log --pretty=format:%H -n1)\"",
"deploy": "touch build/.nojekyll && gh-pages -t -d build -m \"Build for $(git log --pretty=format:%H -n1) [skip ci]\"",
"prune": "./prune-gh-pages.sh",
"i18n:push": "tx-push-src scratch-editor interface translations/en.json",
"i18n:src": "rimraf ./translations/messages/src && babel src > tmp.js && rimraf tmp.js && build-i18n-src ./translations/messages/src ./translations/ && npm run i18n:push",
Expand Down Expand Up @@ -44,7 +44,7 @@
"babel-loader": "^8.0.4",
"base64-loader": "1.0.0",
"bowser": "1.9.4",
"chromedriver": "78.0.1",
"chromedriver": "80.0.0",
"classnames": "2.2.6",
"computed-style-to-inline-style": "3.0.0",
"copy-webpack-plugin": "^4.5.1",
Expand Down Expand Up @@ -78,7 +78,7 @@
"lodash.pick": "4.4.0",
"lodash.throttle": "4.0.1",
"minilog": "3.1.0",
"mkdirp": "^0.5.1",
"mkdirp": "^1.0.3",
"omggif": "1.0.9",
"papaparse": "5.1.1",
"postcss-import": "^12.0.0",
Expand Down Expand Up @@ -108,13 +108,13 @@
"redux-throttle": "0.1.1",
"rimraf": "^2.6.1",
"scratch-audio": "0.1.0-prerelease.20190925183642",
"scratch-l10n": "3.7.20191219145348",
"scratch-blocks": "0.1.0-prerelease.1576850350",
"scratch-paint": "0.2.0-prerelease.20191217213717",
"scratch-render": "0.1.0-prerelease.20191217212645",
"scratch-l10n": "3.7.20200225213156",
"scratch-blocks": "0.1.0-prerelease.1582033791",
"scratch-paint": "0.2.0-prerelease.20200213174123",
"scratch-render": "0.1.0-prerelease.20200228152431",
"scratch-storage": "1.3.2",
"scratch-svg-renderer": "0.2.0-prerelease.20191217211338",
"scratch-vm": "0.2.0-prerelease.20191227164934",
"scratch-svg-renderer": "0.2.0-prerelease.20200205003400",
"scratch-vm": "0.2.0-prerelease.20200227204654",
"selenium-webdriver": "3.6.0",
"startaudiocontext": "1.2.1",
"style-loader": "^0.23.0",
Expand Down
24 changes: 10 additions & 14 deletions src/containers/library-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,21 @@ class LibraryItem extends React.PureComponent {
this.setState({iconIndex: nextIconIndex});
}
curIconMd5 () {
const iconMd5Prop = this.props.iconMd5;
if (this.props.icons &&
this.state.isRotatingIcon &&
this.state.iconIndex < this.props.icons.length &&
this.props.icons[this.state.iconIndex] &&
this.props.icons[this.state.iconIndex].baseLayerMD5) {
return this.props.icons[this.state.iconIndex].baseLayerMD5;
this.state.iconIndex < this.props.icons.length) {
const icon = this.props.icons[this.state.iconIndex] || {};
return icon.md5ext || // 3.0 library format
icon.baseLayerMD5 || // 2.0 library format, TODO GH-5084
iconMd5Prop;
}
return this.props.iconMd5;
return iconMd5Prop;
}
render () {
const iconMd5 = this.curIconMd5();
let assetCDN
if('assetCDN' in window.scratchConfig){
assetCDN = window.scratchConfig.assetCDN+`/internalapi/asset/${iconMd5}`
}else{
assetCDN = `https://cdn.assets.scratch.mit.edu/internalapi/asset/${iconMd5}/get/`
}

const iconURL = iconMd5 ?
assetCDN :
`https://cdn.assets.scratch.mit.edu/internalapi/asset/${iconMd5}/get/` :
this.props.iconRawURL;
return (
<LibraryItemComponent
Expand Down Expand Up @@ -158,7 +153,8 @@ LibraryItem.propTypes = {
iconRawURL: PropTypes.string,
icons: PropTypes.arrayOf(
PropTypes.shape({
baseLayerMD5: PropTypes.string
baseLayerMD5: PropTypes.string, // 2.0 library format, TODO GH-5084
md5ext: PropTypes.string // 3.0 library format
})
),
id: PropTypes.number.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/audio/audio-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const dropEveryOtherSample = buffer => {
}
return {
samples: newSamples,
sampleRate: buffer.rate / 2
sampleRate: buffer.sampleRate / 2
};
};

Expand Down
28 changes: 16 additions & 12 deletions src/lib/cloud-manager-hoc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ const cloudManagerHOC = function (WrappedComponent) {
canUseCloud (props) {
return !!(props.cloudHost && props.username && props.vm && props.projectId && props.hasCloudPermission);
}
shouldNotModifyCloudData (props) {
return (props.hasEverEnteredEditor && !props.canSave);
}
shouldConnect (props) {
return !this.isConnected() && this.canUseCloud(props) &&
props.isShowingWithId && props.vm.runtime.hasCloudData() &&
!this.shouldNotModifyCloudData(props);
props.canModifyCloudData;
}
shouldDisconnect (props, prevProps) {
return this.isConnected() &&
Expand All @@ -70,7 +67,7 @@ const cloudManagerHOC = function (WrappedComponent) {
(props.projectId !== prevProps.projectId) ||
(props.username !== prevProps.username) ||
// Editing someone else's project
this.shouldNotModifyCloudData(props)
!props.canModifyCloudData
);
}
isConnected () {
Expand Down Expand Up @@ -102,11 +99,11 @@ const cloudManagerHOC = function (WrappedComponent) {
render () {
const {
/* eslint-disable no-unused-vars */
canModifyCloudData,
cloudHost,
projectId,
username,
hasCloudPermission,
hasEverEnteredEditor,
isShowingWithId,
onShowCloudInfo,
/* eslint-enable no-unused-vars */
Expand All @@ -124,23 +121,30 @@ const cloudManagerHOC = function (WrappedComponent) {
}

CloudManager.propTypes = {
canSave: PropTypes.bool.isRequired,
canModifyCloudData: PropTypes.bool.isRequired,
cloudHost: PropTypes.string,
hasCloudPermission: PropTypes.bool,
hasEverEnteredEditor: PropTypes.bool,
isShowingWithId: PropTypes.bool,
isShowingWithId: PropTypes.bool.isRequired,
onShowCloudInfo: PropTypes.func,
projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
username: PropTypes.string,
vm: PropTypes.instanceOf(VM).isRequired
};

const mapStateToProps = state => {
CloudManager.defaultProps = {
cloudHost: null,
hasCloudPermission: false,
onShowCloudInfo: () => {},
username: null
};

const mapStateToProps = (state, ownProps) => {
const loadingState = state.scratchGui.projectState.loadingState;
return {
hasEverEnteredEditor: state.scratchGui.mode.hasEverEnteredEditor,
isShowingWithId: getIsShowingWithId(loadingState),
projectId: state.scratchGui.projectState.projectId
projectId: state.scratchGui.projectState.projectId,
// if you're editing someone else's project, you can't modify cloud data
canModifyCloudData: (!state.scratchGui.mode.hasEverEnteredEditor || ownProps.canSave)
};
};

Expand Down
12 changes: 6 additions & 6 deletions src/lib/libraries/backdrops.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
},
{
"name": "Blue Sky 2 ",
"md5": "5a906c2f272b77f59f0ef207857a8b3a.svg",
"md5": "8eb8790be5507fdccf73e7c1570bbbab.svg",
"type": "backdrop",
"tags": [
"outdoors",
Expand Down Expand Up @@ -286,7 +286,7 @@
},
{
"name": "Circles",
"md5": "4e29033ec2b891a8f1ca21242811d403.svg",
"md5": "c9847be305920807c5597d81576dd0c4.svg",
"type": "backdrop",
"tags": [
"patterns"
Expand Down Expand Up @@ -491,7 +491,7 @@
},
{
"name": "Hearts",
"md5": "26d3418b2fbc1af2c5fea82e1c3df1db.svg",
"md5": "f98526ccb0eec3ac7d6c8f8ab502825e.svg",
"type": "backdrop",
"tags": [
"patterns"
Expand Down Expand Up @@ -1050,7 +1050,7 @@
},
{
"name": "Underwater 1",
"md5": "fb907f72b310acc8b95cbf2d2cccabc9.svg",
"md5": "d3344650f594bcecdf46aa4a9441badd.svg",
"type": "backdrop",
"tags": [
"ocean",
Expand Down Expand Up @@ -1175,7 +1175,7 @@
},
{
"name": "Witch House",
"md5": "597b9a9813fe5d8d387283138a0b8f2b.svg",
"md5": "30085b2d27beb5acdbe895d8b3e64b04.svg",
"type": "backdrop",
"tags": [
"fantasy",
Expand All @@ -1190,7 +1190,7 @@
},
{
"name": "Woods",
"md5": "d26cfd278999c9e37d6af75c296a58df.svg",
"md5": "f3eb165d6f3fd23370f97079f2e631bf.svg",
"type": "backdrop",
"tags": [
"fantasy",
Expand Down
Loading

0 comments on commit c353eb6

Please sign in to comment.